source: StockMaster/Views/Product/Index.cshtml@ dfe03b8

main
Last change on this file since dfe03b8 was dfe03b8, checked in by Ceyda <ceyda.huseini@…>, 4 days ago

Initialize StockMaster project

  • Property mode set to 100644
File size: 4.7 KB
Line 
1@model List<StockMaster.Models.Product>
2@{
3 ViewData["Title"] = "Products";
4}
5
6<div class="row mb-4">
7 <div class="col-md-6">
8 <h2><i class="fas fa-box"></i> Product Management</h2>
9 </div>
10 <div class="col-md-6 text-end">
11 <a href="/Product/Create" class="btn btn-primary">
12 <i class="fas fa-plus"></i> Add New Product
13 </a>
14 </div>
15</div>
16
17<div class="card">
18 <div class="card-header">
19 <i class="fas fa-list"></i> Product List
20 </div>
21 <div class="card-body">
22 @Html.AntiForgeryToken()
23 <div class="mb-3">
24 <input type="text" class="form-control" placeholder="Search products..." id="searchBox">
25 </div>
26
27 <div class="table-responsive">
28 <table class="table table-hover" id="productsTable">
29 <thead>
30 <tr>
31 <th>SKU</th>
32 <th>Product Name</th>
33 <th>Category</th>
34 <th>Supplier</th>
35 <th>Unit Price</th>
36 <th>Reorder Level</th>
37 <th>Status</th>
38 <th>Actions</th>
39 </tr>
40 </thead>
41 <tbody>
42 @foreach (var product in Model)
43 {
44 <tr>
45 <td><code>@product.Sku</code></td>
46 <td><strong>@product.Name</strong></td>
47 <td>@(product.Category?.Name ?? "-")</td>
48 <td>@(product.Supplier?.Name ?? "-")</td>
49 <td><strong>@product.UnitPrice.ToString("N2") MKD</strong></td>
50 <td>
51 <span class="badge bg-info">@product.ReorderLevel</span>
52 </td>
53 <td>
54 @if (product.IsActive)
55 {
56 <span class="badge bg-success">
57 <i class="fas fa-check"></i> Active
58 </span>
59 }
60 else
61 {
62 <span class="badge bg-secondary">Inactive</span>
63 }
64 </td>
65 <td>
66 <div class="btn-group btn-group-sm">
67 <a href="/Product/Edit/@product.ProductId" class="btn btn-warning">
68 <i class="fas fa-edit"></i>
69 </a>
70 <button onclick="deleteProduct(@product.ProductId)" class="btn btn-danger">
71 <i class="fas fa-trash"></i>
72 </button>
73 </div>
74 </td>
75 </tr>
76 }
77 </tbody>
78 </table>
79 </div>
80
81 @if (!Model.Any())
82 {
83 <div class="text-center py-5">
84 <i class="fas fa-inbox fa-3x text-muted mb-3"></i>
85 <p class="text-muted">No products found.</p>
86 <a href="/Product/Create" class="btn btn-primary">
87 <i class="fas fa-plus"></i> Add First Product
88 </a>
89 </div>
90 }
91 </div>
92</div>
93
94@section Scripts {
95 <script>
96 function deleteProduct(id) {
97 if (confirm('Are you sure you want to delete this product?')) {
98 const form = document.createElement('form');
99 form.method = 'POST';
100 form.action = '/Product/Delete/' + id;
101
102
103 const token = document.querySelector('input[name="__RequestVerificationToken"]');
104 if (token) {
105 const input = document.createElement('input');
106 input.type = 'hidden';
107 input.name = '__RequestVerificationToken';
108 input.value = token.value;
109 form.appendChild(input);
110 }
111
112 document.body.appendChild(form);
113 form.submit();
114 }
115 }
116
117 $(document).ready(function() {
118 $('#searchBox').on('keyup', function() {
119 const value = $(this).val().toLowerCase();
120 $('#productsTable tbody tr').filter(function() {
121 $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
122 });
123 });
124 });
125 </script>
126}
Note: See TracBrowser for help on using the repository browser.