@if(!empty($invoice->ID))
@if($invoice->INVOICE_IS_ZATCA && !empty($invoice->INVOICE_ZATCA_SERIAL_NUMBER)) @endif
INVOICE NUMBER: {{$invoice->INVOICE_NO}}
ZATCA INVOICE NUMBER: {{$invoice->INVOICE_ZATCA_SERIAL_NUMBER}}
INVOICE DATE: {{empty($date_to) ? date('Y-m-d',strtotime("+3 hours")) : date("Y-m-d",strtotime($date_to))}}
INVOICING FROM: {{date("Y-m-d",strtotime($date_from))}}
INVOICING TO: {{date("Y-m-d",strtotime($date_to))}}

@if($invoice->STATUS == 0 || is_null($invoice->STATUS)) Draft Invoice @else {{$global_symbol['tax'] ?? 'TAX'}} Invoice @endif

@if($qr_image) @endif
@endif

Vendor Information

NAME: {{$profile->C_INV_NAME}}
BUILDING NO: {{$profile->C_BUILDING_NO}}
STREET: {{$profile->C_STREET}}
DISTRICT: {{$profile->C_DISTRICT}}
CITY: {{$profile->C_CITY}}
COUNTRY: {{$profile->C_COUNTRY}}
POSTAL CODE: {{$profile->C_POST_CODE}}
VAT NO: {{$profile->VAT_NO}}

Client Information

@if(!empty($user->CONTRACT_NO)) @endif @if(!empty($user->TENDER_NO)) @endif @if(!empty($user->PO_NO)) @endif
NAME: {{$user->C_INV_NAME}}
BUILDING NO: {{$user->C_BUILDING_NO}}
STREET: {{$user->C_STREET}}
DISTRICT: {{$user->C_DISTRICT}}
CITY: {{$user->C_CITY}}
COUNTRY: {{$user->C_COUNTRY}}
POSTAL CODE: {{$user->C_POST_CODE}}
VAT NO: {{$user->C_VAT_NO}}
Contract NO: {{$user->CONTRACT_NO}}
Tender NO: {{$user->TENDER_NO}}
PO NO: {{$user->PO_NO}}
@if(!empty($invoice->eNDUSER->CLIENT_LOGO))
@endif

This invoice is considered final and valid unless it is returned to us within a week from the date of receipt.

