adding rooms to doctors

This commit is contained in:
Flatlogic Bot 2026-03-23 03:54:02 +00:00
parent 620485b60a
commit 3ca5cde9e3
2 changed files with 41 additions and 199 deletions

View File

@ -88,7 +88,7 @@
</div>
<div class="col-md-3 mb-3">
<label class="form-label"><?php echo __('dob'); ?></label>
<input type="text" name="dob" id="add_patient_dob" class="form-control masked-date" placeholder="YYYY-MM-DD">
<input type="text" name="dob" id="add_patient_dob" class="form-control masked-date" placeholder="YYYY-MM-DD" data-inputmask-alias="datetime" data-inputmask-inputformat="yyyy-mm-dd">
</div>
<div class="col-md-2 mb-3">
<label class="form-label"><?php echo __('age'); ?></label>
@ -192,7 +192,7 @@
</div>
<div class="col-md-3 mb-3">
<label class="form-label"><?php echo __('dob'); ?></label>
<input type="text" name="dob" id="edit_patient_dob" class="form-control masked-date" placeholder="YYYY-MM-DD">
<input type="text" name="dob" id="edit_patient_dob" class="form-control masked-date" placeholder="YYYY-MM-DD" data-inputmask-alias="datetime" data-inputmask-inputformat="yyyy-mm-dd">
</div>
<div class="col-md-2 mb-3">
<label class="form-label"><?php echo __('age'); ?></label>
@ -598,157 +598,6 @@
</div>
</div>
<!-- Add Employee Modal -->
<div class="modal fade" id="addEmployeeModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="add_employee">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold text-white"><?php echo __('add_employee'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label"><?php echo __('name_en'); ?></label>
<input type="text" name="name_en" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('name_ar'); ?></label>
<input type="text" name="name_ar" class="form-control" dir="rtl" required>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('dob'); ?></label>
<input type="text" name="dob" class="form-control masked-date" placeholder="YYYY-MM-DD">
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('mobile'); ?></label>
<input type="text" name="mobile" class="form-control">
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('email'); ?></label>
<input type="email" name="email" class="form-control">
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('department'); ?></label>
<select name="department_id" class="form-select">
<option value=""><?php echo __('search'); ?>...</option>
<?php foreach ($all_departments as $dept): ?>
<option value="<?php echo $dept['id']; ?>"><?php echo htmlspecialchars($dept['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('position'); ?></label>
<select name="position_id" class="form-select">
<option value=""><?php echo __('select'); ?>...</option>
<?php foreach ($all_positions as $pos): ?>
<option value="<?php echo $pos['id']; ?>"><?php echo htmlspecialchars($pos['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-primary px-4"><?php echo __('save'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Edit Employee Modal -->
<div class="modal fade" id="editEmployeeModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="edit_employee">
<input type="hidden" name="id" id="edit_employee_id">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold text-white"><?php echo __('edit_employee'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label"><?php echo __('name_en'); ?></label>
<input type="text" name="name_en" id="edit_employee_name_en" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('name_ar'); ?></label>
<input type="text" name="name_ar" id="edit_employee_name_ar" class="form-control" dir="rtl" required>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('dob'); ?></label>
<input type="text" name="dob" id="edit_employee_dob" class="form-control masked-date" placeholder="YYYY-MM-DD">
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('mobile'); ?></label>
<input type="text" name="mobile" id="edit_employee_mobile" class="form-control">
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('email'); ?></label>
<input type="email" name="email" id="edit_employee_email" class="form-control">
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('department'); ?></label>
<select name="department_id" id="edit_employee_dept_id" class="form-select">
<option value=""><?php echo __('search'); ?>...</option>
<?php foreach ($all_departments as $dept): ?>
<option value="<?php echo $dept['id']; ?>"><?php echo htmlspecialchars($dept['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('position'); ?></label>
<select name="position_id" id="edit_employee_position_id" class="form-select">
<option value=""><?php echo __('select'); ?>...</option>
<?php foreach ($all_positions as $pos): ?>
<option value="<?php echo $pos['id']; ?>"><?php echo htmlspecialchars($pos['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-primary px-4"><?php echo __('save'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Delete Employee Modal -->
<div class="modal fade" id="deleteEmployeeModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST">
<input type="hidden" name="action" value="delete_employee">
<input type="hidden" name="id" id="delete_employee_id">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold text-white"><?php echo __('delete'); ?> <?php echo __('employee'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p><?php echo __('confirm_delete'); ?>?</p>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-danger px-4"><?php echo __('delete'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Add City Modal -->
<div class="modal fade" id="addCityModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
@ -1649,26 +1498,6 @@ function showDeleteNurseModal(id) {
modal.show();
}
function showEditEmployeeModal(data) {
document.getElementById('edit_employee_id').value = data.id;
document.getElementById('edit_employee_name_en').value = data.name_en;
document.getElementById('edit_employee_name_ar').value = data.name_ar;
document.getElementById('edit_employee_dob').value = data.dob || '';
document.getElementById('edit_employee_mobile').value = data.mobile || '';
document.getElementById('edit_employee_email').value = data.email || '';
document.getElementById('edit_employee_dept_id').value = data.department_id || '';
document.getElementById('edit_employee_position_id').value = data.position_id || '';
var modal = new bootstrap.Modal(document.getElementById('editEmployeeModal'));
modal.show();
}
function showDeleteEmployeeModal(id) {
document.getElementById('delete_employee_id').value = id;
var modal = new bootstrap.Modal(document.getElementById('deleteEmployeeModal'));
modal.show();
}
function showEditCityModal(data) {
document.getElementById('edit_city_id').value = data.id;
document.getElementById('edit_city_name_en').value = data.name_en;
@ -1741,7 +1570,7 @@ $(document).ready(function() {
// Initialize Inputmask
if (typeof Inputmask !== 'undefined') {
Inputmask().mask(document.querySelectorAll("input"));
Inputmask().mask(document.querySelectorAll("[data-inputmask], [data-inputmask-alias], [data-inputmask-mask]"));
}
// Initialize Summernote

View File

@ -6,6 +6,8 @@ $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] :
$limit = 10;
$offset = ($page - 1) * $limit;
$lang = $_SESSION['lang'] ?? 'en';
$where = "WHERE 1=1";
$params = [];
@ -27,8 +29,9 @@ $totalEmployees = $stmt->fetchColumn();
$totalPages = ceil($totalEmployees / $limit);
// Fetch Data
// Explicitly selecting room_number just to be safe, though e.* covers it.
$query = "
SELECT e.*, d.name_$lang as department_name, p.name_$lang as position_name
SELECT e.*, e.room_number, 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
@ -41,14 +44,25 @@ $stmt->execute($params);
$employees = $stmt->fetchAll();
// Fetch Departments for Dropdown (Needed for Search Bar and Modal)
$deptQuery = "SELECT * FROM departments ORDER BY name_$lang";
$deptStmt = $db->query($deptQuery);
$all_departments = $deptStmt->fetchAll();
$deptNameCol = ($lang === 'ar') ? 'name_ar' : 'name_en';
$deptQuery = "SELECT id, $deptNameCol as name, active FROM departments ORDER BY $deptNameCol";
try {
$deptStmt = $db->query($deptQuery);
$all_departments = $deptStmt->fetchAll();
} catch (Exception $e) {
$all_departments = [];
error_log("Error fetching departments: " . $e->getMessage());
}
// Fetch Positions for Dropdown (Needed for Modal)
$posQuery = "SELECT * FROM positions ORDER BY name_$lang";
$posStmt = $db->query($posQuery);
$all_positions = $posStmt->fetchAll();
$posNameCol = ($lang === 'ar') ? 'name_ar' : 'name_en';
$posQuery = "SELECT id, $posNameCol as name FROM positions ORDER BY $posNameCol";
try {
$posStmt = $db->query($posQuery);
$all_positions = $posStmt->fetchAll();
} catch (Exception $e) {
$all_positions = [];
}
// --- AJAX HANDLER ---
if (isset($_GET['ajax_search'])) {
@ -177,7 +191,7 @@ if (isset($_GET['ajax_search'])) {
<option value=""><?php echo __('department'); ?> (<?php echo __('all'); ?>)</option>
<?php foreach ($all_departments as $dept): ?>
<option value="<?php echo $dept['id']; ?>" <?php echo $search_dept == $dept['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($dept['name_'.$lang]); ?>
<?php echo htmlspecialchars($dept['name']); ?>
</option>
<?php endforeach; ?>
</select>
@ -324,9 +338,9 @@ if (isset($_GET['ajax_search'])) {
<input type="text" class="form-control" name="name_ar" id="empNameAr" required>
</div>
<!-- Room Number moved to top -->
<!-- Room Number -->
<div class="col-md-6">
<label class="form-label"><?php echo __('room_number') ?: 'Room Number'; ?></label>
<label class="form-label fw-bold" for="empRoomNumber"><?php echo __('room_number'); ?></label>
<input type="text" class="form-control" name="room_number" id="empRoomNumber" placeholder="<?php echo __('room_number'); ?>">
</div>
@ -343,7 +357,7 @@ if (isset($_GET['ajax_search'])) {
<label class="form-label"><?php echo __('dob'); ?></label>
<div class="input-group">
<span class="input-group-text bg-light"><i class="bi bi-calendar3"></i></span>
<input type="text" class="form-control" name="dob" id="empDob" placeholder="YYYY-MM-DD" data-inputmask="'alias': 'datetime', 'inputFormat': 'yyyy-mm-dd'" inputmode="numeric">
<input type="text" class="form-control" name="dob" id="empDob" placeholder="YYYY-MM-DD" data-inputmask-alias="datetime" data-inputmask-inputformat="yyyy-mm-dd" inputmode="numeric">
</div>
</div>
@ -353,7 +367,7 @@ if (isset($_GET['ajax_search'])) {
<option value=""><?php echo __('select_department'); ?></option>
<?php foreach ($all_departments as $dept): ?>
<option value="<?php echo $dept['id']; ?>">
<?php echo htmlspecialchars($dept['name_' . $lang]); ?>
<?php echo htmlspecialchars($dept['name']); ?>
</option>
<?php endforeach; ?>
</select>
@ -364,7 +378,7 @@ if (isset($_GET['ajax_search'])) {
<option value=""><?php echo __('select_position'); ?></option>
<?php foreach ($all_positions as $pos): ?>
<option value="<?php echo $pos['id']; ?>">
<?php echo htmlspecialchars($pos['name_' . $lang]); ?>
<?php echo htmlspecialchars($pos['name']); ?>
</option>
<?php endforeach; ?>
</select>
@ -418,10 +432,8 @@ document.addEventListener('DOMContentLoaded', function() {
const searchDept = document.getElementById('empSearchDept');
const paginationContainer = document.getElementById('employeesPagination');
// Initialize Inputmask for DOB
if (document.getElementById('empDob')) {
Inputmask().mask(document.getElementById('empDob'));
}
// Initialize Inputmask for DOB is handled globally in footer.php, but if not we can add it here if footer is not included.
// However, footer is included. The global init should pick up data-inputmask attribute.
let timeout = null;
@ -503,19 +515,20 @@ function resetEmployeeModal() {
}
function showEditEmployeeModal(emp) {
console.log('Employee Data:', emp); // Debug: Check if room_number is present
document.getElementById('empModalTitle').textContent = '<?php echo __('edit_employee'); ?>';
document.getElementById('empAction').value = 'edit_employee';
document.getElementById('empId').value = emp.id;
document.getElementById('empNameEn').value = emp.name_en;
document.getElementById('empNameAr').value = emp.name_ar;
document.getElementById('empEmail').value = emp.email;
document.getElementById('empMobile').value = emp.mobile;
document.getElementById('empNameEn').value = emp.name_en || '';
document.getElementById('empNameAr').value = emp.name_ar || '';
document.getElementById('empEmail').value = emp.email || '';
document.getElementById('empMobile').value = emp.mobile || '';
document.getElementById('empRoomNumber').value = emp.room_number || '';
document.getElementById('empDob').value = emp.dob;
document.getElementById('empDeptId').value = emp.department_id;
document.getElementById('empPosId').value = emp.position_id;
document.getElementById('empAddress').value = emp.address;
document.getElementById('empDob').value = emp.dob || '';
document.getElementById('empDeptId').value = emp.department_id || '';
document.getElementById('empPosId').value = emp.position_id || '';
document.getElementById('empAddress').value = emp.address || '';
var modal = new bootstrap.Modal(document.getElementById('addEmployeeModal'));
modal.show();