-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewCustomersFront.php
More file actions
368 lines (262 loc) · 14.5 KB
/
viewCustomersFront.php
File metadata and controls
368 lines (262 loc) · 14.5 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php
session_start();
include_once 'object/Customer.php';
$user = new User();
if (isset($_GET['name'])) {
if (($_GET['name']) == "NotPaid") {
$notPaidResult = $user->notPaidFilter();
} else if (($_GET['name']) == "Paid") {
$paidResult = $user->paidFilter();
} else if (($_GET['name']) == "Arrears") {
$arrearsResult = $user->arrearsFilter();
} else if ($_GET['name'] == 'ASC') {
$sort = 'DESC';
$sortByArrears = $user->sortByPayable($sort);
} else {
$sort = 'ASC';
$sortByArrears = $user->sortByPayable($sort);
}
}
// if (isset($_GET['sort']) && $_GET['sort'] == 'ASC') {
// $sort = 'DESC';
// $sortByArrears = $user->sortByPayable($sort);
// } else {
// $sort = 'ASC';
// $sortByArrears = $user->sortByPayable($sort);
// }
// Form Search Button on Top in ViewCustomerFrontPage
if (isset($_POST['searchCustomerForm'])) {
$search = $_POST['search'];
if (isset($_GET['name'])) {
$_GET['name'] = 'search';
} else {
$_GET['name'] = 'search';
}
if ($user->searchCustomerViewFront($search)) {
$customerSearchResult = $user->searchCustomerViewFront($search);
} else {
$_SESSION['resultNotFound'] = "No Result Found";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include_once 'head.php' ?>
<body>
<?php include_once 'header.php' ?>
<form method="POST">
<div class="input-group container w-25 justify-content-center mb-3 pt-3">
<input type="text" name="search" class="form-control" placeholder="Search" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<input type="submit" class=" btn-primary " name="searchCustomerForm" value="Search">
</div>
</div>
</form>
<div class="float-left ">
<ul class="nav flex-column m-3 ">
<li class="nav-item">
<label class=" form-control ">Filter Options</label>
</li>
<ul class="nav flex-column">
<form>
<li class="nav-item">
<a class="nav-link btn-primary " href="viewCustomersFront.php?name=NotPaid">Not Paid</a>
</li>
</form>
<li class="nav-item">
<a class="nav-link btn-primary " href="viewCustomersFront.php?name=Paid">Paid</a>
</li>
<li class="nav-item">
<a class="nav-link btn-primary " href="viewCustomersFront.php?name=Arrears">Payable</a>
</li>
<li class="nav-item">
<a class="nav-link btn-primary " href="viewCustomersFront.php?name=ClearFilter">Clear Filters</a>
</li>
</ul>
</div>
<!-- some php code to fetch data from customer and customer detail tables -->
<?php
$user = new User();
$customerResult = $user->selectAllCustomer();
?>
<div class="row justify-content-center ">
<div class=" container col-auto">
<table class="table table-sm table-hover table-responsive">
<thead>
<tr>
<th scope="col">CustomerID</th>
<th scope="col">Name</th>
<th scope="col">Mobile Number</th>
<th scope="col">City</th>
<th scope="col">Area</th>
<th scope="col">Status</th>
<?php if (!isset($sort)) $sort = 'ASC'; ?>
<th scope="col"><a href="viewCustomersFront.php?name=<?php echo $sort ?>">Payable</a></th>
<th scope="col">Paid</th>
<th scope="col ">Action</th>
</tr>
</thead>
<tbody>
<div style="text-align : center; margin-top:5px !important; width:50%; margin:auto;">
<span><?php if (isset($_SESSION['resultNotFound'])) {
echo "<div class='alert alert-danger'>";
echo $_SESSION['resultNotFound'];
echo "</div>";
unset($_SESSION['resultNotFound']);
} ?> </span>
</div>
<?php if (!empty($sortByArrears) && isset($_GET['name']) && ($_GET['name'] == 'ASC' || $_GET['name'] == 'DESC')) { ?>
<?php foreach ($sortByArrears as $aResult) { ?>
<tr>
<th scope="row"><?php echo $aResult['Customer_ID'] ?></th>
<td><?php echo $aResult['name'] ?></td>
<td><?php echo $aResult['mobile'] ?></td>
<td><?php echo $aResult['city'] ?></td>
<td><?php echo $aResult['area'] ?></td>
<td><?php echo $aResult['status'] ?></td>
<!-- <?php $feeSUM = $user->selectAllCustomerDetail($aResult['Customer_ID']) ?> -->
<td><?php if (!empty($feeSUM)) echo $aResult['totalArrears'] ?></td>
<td><?php if (!empty($feeSUM)) echo $aResult['totalPaid'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $aResult['Customer_ID'] ?>&customerReportName=<?php echo $aResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $aResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $aResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<!-- end of foreach -->
<?php } else if (!empty($arrearsResult) && isset($_GET['name']) && $_GET['name'] == "Arrears") { ?>
<!-- end of if start of else if -->
<?php foreach ($arrearsResult as $aResult) { ?>
<?php $feeSUM = $user->selectAllCustomerDetail($aResult['Customer_ID']) ?>
<?php if ($feeSUM['ArrearsSum'] != 0) { ?>
<tr>
<th scope="row"><?php echo $aResult['Customer_ID'] ?></th>
<td><?php echo $aResult['name'] ?></td>
<td><?php echo $aResult['mobile'] ?></td>
<td><?php echo $aResult['city'] ?></td>
<td><?php echo $aResult['area'] ?></td>
<td><?php echo $aResult['status'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['ArrearsSum'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['FeeSum'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $aResult['Customer_ID'] ?>&customerReportName=<?php echo $aResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $aResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $aResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<!-- End of if statement -->
<?php } ?>
<!-- end of foreach loop -->
<!-- Start of Not Paid Filter Result to show in table -->
<?php } else if (!empty($paidResult) && isset($_GET['name']) && $_GET['name'] == "Paid") { ?>
<!-- end of if and start of else if -->
<?php foreach ($paidResult as $pResult) { ?>
<?php $feeSUM = $user->selectAllCustomerDetail($pResult['Customer_ID']) ?>
<?php if (!empty($feeSUM) && $feeSUM['ArrearsSum'] == 0) { ?>
<th scope="row"><?php echo $pResult['Customer_ID'] ?></th>
<td><?php echo $pResult['name'] ?></td>
<td><?php echo $pResult['mobile'] ?></td>
<td><?php echo $pResult['city'] ?></td>
<td><?php echo $pResult['area'] ?></td>
<td><?php echo $pResult['status'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['ArrearsSum'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['FeeSum'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $pResult['Customer_ID'] ?>&customerReportName=<?php echo $pResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $pResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $pResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<?php } ?>
<!-- end of foreach loop -->
<!-- Start of Not Paid Filter Result to show in table -->
<?php } else if (!empty($notPaidResult) && isset($_GET['name']) && $_GET['name'] == "NotPaid") { ?>
<!-- end of if and start of else -->
<?php foreach ($notPaidResult as $npResult) { ?>
<?php $feeSUM = $user->selectAllCustomerDetail($npResult['Customer_ID']) ?>
<?php if ($feeSUM['FeeSum'] == 0) { ?>
<tr>
<th scope="row"><?php echo $npResult['Customer_ID'] ?></th>
<td><?php echo $npResult['name'] ?></td>
<td><?php echo $npResult['mobile'] ?></td>
<td><?php echo $npResult['city'] ?></td>
<td><?php echo $npResult['area'] ?></td>
<td><?php echo $npResult['status'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['ArrearsSum'] ?></td>
<td><?php if (!empty($feeSUM)) echo $feeSUM['FeeSum'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $npResult['Customer_ID'] ?>&customerReportName=<?php echo $npResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $npResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $npResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<!-- end of if -->
<?php } ?>
<!-- End of for Loop -->
<!-- Start of Search Button Filter -->
<?php } else if (!empty($customerSearchResult) && isset($_GET['name']) && $_GET['name'] = 'search') { ?>
<?php foreach ($customerSearchResult as $cusResult) { ?>
<?php
$customerDetailResult = $user->selectAllCustomerDetail($cusResult['Customer_ID']);
?>
<tr>
<th scope="row"><?php echo $cusResult['Customer_ID'] ?></th>
<td><?php echo $cusResult['name'] ?></td>
<td><?php echo $cusResult['mobile'] ?></td>
<td><?php echo $cusResult['city'] ?></td>
<td><?php echo $cusResult['area'] ?></td>
<td><?php echo $cusResult['status'] ?></td>
<td><?php echo $customerDetailResult['ArrearsSum'] ?></td>
<td><?php echo $customerDetailResult['FeeSum'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $cusResult['Customer_ID'] ?>&customerReportName=<?php echo $cusResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $cusResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $cusResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<!-- end of Search Button and start if else if -->
<?php } else if (!empty($customerResult)) { ?>
<?php foreach ($customerResult as $cusResult) { ?>
<?php
$customerDetailResult = $user->selectAllCustomerDetail($cusResult['Customer_ID']);
?>
<tr>
<th scope="row"><?php echo $cusResult['Customer_ID'] ?></th>
<td><?php echo $cusResult['name'] ?></td>
<td><?php echo $cusResult['mobile'] ?></td>
<td><?php echo $cusResult['city'] ?></td>
<td><?php echo $cusResult['area'] ?></td>
<td><?php echo $cusResult['status'] ?></td>
<td><?php echo $customerDetailResult['ArrearsSum'] ?></td>
<td><?php echo $customerDetailResult['FeeSum'] ?></td>
<td><a type="button" class="btn btn-sm btn-primary" href="generateReportFront.php?customerReportID=<?php echo $cusResult['Customer_ID'] ?>&customerReportName=<?php echo $cusResult['name'] ?> ">Report</a></td>
<td><a type="button" class="btn btn-sm btn-danger" href="deleteCustomer.php?customerReportID=<?php echo $cusResult['Customer_ID'] ?> ">Delete</a></td>
<td><a type="button" class="btn btn-sm btn-success" href="EditCustomersFront.php?editCustomerName=<?php echo $cusResult['name'] ?> ">Pay Fees</a></td>
</tr>
<?php } ?>
<!-- Paging Link -->
<?php } ?>
<!-- end of else if -->
</tbody>
</table>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
<?php include_once 'footer.php' ?>
</body>
</html>