ipd_id ?? 0) > 0); ?>
Medical Invoice No. inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?>
ipd_id ?? 0) > 0): ?>
Invoice is finalized. Edit actions are locked.
Name : inv_name ?? '-') ?> / P Code : patient_code ?? '-') ?> / ipd_id ?? 0) > 0): ?> IPD ID : ipd_id ?? 0))) ?> / Invoice No. : inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?> / Date : 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 : doc_name ?: 'Not Specified') ?>
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;'; } ?> > >item_Name ?? '-') ?>
# Item Name Batch No Exp. Rate S.Qty. Qty Disc. Amount Action
batch_no ?? '-') ?> expiry) ? date('Y-m-d', strtotime((string)$item->expiry)) : '-') ?> price ?? 0), 2)) ?> qty ?? 0), 0, '.', '')) ?> sale_return ?? 0) === 0): ?>
qty ?? 0), 2)) ?>
disc_amount ?? 0), 2)) ?> tamount ?? 0), 2)) ?>
Locked
No items in invoice.
Gross Total gross ?? 0), 2)) ?>
Net Total net ?? 0), 2)) ?>
Product Search

Item Batch Exp. S.Qty Rate Add
item_name ?? '-') ?> batch_no ?? '-') ?> expiry_date ?? '-') ?> current_qty ?? 0) ?> selling_unit_rate ?? 0), 2)) ?>
No stock items found for search.
Sale Medicine
patient_id) && !empty($oldInvoices)): ?>
id ?? 0); ?> _items)): ?> _items as $n => $oldItem): ?>
# inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $oldInvId, -7, 7), 7, '0', STR_PAD_LEFT))) ?> inv_date) ? date('Y-m-d', strtotime((string)$old->inv_date)) : '-') ?> Show Bill
# Item Bat. Exp.Dt Qty R.Qty
item_Name ?? '-') ?> batch_no ?? '-') ?> expiry) ? date('m-Y', strtotime((string)$oldItem->expiry)) : '-') ?> qty ?? 0), 0)) ?> id)): ?>
-
No item rows.
patient_id)): ?>
No old invoices for this patient.
Walk-in invoice. Previous patient history is unavailable.