-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelivery.php
48 lines (38 loc) · 1.51 KB
/
delivery.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
<?php
require_once('Models/DeliveryPointDataSet.php');
session_start();
// Create a view for the parcels page
$view = new stdClass();
$view->pageTitle = 'Parcels';
// Instance of DeliveryPointDataSet class
$deliveryPointDataSet = new DeliveryPointDataSet();
$view->deliveryPointStatus = $deliveryPointDataSet->getDeliveryStatus();
// Pagination
$itemsPerPage = 10;
// Determine the total number of items based on the search results if a search is performed
if (isset($_GET['searchBtn'])) {
$searchTerm = $_GET['search'];
$totalItems = count($deliveryPointDataSet->getDeliveryPointBySearch($searchTerm));
} else {
$totalItems = count($deliveryPointDataSet->getDeliveryPointInfo());
}
$totalPages = ceil($totalItems / $itemsPerPage);
$pageNumber = isset($_GET['page']) ? $_GET['page'] : 1;
$pageNumber = max(1, min($pageNumber, $totalPages));
$view->totalPages = $totalPages;
$view->pageNumber = $pageNumber;
// Display all or only searched values
if (isset ($_GET['searchBtn'])) {
$searchTerm = $_GET['search'];
$view->deliveryPointDataSet = $deliveryPointDataSet->getDeliveryPointBySearch($searchTerm);
} else {
$view->deliveryPointDataSet = $deliveryPointDataSet->getPagedDeliveryPointInfo($pageNumber, $itemsPerPage);
}
// Check if the user is not logged in
if (!isset($_SESSION['login'])) {
// Include the login.php file for authentication
header('Location: login.php');
exit(); // Stop further execution
}
// Include the HTML view file for the parcels page
require_once('Views/delivery.phtml');