-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory_memo.php
More file actions
150 lines (127 loc) · 4.93 KB
/
category_memo.php
File metadata and controls
150 lines (127 loc) · 4.93 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
<?php
require_once('includes/session.php');
require_once('includes/load.php');
require_once('includes/functions.php');
require_once('includes/sql.php');
$page_title = 'Category Memo';
$user = current_user();
if (isset($_GET['section'])) {
$section = $_GET['section'];
if ($section === 'all') {
$products_in_category = find_all("products");
} else {
$categories_in_section = find_where("categories", "WHERE section = '{$section}'");
$products_in_category = [];
foreach ($categories_in_section as $category) {
$products_in_this_category = find_where("products", "WHERE categorie_id = '{$category['id']}'");
$products_in_category = array_merge($products_in_category, $products_in_this_category);
}
}
} elseif (isset($_GET['id'])) {
$category_id = (int)$_GET['id'];
$category = find_by_id('categories', $category_id);
$products_in_category = find_where("products", "WHERE categorie_id = '{$category_id}'");
} else {
redirect('categorie.php');
}
$subTotalProducts = 0;
$subTotalQuantityArrived = 0;
$subTotalUsing = 0;
$subTotalLastInventory = 0;
$subTotalInactiveProducts = 0;
$subTotalPresentQuantity = 0;
$selected_design = isset($_GET['selected_design']) ? $_GET['selected_design'] : 'color'; // Default to 'color' design
?>
<link rel="stylesheet" href="<?php echo $selected_design === 'color' ? 'libs/css/memo.css' : 'libs/css/memo-classic.css'; ?>">
<div class="headings">
<h2 class="h-text">ABCXYZ Institute</h2>
<h3 class="h-text">Department of XYZ Technology</h3>
<h3 class="h-text">ABC LAB</h3>
<h4 class="h-text">Inventory Management System</h4>
<h4 class="h-text">Report of Category : <?php echo isset($section) ? ($section === 'all' ? 'All Categories' : ($section === 'fixed' ? 'Fixed Items' : 'Raw Materials')) : $category['name'];?></h4>
</div>
<p class="date">
<?php
date_default_timezone_set('Asia/Dhaka');
echo "Date: " . date("d/m/Y | h:i a");
?>
</p>
<table class="<?php echo $selected_design === 'color' ? 'table' : 'table-classic'; ?>">
<tr class="trh">
<th>#</th>
<th>Indent No., Item Name & Specification</th>
<th>Receive <br> Date</th>
<th>Quantity <br> Arrived</th>
<th>Using</th>
<!-- <th>Last <br> Inventory</th> -->
<th>Inactive <br> Quantity</th>
<th>Inactive <br> Date</th>
<th>Last <br> Inventory</th>
</tr>
<?php foreach ($products_in_category as $product): ?>
<tr>
<td><?php echo $subTotalProducts + 1; ?></td>
<td>
<?php echo $product['name']; ?> <br>
Spec: <?php echo $product['specification']; ?>
</td>
<td><?php echo date('d/m/Y', strtotime($product['date'])); ?></td>
<td>
<?php
$quantity_arrived = get_total_product_using($product['id']) + get_total_product_reserved($product['id']) + get_total_product_defect($product['id']) + $product['quantity'];
echo $quantity_arrived;
?>
</td>
<td><?php echo get_total_product_using($product['id']); ?></td>
<!-- <td><?php echo get_total_product_reserved($product['id']); ?></td> -->
<td><?php echo get_total_product_defect($product['id']); ?></td>
<!-- Add the sales date here -->
<td>
<?php
// Fetch sales date for the current product
$sales_date = get_sales_date($product['id']);
echo date('d/m/Y', strtotime($sales_date));
?>
</td>
<td><?php echo $product['quantity']; ?></td>
<!-- Update the subtotal variables for the current product -->
<?php
$subTotalQuantityArrived += $product['quantity'];
$subTotalUsing += get_total_product_using($product['id']);
$subTotalLastInventory += get_total_product_reserved($product['id']);
$subTotalInactiveProducts += get_total_product_defect($product['id']);
$subTotalPresentQuantity += $quantity_arrived;
++$subTotalProducts;
?>
</tr>
<?php endforeach; ?>
<!-- Display the subtotals -->
<tr class="tr-subtotal">
<td></td>
<td><strong>SUBTOTAL (<?= count($products_in_category) ?>)</strong></td>
<td></td>
<td><strong><?= number_format($subTotalPresentQuantity) ?></strong></td>
<td><strong><?= number_format($subTotalUsing) ?></strong></td>
<!-- <td><strong><?= number_format($subTotalLastInventory) ?></strong></td> -->
<td><strong><?= number_format($subTotalInactiveProducts) ?></strong></td>
<td></td>
<td><strong><?= number_format($subTotalQuantityArrived) ?></strong></td>
</tr>
</table>
<div class="subtitle-wrapper">
<div class="subtitle">
<br>
<p>_________________________</p>
<p>Head of The Department</p>
<br>
<?php echo date("d-M-Y | h:i A"); ?>
</div>
<div class="subtitle">
<br>
<p>______________________</p>
<p>Report Generated by </p>
<?php echo remove_junk(ucfirst($user['name'])); ?>
<br>
<?php echo date("d-M-Y | h:i A"); ?>
</div>
</div>