= esc($message) ?>
Invoice is finalized. Edit actions are locked.
Name : = esc($invoice->inv_name ?? '-') ?> /
P Code : = esc($invoice->patient_code ?? '-') ?> /
ipd_id ?? 0) > 0): ?>
IPD ID : = esc((string) ((int)($invoice->ipd_id ?? 0))) ?> /
Invoice No. : = esc($invoice->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?> /
Date : = esc(!empty($invoice->inv_date) ? date('d/m/Y', strtotime((string)$invoice->inv_date)) : '-') ?>
doc_id ?? 0);
$currentDocName = trim((string) ($invoice->doc_name ?? ''));
$docFound = false;
if (!empty($docList) && $currentDocId > 0) {
foreach ($docList as $d) {
if ((int) ($d->id ?? 0) === $currentDocId) {
$docFound = true;
break;
}
}
}
// Auto-match doctor by name if doc_id is 0 or unassigned
if (!$docFound && !empty($docList) && $currentDocName !== '') {
$cleanCurrentDoc = trim(preg_replace('/^(dr\.?|doctor)\s+/i', '', $currentDocName));
foreach ($docList as $d) {
$dName = trim((string) ($d->p_fname ?? ''));
$cleanDName = trim(preg_replace('/^(dr\.?|doctor)\s+/i', '', $dName));
if (strcasecmp($dName, $currentDocName) === 0 || strcasecmp($cleanDName, $cleanCurrentDoc) === 0) {
$currentDocId = (int) ($d->id ?? 0);
$currentDocName = $dName;
$docFound = true;
break;
}
}
}
// If not found in hospital doctors list but doctor name exists, treat as outside doctor
$isOtherDoc = (!$docFound && ($currentDocId === 0 || $currentDocId === 999999) && $currentDocName !== '');
?>
Saved
Doctor : = esc($invoice->doc_name ?: 'Not Specified') ?>
| # |
Item Name |
Batch No |
Exp. |
Rate |
S.Qty. |
Qty |
Disc. |
Amount |
Action |
item_code ?? '');
if ($codeKey !== '') {
$itemCodeCounts[$codeKey] = ($itemCodeCounts[$codeKey] ?? 0) + 1;
}
}
}
?>
$item): ?>
sale_return ?? 0) === 1)
|| ((float) ($item->amount ?? 0) < 0)
|| ((float) ($item->tamount ?? 0) < 0)
|| ((float) ($item->twdisc_amount ?? 0) < 0);
if ($isReturnRow) {
$rowStyle = 'background:orange;';
}
$expiryDays = 1000;
if (!empty($item->expiry)) {
$expiryTs = strtotime((string) $item->expiry);
if ($expiryTs !== false) {
$expiryDays = (int) floor(($expiryTs - strtotime(date('Y-m-d'))) / 86400);
}
}
if ($expiryDays < 90) {
$rowStyle = 'color:red;';
}
$sQty = (float) ($item->s_qty ?? 0);
if ($sQty < 6) {
$rowStyle = 'color:red;';
}
$itemCode = (string) ($item->item_code ?? '');
if ($itemCode !== '' && (int) ($itemCodeCounts[$itemCode] ?? 0) > 1) {
$itemNameStyle = 'color:green;';
}
?>
>
| = $i + 1 ?> |
>= esc($item->item_Name ?? '-') ?> |
= esc($item->batch_no ?? '-') ?> |
= esc(!empty($item->expiry) ? date('Y-m-d', strtotime((string)$item->expiry)) : '-') ?> |
= esc(number_format((float)($item->price ?? 0), 2)) ?> |
= esc(number_format((float)($item->qty ?? 0), 0, '.', '')) ?> |
sale_return ?? 0) === 0): ?>
= esc(number_format((float)($item->qty ?? 0), 2)) ?>
|
= esc(number_format((float)($item->disc_amount ?? 0), 2)) ?> |
= esc(number_format((float)($item->tamount ?? 0), 2)) ?> |
Locked
|
| No items in invoice. |
| Gross Total |
= esc(number_format((float)($totals->gross ?? 0), 2)) ?> |
|
| Net Total |
= esc(number_format((float)($totals->net ?? 0), 2)) ?> |
|
Product Search
| Item |
Batch |
Exp. |
S.Qty |
Rate |
Add |
| = esc($row->item_name ?? '-') ?> |
= esc($row->batch_no ?? '-') ?> |
= esc($row->expiry_date ?? '-') ?> |
= esc($row->current_qty ?? 0) ?> |
= esc(number_format((float)($row->selling_unit_rate ?? 0), 2)) ?> |
|
No stock items found for search.