-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.php
138 lines (121 loc) · 5.43 KB
/
dashboard.php
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
<?php
define('APP_RUNNING', 1);
ob_start();
session_start();
require_once 'globals.include.php';
if (!isset($_SESSION["user"])) {
header("Location: login.php");
}
$user_id = $_SESSION["user"];
$stmt = $dbConn->prepare("SELECT name,email FROM users WHERE user_id= :user_id");
$stmt->bindParam(":user_id", $user_id);
$stmt->execute();
$user = $stmt->fetch();
$name = $user["name"];
$email = $user["email"];
$parcels = [];
$stmt = $dbConn->prepare("SELECT p.code, p.status, p.type, pr.name, pr.company, pr.city, pr.state
FROM parcels AS p
JOIN parcel_recipient AS pr ON p.parcel_recipient_id = pr.parcel_recipient_id
WHERE p.user_id = :user_id");
$stmt->bindParam(":user_id", $user_id);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$parcels = $stmt->fetchAll();
}
$transactions = [];
$stmt = $dbConn->prepare("SELECT * FROM transactions WHERE user_id = :user_id");
$stmt->bindParam(":user_id", $user_id);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$transactions = $stmt->fetchAll();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>iParcel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<?php include 'navbar.include.php'; ?>
<div class="px-4 py-5 my-5">
<div class="container">
<?php include 'confirm-email.include.php'; ?>
<h2 class="mb-4">Welcome <?= $name; ?> <small class="text-body-secondary">(<?= $email; ?>)</small></h2>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Tracking ID</th>
<th scope="col">Status</th>
<th scope="col">Recipient name</th>
<th scope="col">Recipient company</th>
<th scope="col">Recipient city</th>
</tr>
</thead>
<tbody>
<?php if (empty($parcels)) : ?>
<tr class="text-center">
<td colspan="5">
<h4 class="py-4 my-4"><i class="bi bi-box2-heart-fill"></i>
Ready to start shipping? <a href="newshipping.php">Get started now!</a></h4>
</td>
</tr>
<?php endif; ?>
<?php foreach ($parcels as $parcel) : ?>
<tr>
<th><a href="viewtracking.php?tracknum=<?= $parcel["code"]; ?>"><?= $parcel["code"]; ?></a></th>
<td><?= getDeliveryStatus($parcel["status"]); ?>
<?php if ($parcel["type"] == 1) : ?>
<span class="badge rounded-pill text-bg-warning">Heavy</span>
<?php endif; ?>
</td>
<th><?= $parcel["name"]; ?></th>
<th><?= $parcel["company"]; ?></th>
<th><?= $parcel["city"]; ?></th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h4>My transaction history</h4>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Transaction ID</th>
<th scope="col">Status</th>
<th scope="col">Total</th>
<th scope="col">Paid on</th>
</tr>
</thead>
<tbody>
<?php if (empty($transactions)) : ?>
<tr class="text-center">
<td colspan="5">
<h4 class="py-4 my-4">You have no transaction history with us</h4>
</td>
</tr>
<?php endif; ?>
<?php foreach ($transactions as $transaction) : ?>
<tr>
<th><?= $transaction["transaction_id"]; ?></th>
<th><span class="badge rounded-pill text-bg-success"><?= getPaidStatus($transaction["status"]); ?></span></th>
<th>$ <?= $transaction["total"]; ?></th>
<?php $dt = new DateTime($transaction["paid_on"]); ?>
<td><?= $dt->format('l, F j, Y'); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
* If you have a transaction dispute, please contact us.
</div>
</div>
<?php include 'footer.include.php'; ?>
</body>
</html>