diff --git a/app/Views/billing/ipd/bill_print.php b/app/Views/billing/ipd/bill_print.php index 88432cc..94ca180 100644 --- a/app/Views/billing/ipd/bill_print.php +++ b/app/Views/billing/ipd/bill_print.php @@ -161,6 +161,8 @@ $cleanNursingMarker = static function (string $text): string { .center { text-align: center; } .right { text-align: right; } .group { font-weight: 700; font-size: 10.2px; } + .group-row td { background: #f4f4f4; } + .group-subtotal td { background: #fafafa; } .totalline { font-weight: 700; } .footer-sign { margin-top: 48px; width: 100%; } .footer-sign td { border: none; width: 50%; font-weight: 700; font-size: 10.4px; } @@ -247,8 +249,20 @@ $cleanNursingMarker = static function (string $text): string { $headDesc = ''; $headTotal = 0.0; + $printGroupSubtotal = static function (float $total, bool $mode3) { + echo ''; + echo ''; + echo 'Sub Total'; + echo '' . esc(number_format($total, 2)) . ''; + if ($mode3) { + echo ''; + } + echo ''; + }; + if (! empty($packages)) { - echo 'Package' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; + echo 'Package' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; + $packageTotal = 0.0; foreach ($packages as $row) { $amt = (float) ($row->package_Amount ?? 0); echo ''; @@ -263,14 +277,20 @@ $cleanNursingMarker = static function (string $text): string { } echo ''; $srNo++; + $packageTotal += $amt; } + $printGroupSubtotal($packageTotal, $mode3ShowAmountAfterDiscount); } for ($i = 0, $n = count($ipdItems); $i < $n; $i++) { $row = $ipdItems[$i]; if ($headDesc !== (string) ($row->group_desc ?? '')) { + if ($headDesc !== '') { + $printGroupSubtotal($headTotal, $mode3ShowAmountAfterDiscount); + } $headDesc = (string) ($row->group_desc ?? ''); - echo '' . esc($headDesc) . '' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; + $headTotal = 0.0; + echo '' . esc($headDesc) . '' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; } $amt = (float) ($row->item_amount ?? 0); @@ -313,8 +333,12 @@ $cleanNursingMarker = static function (string $text): string { for ($i = 0, $n = count($showItems); $i < $n; $i++) { $row = $showItems[$i]; if ($headDesc !== (string) ($row->Charge_type ?? '')) { + if ($headDesc !== '') { + $printGroupSubtotal($headTotal, $mode3ShowAmountAfterDiscount); + } $headDesc = (string) ($row->Charge_type ?? ''); - echo '' . esc($headDesc) . '' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; + $headTotal = 0.0; + echo '' . esc($headDesc) . '' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; } $amt = (float) ($row->amount ?? 0); @@ -330,10 +354,21 @@ $cleanNursingMarker = static function (string $text): string { } echo ''; $srNo++; + $headTotal += $amt; + } + + if ($headDesc !== '') { + $printGroupSubtotal($headTotal, $mode3ShowAmountAfterDiscount); + $headDesc = ''; + $headTotal = 0.0; } foreach ($medicalItems as $row) { $amt = (float) ($row->net_amount ?? 0); + if ($headDesc === '') { + $headDesc = 'Medical'; + echo 'Medical' . ($mode3ShowAmountAfterDiscount ? '' : '') . ''; + } echo ''; echo '' . $srNo . ''; echo '' . esc((string) ($row->inv_med_code ?? 'Medicine')) . ''; @@ -344,6 +379,11 @@ $cleanNursingMarker = static function (string $text): string { } echo ''; $srNo++; + $headTotal += $amt; + } + + if ($headDesc !== '' && $headTotal > 0) { + $printGroupSubtotal($headTotal, $mode3ShowAmountAfterDiscount); } ?>