Autosave: 20260312-174549
This commit is contained in:
parent
d79aa1e948
commit
0a3eff3c92
3
db/migrations/20260306_change_passion_to_position.sql
Normal file
3
db/migrations/20260306_change_passion_to_position.sql
Normal file
@ -0,0 +1,3 @@
|
||||
ALTER TABLE employees ADD COLUMN position_id INT NULL;
|
||||
ALTER TABLE employees DROP COLUMN passion_en;
|
||||
ALTER TABLE employees DROP COLUMN passion_ar;
|
||||
1
db/migrations/20260306_rename_poisons_to_positions.sql
Normal file
1
db/migrations/20260306_rename_poisons_to_positions.sql
Normal file
@ -0,0 +1 @@
|
||||
RENAME TABLE poisons TO positions;
|
||||
@ -393,12 +393,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$mobile = $_POST['mobile'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$dept_id = $_POST['department_id'] ?: null;
|
||||
$passion_en = $_POST['passion_en'] ?? '';
|
||||
$passion_ar = $_POST['passion_ar'] ?? '';
|
||||
$position_id = $_POST['position_id'] ?: null;
|
||||
|
||||
if ($name_en && $name_ar) {
|
||||
$stmt = $db->prepare("INSERT INTO employees (name_en, name_ar, dob, mobile, email, department_id, passion_en, passion_ar) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name_en, $name_ar, $dob, $mobile, $email, $dept_id, $passion_en, $passion_ar]);
|
||||
$stmt = $db->prepare("INSERT INTO employees (name_en, name_ar, dob, mobile, email, department_id, position_id) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name_en, $name_ar, $dob, $mobile, $email, $dept_id, $position_id]);
|
||||
$_SESSION['flash_message'] = __('add_employee') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
}
|
||||
@ -410,12 +409,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$mobile = $_POST['mobile'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$dept_id = $_POST['department_id'] ?: null;
|
||||
$passion_en = $_POST['passion_en'] ?? '';
|
||||
$passion_ar = $_POST['passion_ar'] ?? '';
|
||||
$position_id = $_POST['position_id'] ?: null;
|
||||
|
||||
if ($id && $name_en && $name_ar) {
|
||||
$stmt = $db->prepare("UPDATE employees SET name_en = ?, name_ar = ?, dob = ?, mobile = ?, email = ?, department_id = ?, passion_en = ?, passion_ar = ? WHERE id = ?");
|
||||
$stmt->execute([$name_en, $name_ar, $dob, $mobile, $email, $dept_id, $passion_en, $passion_ar, $id]);
|
||||
$stmt = $db->prepare("UPDATE employees SET name_en = ?, name_ar = ?, dob = ?, mobile = ?, email = ?, department_id = ?, position_id = ? WHERE id = ?");
|
||||
$stmt->execute([$name_en, $name_ar, $dob, $mobile, $email, $dept_id, $position_id, $id]);
|
||||
$_SESSION['flash_message'] = __('edit_employee') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
}
|
||||
@ -427,19 +425,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
}
|
||||
} elseif ($_POST['action'] === 'add_poison') {
|
||||
} elseif ($_POST['action'] === 'add_position') {
|
||||
$name_en = $_POST['name_en'] ?? '';
|
||||
$name_ar = $_POST['name_ar'] ?? '';
|
||||
$desc_en = $_POST['description_en'] ?? '';
|
||||
$desc_ar = $_POST['description_ar'] ?? '';
|
||||
|
||||
if ($name_en && $name_ar) {
|
||||
$stmt = $db->prepare("INSERT INTO poisons (name_en, name_ar, description_en, description_ar) VALUES (?, ?, ?, ?)");
|
||||
$stmt = $db->prepare("INSERT INTO positions (name_en, name_ar, description_en, description_ar) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar]);
|
||||
$_SESSION['flash_message'] = __('add_poison') . ' ' . __('successfully');
|
||||
$_SESSION['flash_message'] = __('add_position') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
}
|
||||
} elseif ($_POST['action'] === 'edit_poison') {
|
||||
} elseif ($_POST['action'] === 'edit_position') {
|
||||
$id = $_POST['id'] ?? '';
|
||||
$name_en = $_POST['name_en'] ?? '';
|
||||
$name_ar = $_POST['name_ar'] ?? '';
|
||||
@ -447,15 +445,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$desc_ar = $_POST['description_ar'] ?? '';
|
||||
|
||||
if ($id && $name_en && $name_ar) {
|
||||
$stmt = $db->prepare("UPDATE poisons SET name_en = ?, name_ar = ?, description_en = ?, description_ar = ? WHERE id = ?");
|
||||
$stmt = $db->prepare("UPDATE positions SET name_en = ?, name_ar = ?, description_en = ?, description_ar = ? WHERE id = ?");
|
||||
$stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $id]);
|
||||
$_SESSION['flash_message'] = __('edit_poison') . ' ' . __('successfully');
|
||||
$_SESSION['flash_message'] = __('edit_position') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
}
|
||||
} elseif ($_POST['action'] === 'delete_poison') {
|
||||
} elseif ($_POST['action'] === 'delete_position') {
|
||||
$id = $_POST['id'] ?? '';
|
||||
if ($id) {
|
||||
$stmt = $db->prepare("DELETE FROM poisons WHERE id = ?");
|
||||
$stmt = $db->prepare("DELETE FROM positions WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
|
||||
$redirect = true;
|
||||
|
||||
@ -5,7 +5,7 @@ $all_patients = $db->query("SELECT id, name, dob, gender FROM patients")->fetchA
|
||||
$all_nurses = $db->query("SELECT id, name_$lang as name FROM nurses")->fetchAll();
|
||||
$all_departments = $db->query("SELECT id, name_$lang as name FROM departments")->fetchAll();
|
||||
$all_employees = $db->query("SELECT id, name_$lang as name FROM employees")->fetchAll();
|
||||
$all_poisons = $db->query("SELECT id, name_$lang as name FROM poisons")->fetchAll();
|
||||
$all_positions = $db->query("SELECT id, name_$lang as name FROM positions")->fetchAll();
|
||||
$all_insurance = $db->query("SELECT id, name_$lang as name FROM insurance_companies")->fetchAll();
|
||||
$all_test_groups = $db->query("SELECT id, name_$lang as name FROM test_groups")->fetchAll();
|
||||
$all_tests = $db->query("SELECT id, name_$lang as name, price, normal_range FROM laboratory_tests")->fetchAll();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -145,19 +145,19 @@ $site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['comp
|
||||
<a href="insurance.php" class="sidebar-link <?php echo $section === 'insurance' ? 'active' : ''; ?>"><i class="bi bi-shield-check me-2"></i> <?php echo __('insurance'); ?></a>
|
||||
<a href="doctors.php" class="sidebar-link <?php echo $section === 'doctors' ? 'active' : ''; ?>"><i class="bi bi-person-badge me-2"></i> <?php echo __('doctors'); ?></a>
|
||||
<a href="nurses.php" class="sidebar-link <?php echo $section === 'nurses' ? 'active' : ''; ?>"><i class="bi bi-person-heart me-2"></i> <?php echo __('nurses'); ?></a>
|
||||
<a href="departments.php" class="sidebar-link <?php echo $section === 'departments' ? 'active' : ''; ?>"><i class="bi bi-diagram-3 me-2"></i> <?php echo __('departments'); ?></a>
|
||||
<a href="hospital_services.php" class="sidebar-link <?php echo $section === 'services' ? 'active' : ''; ?>"><i class="bi bi-activity me-2"></i> <?php echo __('services'); ?></a>
|
||||
<a href="cities.php" class="sidebar-link <?php echo $section === 'cities' ? 'active' : ''; ?>"><i class="bi bi-building me-2"></i> <?php echo __('cities'); ?></a>
|
||||
|
||||
<a href="#settingsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['employees', 'poisons', 'company_profile']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
|
||||
<a href="#settingsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['employees', 'positions', 'company_profile', 'cities', 'services', 'departments']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-gear me-2"></i> <?php echo __('settings'); ?></span>
|
||||
<i class="bi bi-chevron-down small"></i>
|
||||
</a>
|
||||
<div class="collapse <?php echo in_array($section, ['employees', 'poisons', 'company_profile']) ? 'show' : ''; ?>" id="settingsSubmenu">
|
||||
<div class="collapse <?php echo in_array($section, ['employees', 'positions', 'company_profile', 'cities', 'services', 'departments']) ? 'show' : ''; ?>" id="settingsSubmenu">
|
||||
<div class="sidebar-submenu">
|
||||
<a href="settings.php" class="sidebar-link py-2 <?php echo $section === 'company_profile' ? 'active' : ''; ?>"><i class="bi bi-building me-2"></i> <?php echo __('company_profile'); ?></a>
|
||||
<a href="employees.php" class="sidebar-link py-2 <?php echo $section === 'employees' ? 'active' : ''; ?>"><i class="bi bi-person-workspace me-2"></i> <?php echo __('employees'); ?></a>
|
||||
<a href="poisons.php" class="sidebar-link py-2 <?php echo $section === 'poisons' ? 'active' : ''; ?>"><i class="bi bi-radioactive me-2"></i> <?php echo __('poisons'); ?></a>
|
||||
<a href="positions.php" class="sidebar-link py-2 <?php echo $section === 'positions' ? 'active' : ''; ?>"><i class="bi bi-diagram-2 me-2"></i> <?php echo __('positions'); ?></a>
|
||||
<a href="departments.php" class="sidebar-link py-2 <?php echo $section === 'departments' ? 'active' : ''; ?>"><i class="bi bi-diagram-3 me-2"></i> <?php echo __('departments'); ?></a>
|
||||
<a href="hospital_services.php" class="sidebar-link py-2 <?php echo $section === 'services' ? 'active' : ''; ?>"><i class="bi bi-activity me-2"></i> <?php echo __('services'); ?></a>
|
||||
<a href="cities.php" class="sidebar-link py-2 <?php echo $section === 'cities' ? 'active' : ''; ?>"><i class="bi bi-building me-2"></i> <?php echo __('cities'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@ -197,4 +197,4 @@ $site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['comp
|
||||
<?php echo $message; ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -3,9 +3,10 @@ $search_name = $_GET['name'] ?? '';
|
||||
$search_dept = $_GET['department_id'] ?? '';
|
||||
|
||||
$query = "
|
||||
SELECT e.*, d.name_$lang as department_name
|
||||
SELECT e.*, d.name_$lang as department_name, p.name_$lang as position_name
|
||||
FROM employees e
|
||||
LEFT JOIN departments d ON e.department_id = d.id
|
||||
LEFT JOIN positions p ON e.position_id = p.id
|
||||
WHERE 1=1";
|
||||
$params = [];
|
||||
|
||||
@ -66,7 +67,7 @@ $employees = $stmt->fetchAll();
|
||||
<thead class="table-light text-secondary">
|
||||
<tr>
|
||||
<th class="px-4 py-3"><?php echo __('name'); ?></th>
|
||||
<th class="py-3"><?php echo __('department'); ?></th>
|
||||
<th class="py-3"><?php echo __('department'); ?> / <?php echo __('position'); ?></th>
|
||||
<th class="py-3"><?php echo __('contact'); ?></th>
|
||||
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
||||
</tr>
|
||||
@ -90,6 +91,9 @@ $employees = $stmt->fetchAll();
|
||||
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary border-opacity-25 px-2 py-1">
|
||||
<?php echo htmlspecialchars($emp['department_name'] ?: '-'); ?>
|
||||
</span>
|
||||
<div class="small text-muted mt-1">
|
||||
<i class="bi bi-diagram-2 me-1"></i> <?php echo htmlspecialchars($emp['position_name'] ?: '-'); ?>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small text-secondary"><i class="bi bi-telephone me-1"></i> <?php echo htmlspecialchars($emp['mobile'] ?: '-'); ?></div>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
$search_name = $_GET['name'] ?? '';
|
||||
|
||||
$query = "SELECT * FROM poisons WHERE 1=1";
|
||||
$query = "SELECT * FROM positions WHERE 1=1";
|
||||
$params = [];
|
||||
|
||||
if ($search_name) {
|
||||
@ -13,13 +13,13 @@ if ($search_name) {
|
||||
$query .= " ORDER BY id DESC";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->execute($params);
|
||||
$poisons = $stmt->fetchAll();
|
||||
$positions = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h3 class="fw-bold text-secondary"><?php echo __('poisons'); ?></h3>
|
||||
<button class="btn btn-danger shadow-sm" data-bs-toggle="modal" data-bs-target="#addPoisonModal">
|
||||
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_poison'); ?>
|
||||
<h3 class="fw-bold text-secondary"><?php echo __('positions'); ?></h3>
|
||||
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addPositionModal">
|
||||
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_position'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -54,29 +54,29 @@ $poisons = $stmt->fetchAll();
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($poisons)): ?>
|
||||
<?php if (empty($positions)): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-radioactive display-4 d-block mb-3"></i>
|
||||
No poisons found.
|
||||
<i class="bi bi-person-badge display-4 d-block mb-3"></i>
|
||||
No positions found.
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($poisons as $poison): ?>
|
||||
<?php foreach ($positions as $position): ?>
|
||||
<tr>
|
||||
<td class="px-4 text-secondary"><?php echo $poison['id']; ?></td>
|
||||
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($poison['name_en']); ?></td>
|
||||
<td class="text-secondary"><?php echo htmlspecialchars($poison['name_ar']); ?></td>
|
||||
<td><small class="text-truncate d-inline-block text-muted" style="max-width: 300px;"><?php echo htmlspecialchars($poison['description_en']); ?></small></td>
|
||||
<td class="px-4 text-secondary"><?php echo $position['id']; ?></td>
|
||||
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($position['name_en']); ?></td>
|
||||
<td class="text-secondary"><?php echo htmlspecialchars($position['name_ar']); ?></td>
|
||||
<td><small class="text-truncate d-inline-block text-muted" style="max-width: 300px;"><?php echo htmlspecialchars($position['description_en']); ?></small></td>
|
||||
<td class="text-end px-4">
|
||||
<div class="btn-group shadow-sm border rounded bg-white">
|
||||
<button class="btn btn-link text-primary py-1 px-2 border-end"
|
||||
onclick="showEditPoisonModal(<?php echo htmlspecialchars(json_encode($poison, JSON_UNESCAPED_UNICODE)); ?>)"
|
||||
onclick="showEditPositionModal(<?php echo htmlspecialchars(json_encode($position, JSON_UNESCAPED_UNICODE)); ?>)"
|
||||
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</button>
|
||||
<button class="btn btn-link text-danger py-1 px-2"
|
||||
onclick="showDeletePoisonModal(<?php echo $poison['id']; ?>)"
|
||||
onclick="showDeletePositionModal(<?php echo $position['id']; ?>)"
|
||||
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
|
||||
<i class="bi bi-trash3"></i>
|
||||
</button>
|
||||
38
lang.php
38
lang.php
@ -124,21 +124,21 @@ $translations = [
|
||||
'no_nurses_found' => 'No nurses found',
|
||||
'settings' => 'Settings',
|
||||
'employees' => 'Employees',
|
||||
'poisons' => 'Poisons',
|
||||
'positions' => 'Positions',
|
||||
'mobile' => 'Mobile',
|
||||
'passion' => 'Passion',
|
||||
'passion_en' => 'Passion (English)',
|
||||
'passion_ar' => 'Passion (Arabic)',
|
||||
'position' => 'Position',
|
||||
'position_en' => 'Position (English)',
|
||||
'position_ar' => 'Position (Arabic)',
|
||||
'add_employee' => 'Add Employee',
|
||||
'edit_employee' => 'Edit Employee',
|
||||
'update_employee' => 'Update Employee',
|
||||
'delete_employee' => 'Delete Employee',
|
||||
'no_employees_found' => 'No employees found',
|
||||
'add_poison' => 'Add Poison',
|
||||
'edit_poison' => 'Edit Poison',
|
||||
'update_poison' => 'Update Poison',
|
||||
'delete_poison' => 'Delete Poison',
|
||||
'no_poisons_found' => 'No poisons found',
|
||||
'add_position' => 'Add Position',
|
||||
'edit_position' => 'Edit Position',
|
||||
'update_position' => 'Update Position',
|
||||
'delete_position' => 'Delete Position',
|
||||
'no_positions_found' => 'No positions found',
|
||||
'description_en' => 'Description (English)',
|
||||
'description_ar' => 'Description (Arabic)',
|
||||
'laboratory' => 'Laboratory',
|
||||
@ -404,21 +404,21 @@ $translations = [
|
||||
'no_nurses_found' => 'لم يتم العثور على ممرضات',
|
||||
'settings' => 'الإعدادات',
|
||||
'employees' => 'الموظفون',
|
||||
'poisons' => 'السموم',
|
||||
'positions' => 'المناصب',
|
||||
'mobile' => 'الجوال',
|
||||
'passion' => 'الشغف',
|
||||
'passion_en' => 'الشغف (إنجليزي)',
|
||||
'passion_ar' => 'الشغف (عربي)',
|
||||
'position' => 'المنصب',
|
||||
'position_en' => 'المنصب (إنجليزي)',
|
||||
'position_ar' => 'المنصب (عربي)',
|
||||
'add_employee' => 'إضافة موظف',
|
||||
'edit_employee' => 'تعديل موظف',
|
||||
'update_employee' => 'تحديث بيانات الموظف',
|
||||
'delete_employee' => 'حذف موظف',
|
||||
'no_employees_found' => 'لم يتم العثور على موظفين',
|
||||
'add_poison' => 'إضافة سم',
|
||||
'edit_poison' => 'تعديل سم',
|
||||
'update_poison' => 'تحديث بيانات السم',
|
||||
'delete_poison' => 'حذف سم',
|
||||
'no_poisons_found' => 'لم يتم العثور على سموم',
|
||||
'add_position' => 'إضافة منصب',
|
||||
'edit_position' => 'تعديل منصب',
|
||||
'update_position' => 'تحديث بيانات المنصب',
|
||||
'delete_position' => 'حذف منصب',
|
||||
'no_positions_found' => 'لم يتم العثور على مناصب',
|
||||
'description_en' => 'الوصف (إنجليزي)',
|
||||
'description_ar' => 'الوصف (عربي)',
|
||||
'laboratory' => 'المختبر',
|
||||
@ -538,4 +538,4 @@ $translations = [
|
||||
'inactive' => 'غير نشط',
|
||||
'are_you_sure_delete_service' => 'هل أنت متأكد أنك تريد حذف هذه الخدمة؟',
|
||||
]
|
||||
];
|
||||
];
|
||||
@ -13,11 +13,11 @@ require_once 'helpers.php';
|
||||
|
||||
$db = db();
|
||||
$lang = $_SESSION['lang'];
|
||||
$section = 'poisons';
|
||||
$section = 'positions';
|
||||
|
||||
require_once 'includes/actions.php';
|
||||
require_once 'includes/common_data.php';
|
||||
|
||||
include 'includes/layout/header.php';
|
||||
include 'includes/pages/poisons.php';
|
||||
include 'includes/layout/footer.php';
|
||||
include 'includes/pages/positions.php';
|
||||
include 'includes/layout/footer.php';
|
||||
Loading…
x
Reference in New Issue
Block a user