ascending order in eid list

This commit is contained in:
Flatlogic Bot 2026-05-05 02:07:08 +00:00
parent f9e55d0ef0
commit 4e6f8a4404

View File

@ -69,7 +69,7 @@ $deliveryStatus = trim((string) ($_GET['delivery_status'] ?? ''));
$dateFrom = trim((string) ($_GET['date_from'] ?? '')); $dateFrom = trim((string) ($_GET['date_from'] ?? ''));
$dateTo = trim((string) ($_GET['date_to'] ?? '')); $dateTo = trim((string) ($_GET['date_to'] ?? ''));
$sort = trim((string) ($_GET['sort'] ?? 'delivery_date')); $sort = trim((string) ($_GET['sort'] ?? 'delivery_date'));
$dir = strtolower(trim((string) ($_GET['dir'] ?? 'desc'))); $dir = strtolower(trim((string) ($_GET['dir'] ?? 'asc')));
$sortMap = [ $sortMap = [
'receipt_no' => 'receipt_no', 'receipt_no' => 'receipt_no',
'customer' => 'customer_name', 'customer' => 'customer_name',
@ -174,10 +174,11 @@ try {
$total = (int) $countStmt->fetchColumn(); $total = (int) $countStmt->fetchColumn();
$totalPages = max(1, (int) ceil($total / $limit)); $totalPages = max(1, (int) ceil($total / $limit));
$primarySort = $sortMap[$sort] . ' ' . strtoupper($dir); $sortDirection = strtoupper($dir);
$primarySort = $sortMap[$sort] . ' ' . $sortDirection;
$secondarySort = $sort === 'delivery_date' $secondarySort = $sort === 'delivery_date'
? ', sale_date DESC, id DESC' ? ', sale_date ' . $sortDirection . ', id ' . $sortDirection
: ', COALESCE(delivery_date, DATE(sale_date)) DESC, sale_date DESC, id DESC'; : ', COALESCE(delivery_date, DATE(sale_date)) ' . $sortDirection . ', sale_date ' . $sortDirection . ', id ' . $sortDirection;
$sql = "SELECT sales_orders.*, ( $sql = "SELECT sales_orders.*, (
SELECT COUNT(*) SELECT COUNT(*)