-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin_transaction.php
More file actions
90 lines (82 loc) · 3.43 KB
/
admin_transaction.php
File metadata and controls
90 lines (82 loc) · 3.43 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
<?php
$title = "Food Court Rental System | Admin Dashboard";
require('template/header.php');
require('template/admin_nav.php');
require('includes/connectDB.php');
$sql = "SELECT
t.transaction_id,
t.stall_id,
CONCAT(u.first_name, ' ', u.last_name) AS name,
t.years_contract,
t.start_date,
t.paid,
t.amount_paid,
t.total_price,
t.transaction_date
FROM
transaction t
JOIN
user u ON t.user_id = u.user_id";
$result = mysqli_query($connection, $sql);
if (!$result) {
$error_message = "Error executing query: " . mysqli_error($connection);
$transactions = [];
} else {
$transactions = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
?>
<main class="container mt-5">
<h2 class="text-center mb-4">Transactions</h2>
<?php
if (isset($_GET['errorMsg'])) {
echo '<div class="alert alert-danger" role="alert">'. htmlspecialchars($_GET['errorMsg']) . '</div>';
}
if (isset($_GET['successMsg'])) {
echo '<div class="alert alert-success" role="alert">'. htmlspecialchars($_GET['successMsg']) . '</div>';
}
if (isset($error_message)) {
echo '<div class="alert alert-danger" role="alert">'. htmlspecialchars($error_message) . '</div>';
}
?>
<table class="table">
<thead>
<tr>
<th>Transaction ID</th>
<th>Stall ID</th>
<th>User Name</th>
<th>Years Contract</th>
<th>Paid</th>
<th>Balance</th>
<th>Total Price</th>
<th>Start Date</th>
<th>Transaction Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if (empty($transactions)) { ?>
<tr>
<td colspan="10" class="text-center">No transactions found.</td>
</tr>
<?php } else {
foreach ($transactions as $row) { ?>
<tr>
<td><?php echo htmlspecialchars($row['transaction_id']); ?></td>
<td><?php echo htmlspecialchars($row['stall_id']); ?></td>
<td><?php echo htmlspecialchars($row['name']); ?></td>
<td><?php echo htmlspecialchars($row['years_contract']); ?></td>
<td><?php echo $row['paid'] ? 'Yes' : 'No'; ?></td>
<td><?php echo htmlspecialchars($row['balance']); ?></td>
<td><?php echo htmlspecialchars($row['total_price']); ?></td>
<td><?php echo htmlspecialchars($row['start_date']); ?></td>
<td><?php echo htmlspecialchars($row['transaction_date']); ?></td>
<td>
<a href="/edit_transaction.php?transaction_id=<?php echo htmlspecialchars($row['transaction_id']); ?>" class="btn btn-primary btn-sm">Update</a>
<a href="/controller/deleteTransaction.php?transaction_id=<?php echo htmlspecialchars($row['transaction_id']); ?>" class="btn btn-danger btn-sm">Delete</a>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
</main>
<?php require('template/footer.php'); ?>