125 lines
6.2 KiB
PHP
125 lines
6.2 KiB
PHP
<?php
|
|
$search_patient = $_GET['patient'] ?? '';
|
|
$search_doctor = $_GET['doctor'] ?? '';
|
|
$search_date = $_GET['date'] ?? '';
|
|
|
|
$query = "
|
|
SELECT v.*, p.name as patient_name, d.name_$lang as doctor_name
|
|
FROM visits v
|
|
JOIN patients p ON v.patient_id = p.id
|
|
JOIN doctors d ON v.doctor_id = d.id
|
|
WHERE 1=1";
|
|
$params = [];
|
|
|
|
if ($search_patient) {
|
|
$query .= " AND p.name LIKE ?";
|
|
$params[] = "%$search_patient%";
|
|
}
|
|
if ($search_doctor) {
|
|
$query .= " AND (d.name_en LIKE ? OR d.name_ar LIKE ?)";
|
|
$params[] = "%$search_doctor%";
|
|
$params[] = "%$search_doctor%";
|
|
}
|
|
if ($search_date) {
|
|
$query .= " AND DATE(v.visit_date) = ?";
|
|
$params[] = $search_date;
|
|
}
|
|
|
|
$query .= " ORDER BY v.visit_date DESC";
|
|
$stmt = $db->prepare($query);
|
|
$stmt->execute($params);
|
|
$visits = $stmt->fetchAll();
|
|
?>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h3 class="fw-bold text-secondary"><?php echo __('visits'); ?></h3>
|
|
<button class="btn btn-info shadow-sm text-white" data-bs-toggle="modal" data-bs-target="#recordVisitModal">
|
|
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_visit'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Search Bar -->
|
|
<div class="card shadow-sm border-0 mb-4">
|
|
<div class="card-body">
|
|
<form method="GET" action="" class="row g-3">
|
|
<div class="col-md-3">
|
|
<div class="input-group">
|
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
|
|
<input type="text" name="patient" class="form-control bg-light border-start-0" placeholder="<?php echo __('patient'); ?>" value="<?php echo htmlspecialchars($search_patient); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="input-group">
|
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-person-badge"></i></span>
|
|
<input type="text" name="doctor" class="form-control bg-light border-start-0" placeholder="<?php echo __('doctor'); ?>" value="<?php echo htmlspecialchars($search_doctor); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="input-group">
|
|
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-calendar-event"></i></span>
|
|
<input type="date" name="date" class="form-control bg-light border-start-0" value="<?php echo htmlspecialchars($search_date); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<button type="submit" class="btn btn-secondary w-100"><?php echo __('search'); ?></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card shadow-sm border-0">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0">
|
|
<thead class="table-light text-secondary">
|
|
<tr>
|
|
<th class="px-4 py-3"><?php echo __('date'); ?></th>
|
|
<th class="py-3"><?php echo __('patient'); ?></th>
|
|
<th class="py-3"><?php echo __('doctor'); ?></th>
|
|
<th class="py-3"><?php echo __('diagnosis'); ?></th>
|
|
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($visits)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center py-5 text-muted">
|
|
<i class="bi bi-clipboard2-pulse display-4 d-block mb-3"></i>
|
|
No visits found.
|
|
</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($visits as $v): ?>
|
|
<tr>
|
|
<td class="px-4 text-secondary"><?php echo date('Y-m-d H:i', strtotime($v['visit_date'])); ?></td>
|
|
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($v['patient_name']); ?></td>
|
|
<td class="text-secondary"><?php echo htmlspecialchars($v['doctor_name']); ?></td>
|
|
<td><small class="text-truncate d-inline-block text-muted" style="max-width: 200px;"><?php echo htmlspecialchars($v['diagnosis']); ?></small></td>
|
|
<td class="text-end px-4">
|
|
<div class="btn-group shadow-sm border rounded bg-white">
|
|
<button class="btn btn-link text-warning py-1 px-2 border-end"
|
|
onclick="showEditVisitModal(<?php echo htmlspecialchars(json_encode($v, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | 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-primary py-1 px-2 border-end"
|
|
onclick="showReportModal(<?php echo $v['id']; ?>)"
|
|
data-bs-toggle="tooltip" title="<?php echo __('new_report'); ?>">
|
|
<i class="bi bi-file-earmark-plus"></i>
|
|
</button>
|
|
<button class="btn btn-link text-success py-1 px-2"
|
|
onclick="showBillModal(<?php echo $v['id']; ?>, <?php echo $v['patient_id']; ?>, <?php echo htmlspecialchars(json_encode($v['patient_name'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
|
|
data-bs-toggle="tooltip" title="<?php echo __('create_bill'); ?>">
|
|
<i class="bi bi-receipt"></i>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|