prepare($countSql); foreach ($params as $key => $value) { $countStmt->bindValue($key, $value); } $countStmt->execute(); $total = $countStmt->fetchColumn(); $totalPages = max(1, ceil($total / $limit)); // Fetch Data $sql = 'SELECT * FROM sales_orders' . $where . ' ORDER BY sale_date DESC LIMIT :limit OFFSET :offset'; $stmt = db()->prepare($sql); foreach ($params as $key => $value) { $stmt->bindValue($key, $value); } $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $sales = $stmt->fetchAll(); } catch (Throwable $e) { $dbError = $e->getMessage(); } require __DIR__ . '/includes/header.php'; ?> = h(tr('سجل الفواتير', 'Invoice ledger')) ?> = h(tr('ابحث بصرياً في أحدث المبيعات مع صلاحيات حسب الدور والفرع.', 'Scan the latest sales with role and branch scoping.')) ?> = h(tr('الكل', 'All')) ?> POS = h(tr('بيع عادي', 'Normal')) ?> = h($dbError) ?> = h(tr('لا توجد نتائج', 'No sales found')) ?> = h(tr('جرّب إنشاء فاتورة جديدة من صفحة البيع.', 'Try creating a new invoice from the sale page.')) ?> POS = h(tr('بيع عادي', 'Normal Sale')) ?> = h(tr('الإيصال', 'Receipt')) ?> = h(tr('الفرع', 'Branch')) ?> = h(tr('النوع', 'Type')) ?> = h(tr('الكاشير', 'Cashier')) ?> = h(tr('الإجمالي', 'Total')) ?> = h(tr('التاريخ', 'Date')) ?> = h(tr('إجراءات', 'Actions')) ?> = h($sale['receipt_no']) ?> = h((string) $sale['item_count']) ?> = h(tr('قطعة', 'items')) ?> = h(branch_label((string) $sale['branch_code'])) ?> = h(sale_mode_label((string) $sale['sale_mode'])) ?> = h((string) $sale['cashier_name']) ?> = h(currency((float) $sale['total_amount'])) ?> = h(date('Y-m-d H:i', strtotime((string) $sale['sale_date']))) ?> 1): ?> = $i ?>
= h(tr('جرّب إنشاء فاتورة جديدة من صفحة البيع.', 'Try creating a new invoice from the sale page.')) ?>