139 lines
7.1 KiB
PHP
139 lines
7.1 KiB
PHP
<?php
|
|
$search_patient = $_GET['patient'] ?? '';
|
|
$search_source = $_GET['source'] ?? '';
|
|
|
|
$query = "
|
|
SELECT i.*, t.name_$lang as test_name
|
|
FROM laboratory_inquiries i
|
|
LEFT JOIN laboratory_tests t ON i.test_id = t.id
|
|
WHERE 1=1";
|
|
$params = [];
|
|
|
|
if ($search_patient) {
|
|
$query .= " AND i.patient_name LIKE ?";
|
|
$params[] = "%$search_patient%";
|
|
}
|
|
if ($search_source) {
|
|
$query .= " AND i.source = ?";
|
|
$params[] = $search_source;
|
|
}
|
|
|
|
$query .= " ORDER BY i.inquiry_date DESC";
|
|
$stmt = $db->prepare($query);
|
|
$stmt->execute($params);
|
|
$inquiries = $stmt->fetchAll();
|
|
|
|
// Get all tests for the add/edit modal
|
|
$stmt = $db->query("SELECT id, name_$lang as name FROM laboratory_tests ORDER BY name_$lang ASC");
|
|
$all_tests = $stmt->fetchAll();
|
|
?>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h3 class="fw-bold text-secondary"><?php echo __('inquiries'); ?></h3>
|
|
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addInquiryModal">
|
|
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_inquiry'); ?>
|
|
</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-6">
|
|
<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-4">
|
|
<select name="source" class="form-select bg-light">
|
|
<option value=""><?php echo __('source'); ?> (<?php echo __('all'); ?>)</option>
|
|
<option value="Internal" <?php echo $search_source == 'Internal' ? 'selected' : ''; ?>><?php echo __('internal'); ?></option>
|
|
<option value="External" <?php echo $search_source == 'External' ? 'selected' : ''; ?>><?php echo __('external'); ?></option>
|
|
</select>
|
|
</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">#</th>
|
|
<th class="py-3"><?php echo __('patient'); ?></th>
|
|
<th class="py-3"><?php echo __('test'); ?></th>
|
|
<th class="py-3"><?php echo __('inquiry_date'); ?></th>
|
|
<th class="py-3"><?php echo __('source'); ?></th>
|
|
<th class="py-3"><?php echo __('status'); ?></th>
|
|
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($inquiries)): ?>
|
|
<tr>
|
|
<td colspan="7" class="text-center py-5 text-muted">
|
|
<i class="bi bi-question-circle display-4 d-block mb-3"></i>
|
|
<?php echo __('no_inquiries_found'); ?>
|
|
</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($inquiries as $inquiry): ?>
|
|
<tr>
|
|
<td class="px-4 fw-medium text-secondary"><?php echo $inquiry['id']; ?></td>
|
|
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($inquiry['patient_name']); ?></td>
|
|
<td>
|
|
<span class="badge bg-info bg-opacity-10 text-info border border-info border-opacity-25 px-2 py-1">
|
|
<?php echo htmlspecialchars($inquiry['test_name'] ?? '-'); ?>
|
|
</span>
|
|
</td>
|
|
<td class="text-secondary"><?php echo date('Y-m-d H:i', strtotime($inquiry['inquiry_date'])); ?></td>
|
|
<td>
|
|
<?php if ($inquiry['source'] == 'External'): ?>
|
|
<span class="badge bg-warning bg-opacity-10 text-warning border border-warning border-opacity-25 px-2 py-1">
|
|
<i class="bi bi-hospital me-1"></i> <?php echo __('external'); ?>
|
|
</span>
|
|
<?php else: ?>
|
|
<span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25 px-2 py-1">
|
|
<i class="bi bi-building me-1"></i> <?php echo __('internal'); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<?php
|
|
$status_class = 'bg-secondary';
|
|
if ($inquiry['status'] == 'Pending') $status_class = 'bg-warning';
|
|
if ($inquiry['status'] == 'Completed') $status_class = 'bg-success';
|
|
if ($inquiry['status'] == 'Cancelled') $status_class = 'bg-danger';
|
|
?>
|
|
<span class="badge <?php echo $status_class; ?> bg-opacity-10 <?php echo str_replace('bg-', 'text-', $status_class); ?> border <?php echo str_replace('bg-', 'border-', $status_class); ?> border-opacity-25 px-2 py-1">
|
|
<?php echo __($inquiry['status']); ?>
|
|
</span>
|
|
</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="showEditInquiryModal(<?php echo htmlspecialchars(json_encode($inquiry)); ?>)"
|
|
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="showDeleteInquiryModal(<?php echo $inquiry['id']; ?>)"
|
|
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
|
|
<i class="bi bi-trash3"></i>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|