diff --git a/index.php b/index.php index bb3c0e9..d95e2b8 100644 --- a/index.php +++ b/index.php @@ -256,6 +256,46 @@ function numberToWordsArabic($num) { return (string)$num; } +function renderPagination($currentPage, $totalPages) { + if ($totalPages <= 1) return ''; + + $query = $_GET; + unset($query['p']); + $url = 'index.php?' . http_build_query($query) . '&p='; + + $html = ''; + return $html; +} + // Login Logic $login_error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['login'])) { @@ -2992,11 +3032,24 @@ switch ($page) { $params[] = $_GET['end_date']; } $whereSql = implode(" AND ", $where); + + $limit = 20; + $page_num = isset($_GET['p']) ? (int)$_GET['p'] : 1; + if ($page_num < 1) $page_num = 1; + $offset = ($page_num - 1) * $limit; + + $countStmt = db()->prepare("SELECT COUNT(*) FROM quotations q JOIN customers c ON q.customer_id = c.id WHERE $whereSql"); + $countStmt->execute($params); + $total_records = (int)$countStmt->fetchColumn(); + $data['total_pages'] = ceil($total_records / $limit); + $data['current_page'] = $page_num; + $stmt = db()->prepare("SELECT q.*, c.name as customer_name FROM quotations q JOIN customers c ON q.customer_id = c.id WHERE $whereSql - ORDER BY q.id DESC"); + ORDER BY q.id DESC + LIMIT $limit OFFSET $offset"); $stmt->execute($params); $data['quotations'] = $stmt->fetchAll(); break; @@ -3030,11 +3083,24 @@ switch ($page) { $params[] = $_GET['end_date']; } $whereSql = implode(" AND ", $where); + + $limit = 20; + $page_num = isset($_GET['p']) ? (int)$_GET['p'] : 1; + if ($page_num < 1) $page_num = 1; + $offset = ($page_num - 1) * $limit; + + $countStmt = db()->prepare("SELECT COUNT(*) FROM lpos q JOIN suppliers s ON q.supplier_id = s.id WHERE $whereSql"); + $countStmt->execute($params); + $total_records = (int)$countStmt->fetchColumn(); + $data['total_pages'] = ceil($total_records / $limit); + $data['current_page'] = $page_num; + $stmt = db()->prepare("SELECT q.*, s.name as supplier_name FROM lpos q JOIN suppliers s ON q.supplier_id = s.id WHERE $whereSql - ORDER BY q.id DESC"); + ORDER BY q.id DESC + LIMIT $limit OFFSET $offset"); $stmt->execute($params); $data['lpos'] = $stmt->fetchAll(); break; @@ -4278,8 +4344,9 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; - - + + +
@@ -7426,9 +7493,10 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; - -
-
+ + + + diff --git a/post_debug.log b/post_debug.log index 7b7ea16..e07ae0a 100644 --- a/post_debug.log +++ b/post_debug.log @@ -10,3 +10,15 @@ 2026-02-22 05:45:16 - POST: {"type":"sale","customer_id":"4","invoice_date":"2026-02-22","due_date":"2026-02-26","payment_type":"cash","status":"unpaid","paid_amount":"0.000","item_ids":["6"],"quantities":["1"],"prices":["0.100"],"add_invoice":""} 2026-02-22 05:45:44 - POST: {"type":"sale","customer_id":"4","invoice_date":"2026-02-22","due_date":"","payment_type":"cash","status":"unpaid","paid_amount":"0.000","item_ids":["6"],"quantities":["1"],"prices":["0.100"],"add_invoice":""} 2026-02-22 05:46:02 - POST: {"invoice_id":"32","return_date":"2026-02-22","quantities":["1"],"item_ids":["6"],"prices":["0.100"],"notes":"","add_sales_return":""} +2026-02-22 06:41:12 - POST: {"action":"save_theme","theme":"forest"} +2026-02-22 06:41:25 - POST: {"action":"save_theme","theme":"forest"} +2026-02-22 06:43:27 - POST: {"action":"save_theme","theme":"default"} +2026-02-22 06:43:29 - POST: {"action":"save_theme","theme":"ocean"} +2026-02-22 06:43:30 - POST: {"action":"save_theme","theme":"dracula"} +2026-02-22 06:43:38 - POST: {"action":"save_theme","theme":"default"} +2026-02-22 07:19:04 - POST: {"customer_id":"1","quotation_date":"2026-02-22","valid_until":"","item_ids":["6"],"quantities":["1"],"prices":["0.100"],"add_quotation":""} +2026-02-22 07:19:14 - POST: {"customer_id":"1","quotation_date":"2026-02-22","valid_until":"","item_ids":["6"],"quantities":["1"],"prices":["0.100"],"add_quotation":""} +2026-02-22 07:19:45 - POST: {"customer_id":"1","quotation_date":"2026-02-22","valid_until":"","item_ids":["2","1"],"quantities":["10","5"],"prices":["0.250","0.450"],"add_quotation":""} +2026-02-22 07:19:52 - POST: {"customer_id":"1","quotation_date":"2026-02-22","valid_until":"","item_ids":["2","1"],"quantities":["10","5"],"prices":["0.250","0.450"],"add_quotation":""} +2026-02-22 07:20:11 - POST: {"type":"sale","customer_id":"4","invoice_date":"2026-02-22","due_date":"","payment_type":"cash","status":"unpaid","paid_amount":"0.000","item_ids":["2"],"quantities":["1"],"prices":["0.250"],"add_invoice":""} +2026-02-22 07:20:34 - POST: {"customer_id":"4","quotation_date":"2026-02-22","valid_until":"","item_ids":["2"],"quantities":["1"],"prices":["0.250"],"add_quotation":""} diff --git a/search_debug.log b/search_debug.log index b67f4d7..6f73cd0 100644 --- a/search_debug.log +++ b/search_debug.log @@ -3,3 +3,8 @@ 2026-02-22 05:32:10 - search_items call: q=on 2026-02-22 05:32:45 - search_items call: q=on 2026-02-22 05:45:42 - search_items call: q=on +2026-02-22 07:19:01 - search_items call: q=on +2026-02-22 07:19:25 - search_items call: q=on +2026-02-22 07:19:37 - search_items call: q=to +2026-02-22 07:20:08 - search_items call: q=on +2026-02-22 07:20:31 - search_items call: q=on