diff --git a/accounting.php b/accounting.php index 0f66122..16d8e95 100644 --- a/accounting.php +++ b/accounting.php @@ -15,14 +15,13 @@ if (!$stmt->fetch()) { // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_entry'])) { - $date = $_POST['date']; - $description = $_POST['description']; - $reference = $_POST['reference']; - $account = $_POST['account']; - $debit = (float)$_POST['debit']; - $credit = (float)$_POST['credit']; - - $entries = [['account' => $account, 'debit' => $debit, 'credit' => $credit]]; + $date = $_POST["date"] ?? ""; + $description = $_POST["description"] ?? ""; + $reference = $_POST["reference"] ?? ""; + $entries = [ + ["account" => $_POST["debit_account"] ?? "", "debit" => (float)($_POST["amount"] ?? 0), "credit" => 0], + ["account" => $_POST["credit_account"] ?? "", "debit" => 0, "credit" => (float)($_POST["amount"] ?? 0)] + ]; if (add_journal_entry($date, $description, $reference, $entries)) { $message = "تم إضافة القيد بنجاح."; @@ -31,113 +30,125 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_entry'])) { } } -// Pagination setup +// Pagination and Filtering setup $page = isset($_GET['p']) ? (int)$_GET['p'] : 1; $limit = 10; $offset = ($page - 1) * $limit; +$search = $_GET['search'] ?? ''; +$date_from = $_GET['date_from'] ?? ''; +$date_to = $_GET['date_to'] ?? ''; -// Fetch ledger data with pagination -$ledger_all = get_full_ledger(); +// Fetch ledger data with filters +$ledger_all = get_full_ledger_filtered($search, $date_from, $date_to); $total_items = count($ledger_all); $total_pages = ceil($total_items / $limit); $ledger = array_slice($ledger_all, $offset, $limit); - -$trial_balance = get_trial_balance(); -$balance_sheet = get_balance_sheet(); ?> + +
| التاريخ | الوصف | المرجع | الحساب | مدين | دائن |
|---|
| التاريخ | الوصف | المرجع | الحساب | مدين | دائن | الإجراءات |
|---|---|---|---|---|---|---|
| = htmlspecialchars($row['account_name']) ?> | = number_format($row['debit'], 2) ?> | = number_format($row['credit'], 2) ?> | ++ ')"> + ')"> + |