-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview_warehouse.php
More file actions
136 lines (130 loc) · 5.37 KB
/
view_warehouse.php
File metadata and controls
136 lines (130 loc) · 5.37 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
<?php
$page_title = 'View Warehouse';
require_once('includes/load.php');
// Check user permission
page_require_level(1);
$warehouse_id = (int)$_GET['id'];
if(empty($warehouse_id)){
redirect('warehouse.php');
}
$warehouse = find_by_warehouse_id($warehouse_id);
if(!$warehouse){
$session->msg("d","Missing warehouse id.");
redirect('warehouse.php');
}
// Modify the query to properly join with categories table
$products = find_products_by_warehouse($warehouse_id);
?>
<?php include_once('layouts/header.php'); ?>
<div class="row">
<div class="col-md-12">
<?php echo display_msg($msg); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Warehouse: <?php echo remove_junk($warehouse['name']); ?></span>
</strong>
<div class="pull-right">
<a href="warehouse.php" class="btn btn-primary">Back to Warehouses</a>
</div>
</div>
<div class="panel-body">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td class="text-right" style="width: 20%;">Warehouse Name:</td>
<td><?php echo remove_junk($warehouse['name']); ?></td>
</tr>
<tr>
<td class="text-right">Location:</td>
<td><?php echo remove_junk($warehouse['location']); ?></td>
</tr>
<tr>
<td class="text-right">Description:</td>
<td><?php echo remove_junk($warehouse['description']); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Products in this Warehouse</span>
</strong>
<div class="pull-right">
<a href="add_product.php" class="btn btn-primary">Add New Product</a>
</div>
</div>
<div class="panel-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center" style="width: 50px;">#</th>
<th>Photo</th>
<th>Product Name</th>
<th>Category</th>
<th class="text-center" style="width: 10%;">Quantity</th>
<th class="text-center" style="width: 10%;">Buy Price</th>
<th class="text-center" style="width: 10%;">Sale Price</th>
<th class="text-center" style="width: 10%;">Added Date</th>
<th class="text-center" style="width: 100px;">Actions</th>
</tr>
</thead>
<tbody>
<?php if(empty($products)): ?>
<tr>
<td colspan="9" class="text-center">No products found in this warehouse</td>
</tr>
<?php else: ?>
<?php foreach ($products as $product): ?>
<tr>
<td class="text-center"><?php echo count_id();?></td>
<td>
<?php if($product['media_id'] === '0' || empty($product['image'])): // Check if media_id is 0 OR image filename is empty ?>
<img class="img-avatar img-circle" src="uploads/products/no_image.png" alt="No image available"> <? // Line 100: Default image with descriptive alt text ?>
<?php else: ?>
<img class="img-avatar img-circle" src="uploads/products/<?php echo $product['image']; ?>" alt="<?php echo remove_junk($product['name']); ?>"> <? // Line 102: Product image with product name as alt text ?>
<?php endif; ?>
</td>
<td><?php echo remove_junk($product['name']); ?></td>
<td>
<?php
// Check if category key exists before trying to access it
echo isset($product['category']) ? remove_junk($product['category']) : 'N/A';
?>
</td>
<td class="text-center"><?php echo remove_junk($product['quantity']); ?></td>
<td class="text-center"><?php echo remove_junk($product['buy_price']); ?></td>
<td class="text-center"><?php echo remove_junk($product['sale_price']); ?></td>
<td class="text-center"><?php echo read_date($product['date']); ?></td>
<td class="text-center">
<div class="btn-group">
<a href="edit_product.php?id=<?php echo (int)$product['id'];?>" class="btn btn-info btn-xs" title="Edit" data-toggle="tooltip">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a href="delete_product.php?id=<?php echo (int)$product['id'];?>" class="btn btn-danger btn-xs" title="Delete" data-toggle="tooltip">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include_once('layouts/footer.php'); ?>