update payments

This commit is contained in:
Flatlogic Bot 2026-03-29 17:49:28 +00:00
parent 913366b874
commit 9a0a41e1cd
22 changed files with 84 additions and 208 deletions

View File

@ -1,6 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$stmt = $db->query("DESCRIBE appointments");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
print_r($columns);

View File

@ -1,20 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
// Fetch one patient
$patient = $db->query("SELECT id, name FROM patients LIMIT 1")->fetch(PDO::FETCH_ASSOC);
// Fetch one doctor (employee with position 'Doctor')
$doctor = $db->query("
SELECT e.id, e.name_en
FROM employees e
JOIN positions p ON e.position_id = p.id
WHERE UPPER(p.name_en) = 'DOCTOR'
LIMIT 1")->fetch(PDO::FETCH_ASSOC);
if ($patient && $doctor) {
echo "Found Patient: " . $patient['name'] . " (ID: " . $patient['id'] . ")\n";
echo "Found Doctor: " . $doctor['name_en'] . " (ID: " . $doctor['id'] . ")\n";
} else {
echo "Could not find patient or doctor.\n";
}

View File

@ -1,16 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$tables = ['xray_inquiry_items', 'inquiry_tests', 'visit_prescriptions', 'laboratory_inquiries'];
foreach ($tables as $table) {
try {
$stmt = $db->query("SHOW CREATE TABLE $table");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['Create Table'] . "\n\n";
} catch (Exception $e) {
echo "Table $table not found: " . $e->getMessage() . "\n\n";
}
}

View File

@ -1,19 +0,0 @@
<?php
require_once __DIR__ . '/db/config.php';
$db = db();
try {
$result = $db->query("SHOW COLUMNS FROM doctor_holidays");
if ($result) {
$columns = $result->fetchAll(PDO::FETCH_ASSOC);
echo "Table 'doctor_holidays' exists with columns:\n";
foreach ($columns as $col) {
echo "- " . $col['Field'] . " (" . $col['Type'] . ")\n";
}
} else {
echo "Table 'doctor_holidays' does not exist.\n";
}
} catch (PDOException $e) {
echo "Error: " . $e->getMessage() . "\n";
}

View File

@ -1,8 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$stmt = $db->query("DESCRIBE employees");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo "Columns in employees table:\n";
print_r($columns);
?>

View File

@ -1,6 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$stmt = $db->query("DESCRIBE nurses");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
print_r($columns);

View File

@ -1,24 +0,0 @@
<?php
require_once 'db/config.php';
$pdo = db();
$tables = ['drugs', 'suppliers', 'visit_prescriptions'];
foreach ($tables as $table) {
echo "--- Table: $table ---
";
try {
$stmt = $pdo->query("DESCRIBE $table");
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($columns as $col) {
echo "{$col['Field']} ({$col['Type']})
";
}
} catch (PDOException $e) {
echo "Error describing $table: " . $e->getMessage() . "
";
}
echo "
";
}

View File

@ -1,16 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$tables = ['laboratory_tests', 'xray_tests', 'drugs'];
foreach ($tables as $table) {
try {
$stmt = $db->query("SHOW CREATE TABLE $table");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['Create Table'] . "\n\n";
} catch (Exception $e) {
echo "Table $table not found or error: " . $e->getMessage() . "\n\n";
}
}

View File

@ -1,16 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
$tables = ['services', 'xray_inquiries', 'laboratory_inquiries', 'visit_prescriptions', 'bill_items'];
foreach ($tables as $table) {
try {
$stmt = $db->query("SHOW CREATE TABLE $table");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['Create Table'] . "\n\n";
} catch (Exception $e) {
echo "Table $table not found or error: " . $e->getMessage() . "\n\n";
}
}

View File

@ -0,0 +1 @@
ALTER TABLE bills MODIFY COLUMN payment_method VARCHAR(50) DEFAULT 'Cash';

View File

@ -386,6 +386,15 @@ $sick_leave_start_date = !empty($_POST['sick_leave_start_date']) ? $_POST['sick_
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'mark_paid') {
$bill_id = $_POST['bill_id'] ?? 0;
$payment_method = $_POST['payment_method'] ?? 'Cash';
if ($bill_id > 0) {
$stmt = $db->prepare("UPDATE bills SET status = 'Paid', payment_method = ? WHERE id = ?");
$stmt->execute([$payment_method, $bill_id]);
$_SESSION['flash_message'] = __('mark_as_paid') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'create_bill') {
$patient_id = $_POST['patient_id'] ?? '';
$visit_id = $_POST['visit_id'] ?: null;

View File

@ -92,10 +92,23 @@ $bills = $stmt->fetchAll();
</td>
<td class="text-end px-4">
<?php if ($b['status'] === 'Pending'): ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=billing" method="POST" class="d-inline">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=billing" method="POST" class="d-inline-flex align-items-center gap-2">
<input type="hidden" name="action" value="mark_paid">
<input type="hidden" name="bill_id" value="<?php echo $b['id']; ?>">
<button type="submit" class="btn btn-sm btn-success px-3">
<select name="payment_method" class="form-select form-select-sm" style="width: auto;">
<?php
$payment_types_setting = $settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other';
$payment_types = array_map('trim', explode(',', $payment_types_setting));
foreach ($payment_types as $pt):
if (!empty($pt)):
?>
<option value="<?php echo htmlspecialchars($pt); ?>"><?php echo htmlspecialchars($pt); ?></option>
<?php
endif;
endforeach;
?>
</select>
<button type="submit" class="btn btn-sm btn-success px-3 text-nowrap">
<i class="bi bi-check-circle me-1"></i> <?php echo __('mark_as_paid'); ?>
</button>
</form>

View File

@ -575,11 +575,16 @@ $appointments = $db->query($appointments_sql)->fetchAll();
<div class="row g-3 align-items-end">
<div class="col-md-6">
<label class="form-label small text-muted">Payment Method</label>
<?php
$payment_types_setting = $settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other';
$payment_types = array_map('trim', explode(',', $payment_types_setting));
?>
<select id="checkout_payment_method" class="form-select">
<option value="Cash">Cash</option>
<option value="Card">Card</option>
<option value="Online">Online</option>
<option value="Insurance">Insurance Only</option>
<?php foreach ($payment_types as $pt): ?>
<?php if (!empty($pt)): ?>
<option value="<?php echo htmlspecialchars($pt); ?>"><?php echo htmlspecialchars($pt); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">

View File

@ -711,11 +711,16 @@ if (isset($_GET['ajax_search'])) {
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('payment_method'); ?></label>
<?php
$payment_types_setting = $settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other';
$payment_types = array_map('trim', explode(',', $payment_types_setting));
?>
<select name="payment_method" class="form-select">
<option value="Check"><?php echo __('payment_method_check'); ?></option>
<option value="Bank Transfer"><?php echo __('payment_method_transfer'); ?></option>
<option value="Cash"><?php echo __('payment_method_cash'); ?></option>
<option value="Credit Card"><?php echo __('payment_method_card'); ?></option>
<?php foreach ($payment_types as $pt): ?>
<?php if (!empty($pt)): ?>
<option value="<?php echo htmlspecialchars($pt); ?>"><?php echo htmlspecialchars($pt); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 mb-3">
@ -774,11 +779,16 @@ if (isset($_GET['ajax_search'])) {
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('payment_method'); ?></label>
<?php
$payment_types_setting = $settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other';
$payment_types = array_map('trim', explode(',', $payment_types_setting));
?>
<select name="payment_method" id="editTransMethod" class="form-select">
<option value="Check"><?php echo __('payment_method_check'); ?></option>
<option value="Bank Transfer"><?php echo __('payment_method_transfer'); ?></option>
<option value="Cash"><?php echo __('payment_method_cash'); ?></option>
<option value="Credit Card"><?php echo __('payment_method_card'); ?></option>
<?php foreach ($payment_types as $pt): ?>
<?php if (!empty($pt)): ?>
<option value="<?php echo htmlspecialchars($pt); ?>"><?php echo htmlspecialchars($pt); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 mb-3">

View File

@ -98,14 +98,21 @@ try {
<div class="mb-3">
<label class="form-label"><?php echo __('payment_method'); ?></label>
<div class="btn-group w-100" role="group">
<input type="radio" class="btn-check" name="payment_method" id="pay_cash" value="cash" checked>
<label class="btn btn-outline-primary" for="pay_cash"><i class="bi bi-cash me-1"></i> <?php echo __('cash'); ?></label>
<input type="radio" class="btn-check" name="payment_method" id="pay_card" value="card">
<label class="btn btn-outline-primary" for="pay_card"><i class="bi bi-credit-card me-1"></i> <?php echo __('card'); ?></label>
<input type="radio" class="btn-check" name="payment_method" id="pay_insurance" value="insurance">
<label class="btn btn-outline-primary" for="pay_insurance"><i class="bi bi-shield-check me-1"></i> <?php echo __('insurance'); ?></label>
<?php
$payment_types_setting = $settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other';
$payment_types = array_map('trim', explode(',', $payment_types_setting));
$first = true;
foreach ($payment_types as $pt):
if (!empty($pt)):
$id = 'pay_' . strtolower(str_replace(' ', '_', $pt));
?>
<input type="radio" class="btn-check" name="payment_method" id="<?php echo $id; ?>" value="<?php echo htmlspecialchars($pt); ?>" <?php echo $first ? 'checked' : ''; ?>>
<label class="btn btn-outline-primary" for="<?php echo $id; ?>"><?php echo htmlspecialchars($pt); ?></label>
<?php
$first = false;
endif;
endforeach;
?>
</div>
</div>

View File

@ -136,6 +136,17 @@
</div>
</div>
<!-- Payment Settings -->
<div class="col-12 mt-4"><hr></div>
<div class="col-12 mb-2">
<h6 class="fw-bold text-dark"><i class="bi bi-credit-card me-2"></i> <?php echo __('payment_settings'); ?></h6>
</div>
<div class="col-md-12">
<label for="payment_types" class="form-label fw-semibold text-muted small text-uppercase"> <?php echo __('payment_types'); ?></label>
<input type="text" class="form-control" id="payment_types" name="payment_types" value="<?php echo htmlspecialchars($settings['payment_types'] ?? 'Cash, Card, Insurance, Online, Other'); ?>" placeholder="Cash, Card, Insurance, Online, Other">
<div class="form-text text-muted"> <?php echo __('payment_types_desc'); ?></div>
</div>
<!-- Currency Settings -->
<div class="col-12 mt-4"><hr></div>
<div class="col-12 mb-2">

View File

@ -366,6 +366,9 @@ $translations = array (
'timezone' => 'Timezone',
'working_hours_start' => 'Working Hours Start',
'working_hours_end' => 'Working Hours End',
'payment_settings' => 'Payment Settings',
'payment_types' => 'Payment Types',
'payment_types_desc' => 'Comma separated list of payment types (e.g. Cash, Card, Insurance, Online, Other)',
'currency_settings' => 'Currency Settings',
'currency_symbol' => 'Currency Symbol',
'decimal_digits' => 'Decimal Digits',
@ -897,6 +900,9 @@ $translations = array (
'timezone' => 'المنطقة الزمنية',
'working_hours_start' => 'بداية ساعات العمل',
'working_hours_end' => 'نهاية ساعات العمل',
'payment_settings' => 'إعدادات الدفع',
'payment_types' => 'طرق الدفع',
'payment_types_desc' => 'قائمة مفصولة بفواصل لطرق الدفع (مثل: نقدي، بطاقة، تأمين، عبر الإنترنت، أخرى)',
'currency_settings' => 'إعدادات العملة',
'currency_symbol' => 'رمز العملة',
'decimal_digits' => 'الخانات العشرية',

1
p.php
View File

@ -1 +0,0 @@
<?php $content = file_get_contents('lang.php'); $en_add = "'timezone' => 'Timezone',\n 'working_hours_start' => 'Working Hours Start',\n 'working_hours_end' => 'Working Hours End',"; $ar_add = "'timezone' => 'المنطقة الزمنية',\n 'working_hours_start' => 'بداية ساعات العمل',\n 'working_hours_end' => 'نهاية ساعات العمل',"; $content = str_replace("'company_vat_no' => 'VAT No',", "'company_vat_no' => 'VAT No',\n " . $en_add, $content); $content = str_replace("'vat_no' => 'الرقم الضريبي',", "'vat_no' => 'الرقم الضريبي',\n " . $ar_add, $content); file_put_contents('lang.php', $content); echo 'patched';

1
p2.php
View File

@ -1 +0,0 @@
<?php $c = file_get_contents('includes/pages/settings.php'); $new_fields = " <!-- Timezone & Working Hours -->\n <div class=\"col-12 mt-4\"><hr></div>\n <div class=\"col-md-4\">\n <label for=\"timezone\" class=\"form-label fw-semibold text-muted small text-uppercase\"><?php echo __('timezone'); ?></label>\n <select class=\"form-select\" id=\"timezone\" name=\"timezone\">\n <?php\n \$timezones = DateTimeZone::listIdentifiers();\n \$current_tz = \$settings['timezone'] ?? 'UTC';\n foreach (\$timezones as \$tz) {\n \$selected = (\$tz === \$current_tz) ? 'selected' : '';\n echo \"<option value=\\\"{\$tz}\\\" {\$selected}>{\$tz}</option>\";\n }\n ?>\n </select>\n </div>\n <div class=\"col-md-4\">\n <label for=\"working_hours_start\" class=\"form-label fw-semibold text-muted small text-uppercase\"><?php echo __('working_hours_start'); ?></label>\n <input type=\"time\" class=\"form-control\" id=\"working_hours_start\" name=\"working_hours_start\" value=\"<?php echo htmlspecialchars(\$settings['working_hours_start'] ?? '08:00'); ?>\">\n </div>\n <div class=\"col-md-4\">\n <label for=\"working_hours_end\" class=\"form-label fw-semibold text-muted small text-uppercase\"><?php echo __('working_hours_end'); ?></label>\n <input type=\"time\" class=\"form-control\" id=\"working_hours_end\" name=\"working_hours_end\" value=\"<?php echo htmlspecialchars(\$settings['working_hours_end'] ?? '17:00'); ?>\">\n </div>"; $c = str_replace('<!-- Branding -->', $new_fields . "\n\n <!-- Branding -->", $c); file_put_contents('includes/pages/settings.php', $c); echo 'patched settings UI';

View File

@ -1,12 +0,0 @@
<?php
$content = file_get_contents('db/migrations/20260322_merge_doctors_nurses_into_hr_final.sql');
$content = str_replace(
'ALTER TABLE patient_queue ADD CONSTRAINT fk_queue_doctor_employee',
'ALTER TABLE patient_queue DROP FOREIGN KEY IF EXISTS fk_queue_doctor_employee;' . "\n" . 'ALTER TABLE patient_queue ADD CONSTRAINT fk_queue_doctor_employee',
$content
);
file_put_contents('db/migrations/20260322_merge_doctors_nurses_into_hr_final.sql', $content);
echo "Patched final.sql\n";

View File

@ -1,26 +0,0 @@
<?php
$section = 'test_groups';
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/helpers.php';
require_once __DIR__ . '/includes/auth.php';
check_auth();
$db = db();
$lang = $_SESSION['lang'];
require_once __DIR__ . '/includes/actions.php';
require_once __DIR__ . '/includes/common_data.php';
$is_ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
if (!$is_ajax) {
require_once __DIR__ . '/includes/layout/header.php';
}
require_once __DIR__ . '/includes/pages/test_groups.php';
if (!$is_ajax) {
require_once __DIR__ . '/includes/layout/footer.php';
}
?>

View File

@ -1,15 +0,0 @@
<?php
require_once 'db/config.php';
$db = db();
try {
$sql = "SELECT a.id, p.name as patient_name, a.start_time, a.patient_id, a.doctor_id
FROM appointments a
JOIN patients p ON a.patient_id = p.id
WHERE a.status = 'Scheduled'
ORDER BY a.start_time ASC";
$scheduled_appointments = $db->query($sql)->fetchAll();
print_r($scheduled_appointments);
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}