Skip to content

Commit ee47312

Browse files
Refactor code to display prices with two decimal
places
1 parent 05cb3aa commit ee47312

File tree

13 files changed

+97
-32
lines changed

13 files changed

+97
-32
lines changed

functions/proceed-transaction.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
$stmt->bindParam(':user_id', $_SESSION['id']);
3131
$stmt->execute();
3232
$results = $stmt->fetchAll();
33-
33+
if (count($results) == 0){
34+
header('location: ../transaction.php?type=error&message=No items');
35+
exit();
36+
}
3437
$item_total = 0;
3538
foreach ($results as $result){
3639
$item_total += $result['total'];

functions/views/dashboard-chart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function daily_chart(){
55
global $db;
66
$sql = "SELECT DATE(created_at) AS date, SUM(total) AS total_sales
77
FROM transactions
8-
WHERE status = 4
8+
WHERE status >= 1
99
GROUP BY DATE(created_at)
1010
ORDER BY DATE(created_at)";
1111

@@ -43,7 +43,7 @@ function month_chart(){
4343
global $db;
4444
$sql = "SELECT YEAR(created_at) AS year, MONTH(created_at) AS month, SUM(total) AS total_sales
4545
FROM transactions
46-
WHERE status = 4
46+
WHERE status >= 1
4747
GROUP BY YEAR(created_at), MONTH(created_at)
4848
ORDER BY YEAR(created_at), MONTH(created_at)";
4949

functions/views/dashboard-count.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function get_monthly(){
55
global $db;
66
$sql = "SELECT SUM(total) AS total_earnings
77
FROM transactions
8-
WHERE status = 4
8+
WHERE status >= 1
99
AND MONTH(created_at) = MONTH(CURRENT_TIMESTAMP)
1010
AND YEAR(created_at) = YEAR(CURRENT_TIMESTAMP)";
1111
$stmt = $db->prepare($sql);
@@ -16,7 +16,7 @@ function get_monthly(){
1616
echo "0";
1717
}
1818
else{
19-
echo $row['total_earnings'];
19+
echo number_format($row['total_earnings'],2);
2020
}
2121
}
2222
}
@@ -26,14 +26,14 @@ function get_yearly(){
2626
$sql = "SELECT YEAR(CURRENT_TIMESTAMP) AS year,
2727
SUM(total) AS total_earnings
2828
FROM transactions
29-
WHERE status = 4
29+
WHERE status >= 1
3030
GROUP BY YEAR(created_at) = YEAR(CURRENT_TIMESTAMP)";
3131
$stmt = $db->prepare($sql);
3232
$stmt->execute();
3333
$results = $stmt->fetchAll();
3434
if ($results){
3535
foreach ($results as $row) {
36-
echo $row['total_earnings'];
36+
echo number_format($row['total_earnings'],2);
3737
}}
3838
else{
3939
echo "0";

functions/views/navbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
} else {
1414
?>
1515
<li class="nav-item"><a class="nav-link <?= ($currentPage == 'index.php') ? 'active' : ''; ?>" href="index.php"><i class="fas fa-tachometer-alt"></i><span>Dashboard</span></a></li>
16-
<a class="nav-link <?= ($currentPage == 'transaction.php') ? 'active' : ''; ?>" href="transaction.php"><i class="far fa-credit-card"></i><span>Transaction</span></a></li>
16+
<li class="nav-item"><a class="nav-link <?= ($currentPage == 'transaction.php') ? 'active' : ''; ?>" href="transaction.php"><i class="far fa-credit-card"></i><span>Transaction</span></a></li>
1717
<li class="nav-item"><a class="nav-link <?= ($currentPage == 'customer.php') ? 'active' : ''; ?>" href="customer.php"><i class="fas fa-user"></i><span>Customers</span></a></li>
1818
<li class="nav-item"><a class="nav-link <?= ($currentPage == 'queue.php') ? 'active' : ''; ?>" href="queue.php"><i class="fas fa-table"></i><span>Queuing</span></a></li>
1919
<?php

functions/views/price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<tr>
1414
<td>#<?php echo $row['id']; ?></td>
1515
<td><?php echo $row['name']; ?></td>
16-
<td><?php echo $row['price']; ?></td>
16+
<td><?php echo number_format($row['price'], 2); ?></td>
1717
<td><?php echo $row['created_at']; ?></td>
1818
<td class="text-center">
1919
<a class="mx-1" href="#" role="button" data-bs-target="#update" data-bs-toggle="modal" data-id="<?php echo $row['id']?>" data-name="<?php echo $row['name']?>" data-price="<?php echo $row['price']?>"><i class="far fa-edit text-warning" style="font-size: 20px;"></i></a>

functions/views/products.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr>
2323
<td>#<?php echo $row['id']; ?></td>
2424
<td><?php echo $row['name']; ?></td>
25-
<td>₱<?php echo $row['price']; ?></td>
25+
<td>₱<?php echo number_format($row['price'], 2); ?></td>
2626
<td><?php echo $row['qty']; ?></td>
2727
<td><?php echo $row['created_at']; ?></td>
2828

functions/views/queue-dashboard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$sql = 'SELECT t.status, t.id, t.kilo, t.total, t.total, t.created_at, c.fullname, ROW_NUMBER() OVER (ORDER BY status DESC, kilo ASC) AS queue_number
44
FROM Transactions AS t
55
JOIN customers AS c ON t.customer_id = c.id
6-
WHERE t.status < 4
6+
WHERE t.status > 0 AND t.status < 4
77
';
88

99
$stmt = $db->prepare($sql);
@@ -31,7 +31,7 @@
3131
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/profile.png"><?php echo $row['fullname']; ?></td>
3232
<td><?php echo $row['id']; ?></td>
3333
<td><?php echo $row['kilo']; ?></td>
34-
<td><?php echo $row['total']; ?></td>
34+
<td><?php echo number_format($row['total'] , 2); ?></td>
3535
<td><?php echo $status ?></td>
3636
<td><?php echo $row['created_at']; ?></td>
3737
</tr>

functions/views/queue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$sql = 'SELECT t.status, t.id, t.kilo, t.total, t.total, t.created_at, c.fullname, ROW_NUMBER() OVER (ORDER BY status DESC, kilo ASC) AS queue_number
44
FROM Transactions AS t
55
JOIN customers AS c ON t.customer_id = c.id
6-
WHERE t.status < 4
6+
WHERE t.status > 0 AND t.status < 4
77
';
88

99
$stmt = $db->prepare($sql);
@@ -31,7 +31,7 @@
3131
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/profile.png"><?php echo $row['fullname']; ?></td>
3232
<td><?php echo $row['id']; ?></td>
3333
<td><?php echo $row['kilo']; ?></td>
34-
<td><?php echo $row['total']; ?></td>
34+
<td><?php echo number_format($row['total'], 2); ?></td>
3535
<td><?php echo $status ?></td>
3636
<td><?php echo $row['created_at']; ?></td>
3737
<td class="text-center">

functions/views/sales.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
FROM Transactions
66
JOIN users ON Transactions.user_id = users.id
77
JOIN customers ON Transactions.customer_id = customers.id
8-
WHERE Transactions.status = 4;';
8+
WHERE Transactions.status >= 1;';
99
$stmt = $db->prepare($sql);
1010
$stmt->execute();
1111
$results = $stmt->fetchAll();
@@ -30,7 +30,7 @@
3030
echo '<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/profile.png">' . $row['fullname'] . '</td>';
3131
echo '<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/profile.png">' . $row['username'] . '</td>';
3232
echo '<td>' . $row['kilo'] . '</td>';
33-
echo '<td>' . $row['total'] . '</td>';
33+
echo '<td>' . number_format($row['total'], 2) . '</td>';
3434
echo '<td>' . $status. '</td>';
3535
echo '<td>' . $row['created_at'] . '</td>';
3636
echo '</tr>';

functions/views/supply.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<tr>
1414
<td>#<?php echo $row['id']; ?></td>
1515
<td><?php echo $row['name']; ?></td>
16-
<td><?php echo $row['price']; ?></td>
16+
<td><?php echo number_format($row['price'], 2); ?></td>
1717
<td><?php echo $row['stock']; ?></td>
1818
<td><?php echo $row['created_at']; ?></td>
1919
<td class="text-center">

0 commit comments

Comments
 (0)