-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct.php
More file actions
321 lines (265 loc) · 13.1 KB
/
Copy pathproduct.php
File metadata and controls
321 lines (265 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
$page_title = 'All Product';
require_once('includes/load.php');
require_once('includes/functions.php');
// Checkin What level user has permission to view this page
page_require_level(3);
$all_categories = find_all('categories');
$all_photo = find_all('media');
$sort_column = isset($_GET['sort']) ? $_GET['sort'] : 'date'; // Default sorting column set to 'date'
$sort_order = isset($_GET['order']) ? $_GET['order'] : 'desc'; // Default sorting order set to 'desc'
$products = join_product_table(null, $sort_column, $sort_order);
$search = isset($_GET['search']) ? $_GET['search'] : '';
if ($search !== '') {
$products = search_products($search);
} else {
$products = join_product_table(null, $sort_column, $sort_order);
}
?>
<?php include_once('layouts/header.php'); ?>
<link rel="stylesheet" href="libs/css/inventoryPopup.css"/>
<div class="row zindex">
<div class="col-md-12">
<?php echo display_msg($msg); ?>
</div>
</div>
<div class="row">
<div class="panel panel-default">
<!----- TABLE HEAD ----->
<div class="panel-heading wrapper">
<div>
<img src="libs/logos/table-logo/inventory.png" alt="inventory-logo">
<span>All Inventory</span>
</div>
<div class=" wrapper search-add">
<div class="allCategoryForm">
<form action="" method="get" class="allCategoryFormWrap">
<div class="allCategoryInput">
<input type="text" class="allCategoryInputWrap" name="search" placeholder="Search Inventory">
<button class="searchBtn" type="submit"><img src="libs/logos/table-logo/search.png" class="searchBtnImg" alt=""></button>
</div>
<span class="searchBtnClose">
<a href="product.php">
<img src="libs/logos/table-logo/close.png"class="searchBtnCloseImg" alt="close">
</a>
</span>
</form>
</div>
<div class="table-add-btn-div">
<button class="btn btn-info pull-right btn-sm addNewGrp"> Add Inventory</button>
</div>
</div>
</div>
<!----- TABLE DATA ----->
<div class="panel-body">
<table class="table table-bordered">
<thead>
<tr>
<th class="text-center" style="width: 50px;">#</th>
<!-- <th style="width: 8%; "> Photo</th> -->
<th><a href="product.php?sort=name&order=<?php echo $sort_column === 'name' && $sort_order === 'asc' ? 'desc' : 'asc'; ?>">Product Title</a></th>
<th><a href="product.php?sort=categorie&order=<?php echo $sort_column === 'categorie' && $sort_order === 'asc' ? 'desc' : 'asc'; ?>">Categories</a></th>
<th><a href="product.php?sort=quantity&order=<?php echo $sort_column === 'quantity' && $sort_order === 'asc' ? 'desc' : 'asc'; ?>">Quantity</a></th>
<th><a href="product.php?sort=date&order=<?php echo $sort_column === 'date' && $sort_order === 'asc' ? 'desc' : 'asc'; ?>">Receive Date</a></th>
<th><a href="#">Specification</a></th>
<th><a href="#">Remarks</a></th>
<th class="text-center" style="width: 15%;">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product):?>
<tr style="">
<td><?php echo count_id();?></td>
<!-- <td>
<?php if($product['media_id'] === '0'): ?>
<img class="img-avatar " src="uploads/products/no_image.png" alt="no-image">
<?php else: ?>
<img class="img-avatar img-circle" src="uploads/products/<?php echo $product['image']; ?>" alt="">
<?php endif; ?>
</td> -->
<td class="productname" style="text-align :left !important"> <?php echo remove_junk($product['name']); ?></td>
<td>
<?php if (isset($product['categorie'])): ?>
<a href="view_category.php?id=<?php echo (int)$product['categorie_id']; ?>" class="tdLink"><?php echo remove_junk($product['categorie']); ?></a>
<?php else: ?>
N/A
<?php endif; ?>
</td>
<td> <?php echo remove_junk($product['quantity']); ?></td>
<td> <?php echo date("M d, Y", strtotime($product['date'])); ?></td>
<td>
<a class="tdLink" data-toggle="modal" data-target="#specModal_<?php echo $product['id']; ?>">View Specification</a>
</td>
<td>
<a class="tdLink" data-toggle="modal" data-target="#remarksModal_<?php echo $product['id']; ?>">View Comments</a>
</td>
<td>
<div class="btn-group edit-dlt-btn-group">
<a href="edit_product.php?id=<?php echo (int)$product['id'];?>" class="editBtn" data-toggle="tooltip" title="Edit">
<p>Edit <img src="libs/logos/table-logo/edit.png" alt="edit-logo"></p>
</a>
<a href="#" class="categoryDeleteBtn" title="Delete" data-toggle="tooltip" onclick="confirmDelete(<?php echo $product['id'];?>)">
<img src="libs/logos/table-logo/delete.png" alt="delete-logo">
</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Modals for displaying product specifications -->
<?php foreach ($products as $product): ?>
<div class="modal fade" id="specModal_<?php echo $product['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="specModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="specModalLabel">Product Specification</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php echo nl2br(htmlspecialchars($product['specification'])); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<!-- Modals for displaying product remarks -->
<?php foreach ($products as $product): ?>
<div class="modal fade" id="remarksModal_<?php echo $product['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="remarksModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="remarksModalLabel">Product Remarks</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php echo nl2br(htmlspecialchars($product['remarks'])); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<!-- popup de agregar inventario (Popup - Add Inventory) -->
<!-- yes, written by muhib for emnei -->
<div class="addNewgGroupPopUpWap display">
<div class="newgroupPopHeadWrap">
<div class="iconHeadGroup">
<img src="libs/logos/table-logo/inventory.png" alt="logo">
<div class="addPopGroupTitle">Add Active</div>
</div>
<div class="addNewGroupContent">
<div class="addNewForm">
<form method="post" action="add_product.php" class="">
<!-- Wrapper to divide into 50 50 -->
<div class="wrapperDividerGroup wrapper">
<!-- wrapperGroup Left STARTS -->
<div class="wrapperGroup wrapper">
<div class="inputGrup productNameField">
<label for="name">Product Name</label>
<input type="text" class="form-control" name="product-title" placeholder="Product Title">
</div>
<!-- Wrapper : Category | Image -->
<div class="wrapper">
<!-- Category -->
<div class="inputGrup">
<h3 class="inputTitle">Select Product Category</h3>
<select class="form-control" name="product-categorie">
<option value="">Select Category</option>
<?php foreach ($all_categories as $cat): ?>
<option value="<?php echo (int)$cat['id'] ?>">
<?php echo $cat['name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<!-- Image -->
<div class="inputGrup">
<h3 class="inputTitle">Select Product Image</h3>
<select class="form-control" name="product-photo">
<option value="">Select Photo</option>
<?php foreach ($all_photo as $photo): ?>
<option value="<?php echo (int)$photo['id'] ?>">
<?php echo $photo['file_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<!-- Wrapper : Quantity | Date -->
<div class="wrapper">
<!-- Quantity -->
<div class="inputGrup">
<label for="quantity">Quantity</label>
<input type="number" class="form-control" name="product-quantity" placeholder="Product Quantity">
</div>
<!-- Date -->
<div class="inputGrup">
<label for="date">Date</label>
<input type="date" class="form-control" name="date-added" placeholder="Date Added">
</div>
</div>
<!-- Wrapper : Buy Price | Sale Price -->
<div class="wrapper">
<!-- Buying Price -->
<div class="inputGrup">
<label for="b_price">Buying Price</label>
<input type="number" class="form-control" name="buying-price" placeholder="Buying Price" step="any" value="0">
</div>
<!-- Selling Price -->
<div class="inputGrup">
<label for="s_price">Selling Price</label>
<input type="number" class="form-control" name="saleing-price" placeholder="Selling Price" step="any" value="0">
</div>
</div>
</div>
<!-- wrapperGroup Left ENDS -->
<!-- wrapperGroup Right STARTS -->
<div class="wrapperGroup wrapper ">
<!-- Specification -->
<div class="inputGrup w80">
<label for="product-specification">Product Specification</label>
<textarea class="form-control" name="product-specification" rows="4" cols="50" style="resize: none !important;" placeholder="Product Specification"></textarea>
</div>
<!-- Comment -->
<div class="inputGrup w80">
<label for="product-remarks">Comment</label>
<textarea class="form-control" name="product-remarks" rows="4" cols="50" style="resize: none !important;" placeholder="Product Comment"></textarea>
</div>
</div>
<!-- wrapperGroup Right ENDS -->
</div>
<!-- Button -->
<div class="buttonGroup">
<div>
<div class="cancelBtn">
<button type="button">Cancel</button>
</div>
<div class="submitbtn">
<button type="submit" name="add_product" class="btn">Add product</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function confirmDelete(productId) {
if (confirm("Are you sure you want to delete this entry? This data may be lost.")) {
window.location.href = "delete_product.php?id=" + productId;
}
}
</script>
<?php include_once('layouts/footer.php'); ?>