From 913366b874362f9d255c4245e84690a2d2c1ba86 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 29 Mar 2026 17:20:23 +0000 Subject: [PATCH] adding company details to sick leave --- includes/layout/header.php | 5 +- includes/pages/sick_leave_report.php | 257 +++++++++++++++++++++++++++ lang.php | 18 ++ patch_actions.py | 72 -------- patch_footer.py | 26 --- print_bill.php | 7 +- print_insurance_statement.php | 7 +- print_prescription.php | 22 ++- print_sick_leave.php | 51 +++++- sick_leave_report.php | 17 ++ 10 files changed, 367 insertions(+), 115 deletions(-) create mode 100644 includes/pages/sick_leave_report.php delete mode 100644 patch_actions.py delete mode 100644 patch_footer.py create mode 100644 sick_leave_report.php diff --git a/includes/layout/header.php b/includes/layout/header.php index fd720b3..000abff 100644 --- a/includes/layout/header.php +++ b/includes/layout/header.php @@ -219,13 +219,14 @@ $site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['comp - + -
+ diff --git a/includes/pages/sick_leave_report.php b/includes/pages/sick_leave_report.php new file mode 100644 index 0000000..a832501 --- /dev/null +++ b/includes/pages/sick_leave_report.php @@ -0,0 +1,257 @@ + 0 +"; +$params = []; + +// Apply Filters +if (!empty($search_name)) { + $query .= " AND p.name LIKE ?"; + $params[] = "%$search_name%"; +} +if (!empty($search_phone)) { + $query .= " AND p.phone LIKE ?"; + $params[] = "%$search_phone%"; +} +if (!empty($search_doctor)) { + $query .= " AND v.doctor_id = ?"; + $params[] = $search_doctor; +} +if (!empty($start_date) && !empty($end_date)) { + $query .= " AND DATE(v.sick_leave_start_date) BETWEEN ? AND ?"; + $params[] = $start_date; + $params[] = $end_date; +} + +// Count total for pagination +$count_query = "SELECT COUNT(*) FROM (" . $query . ") as total_count"; +$stmt = $db->prepare($count_query); +$stmt->execute($params); +$total_records = $stmt->fetchColumn(); +$total_pages = ceil($total_records / $limit); + +// Add sorting and pagination +$query .= " ORDER BY v.sick_leave_start_date DESC LIMIT $limit OFFSET $offset"; +$stmt = $db->prepare($query); +$stmt->execute($params); +$sick_leaves = $stmt->fetchAll(PDO::FETCH_ASSOC); + +// Fetch doctors for filter +$stmt = $db->query("SELECT e.id, e.name_$lang as name FROM employees e JOIN positions po ON e.position_id = po.id WHERE po.name_en = 'Doctor' ORDER BY e.name_$lang"); +$doctors = $stmt->fetchAll(PDO::FETCH_ASSOC); + +?> + +
+

+ +
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + - + +
+
+
+ +
+
+
+
+ + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ # + +
+ +
+ + + + + + + + + + +
+
+
+
+ + + 1): ?> +
+ + + + +
+ + + diff --git a/lang.php b/lang.php index c53f328..e48918d 100644 --- a/lang.php +++ b/lang.php @@ -2,6 +2,15 @@ $translations = array ( 'en' => array ( + 'sick_leave_report' => 'Patient Sick Leave', + 'date_issued' => 'Date Issued', + 'number_of_days' => 'Number of Days', + 'issued_by' => 'Issued By', + 'filter_by_patient_name' => 'Patient Name', + 'filter_by_telephone' => 'Telephone', + 'filter_by_doctor' => 'Select Doctor', + 'filter_by_date_range' => 'Date Range', + 'to' => 'To', 'generate' => 'Generate', 'no_data_found' => 'No Data Found', @@ -520,6 +529,15 @@ $translations = array ( ), 'ar' => array ( + 'sick_leave_report' => 'إجازات المرضى', + 'date_issued' => 'تاريخ الإصدار', + 'number_of_days' => 'عدد الأيام', + 'issued_by' => 'صدرت بواسطة', + 'filter_by_patient_name' => 'اسم المريض', + 'filter_by_telephone' => 'رقم الهاتف', + 'filter_by_doctor' => 'اختر الطبيب', + 'filter_by_date_range' => 'نطاق التاريخ', + 'to' => 'إلى', 'generate' => 'توليد', 'no_data_found' => 'لا توجد بيانات', diff --git a/patch_actions.py b/patch_actions.py deleted file mode 100644 index 250e1d5..0000000 --- a/patch_actions.py +++ /dev/null @@ -1,72 +0,0 @@ -import sys - -with open('includes/actions.php', 'r', encoding='utf-8') as f: - content = f.read() - -# First remove the previously injected block -if "} elseif ($_POST['action'] === 'import_patients') {" in content: - import re - # We will use string manipulation to remove the whole block. - # It starts with "} elseif ($_POST['action'] === 'import_patients') {" - # and ends right before "} elseif ($_POST['action'] === 'import_drugs_groups') {" - start_idx = content.find("} elseif ($_POST['action'] === 'import_patients') {") - end_idx = content.find("} elseif ($_POST['action'] === 'import_drugs_groups') {", start_idx + 1) - if start_idx != -1 and end_idx != -1: - content = content[:start_idx] + content[end_idx:] - -inject_code = """ } elseif ($_POST['action'] === 'import_patients') { - if (isset($_FILES['file'])) { - try { - $rows = parse_import_file($_FILES['file']); - if ($rows) { - $db->beginTransaction(); - $stmt = $db->prepare("INSERT INTO patients (name, dob, nationality, phone, city) VALUES (?, ?, ?, ?, ?)"); - - foreach ($rows as $row) { - $name = trim($row[0] ?? ''); - if (empty($name)) continue; - - $dob = trim($row[1] ?? ''); - if (!empty($dob)) { - $parsed_date = strtotime(str_replace('/', '-', $dob)); - if ($parsed_date) { - $dob = date('Y-m-d', $parsed_date); - } else { - $dob = null; - } - } else { - $dob = null; - } - - $nationality = trim($row[2] ?? ''); - $phone = trim($row[3] ?? ''); - $city = trim($row[4] ?? ''); - - $stmt->execute([$name, $dob, $nationality, $phone, $city]); - } - - $db->commit(); - $_SESSION['flash_message'] = __('patients').' '.__('imported_successfully') ?? 'Import successful'; - } else { - $_SESSION['flash_message'] = $_SESSION['import_error'] ?? 'Failed to parse file or empty.'; unset($_SESSION['import_error']); - } - } catch (Exception $e) { - if ($db->inTransaction()) { - $db->rollBack(); - } - $_SESSION['flash_message'] = "Error importing data: " . $e->getMessage(); - } - } else { - $_SESSION['flash_message'] = "No file selected."; - } - header('Location: ../patients.php'); - exit; -""" - -if "} elseif ($_POST['action'] === 'import_drugs_groups') {" in content: - content = content.replace("} elseif ($_POST['action'] === 'import_drugs_groups') {", inject_code + "} elseif ($_POST['action'] === 'import_drugs_groups') {") - with open('includes/actions.php', 'w', encoding='utf-8') as f: - f.write(content) - print("Injected successfully") -else: - print("Could not find the hook in actions.php") \ No newline at end of file diff --git a/patch_footer.py b/patch_footer.py deleted file mode 100644 index 6ba1f63..0000000 --- a/patch_footer.py +++ /dev/null @@ -1,26 +0,0 @@ -import re - -with open("includes/layout/footer.php", "r") as f: - content = f.read() - -new_body = """
- - -
- -
-
-
- - - -
""" - -content = re.sub( - r'
\s*\s*\s*
\s* <\?php echo __\("excel_format_info"\); \?>\s*
\s*
', - new_body, - content -) - -with open("includes/layout/footer.php", "w") as f: - f.write(content) \ No newline at end of file diff --git a/print_bill.php b/print_bill.php index 57623d4..e925e97 100644 --- a/print_bill.php +++ b/print_bill.php @@ -51,8 +51,11 @@ try { $items = $stmt->fetchAll(); // Fetch Company Settings (Logo, Address, etc.) - $stmt = $db->query("SELECT * FROM settings WHERE id = 1"); - $settings = $stmt->fetch(); + $stmt = $db->query("SELECT setting_key, setting_value FROM settings"); + $settings = []; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $settings[$row[setting_key]] = $row[setting_value]; + } $lang = $_SESSION['lang'] ?? 'en'; } catch (Exception $e) { diff --git a/print_insurance_statement.php b/print_insurance_statement.php index a8369a8..c756917 100644 --- a/print_insurance_statement.php +++ b/print_insurance_statement.php @@ -59,8 +59,11 @@ try { } // Fetch Company Settings (Logo, Address, etc.) - $stmt = $db->query("SELECT * FROM settings WHERE id = 1"); - $settings = $stmt->fetch(); + $stmt = $db->query("SELECT setting_key, setting_value FROM settings"); + $settings = []; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $settings[$row[setting_key]] = $row[setting_value]; + } $lang = $_SESSION['lang'] ?? 'en'; } catch (Exception $e) { diff --git a/print_prescription.php b/print_prescription.php index ccffd1e..a036e18 100644 --- a/print_prescription.php +++ b/print_prescription.php @@ -51,6 +51,14 @@ try { $stmt->execute([$visit_id]); $prescriptions = $stmt->fetchAll(); + + // Fetch Company Settings + $stmt = $db->query("SELECT setting_key, setting_value FROM settings"); + $settings = []; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $settings[$row["setting_key"]] = $row["setting_value"]; + } + $lang = $_SESSION['lang'] ?? 'en'; } catch (Exception $e) { die("Error: " . $e->getMessage()); @@ -66,6 +74,7 @@ try {