forked from hammadshahir/PHP-MySQL-ecommerce-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer-order.php
192 lines (178 loc) · 9.11 KB
/
customer-order.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php require_once('header.php'); ?>
<?php
// Check if the customer is logged in or not
if(!isset($_SESSION['customer'])) {
header('location: '.BASE_URL.'logout.php');
exit;
} else {
// If customer is logged in, but admin make him inactive, then force logout this user.
$statement = $pdo->prepare("SELECT * FROM tbl_customer WHERE cust_id=? AND cust_status=?");
$statement->execute(array($_SESSION['customer']['cust_id'],0));
$total = $statement->rowCount();
if($total) {
header('location: '.BASE_URL.'logout.php');
exit;
}
}
?>
<div class="page">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php require_once('customer-sidebar.php'); ?>
</div>
<div class="col-md-12">
<div class="user-content">
<h3><?php echo LANG_VALUE_25; ?></h3>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th><?php echo LANG_VALUE_7; ?></th>
<th><?php echo LANG_VALUE_48; ?></th>
<th><?php echo LANG_VALUE_27; ?></th>
<th><?php echo LANG_VALUE_28; ?></th>
<th><?php echo LANG_VALUE_29; ?></th>
<th><?php echo LANG_VALUE_30; ?></th>
<th><?php echo LANG_VALUE_31; ?></th>
<th><?php echo LANG_VALUE_32; ?></th>
</tr>
</thead>
<tbody>
<?php
/* ===================== Pagination Code Starts ================== */
$adjacents = 5;
$statement = $pdo->prepare("SELECT * FROM tbl_payment WHERE customer_email=? ORDER BY id DESC");
$statement->execute(array($_SESSION['customer']['cust_email']));
$total_pages = $statement->rowCount();
$targetpage = BASE_URL.'customer-order.php';
$limit = 10;
$page = @$_GET['page'];
if($page)
$start = ($page - 1) * $limit;
else
$start = 0;
$statement = $pdo->prepare("SELECT * FROM tbl_payment WHERE customer_email=? ORDER BY id DESC LIMIT $start, $limit");
$statement->execute(array($_SESSION['customer']['cust_email']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
if ($page > 1)
$pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>";
else
$pagination.= "<span class=\"disabled\">« previous</span>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
}
else
{
$pagination.= "<a href=\"$targetpage?page=1\">1</a>";
$pagination.= "<a href=\"$targetpage?page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
}
}
}
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage?page=$next\">next »</a>";
else
$pagination.= "<span class=\"disabled\">next »</span>";
$pagination.= "</div>\n";
}
/* ===================== Pagination Code Ends ================== */
?>
<?php
$tip = $page*10-10;
foreach ($result as $row) {
$tip++;
?>
<tr>
<td><?php echo $tip; ?></td>
<td>
<?php
$statement1 = $pdo->prepare("SELECT * FROM tbl_order WHERE payment_id=?");
$statement1->execute(array($row['payment_id']));
$result1 = $statement1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $row1) {
echo 'Product Name: '.$row1['product_name'];
echo '<br>Size: '.$row1['size'];
echo '<br>Color: '.$row1['color'];
echo '<br>Quantity: '.$row1['quantity'];
echo '<br>Unit Price: '.$row1['unit_price'];
echo '<br><br>';
}
?>
</td>
<td><?php echo $row['payment_date']; ?></td>
<td><?php echo $row['txnid']; ?></td>
<td><?php echo $row['paid_amount']; ?></td>
<td><?php echo $row['payment_status']; ?></td>
<td><?php echo $row['payment_method']; ?></td>
<td><?php echo $row['payment_id']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="pagination" style="overflow: hidden;">
<?php
echo $pagination;
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>