Advertisement
Guest User

Untitled

a guest
Mar 6th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.43 KB | None | 0 0
  1. @model DenTotal.ViewModels.InventoriesViewModel
  2. @{
  3.  
  4. var currentUnixTimestamp = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
  5. decimal stockValue = 0; long reorderUnit = 0; int reorderProduct = 0;
  6. foreach (var product in Model.Products)
  7. {
  8. stockValue += product.UnitsInStock * product.SellPrice;
  9.  
  10. if (product.UnitsInStock < product.ReorderLevel)
  11. {
  12. reorderUnit += product.ReorderLevel - product.UnitsInStock;
  13. reorderProduct += 1;
  14. }
  15. }
  16. ViewBag.Title = "Index";
  17. Layout = "~/Views/Shared/_Layout.cshtml";
  18. }
  19.  
  20. <section class="content-header">
  21. <h1>
  22. Inventory DashBoard
  23. <small></small>
  24. </h1>
  25.  
  26. </section>
  27. <br>
  28.  
  29. <section class="content">
  30. <div class="box">
  31. <div class="box-header">
  32. <h3 class="box-title"></h3>
  33.  
  34. </div>
  35. <div class="box-body">
  36.  
  37. <div class="row col-lg-12 col-xs-24">
  38. <div class="col-lg-3 col-xs-6">
  39. <!-- Supplier Number-->
  40. <div class="small-box bg-aqua">
  41. <div class="inner">
  42. <h3>@Model.Suppliers.Count()</h3>
  43. <p>Suppliers</p>
  44. </div>
  45. <div class="icon">
  46. <i class="ion ion-man"></i>
  47. </div>
  48. <a id="OpenSupplier" onclick="OpenSupplier(@Model.Suppliers)" href='@Url.Action("Index", "Suppliers")' target='_blank' class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  49. </div>
  50. </div>
  51. <!-- ./col -->
  52. <div class="col-lg-3 col-xs-6">
  53. <!-- Product Number -->
  54. <div class="small-box bg-yellow-gradient">
  55. <div class="inner">
  56. <h3>@Model.Products.Count()</h3>
  57. <p>Products</p>
  58. </div>
  59. <div class="icon">
  60. <i class="ion ion-bag"></i>
  61. </div>
  62. <a href='@Url.Action("PrintAllProducts", "Inventories")' target='_blank' class="small-box-footer" >More info <i class="fa fa-arrow-circle-right"></i></a>
  63. </div>
  64. </div>
  65. <!-- ./col -->
  66. <div class="col-lg-3 col-xs-6">
  67. <!-- small box -->
  68. <div class="small-box bg-blue">
  69. <div class="inner">
  70. <h3>@Model.Products.Sum(a => a.UnitsInStock)</h3>
  71. <p>Total Units in Stock</p>
  72. </div>
  73. <div class="icon">
  74. <i class="ion ion-stats-bars"></i>
  75. </div>
  76. <a href='@Url.Action("Index", "Products")' target='_blank' class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  77. </div>
  78. </div>
  79. <!-- ./col -->
  80. <!-- /.row -->
  81. @*second Row*@
  82. <div class="col-lg-3 col-xs-6">
  83. <!-- small box -->
  84. <div class="small-box bg-gray">
  85. <div class="inner">
  86. <h3>@reorderUnit</h3>
  87. <p>Quantity to be Reordered(units)</p>
  88. </div>
  89. <div class="icon">
  90. <i class="fa fa-sort-numeric-asc"></i>
  91. </div>
  92. <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  93. </div>
  94. </div>
  95. <!-- ./col -->
  96. <div class="col-lg-3 col-xs-6">
  97. <!-- small box -->
  98. <div class="small-box bg-red">
  99. <div class="inner">
  100. <h3>@Model.Products.Where(a => a.UnitsInStock == 0).Count()</h3>
  101. <p>Zero Stock Product</p>
  102. </div>
  103. <div class="icon">
  104. <i class="ion ion-alert-circled"></i>
  105. </div>
  106. <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  107. </div>
  108. </div>
  109. <!-- ./col -->
  110. <div class="col-lg-3 col-xs-6">
  111. <!-- small box -->
  112. <div class="small-box bg-orange">
  113. <div class="inner">
  114. <h3>@Model.Products.Where(a => a.Discontinued == true).Count()</h3>
  115.  
  116. <p>Discontinued Products</p>
  117. </div>
  118. <div class="icon">
  119. <i class="ion ion-crop"></i>
  120. </div>
  121. <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  122. </div>
  123. </div>
  124. <!-- ./col -->
  125. <!-- /.row -->
  126. @*third Row*@
  127. <div class="col-lg-3 col-xs-6">
  128. <!-- small box -->
  129. <div class="small-box bg-maroon">
  130. <div class="inner">
  131. <h3>@reorderProduct</h3>
  132.  
  133. <p>Products below Reorder Level</p>
  134. </div>
  135. <div class="icon">
  136. <i class="fa fa-book"></i>
  137. </div>
  138. <a href='@Url.Action("PrintReorderedProducts", "Inventories")' target='_blank' class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  139. </div>
  140. </div>
  141. <!-- ./col -->
  142.  
  143.  
  144. <div class="col-lg-3 col-xs-6">
  145. <!-- small box -->
  146. <div class="small-box bg-red-gradient">
  147. <div class="inner">
  148. <h3>@Model.expiredProducts</h3>
  149.  
  150. <p>Products to be Expired</p>
  151. </div>
  152. <div class="icon">
  153. <i class="fa fa-money"></i>
  154. @*<ion-icon name="person"></ion-icon>*@
  155. </div>
  156. <a href='@Url.Action("PrintExpiredProducts", "Inventories")' target='_blank' class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
  157. </div>
  158. </div>
  159. </div>
  160. @*box Body Div*@
  161. </div>
  162.  
  163. <div class="box-body">
  164. <table id="PurchaseOrders" class="table table-bordered table-hover" style="cursor:pointer">
  165. <thead>
  166. <tr>
  167. <th>Supplier</th>
  168. <th>Company</th>
  169. <th>Purchase Date</th>
  170. <th>Total Price</th>
  171. <th>Status</th>
  172. </tr>
  173. </thead>
  174. <tbody></tbody>
  175. </table>
  176. </div>
  177. </div>
  178.  
  179. </section>
  180.  
  181. @section scripts{
  182. <script>
  183.  
  184. function format(value) {
  185. Row = Row + '<tr>' +
  186. '<td class="text-center">' + value.Product.ProductName + '</td>' +
  187. '<td class="text-center">' + value.Quantity + '</td>' +
  188. '<td class="text-center">' + value.Product.UnitsInStock + '</td>' +
  189. '<td class="text-center">' + value.UnitPrice + '</td>' +
  190. '</tr>' ;
  191. return Row;
  192. }
  193. var Row;
  194.  
  195. var iTableCounter = 1;
  196. var oTable;
  197. var detailsTableHtml;
  198.  
  199. $(document).ready(function () {
  200.  
  201. var OpenSupplier = function (supplier) {
  202.  
  203. bootbox.confirm({
  204. title: "Supplier List",
  205. message: supplier.CompanyName,
  206. buttons: {
  207. cancel: {
  208. label: '<i class="fa fa-times"></i> Cancel'
  209. },
  210. confirm: {
  211. label: '<i class="fa fa-check"></i> Confirm'
  212. }
  213. },
  214. callback: function (result) {
  215. console.log('This was logged in the callback: ' + result);
  216. }
  217. });
  218. }
  219.  
  220. //$("#OpenSupplier").click(function () {
  221. // bootbox.confirm({
  222. // title: "Destroy planet?",
  223. // message: "Do you want to activate the Deathstar now? This cannot be undone.",
  224. // buttons: {
  225. // cancel: {
  226. // label: '<i class="fa fa-times"></i> Cancel'
  227. // },
  228. // confirm: {
  229. // label: '<i class="fa fa-check"></i> Confirm'
  230. // }
  231. // },
  232. // callback: function (result) {
  233. // console.log('This was logged in the callback: ' + result);
  234. // }
  235. // });
  236. //});
  237.  
  238. var nCloneTh = document.createElement('th');
  239.  
  240. $('#PurchaseOrders thead tr').each(function () {
  241. this.insertBefore(nCloneTh, this.childNodes[0]);
  242. });
  243.  
  244. var expandIcon = function (data, type) {
  245. if (type === 'display') {
  246. return '<i class="fa fa-plus-circle"/>';
  247. }
  248. return data;
  249. };
  250.  
  251. var oTable = $("#PurchaseOrders").DataTable({
  252.  
  253. ajax: {
  254. url: '@Url.Action("GetPurchaseOrder", "Inventories")',
  255. method: "GET",
  256. dataType: "json"
  257. },
  258. autoWidth: false,
  259. columnDefs: [
  260. { width: "10px", targets: 0 },
  261. { className: "details-control text-center", targets: "_all" }
  262. ],
  263. columns: [
  264. {
  265. data: null,
  266. render: expandIcon
  267. },
  268. {
  269. render: function (data, type, supplier) {
  270. return supplier.PurchaseOrder.Supplier.ContactTitle+' '+supplier.PurchaseOrder.Supplier.ContactName;
  271. }
  272. },
  273. {
  274. data: "PurchaseOrder.Supplier.CompanyName"
  275. },
  276. {
  277. data: "PurchaseOrder.OrderDate",
  278. render: function (data) {
  279. return moment(data).format('DD-MMM-YYYY');
  280. }
  281. },
  282. {
  283. data: "PurchaseOrder.TotalPrice"
  284. },
  285. {
  286. data: "PurchaseOrder.POStatus"
  287. }
  288. ]
  289. });
  290.  
  291. $('#PurchaseOrders tbody').on('click', 'tr td.details-control', function () {
  292.  
  293. var tr = $(this).closest('tr');
  294. var row = oTable.row(tr);
  295. var details = row.data().Details;
  296.  
  297. if (row.child.isShown()) {
  298. tr.removeClass('details');
  299. row.child.hide();
  300. }
  301. else {
  302. Row = '<table class="table" style="background-color: #ffffcc; cursor:auto">' +
  303. '<tr>' +
  304. '<th class="text-center">Product Name</th>' +
  305. '<th class="text-center">Quantity</th>' +
  306. '<th class="text-center">In Stock</th>' +
  307. '<th class="text-center">Unit Price</th>' +
  308. '</tr>';
  309.  
  310. $.each(details, function (i, val) {
  311. tr.addClass('details');
  312. row.child(format(val)).show();
  313. });
  314. Row = Row + '</table>';
  315. }
  316. });
  317. });
  318.  
  319. </script>
  320.  
  321. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement