diff --git a/includes/pages/patients.php b/includes/pages/patients.php
index 6211bd2..945042b 100644
--- a/includes/pages/patients.php
+++ b/includes/pages/patients.php
@@ -153,9 +153,14 @@ if (isset($_GET['ajax_search'])) {
diff --git a/lang.php b/lang.php
index 496ec19..c53f328 100644
--- a/lang.php
+++ b/lang.php
@@ -231,6 +231,12 @@ $translations = array (
'today' => 'Today',
'revenue' => 'Revenue',
'pending' => 'Pending',
+ 'import_excel' => 'Import Excel',
+ 'select_file' => 'Select File',
+ 'import' => 'Import',
+ 'excel_format_info' => 'Excel Format: Patient Name | DOB (YYYY-MM-DD) | Nationality | Telephone | City',
+ 'download_sample_template' => 'Download Sample Template',
+ 'imported_successfully' => 'imported successfully',
'add_patient' => 'Add Patient',
'book_appointment' => 'Book Appointment',
'add_visit' => 'Add Visit',
@@ -747,6 +753,12 @@ $translations = array (
'today' => 'اليوم',
'revenue' => 'الإيرادات',
'pending' => 'معلق',
+ 'import_excel' => 'استيراد إكسيل',
+ 'select_file' => 'اختر الملف',
+ 'import' => 'استيراد',
+ 'excel_format_info' => 'تنسيق إكسيل: اسم المريض | تاريخ الميلاد | الجنسية | رقم الهاتف | المدينة',
+ 'download_sample_template' => 'تنزيل نموذج تجريبي',
+ 'imported_successfully' => 'تم الاستيراد بنجاح',
'add_patient' => 'إضافة مريض',
'book_appointment' => 'حجز موعد',
'add_visit' => 'إضافة زيارة',
diff --git a/patch_actions.py b/patch_actions.py
new file mode 100644
index 0000000..250e1d5
--- /dev/null
+++ b/patch_actions.py
@@ -0,0 +1,72 @@
+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
new file mode 100644
index 0000000..6ba1f63
--- /dev/null
+++ b/patch_footer.py
@@ -0,0 +1,26 @@
+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