-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustomer_view.php
More file actions
423 lines (370 loc) · 13.5 KB
/
customer_view.php
File metadata and controls
423 lines (370 loc) · 13.5 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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<?php
require_once('includes/load.php');
$page_title = 'Customer View - Inventory';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?php echo $page_title; ?></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
<link rel="stylesheet" href="libs/css/main.css" />
<style>
body {
background-color: #1e1e1e;
color: #fff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.inventory-header {
background: linear-gradient(to right, #3498db, #2980b9);
color: white;
padding: 20px;
border-radius: 5px;
margin-bottom: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.inventory-header h3 {
margin-top: 0;
font-weight: 600;
}
.filter-section {
background-color: #2c2c2c;
padding: 20px;
border-radius: 5px;
margin-bottom: 30px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.product-card {
background-color: #2c2c2c;
border-radius: 5px;
margin-bottom: 25px;
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}
.product-image {
width: 100%;
height: 180px;
object-fit: cover;
border-bottom: 1px solid #3c3c3c;
}
.product-details {
padding: 15px;
}
.product-title {
font-weight: bold;
margin-bottom: 8px;
font-size: 16px;
}
.warehouse-location {
color: #aaa;
font-size: 12px;
margin-bottom: 12px;
}
.product-price {
margin-bottom: 12px;
font-size: 15px;
font-weight: 500;
}
.stock-status {
display: inline-block;
padding: 5px 10px;
border-radius: 15px;
font-size: 12px;
font-weight: 500;
}
.in-stock {
background-color: rgba(46, 204, 113, 0.2);
color: #2ecc71;
}
.low-stock {
background-color: rgba(241, 196, 15, 0.2);
color: #f1c40f;
}
.form-control {
background-color: #3c3c3c;
border: 1px solid #555;
color: #fff;
height: 40px;
box-shadow: none;
}
.form-control:focus {
background-color: #3c3c3c;
border-color: #3498db;
color: #fff;
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
h4 {
margin-top: 0;
margin-bottom: 10px;
color: #ddd;
}
/* Add a footer */
.footer {
text-align: center;
padding: 20px 0;
margin-top: 30px;
color: #aaa;
font-size: 12px;
border-top: 1px solid #3c3c3c;
}
/* Request button styling */
.request-purchase-btn {
margin-top: 10px;
background-color: #3498db;
border-color: #2980b9;
transition: background-color 0.3s ease;
}
.request-purchase-btn:hover {
background-color: #2980b9;
}
/* Modal styling */
.modal-content {
background-color: #2c2c2c;
color: #fff;
border-radius: 5px;
}
.modal-header {
border-bottom: 1px solid #3c3c3c;
}
.modal-footer {
border-top: 1px solid #3c3c3c;
}
.close {
color: #fff;
opacity: 0.7;
}
.close:hover {
color: #fff;
opacity: 1;
}
.form-control-static {
padding-top: 0;
color: #3498db;
font-weight: 500;
}
</style>
</head>
<body>
<div class="container">
<div class="inventory-header">
<div class="row">
<div class="col-md-12">
<h3><i class="glyphicon glyphicon-shopping-cart"></i> Inventory Browser</h3>
<p>Browse our available products across all warehouse locations</p>
</div>
<!-- Removed the login button section -->
</div>
</div>
<!-- Display messages -->
<?php if(isset($_SESSION['success'])): ?>
<div class="alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert">×</button>
<?php
echo $_SESSION['success'];
unset($_SESSION['success']);
?>
</div>
<?php endif; ?>
<?php if(isset($_SESSION['error'])): ?>
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert">×</button>
<?php
echo $_SESSION['error'];
unset($_SESSION['error']);
?>
</div>
<?php endif; ?>
<?php if(isset($_SESSION['errors']) && is_array($_SESSION['errors'])): ?>
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert">×</button>
<ul>
<?php foreach($_SESSION['errors'] as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
<?php unset($_SESSION['errors']); ?>
</ul>
</div>
<?php endif; ?>
<div class="row filter-section">
<div class="col-md-6">
<h4>Filter by Warehouse</h4>
<select id="warehouse-select" class="form-control">
<option value="all">All Warehouses</option>
<?php
$warehouses = find_all('warehouses');
foreach ($warehouses as $warehouse):
?>
<option value="<?php echo $warehouse['id']; ?>"><?php echo $warehouse['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
<h4>Search Products</h4>
<input type="text" id="product-search" class="form-control" placeholder="Search by product name...">
</div>
</div>
<div class="row" id="product-container">
<?php
// Get all products with their warehouse information
$sql = "SELECT p.id, p.name, p.quantity, p.sale_price, p.media_id, p.warehouse_id, w.name as warehouse_name ";
$sql .= "FROM products p ";
$sql .= "LEFT JOIN warehouses w ON p.warehouse_id = w.id ";
$sql .= "WHERE p.quantity > 0 ";
$sql .= "ORDER BY p.name ASC";
$products = find_by_sql($sql);
foreach ($products as $product):
// Get product image
$media_id = $product['media_id'];
$img_file = find_by_id('media', $media_id);
// Check if image exists, if not, don't display image tag
$has_image = ($img_file && file_exists('uploads/products/'.$img_file['file_name']));
// Determine stock status - moved this here to fix the undefined variable error
$stock_class = ($product['quantity'] > 5) ? 'in-stock' : 'low-stock';
$stock_text = ($product['quantity'] > 5) ? 'In Stock' : 'Low Stock';
?>
<div class="col-md-3 product-item" data-warehouse="<?php echo $product['warehouse_id']; ?>">
<div class="product-card">
<?php if($has_image): ?>
<img src="uploads/products/<?php echo $img_file['file_name']; ?>" class="product-image" alt="<?php echo $product['name']; ?>">
<?php else: ?>
<div class="product-image" style="background-color: #3c3c3c; display: flex; align-items: center; justify-content: center;">
<span class="glyphicon glyphicon-picture" style="font-size: 40px; color: #555;"></span>
</div>
<?php endif; ?>
<div class="product-details">
<h4 class="product-title"><?php echo $product['name']; ?></h4>
<p class="warehouse-location">
<i class="glyphicon glyphicon-map-marker"></i>
<?php echo $product['warehouse_name'] ? $product['warehouse_name'] : 'Main Warehouse'; ?>
</p>
<p class="product-price">Price: $<?php echo number_format($product['sale_price'], 2); ?></p>
<div class="stock-status <?php echo $stock_class; ?>">
<?php echo $stock_text; ?> (<?php echo $product['quantity']; ?> available)
</div>
<!-- Add Request Purchase Button -->
<button class="btn btn-primary btn-block request-purchase-btn"
data-product-id="<?php echo $product['id']; ?>"
data-product-name="<?php echo $product['name']; ?>"
data-warehouse-id="<?php echo $product['warehouse_id']; ?>"
data-warehouse-name="<?php echo $product['warehouse_name']; ?>">
<i class="glyphicon glyphicon-shopping-cart"></i> Request Purchase
</button>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- Added footer -->
<div class="footer">
<p>© <?php echo date('Y'); ?> Inventory Management System. All products shown are subject to availability.</p>
</div>
</div>
<!-- Purchase Request Modal -->
<!-- Purchase Request Modal -->
<!-- 2. Make Sure Customer View Form is Updated
Ensure your customer_view.php file has the purchase request form properly set up:
```php
<!-- Purchase Request Modal -->
<div class="modal fade" id="requestModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Request Purchase</h4>
</div>
<form id="purchase-request-form" action="process_customer_request.php" method="post">
<div class="modal-body">
<input type="hidden" id="product-id" name="product-id">
<input type="hidden" id="warehouse-id" name="warehouse-id">
<div class="form-group">
<label>Product:</label>
<p id="modal-product-name" class="form-control-static"></p>
</div>
<div class="form-group">
<label>Warehouse:</label>
<p id="modal-warehouse-name" class="form-control-static"></p>
</div>
<div class="form-group">
<label for="quantity">Quantity:</label>
<input type="number" class="form-control" id="quantity" name="quantity" min="1" required>
</div>
<h4>Your Information</h4>
<div class="form-group">
<label for="customer-name">Your Name:</label>
<input type="text" class="form-control" id="customer-name" name="customer-name" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="phone">Phone:</label>
<input type="text" class="form-control" id="phone" name="phone">
</div>
<div class="form-group">
<label for="address">Address:</label>
<textarea class="form-control" id="address" name="address" rows="3"></textarea>
</div>
<div class="form-group">
<label for="notes">Notes:</label>
<textarea class="form-control" id="notes" name="notes" rows="3" placeholder="Any special instructions or requirements..."></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Submit Request</button>
</div>
</form>
</div>
</div>
</div>
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
// Warehouse filter functionality
$('#warehouse-select').on('change', function() {
var selectedWarehouse = $(this).val();
if (selectedWarehouse === 'all') {
$('.product-item').show();
} else {
$('.product-item').hide();
$('.product-item[data-warehouse="' + selectedWarehouse + '"]').show();
}
});
// Product search functionality
$('#product-search').on('keyup', function() {
var searchTerm = $(this).val().toLowerCase();
$('.product-item').each(function() {
var productName = $(this).find('.product-title').text().toLowerCase();
if (productName.indexOf(searchTerm) > -1) {
$(this).show();
} else {
$(this).hide();
}
});
});
// Purchase request button functionality
$('.request-purchase-btn').on('click', function() {
var productId = $(this).data('product-id');
var productName = $(this).data('product-name');
var warehouseId = $(this).data('warehouse-id');
var warehouseName = $(this).data('warehouse-name');
// Set values in the modal
$('#product-id').val(productId);
$('#warehouse-id').val(warehouseId);
$('#modal-product-name').text(productName);
$('#modal-warehouse-name').text(warehouseName);
// Show the modal
$('#requestModal').modal('show');
});
});
</script>
</body>
</html>