prepare($countQuery); $stmt->execute($params); $totalInsurance = $stmt->fetchColumn(); $totalPages = ceil($totalInsurance / $limit); // Fetch Companies $query = "SELECT * FROM insurance_companies $where ORDER BY id DESC LIMIT $limit OFFSET $offset"; $stmt = $db->prepare($query); $stmt->execute($params); $insurance_companies = $stmt->fetchAll(); // --- Transactions Logic --- $trans_page = isset($_GET['trans_page']) && is_numeric($_GET['trans_page']) ? (int)$_GET['trans_page'] : 1; $trans_limit = 10; $trans_offset = ($trans_page - 1) * $trans_limit; $trans_where = "WHERE 1=1"; $trans_params = []; $trans_company_id = $_GET['trans_company_id'] ?? ''; $trans_start_date = $_GET['trans_start_date'] ?? ''; $trans_end_date = $_GET['trans_end_date'] ?? ''; if ($trans_company_id) { $trans_where .= " AND t.insurance_company_id = ?"; $trans_params[] = $trans_company_id; } if ($trans_start_date) { $trans_where .= " AND t.payment_date >= ?"; $trans_params[] = $trans_start_date; } if ($trans_end_date) { $trans_where .= " AND t.payment_date <= ?"; $trans_params[] = $trans_end_date; } // Count Transactions $countTransQuery = "SELECT COUNT(*) FROM insurance_payments t $trans_where"; $stmt = $db->prepare($countTransQuery); $stmt->execute($trans_params); $totalTrans = $stmt->fetchColumn(); $totalTransPages = ceil($totalTrans / $trans_limit); // Fetch Transactions $transQuery = "SELECT t.*, c.name_$lang as company_name FROM insurance_payments t LEFT JOIN insurance_companies c ON t.insurance_company_id = c.id $trans_where ORDER BY t.payment_date DESC, t.id DESC LIMIT $trans_limit OFFSET $trans_offset"; $stmt = $db->prepare($transQuery); $stmt->execute($trans_params); $transactions = $stmt->fetchAll(); // --- AJAX HANDLER --- if (isset($_GET['ajax_search'])) { header('Content-Type: application/json'); ob_start(); if (isset($_GET['tab']) && $_GET['tab'] === 'transactions') { if (empty($transactions)): ?> # 1): ?>
-
$table_html, 'pagination' => $pagination_html]); } else { // Companies Tab if (empty($insurance_companies)): ?> # 1): ?>
-
$table_html, 'pagination' => $pagination_html]); } exit; } ?>

ID
#
1): ?>
-
ID
#
1): ?>
-