more updates
This commit is contained in:
parent
4f1232c067
commit
5420bde76a
BIN
assets/uploads/xrays/1773570971_ss.pdf
Normal file
BIN
assets/uploads/xrays/1773570971_ss.pdf
Normal file
Binary file not shown.
BIN
assets/uploads/xrays/1773582607_69b6b90f692da_scale.jfif
Normal file
BIN
assets/uploads/xrays/1773582607_69b6b90f692da_scale.jfif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/uploads/xrays/1773582628_69b6b9245162b_ورد1.jfif
Normal file
BIN
assets/uploads/xrays/1773582628_69b6b9245162b_ورد1.jfif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1 @@
|
||||
ALTER TABLE xray_inquiry_items MODIFY COLUMN attachment LONGTEXT;
|
||||
@ -7,6 +7,15 @@ $lang = $_SESSION['lang'] ?? 'en';
|
||||
|
||||
require_once __DIR__ . '/includes/actions.php';
|
||||
require_once __DIR__ . '/includes/common_data.php';
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
|
||||
$is_ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/pages/drugs_groups.php';
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
}
|
||||
@ -70,6 +70,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function upload_multiple_files_key($key_name, $target_dir = "assets/uploads/") {
|
||||
$uploaded = [];
|
||||
if (!isset($_FILES[$key_name])) return [];
|
||||
|
||||
$files = $_FILES[$key_name];
|
||||
// Normalize array structure
|
||||
if (is_array($files['name'])) {
|
||||
$count = count($files['name']);
|
||||
if (!is_dir(__DIR__ . "/../" . $target_dir)) {
|
||||
mkdir(__DIR__ . "/../" . $target_dir, 0775, true);
|
||||
}
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($files['error'][$i] === UPLOAD_ERR_OK) {
|
||||
$filename = time() . "_" . uniqid() . "_" . basename($files['name'][$i]);
|
||||
$target_file = $target_dir . $filename;
|
||||
if (move_uploaded_file($files['tmp_name'][$i], __DIR__ . "/../" . $target_file)) {
|
||||
$uploaded[] = ['name' => $files['name'][$i], 'path' => $target_file];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $uploaded;
|
||||
}
|
||||
|
||||
$lang = $_SESSION['lang'] ?? 'en';
|
||||
$redirect = false;
|
||||
|
||||
@ -650,6 +675,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} elseif ($_POST['action'] === 'add_xray_inquiry') {
|
||||
$patient_name = $_POST['patient_name'] ?? '';
|
||||
$xray_ids = $_POST['xray_ids'] ?? [];
|
||||
$row_indices = $_POST['row_indices'] ?? []; // Maps array index to UI row index
|
||||
$results = $_POST['results'] ?? [];
|
||||
$source = $_POST['source'] ?? 'Internal';
|
||||
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
|
||||
@ -664,8 +690,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$testStmt = $db->prepare("INSERT INTO xray_inquiry_items (inquiry_id, xray_id, result, attachment) VALUES (?, ?, ?, ?)");
|
||||
foreach ($xray_ids as $index => $tid) {
|
||||
if ($tid) {
|
||||
$attachment = upload_file($_FILES['attachments'] ?? null, $index, "assets/uploads/xrays/");
|
||||
$testStmt->execute([$inquiry_id, $tid, $results[$index] ?? '', $attachment]);
|
||||
$rowIndex = $row_indices[$index] ?? $index;
|
||||
$files = upload_multiple_files_key("new_attachments_" . $rowIndex, "assets/uploads/xrays/");
|
||||
$attachmentJson = !empty($files) ? json_encode($files) : '';
|
||||
$testStmt->execute([$inquiry_id, $tid, $results[$index] ?? '', $attachmentJson]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -677,7 +705,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$id = $_POST['id'] ?? '';
|
||||
$patient_name = $_POST['patient_name'] ?? '';
|
||||
$xray_ids = $_POST['xray_ids'] ?? [];
|
||||
$existing_attachments = $_POST['existing_attachments'] ?? [];
|
||||
$row_indices = $_POST['row_indices'] ?? [];
|
||||
$results = $_POST['results'] ?? [];
|
||||
$source = $_POST['source'] ?? 'Internal';
|
||||
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
|
||||
@ -693,8 +721,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$testStmt = $db->prepare("INSERT INTO xray_inquiry_items (inquiry_id, xray_id, result, attachment) VALUES (?, ?, ?, ?)");
|
||||
foreach ($xray_ids as $index => $tid) {
|
||||
if ($tid) {
|
||||
$attachment = upload_file($_FILES['attachments'] ?? null, $index, "assets/uploads/xrays/") ?: ($existing_attachments[$index] ?? null);
|
||||
$testStmt->execute([$id, $tid, $results[$index] ?? '', $attachment]);
|
||||
$rowIndex = $row_indices[$index] ?? $index;
|
||||
|
||||
// Get new files
|
||||
$newFiles = upload_multiple_files_key("new_attachments_" . $rowIndex, "assets/uploads/xrays/");
|
||||
|
||||
// Get existing files
|
||||
$existingFiles = [];
|
||||
if (isset($_POST['existing_attachments_' . $rowIndex])) {
|
||||
foreach ($_POST['existing_attachments_' . $rowIndex] as $fileJson) {
|
||||
$file = json_decode($fileJson, true);
|
||||
if ($file) {
|
||||
$existingFiles[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$allFiles = array_merge($existingFiles, $newFiles);
|
||||
$attachmentJson = !empty($allFiles) ? json_encode($allFiles) : '';
|
||||
|
||||
$testStmt->execute([$id, $tid, $results[$index] ?? '', $attachmentJson]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,53 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Book Appointment Modal -->
|
||||
<div class="modal fade" id="bookAppointmentModal" 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="book_appointment">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title fw-bold text-white"><?php echo __("book_appointment"); ?></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 __("patient"); ?></label>
|
||||
<select name="patient_id" class="form-select select2-modal" required>
|
||||
<option value=""><?php echo __("select"); ?>...</option>
|
||||
<?php foreach ($all_patients as $p): ?>
|
||||
<option value="<?php echo $p["id"]; ?>"><?php echo htmlspecialchars($p["name"]); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?php echo __("doctor"); ?></label>
|
||||
<select name="doctor_id" class="form-select select2-modal" required>
|
||||
<option value=""><?php echo __("select"); ?>...</option>
|
||||
<?php foreach ($all_doctors as $d): ?>
|
||||
<option value="<?php echo $d["id"]; ?>"><?php echo htmlspecialchars($d["name"]); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?php echo __("date"); ?> & <?php echo __("time"); ?></label>
|
||||
<input type="datetime-local" name="date" class="form-control" required value="<?php echo date("Y-m-d\TH:i"); ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?php echo __("reason"); ?></label>
|
||||
<textarea name="reason" class="form-control" rows="3"></textarea>
|
||||
</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 __("book"); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Patient Modal -->
|
||||
<div class="modal fade" id="addPatientModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
@ -1509,6 +1556,7 @@ function addInquiryTestRow() {
|
||||
function addXrayInquiryTestRow() {
|
||||
const tbody = document.querySelector('#xrayInquiryTestsTable tbody');
|
||||
const tr = document.createElement('tr');
|
||||
const rowIndex = tbody.children.length;
|
||||
|
||||
let options = '<option value="">Select X-Ray...</option>';
|
||||
<?php foreach ($all_xrays as $x): ?>
|
||||
@ -1518,7 +1566,10 @@ function addXrayInquiryTestRow() {
|
||||
tr.innerHTML = `
|
||||
<td><select name="xray_ids[]" class="form-select select2-modal">${options}</select></td>
|
||||
<td><input type="text" name="results[]" class="form-control"></td>
|
||||
<td><input type="file" name="attachments[]" class="form-control"></td>
|
||||
<td>
|
||||
<input type="file" name="new_attachments_${rowIndex}[]" class="form-control" multiple>
|
||||
<input type="hidden" name="row_indices[]" value="${rowIndex}">
|
||||
</td>
|
||||
<td><button type="button" class="btn btn-sm btn-danger" onclick="this.closest('tr').remove()"><i class="bi bi-x-lg"></i></button></td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
$search_patient = $_GET['patient'] ?? '';
|
||||
$search_status = $_GET['status'] ?? '';
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
$limit = 10;
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$query = "
|
||||
SELECT xi.*, p.name as official_patient_name, v.visit_date
|
||||
@ -20,7 +23,14 @@ if ($search_status) {
|
||||
$params[] = $search_status;
|
||||
}
|
||||
|
||||
$query .= " ORDER BY xi.inquiry_date DESC";
|
||||
// Count total records for pagination
|
||||
$count_query = str_replace("xi.*, p.name as official_patient_name, v.visit_date", "COUNT(*)", $query);
|
||||
$stmt = $db->prepare($count_query);
|
||||
$stmt->execute($params);
|
||||
$total_records = $stmt->fetchColumn();
|
||||
$total_pages = ceil($total_records / $limit);
|
||||
|
||||
$query .= " ORDER BY xi.inquiry_date DESC LIMIT $limit OFFSET $offset";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->execute($params);
|
||||
$inquiries = $stmt->fetchAll();
|
||||
@ -37,7 +47,7 @@ foreach ($inquiries as &$inquiry) {
|
||||
}
|
||||
unset($inquiry);
|
||||
|
||||
$all_xrays_list = $db->query("SELECT id, name_$lang as name FROM xray_tests ORDER BY name_$lang ASC")->fetchAll();
|
||||
$all_xrays_list = $db->query("SELECT id, name_$lang as name, price FROM xray_tests ORDER BY name_$lang ASC")->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
@ -129,13 +139,27 @@ $all_xrays_list = $db->query("SELECT id, name_$lang as name FROM xray_tests ORDE
|
||||
</td>
|
||||
<td>
|
||||
<?php foreach ($inquiry['items'] as $item): ?>
|
||||
<div class="small mb-1 d-flex align-items-center">
|
||||
<span class="text-muted me-1"><?php echo htmlspecialchars($item['xray_name']); ?>:</span>
|
||||
<span class="fw-bold me-2"><?php echo htmlspecialchars($item['result'] ?: '-'); ?></span>
|
||||
<?php if ($item['attachment']): ?>
|
||||
<a href="<?php echo $item['attachment']; ?>" target="_blank" class="btn btn-sm btn-outline-info py-0 px-1" title="<?php echo __('view_image'); ?>">
|
||||
<i class="bi bi-image"></i>
|
||||
</a>
|
||||
<div class="small mb-1">
|
||||
<div class="d-flex align-items-center mb-1">
|
||||
<span class="text-muted me-1"><?php echo htmlspecialchars($item['xray_name']); ?>:</span>
|
||||
<span class="fw-bold me-2"><?php echo htmlspecialchars($item['result'] ?: '-'); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
$atts = json_decode($item['attachment'] ?? '', true);
|
||||
if (!is_array($atts) && !empty($item['attachment'])) {
|
||||
$atts = [['name' => basename($item['attachment']), 'path' => $item['attachment']]];
|
||||
} elseif (!is_array($atts)) {
|
||||
$atts = [];
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($atts)): ?>
|
||||
<div class="d-flex flex-wrap gap-1">
|
||||
<?php foreach ($atts as $att): ?>
|
||||
<a href="<?php echo htmlspecialchars($att['path']); ?>" target="_blank" class="btn btn-sm btn-outline-info py-0 px-1" title="<?php echo htmlspecialchars($att['name']); ?>">
|
||||
<i class="bi bi-image"></i> <small><?php echo htmlspecialchars($att['name']); ?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@ -165,5 +189,201 @@ $all_xrays_list = $db->query("SELECT id, name_$lang as name FROM xray_tests ORDE
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<?php if ($total_pages > 1): ?>
|
||||
<nav aria-label="Page navigation" class="p-3 border-top bg-light">
|
||||
<ul class="pagination justify-content-center mb-0">
|
||||
<li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
|
||||
<a class="page-link" href="?section=xray_inquiries&page=<?php echo $page - 1; ?>&patient=<?php echo urlencode($search_patient); ?>&status=<?php echo urlencode($search_status); ?>" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
<?php for ($i = 1; $i <= $total_pages; $i++): ?>
|
||||
<li class="page-item <?php echo $page == $i ? 'active' : ''; ?>">
|
||||
<a class="page-link" href="?section=xray_inquiries&page=<?php echo $i; ?>&patient=<?php echo urlencode($search_patient); ?>&status=<?php echo urlencode($search_status); ?>"><?php echo $i; ?></a>
|
||||
</li>
|
||||
<?php endfor; ?>
|
||||
<li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
|
||||
<a class="page-link" href="?section=xray_inquiries&page=<?php echo $page + 1; ?>&patient=<?php echo urlencode($search_patient); ?>&status=<?php echo urlencode($search_status); ?>">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit X-Ray Inquiry Modal -->
|
||||
<div class="modal fade" id="editXrayInquiryModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=xray_inquiries" method="POST" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="edit_xray_inquiry">
|
||||
<input type="hidden" name="id" id="edit_xray_inquiry_id">
|
||||
<input type="hidden" name="visit_id" id="edit_xray_inquiry_visit_id">
|
||||
<input type="hidden" name="patient_id" id="edit_xray_inquiry_patient_id">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title fw-bold text-white"><?php echo __('edit_xray_inquiry'); ?></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 __('patient_name'); ?></label>
|
||||
<input type="text" name="patient_name" id="edit_xray_inquiry_patient_name" class="form-control" required>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label"><?php echo __('inquiry_date'); ?></label>
|
||||
<input type="datetime-local" name="inquiry_date" id="edit_xray_inquiry_date" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label"><?php echo __('status'); ?></label>
|
||||
<select name="status" id="edit_xray_inquiry_status" class="form-select">
|
||||
<option value="Pending"><?php echo __('Pending'); ?></option>
|
||||
<option value="Completed"><?php echo __('Completed'); ?></option>
|
||||
<option value="Cancelled"><?php echo __('Cancelled'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="form-label fw-bold"><?php echo __('xray_tests'); ?></label>
|
||||
<div class="table-responsive mb-2">
|
||||
<table class="table table-bordered table-sm" id="editXrayInquiryTestsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo __('test'); ?></th>
|
||||
<th><?php echo __('result'); ?></th>
|
||||
<th><?php echo __('attachment'); ?></th>
|
||||
<th style="width: 50px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" onclick="addEditXrayInquiryTestRow()">
|
||||
<i class="bi bi-plus-lg"></i> <?php echo __('add_test'); ?>
|
||||
</button>
|
||||
|
||||
<div class="mt-3">
|
||||
<label class="form-label"><?php echo __('notes'); ?></label>
|
||||
<textarea name="notes" id="edit_xray_inquiry_notes" class="form-control summernote" rows="2"></textarea>
|
||||
</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 X-Ray Inquiry Modal -->
|
||||
<div class="modal fade" id="deleteXrayInquiryModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=xray_inquiries" method="POST">
|
||||
<input type="hidden" name="action" value="delete_xray_inquiry">
|
||||
<input type="hidden" name="id" id="delete_xray_inquiry_id">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title fw-bold text-white"><?php echo __('delete_xray_inquiry'); ?></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>
|
||||
|
||||
<script>
|
||||
function showEditXrayInquiryModal(data) {
|
||||
document.getElementById('edit_xray_inquiry_id').value = data.id;
|
||||
document.getElementById('edit_xray_inquiry_visit_id').value = data.visit_id || '';
|
||||
document.getElementById('edit_xray_inquiry_patient_id').value = data.patient_id || '';
|
||||
document.getElementById('edit_xray_inquiry_patient_name').value = data.patient_name || (data.official_patient_name || '');
|
||||
document.getElementById('edit_xray_inquiry_date').value = data.inquiry_date ? data.inquiry_date.replace(' ', 'T') : '';
|
||||
document.getElementById('edit_xray_inquiry_status').value = data.status;
|
||||
|
||||
// Summernote
|
||||
$('#edit_xray_inquiry_notes').summernote('code', data.notes || '');
|
||||
|
||||
// Populate tests
|
||||
const tbody = document.querySelector('#editXrayInquiryTestsTable tbody');
|
||||
tbody.innerHTML = '';
|
||||
|
||||
if (data.items && data.items.length > 0) {
|
||||
data.items.forEach(item => {
|
||||
addEditXrayInquiryTestRow(item.xray_id, item.result, item.attachment);
|
||||
});
|
||||
} else {
|
||||
addEditXrayInquiryTestRow();
|
||||
}
|
||||
|
||||
var modal = new bootstrap.Modal(document.getElementById('editXrayInquiryModal'));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function addEditXrayInquiryTestRow(xrayId = '', result = '', attachment = '') {
|
||||
const tbody = document.querySelector('#editXrayInquiryTestsTable tbody');
|
||||
const tr = document.createElement('tr');
|
||||
const rowIndex = tbody.children.length; // Unique index for this row
|
||||
|
||||
let options = '<option value="">Select X-Ray...</option>';
|
||||
<?php foreach ($all_xrays_list as $x): ?>
|
||||
options += `<option value="<?php echo $x['id']; ?>" ${xrayId == <?php echo $x['id']; ?> ? 'selected' : ''}><?php echo htmlspecialchars($x['name']); ?> ($<?php echo $x['price']; ?>)</option>`;
|
||||
<?php endforeach; ?>
|
||||
|
||||
// Parse attachments
|
||||
let files = [];
|
||||
try {
|
||||
files = JSON.parse(attachment || '[]');
|
||||
if (!Array.isArray(files)) throw new Error();
|
||||
} catch (e) {
|
||||
if (attachment) files = [{name: 'Attachment', path: attachment}];
|
||||
}
|
||||
|
||||
let attachmentHtml = `
|
||||
<input type="file" name="new_attachments_${rowIndex}[]" class="form-control" multiple>
|
||||
<input type="hidden" name="row_indices[]" value="${rowIndex}">
|
||||
<div class="existing-files mt-1 d-flex flex-wrap gap-1">
|
||||
`;
|
||||
|
||||
files.forEach((file) => {
|
||||
// Escape quotes for value attribute
|
||||
const fileJson = JSON.stringify(file).replace(/"/g, '"');
|
||||
attachmentHtml += `
|
||||
<div class="badge bg-light text-dark border p-1 d-inline-flex align-items-center">
|
||||
<a href="${file.path}" target="_blank" class="text-decoration-none me-2 text-truncate" style="max-width: 100px;">${file.name}</a>
|
||||
<button type="button" class="btn-close btn-close-white small" style="width: 0.5em; height: 0.5em;" onclick="this.parentElement.remove()"></button>
|
||||
<input type="hidden" name="existing_attachments_${rowIndex}[]" value="${fileJson}">
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
attachmentHtml += '</div>';
|
||||
|
||||
tr.innerHTML = `
|
||||
<td><select name="xray_ids[]" class="form-select select2-modal">${options}</select></td>
|
||||
<td><input type="text" name="results[]" class="form-control" value="${result || ''}"></td>
|
||||
<td>${attachmentHtml}</td>
|
||||
<td><button type="button" class="btn btn-sm btn-danger" onclick="this.closest('tr').remove()"><i class="bi bi-x-lg"></i></button></td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
$(tr).find('.select2-modal').select2({ dropdownParent: $(tr).closest('.modal'), width: '100%' });
|
||||
}
|
||||
|
||||
function showDeleteXrayInquiryModal(id) {
|
||||
document.getElementById('delete_xray_inquiry_id').value = id;
|
||||
var modal = new bootstrap.Modal(document.getElementById('deleteXrayInquiryModal'));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function printXrayInquiry(data) {
|
||||
const id = data.id;
|
||||
// Open in new window
|
||||
window.open('print_xray_inquiry.php?id=' + id, '_blank');
|
||||
}
|
||||
</script>
|
||||
147
print_xray_inquiry.php
Normal file
147
print_xray_inquiry.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
require_once __DIR__ . '/helpers.php';
|
||||
|
||||
$db = db();
|
||||
$lang = $_SESSION['lang'] ?? 'en';
|
||||
$id = $_GET['id'] ?? 0;
|
||||
|
||||
if (!$id) {
|
||||
die("Invalid ID");
|
||||
}
|
||||
|
||||
// Fetch Inquiry
|
||||
$stmt = $db->prepare("
|
||||
SELECT xi.*, p.name as patient_name, p.gender, p.dob, p.phone, d.name_$lang as doctor_name
|
||||
FROM xray_inquiries xi
|
||||
LEFT JOIN patients p ON xi.patient_id = p.id
|
||||
LEFT JOIN visits v ON xi.visit_id = v.id
|
||||
LEFT JOIN doctors d ON v.doctor_id = d.id
|
||||
WHERE xi.id = ?
|
||||
");
|
||||
$stmt->execute([$id]);
|
||||
$inquiry = $stmt->fetch();
|
||||
|
||||
if (!$inquiry) {
|
||||
die("Inquiry not found");
|
||||
}
|
||||
|
||||
// Fetch Items
|
||||
$stmt = $db->prepare("
|
||||
SELECT it.*, t.name_$lang as xray_name
|
||||
FROM xray_inquiry_items it
|
||||
JOIN xray_tests t ON it.xray_id = t.id
|
||||
WHERE it.inquiry_id = ?
|
||||
");
|
||||
$stmt->execute([$id]);
|
||||
$items = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang; ?>" dir="<?php echo $lang == 'ar' ? 'rtl' : 'ltr'; ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>X-Ray Inquiry #<?php echo $id; ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #fff; color: #000; }
|
||||
.header { border-bottom: 2px solid #000; padding-bottom: 20px; margin-bottom: 30px; }
|
||||
.logo { max-height: 80px; }
|
||||
.patient-info { background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 30px; border: 1px solid #ddd; }
|
||||
.table th { background-color: #f1f1f1 !important; }
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
.patient-info { background-color: #f8f9fa !important; -webkit-print-color-adjust: exact; }
|
||||
.table th { background-color: #f1f1f1 !important; -webkit-print-color-adjust: exact; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="p-4">
|
||||
|
||||
<div class="container">
|
||||
<!-- Header -->
|
||||
<div class="header d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-0">X-Ray Report</h2>
|
||||
<div class="text-muted small">Inquiry #<?php echo $id; ?></div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<div class="fw-bold"><?php echo date('F j, Y, g:i a', strtotime($inquiry['inquiry_date'])); ?></div>
|
||||
<div class="badge bg-secondary text-white p-2 mt-1"><?php echo htmlspecialchars($inquiry['status']); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Patient Info -->
|
||||
<div class="patient-info">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-2">
|
||||
<span class="text-muted me-2">Patient:</span>
|
||||
<strong class="fs-5"><?php echo htmlspecialchars($inquiry['patient_name']); ?></strong>
|
||||
</div>
|
||||
<div class="col-md-6 mb-2">
|
||||
<span class="text-muted me-2">Gender/Age:</span>
|
||||
<strong>
|
||||
<?php echo $inquiry['gender'] ?? '-'; ?>
|
||||
<?php if(!empty($inquiry['dob'])) echo ' / ' . date_diff(date_create($inquiry['dob']), date_create('today'))->y . ' Years'; ?>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span class="text-muted me-2">Doctor:</span>
|
||||
<strong><?php echo htmlspecialchars($inquiry['doctor_name'] ?? 'Walk-in'); ?></strong>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span class="text-muted me-2">Source:</span>
|
||||
<strong><?php echo htmlspecialchars($inquiry['source']); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Results Table -->
|
||||
<h5 class="fw-bold border-bottom pb-2 mb-3">Examination Results</h5>
|
||||
<table class="table table-bordered mb-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40%;">X-Ray Examination</th>
|
||||
<th>Result / Findings</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<tr>
|
||||
<td class="fw-bold"><?php echo htmlspecialchars($item['xray_name']); ?></td>
|
||||
<td>
|
||||
<?php echo nl2br(htmlspecialchars($item['result'] ?: 'Pending Result')); ?>
|
||||
<?php if ($item['attachment']): ?>
|
||||
<div class="mt-2 no-print">
|
||||
<small class="text-muted"><i class="bi bi-paperclip"></i> Attachment available online</small>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Notes -->
|
||||
<?php if (!empty($inquiry['notes'])): ?>
|
||||
<div class="mb-4">
|
||||
<h5 class="fw-bold border-bottom pb-2 mb-2">Notes</h5>
|
||||
<div class="p-3 bg-light border rounded">
|
||||
<?php echo $inquiry['notes']; // Summernote content is HTML ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="mt-5 pt-4 border-top text-center text-muted small">
|
||||
<p>Generated by Clinic Management System on <?php echo date('Y-m-d H:i:s'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-4 no-print">
|
||||
<button onclick="window.print()" class="btn btn-primary px-4"><i class="bi bi-printer"></i> Print Report</button>
|
||||
<button onclick="window.close()" class="btn btn-secondary px-4">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -8,7 +8,16 @@ $lang = $_SESSION['lang'];
|
||||
|
||||
require_once __DIR__ . '/includes/actions.php';
|
||||
require_once __DIR__ . '/includes/common_data.php';
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
|
||||
$is_ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/pages/test_groups.php';
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
}
|
||||
?>
|
||||
@ -8,7 +8,16 @@ $lang = $_SESSION['lang'];
|
||||
|
||||
require_once __DIR__ . '/includes/actions.php';
|
||||
require_once __DIR__ . '/includes/common_data.php';
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
|
||||
$is_ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/pages/xray_groups.php';
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
}
|
||||
?>
|
||||
@ -8,7 +8,16 @@ $lang = $_SESSION['lang'];
|
||||
|
||||
require_once __DIR__ . '/includes/actions.php';
|
||||
require_once __DIR__ . '/includes/common_data.php';
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
|
||||
$is_ajax = isset($_GET['ajax_search']);
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/header.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/pages/xray_tests.php';
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
|
||||
if (!$is_ajax) {
|
||||
require_once __DIR__ . '/includes/layout/footer.php';
|
||||
}
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user