Invoice No. Invoice From Invoice To Days Qty
@if(!empty($invoice->ID)) {{$invoice->INVOICE_NO}} @endif {{date("Y-m-d",strtotime($date_from))}} {{date("Y-m-d",strtotime($date_to))}} {{date_diff(date_create($date_from),date_create($date_to))->format("%a")}} {{count($orders)}}
Total (Excluding {{$global_symbol['tax'] ?? 'TAX'}}) {{round(($net_total - $total_tax),2)}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Total Discount {{round($invoice->DISCOUNT_TOTAL/100,2)}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Taxable Total (Excluding {{$global_symbol['tax'] ?? 'TAX'}}) {{round(($net_total - $total_tax),2)}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Total {{$global_symbol['tax'] ?? 'TAX'}} {{$total_tax}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Net Total {{round($net_total,2)}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Paid Total {{$paid_total}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
Remaining Total {{round($net_total - $paid_total,2)}} @if(isset($global_symbol['is_html']) && $global_symbol['is_html'] && isset($global_symbol['currency'])) {!! $global_symbol['currency'] !!} @else {{ $global_symbol['currency'] ?? 'SAR' }} @endif
@if(!empty($hospital_bank))
@if(!empty($hospital_bank->BANK_ACCOUNT_NUMBER)) @endif @if(!empty($hospital_bank->BANK_IBAN)) @endif
Bank Account Details
Bank Name {{$hospital_bank->BANK_NAME}}
Account Number {{$hospital_bank->BANK_ACCOUNT_NUMBER}}
IBAN {{$hospital_bank->BANK_IBAN}}
@endif
{{--@php $ordersChunks = $orders->chunk(16); @endphp @php $maxRowsPerPage = 16; // Maximum number of rows (patient names + orders) per page $dynamicChunks = []; $currentChunk = []; $currentRowCount = 0; $lastPatientName = null; foreach ($orders as $order) { if ($lastPatientName != $order['NAME']) { $lastPatientName = $order['NAME']; $currentRowCount++; } if ($currentRowCount >= $maxRowsPerPage) { $dynamicChunks[] = $currentChunk; $currentChunk = []; $currentRowCount = 1; } $currentChunk[] = $order; $currentRowCount++; } if (!empty($currentChunk)) { $dynamicChunks[] = $currentChunk; } @endphp--}} @php $baseRowHeight = 46; $additionalHeightPer29Chars = 21; $charLimit = 29; $patientRowHeight = 49; $maxPageHeight = 1200; $dynamicChunks = []; $currentChunk = []; $currentChunkHeight = 0; $lastPatientName = null; foreach ($orders as $order) { $isNewPatient = ($lastPatientName != $order['NAME']); $orderName = $order['lABCATEGORYPACKAGE']['NAME_EN']; $orderNameLength = strlen($orderName); $additionalHeight = 0; if ($orderNameLength > $charLimit) { $additionalSets = ceil(($orderNameLength - $charLimit) / $charLimit); $additionalHeight = $additionalSets * $additionalHeightPer29Chars; } $rowHeight = $baseRowHeight + $additionalHeight; if ($isNewPatient) { $lastPatientName = $order['NAME']; $rowHeight += $patientRowHeight; } if ($currentChunkHeight + $rowHeight > $maxPageHeight) { $dynamicChunks[] = $currentChunk; $currentChunk = []; $currentChunkHeight = $isNewPatient ? $patientRowHeight : 0; } $currentChunk[] = $order; $currentChunkHeight += $rowHeight; } if (!empty($currentChunk)) { $dynamicChunks[] = $currentChunk; } @endphp @php $summary = []; @endphp @foreach($dynamicChunks as $key => $chunk)

Details

@php $c = 1; @endphp @foreach($chunk as $order) @if(empty(($order['PRICE'] + $order['CREDIT_NOTE_PRICE']))) @continue @endif @if(isset($summary[$order['lABCATEGORYPACKAGE']['ID']])) @php $summary[$order['lABCATEGORYPACKAGE']['ID']]['qty'] +=1; $summary[$order['lABCATEGORYPACKAGE']['ID']]['tax'] +=round(($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) - (($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) / ($order['TAX']+1)),2); $summary[$order['lABCATEGORYPACKAGE']['ID']]['total'] +=($order['PRICE'] + $order['CREDIT_NOTE_PRICE']); $summary[$order['lABCATEGORYPACKAGE']['ID']]['paid'] +=($order['AMOUNT'] / 100); @endphp @else @php $summary[$order['lABCATEGORYPACKAGE']['ID']]['name'] =$user->IS_CLIENT_TEST_DETAILS ? ($order['lABCATEGORYPACKAGE']['CLIENT_TEST_NAME_EN'] ?? $order['lABCATEGORYPACKAGE']['NAME_EN']) : $order['lABCATEGORYPACKAGE']['NAME_EN']; $summary[$order['lABCATEGORYPACKAGE']['ID']]['qty'] =1; $summary[$order['lABCATEGORYPACKAGE']['ID']]['unit_price'] =round((($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) / ($order['TAX']+1)),2); $summary[$order['lABCATEGORYPACKAGE']['ID']]['tax'] =round(($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) - (($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) / ($order['TAX']+1)),2); $summary[$order['lABCATEGORYPACKAGE']['ID']]['total'] =round($order['PRICE'] + $order['CREDIT_NOTE_PRICE'],2); $summary[$order['lABCATEGORYPACKAGE']['ID']]['paid'] =($order['AMOUNT'] / 100); @endphp @endif @php $c++; @endphp @endforeach @if($key == count($dynamicChunks) - 1) @endif
Reservation ID Patient Name ID No MRN Date Reservations Test CODE Test Name Unit Price {{$global_symbol['tax'] ?? 'TAX'}} Total Total Paid
{{$order['eNDUSERLABORDER']['ID']}} {{$order['NAME']}} {{$order['IDENTIFICATION']}} {{$order['MRN']}} {{$order['eNDUSERLABORDER']['CREATE_DATE']}} {{$user->IS_CLIENT_TEST_DETAILS ? ($order['lABCATEGORYPACKAGE']['CLIENT_TEST_CODE'] ?? $order['lABCATEGORYPACKAGE']['CODE']) : $order['lABCATEGORYPACKAGE']['CODE'] }}{{$user->IS_CLIENT_TEST_DETAILS ? ($order['lABCATEGORYPACKAGE']['CLIENT_TEST_NAME_EN'] ?? $order['lABCATEGORYPACKAGE']['NAME_EN']) : $order['lABCATEGORYPACKAGE']['NAME_EN']}} {{round((($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) / ($order['TAX']+1)),2)}} {{round(($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) - (($order['PRICE'] + $order['CREDIT_NOTE_PRICE']) / ($order['TAX']+1)),2)}} {{round($order['PRICE'] + $order['CREDIT_NOTE_PRICE'],2)}} {{$order['AMOUNT'] / 100}}
Total {{round($net_total - $total_tax,2)}} {{round($total_tax,2)}} {{round($net_total,2)}} {{round($paid_total,2)}}
@endforeach
@if(!empty($summary)) @php $summary_total = 0; @endphp

Summary

@foreach($summary as $testSummery) @php $summary_total += ($testSummery['total']); @endphp @endforeach
Test Name Quantity Unit Price {{$global_symbol['tax'] ?? 'TAX'}} Total Total Paid
{{$testSummery['name']}} {{$testSummery['qty']}} {{round($testSummery['unit_price'],2)}}{{$testSummery['tax']}} {{round($testSummery['total'],2)}} {{round($testSummery['paid'],2)}}
Total {{array_sum(array_column($summary, 'qty'))}} {{array_sum(array_column($summary, 'unit_price'))}} {{array_sum(array_column($summary, 'tax'))}} {{round($summary_total,2)}} {{array_sum(array_column($summary, 'paid'))}}
@endif