Fix OPD appointment datetime display and date filtering

This commit is contained in:
DevSoftTech Server 2026-04-28 10:59:04 +05:30
parent de3b940448
commit 5226fde8a0
2 changed files with 21 additions and 9 deletions

View File

@ -833,7 +833,7 @@ class Opd extends BaseController
sum(case when o.opd_status = 3 then 1 else 0 end) as count_cancel
from opd_master o
left join opd_prescription pr on pr.opd_id = o.opd_id
where o.apointment_date = " . $opdDateSql . "
where date(o.apointment_date) = " . $opdDateSql . "
group by o.doc_id
) oa
join doctor_master d on d.id = oa.doc_id and d.active = 1
@ -925,7 +925,7 @@ class Opd extends BaseController
from opd_master o
join patient_master p on o.p_id=p.id
left join opd_prescription pr on o.opd_id=pr.opd_id
where o.apointment_date=" . $opdDateSql . " and o.doc_id=" . $docId;
where date(o.apointment_date)=" . $opdDateSql . " and o.doc_id=" . $docId;
$query = $this->db->query($sql);
$allRows = $query->getResult();
@ -1107,7 +1107,7 @@ class Opd extends BaseController
) as digest_crc
from opd_master o
left join opd_prescription pr on o.opd_id = pr.opd_id
where o.apointment_date = " . $opdDateSql . " and o.doc_id = " . $docId;
where date(o.apointment_date) = " . $opdDateSql . " and o.doc_id = " . $docId;
$row = $this->db->query($sql)->getRow();
@ -1176,7 +1176,7 @@ class Opd extends BaseController
coalesce(pr.queue_no,0) as queue_no
from opd_master o
left join opd_prescription pr on o.opd_id = pr.opd_id
where o.apointment_date = " . $opdDateSql . " and o.doc_id = " . $docId;
where date(o.apointment_date) = " . $opdDateSql . " and o.doc_id = " . $docId;
$rows = $this->db->query($sql)->getResult();

View File

@ -11,6 +11,18 @@ if ($user) {
}
}
$paymentHistoryRows = $payment_history_rows ?? [];
$appointmentDateRaw = trim((string) ($opd_master[0]->apointment_date ?? ''));
$appointmentDateDisplay = '';
$appointmentDateTimeDisplay = '';
$appointmentDatePickerValue = '';
if ($appointmentDateRaw !== '') {
$appointmentTimestamp = strtotime($appointmentDateRaw);
if ($appointmentTimestamp !== false) {
$appointmentDateDisplay = date('d/m/y', $appointmentTimestamp);
$appointmentDateTimeDisplay = date('d/m/y H:i:s', $appointmentTimestamp);
$appointmentDatePickerValue = date('d/m/Y', $appointmentTimestamp);
}
}
?>
<section class="content-header">
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2">
@ -32,7 +44,7 @@ $paymentHistoryRows = $payment_history_rows ?? [];
<address>
<strong><?= esc(strtoupper($opd_master[0]->P_name ?? '')) ?></strong><br>
<?= esc($patient_master[0]->p_relative ?? '') ?> : <?= esc($patient_master[0]->p_rname ?? '') ?><br>
OPD Book Date (y-m-d time) : <?= esc($opd_master[0]->opd_book_date ?? '') ?><br>
OPD Book Time : <?= esc($appointmentDateTimeDisplay !== '' ? $appointmentDateTimeDisplay : $appointmentDateRaw) ?><br>
Gender : <?= esc($patient_master[0]->xgender ?? '') ?><br>
Age : <?= esc($patient_master[0]->age ?? '') ?><br>
Phone No : <?= esc($patient_master[0]->mphone1 ?? '') ?>
@ -40,7 +52,7 @@ $paymentHistoryRows = $payment_history_rows ?? [];
</div>
<div class="col-sm-4 invoice-col">
<b>OPD ID:</b> <?= esc($opd_master[0]->opd_code ?? '') ?><br>
<b>Date of Appointment:</b> <?= esc($opd_master[0]->str_apointment_date ?? '') ?><br>
<b>Date of Appointment:</b> <?= esc($appointmentDateTimeDisplay !== '' ? $appointmentDateTimeDisplay : ($appointmentDateDisplay !== '' ? $appointmentDateDisplay : ($opd_master[0]->str_apointment_date ?? ''))) ?><br>
<b>Patient ID :</b> <?= esc($patient_master[0]->p_code ?? '') ?><br>
<?php if (($opd_master[0]->insurance_id ?? 0) > 1 && !empty($insurance)) : ?>
<strong> Ins. Comp. :</strong> <?= esc($insurance[0]->ins_company_name ?? '') ?><br>
@ -66,7 +78,7 @@ $paymentHistoryRows = $payment_history_rows ?? [];
</thead>
<tbody>
<tr>
<td><?= esc(MysqlDate_to_str($opd_master[0]->apointment_date ?? '')) ?></td>
<td><?= esc($appointmentDateTimeDisplay !== '' ? $appointmentDateTimeDisplay : ($appointmentDateDisplay !== '' ? $appointmentDateDisplay : MysqlDate_to_str($opd_master[0]->apointment_date ?? ''))) ?></td>
<td>Dr. <?= esc($opd_master[0]->doc_name ?? '') ?></td>
<td><?= esc($opd_master[0]->doc_spec ?? '') ?></td>
<td><?= esc($opd_master[0]->opd_fee_gross_amount ?? '') ?></td>
@ -341,8 +353,8 @@ $paymentHistoryRows = $payment_history_rows ?? [];
</select>
</div>
<div class="col-md-3">
<label>Date <?= esc(MysqlDate_to_str($opd_master[0]->apointment_date ?? '')) ?></label>
<input class="form-control datepicker" id="datepicker_opddate" name="datepicker_opddate" type="text" value="<?= esc(MysqlDate_to_str($opd_master[0]->apointment_date ?? '')) ?>" />
<label>Date <?= esc($appointmentDatePickerValue !== '' ? $appointmentDatePickerValue : MysqlDate_to_str($opd_master[0]->apointment_date ?? '')) ?></label>
<input class="form-control datepicker" id="datepicker_opddate" name="datepicker_opddate" type="text" value="<?= esc($appointmentDatePickerValue !== '' ? $appointmentDatePickerValue : MysqlDate_to_str($opd_master[0]->apointment_date ?? '')) ?>" />
</div>
<div class="col-md-3">
<label>OPD Fee <?= esc($opd_master[0]->opd_fee_gross_amount ?? '') ?> / <?= esc($opd_master[0]->opd_fee_amount ?? '') ?></label>