From 4e6f8a4404370ab26ed1ef2701c0e17b7b83f1cf Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 5 May 2026 02:07:08 +0000 Subject: [PATCH] ascending order in eid list --- eid_orders.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eid_orders.php b/eid_orders.php index 8d7d766..0a1fedf 100644 --- a/eid_orders.php +++ b/eid_orders.php @@ -69,7 +69,7 @@ $deliveryStatus = trim((string) ($_GET['delivery_status'] ?? '')); $dateFrom = trim((string) ($_GET['date_from'] ?? '')); $dateTo = trim((string) ($_GET['date_to'] ?? '')); $sort = trim((string) ($_GET['sort'] ?? 'delivery_date')); -$dir = strtolower(trim((string) ($_GET['dir'] ?? 'desc'))); +$dir = strtolower(trim((string) ($_GET['dir'] ?? 'asc'))); $sortMap = [ 'receipt_no' => 'receipt_no', 'customer' => 'customer_name', @@ -174,10 +174,11 @@ try { $total = (int) $countStmt->fetchColumn(); $totalPages = max(1, (int) ceil($total / $limit)); - $primarySort = $sortMap[$sort] . ' ' . strtoupper($dir); + $sortDirection = strtoupper($dir); + $primarySort = $sortMap[$sort] . ' ' . $sortDirection; $secondarySort = $sort === 'delivery_date' - ? ', sale_date DESC, id DESC' - : ', COALESCE(delivery_date, DATE(sale_date)) DESC, sale_date DESC, id DESC'; + ? ', sale_date ' . $sortDirection . ', id ' . $sortDirection + : ', COALESCE(delivery_date, DATE(sale_date)) ' . $sortDirection . ', sale_date ' . $sortDirection . ', id ' . $sortDirection; $sql = "SELECT sales_orders.*, ( SELECT COUNT(*)