38960-vm/includes/pages/visits.php
2026-03-04 04:42:54 +00:00

55 lines
2.8 KiB
PHP

<?php
$visits_sql = "
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
ORDER BY v.visit_date DESC";
$visits = $db->query($visits_sql)->fetchAll();
?>
<div class="card shadow-sm">
<div class="card-header py-3 d-flex justify-content-between align-items-center">
<h5 class="mb-0 fw-bold"><i class="bi bi-clipboard2-pulse me-2 text-primary"></i> <?php echo __('visits'); ?></h5>
<button class="btn btn-info btn-sm text-white" data-bs-toggle="modal" data-bs-target="#recordVisitModal">
<i class="bi bi-plus-lg"></i> <?php echo __('add_visit'); ?>
</button>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th><?php echo __('date'); ?></th>
<th><?php echo __('patient'); ?></th>
<th><?php echo __('doctor'); ?></th>
<th><?php echo __('diagnosis'); ?></th>
<th><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($visits as $v): ?>
<tr>
<td><?php echo date('Y-m-d H:i', strtotime($v['visit_date'])); ?></td>
<td><?php echo htmlspecialchars($v['patient_name']); ?></td>
<td><?php echo htmlspecialchars($v['doctor_name']); ?></td>
<td><small class="text-truncate d-inline-block" style="max-width: 200px;"><?php echo htmlspecialchars($v['diagnosis']); ?></small></td>
<td>
<div class="btn-group">
<button class="btn btn-outline-primary btn-sm" onclick='showReportModal(<?php echo $v["id"]; ?>)'>
<i class="bi bi-file-earmark-plus"></i> <?php echo __('new_report'); ?>
</button>
<button class="btn btn-outline-success btn-sm" onclick='showBillModal(<?php echo $v["id"]; ?>, <?php echo $v["patient_id"]; ?>, "<?php echo addslashes($v["patient_name"]); ?>")'>
<i class="bi bi-receipt"></i> <?php echo __('create_bill'); ?>
</button>
</div>
</td>
</tr>
<?php endforeach; if (empty($visits)): ?>
<tr><td colspan="5" class="text-center py-4 text-muted">No visits recorded yet.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>