<div class="modal fade" id="print_invoice_modal" style="padding-top: 40px; background: rgba(0, 0, 0, 0.54); overflow: auto; padding-left: 17px;">
    <div class="print-preview-header">
        <div class="presult-pagination d-none">
            <input type="text" class="page-number" value="1" onfocus="this.select()"> /
            <span class="page-count">1</span>
        </div>
        <ul>
            <li style="display: inline-block;" class="print">
                <a href="javascript:void(0)" onclick="printJS('presult-1', 'html')" id="doPrinting"><i class="fa fa-print"></i>&nbsp;<b>{{__('invoice.print')}}</b></a>
            </li>
        </ul>
        <span class="close-preview" data-dismiss="modal" title="Close"><i class="fa fa-times"></i></span>
    </div>
    <div class="modal-dialog modal-xxl A4-portrait">
        <div class="psample-result active" id="presult-1">
            <title>Result</title>
            <meta name="viewport" content="width=device-width, initial-scale=.5, maximum-scale=12.0, minimum-scale=.25, user-scalable=yes">
            <style>
                table td, table th{
                    padding: 3px !important; font-size:10pt !important;
                }
                @font-face {
                    font-family: 'KhmerOS_muollight';
                    src: url('{{url(env("APP_URL").'storage/assets/fonts/KhmerOS_muollight.ttf')}}');
                    font-display: swap;
                }
                .KhmerMoulLight {
                    font-family: 'SourceSerifPro-Regular', 'KhmerOS_muollight', 'serif';
                }
                page[size="A4"] {
                    background: white;
                    /*width: 21cm;*/
                    width: 297mm;
                    display: block;
                    margin: 10px auto;
                    box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
                    padding: 1mm;
                    font-family: 'SourceSerifPro-Regular', 'Noto Sans Khmer', 'serif';
                    font-size: 8pt;
                    line-height: 10px;
                    page-break-after: always;
                }
                table th, table td {
                    text-align: left;
                    padding-left: 5px !important;
                    padding-right: 5px !important;
                }
                table td {
                    font-weight: normal;
                }
                table.patient-info, table.department-sample-info  {
                    border: 1px solid #7a7a7a;
                    line-height: 18px;
                    padding: 3px;
                }
                table.patient-info td, table.patient-info th {
                    vertical-align: top;
                }
                .text-center {
                    text-align: center;
                }
                .text-left {
                    text-align: left;
                }
                .text-right {
                    text-align: right;
                }
                .text-top {
                    vertical-align: top;
                }
                .text-no-wrap {
                    white-space: nowrap;
                }
                table.test-result {
                    line-height: 16px;
                }
                #footer {
                    line-height: 17px;
                }
                #footer .laboratory-address td {
                    border-top: 1px solid black;
                    padding-top: 10px;
                }
                #footer .result-footer-signature td {
                    vertical-align: top;
                    padding-bottom: 60px;
                }
                @page {
                    margin: 0.5cm;
                }
                @media print {
            
                    body,
                    page[size="A4"] {
                        box-shadow: none;
                        background-color: #fff;
                    }
                    @page {
                        size: A4 landscape;
                        margin: 0.5cm 0.5cm 0;
                        padding: 0;
                    }
                    @page {
                        size: 210mm 297mm landscape;
                        margin: 0.5cm 0.5cm 0;
                        padding: 0;
                    }
                    @page {
                        size: 11.7in 16.5in landscape;
                        margin: 0.5cm 0.5cm 0;
                        padding: 0;
                    }
                    tbody.sample-result {
                        page-break-inside: avoid;
                    }
                    #footer {
                        display: block;
                        position: fixed;
                        bottom: 0;
                    }
                    
                    .font-changable{
                    font-family: "{{(App::isLocale('en') ? 'Times New Roman' : 'Khmer OS Siemreap')}}";
                }
                }
                #print_invoice_modal .table-inv th, .table-inv td {
                    border: 1px solid black;
                    border-collapse: collapse;
                    padding: 5px !important;
                }
                .bg-light{
                    background: #e8e8e8 !important;
                }
                .border-0{
                    border:none !important;
                }
                
                .font-changable{
                    font-family: "{{(App::isLocale('en') ? 'Times New Roman' : 'Khmer OS Siemreap')}}";
                }
                
                
            </style>
            <page size="A4">
                <div style="width: 297mm; padding: 0px; background-image: linear-gradient(#fafafa, #fafafa); background-size: 1px 100%; background-repeat: no-repeat; background-position: 49.6% center;">
                    <div style="width: 49%; display: inline-block; clear: both; /*border-right: 1px dashed #eee;*/  vertical-align: top; margin-right:1% !important">
                        <table border="0" width="100%" style="font-size: 8pt !important;">
                            <thead>
                            <tr>
                                <td style="width:100%; text-align: center">
                                    @if(!empty($sample->physician->logo))
                                        <img width="100%" class="rounded-0" src="{{url(env("APP_URL").'storage/images/physician/'.$sample->physician->logo)}}"  />
                                    @else
                                        <table width="100%">
                                            <tr>
                                                <td style="width:70px; vertical-align: top;" class="text-center">
                                                    <img src="{{url(env("APP_URL").'storage/images/avatars/labs/'.$labSettings->logo)}}" alt="Logo" style="width: 70px;">
                                                </td>
                                                <td class="text-center">
                                                    <p style="line-height: 13px !important; font-size: 10pt; font-weight: bold;" class="KhmerMoulLight ">{{$labSettings->name_kh}}</p>
                                                    <p style="line-height: 13px !important; font-size: 9pt; font-weight: bold;" class="text-uppercase ">{{$labSettings->name_en}}</p>
                                                    <p class="font-changable" style="line-height: 20px !important;">{{ app()->getLocale()=='kh' ? $labSettings->address_kh : $labSettings->address_en}} </p>
                                                    <p style="line-height: 9px !important;">{{$labSettings->phone_number}} {{$labSettings->email}}</p>
                                                </td>
                                                <td style="width:80px; vertical-align: bottom;" >
                                                    <div class="visible-print text-center">
                                                        @if($labSettings->shareable_lab_result==1)
                                                            {!! QrCode::size(60)->generate(url('/shared/lab-result/'.$sample_id)); !!}
                                                        @endif
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    @endif
                                </td>
                            </tr>
                            <tr>
                                <td class="text-top text-center">
                                    <div style="font-size: 11.5pt; font-family: {{(App::isLocale('en') ? 'Times New Roman' : 'Khmer OS Siemreap')}}; font-weight: 700;">{{__('invoice.tittle')}}</div>
                                </td>
                            </tr>
                            <tr>
                                <th class="p-0">
                                    <table width="100%" class="patient-info font-changable" style="line-height: 15px !important;">
                                        <tbody>
                                        <tr>
                                            <td class="text-left" style="font-size:11pt !important;" width="20%">{{__('invoice.form_invoice_number')}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="30%">: {{$invoice->invoice_code}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="20%">{{__('sample.table_sample_number')}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="30%">: {{$sample->sample_number}}</td>
                                        </tr>
                                        <tr>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('invoice.table_patient_name')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->patient->name_en}}</td>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('patient.form_age')}}</td>
                                            <td style="font-size:11pt !important;" class="text-no-wrap  text-left">
                                                : {{\App\Helpers\Helpers::getAge($sample->patient->dob, $sample->admission_date)}}, {{__('sample.form_patient_gender')}}: {{\App\Helpers\Helpers::getGender($sample->patient->gender)}}
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('patient.table_phon')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->patient->phone_number}}                                                                                                                                                 </td>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('sample.physician_name')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->physician->name_en}}</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </th>
                            </tr>
                            </thead>
                            <tfoot>
                            <tr>
                                <td width="100%">
                                    <table width="100%" border="0">
                                        <tbody>
                                        <tr>
                                            <td colspan="4" style="height: 20px;">&nbsp;</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            </tfoot>
                            <tbody>
                            <tr>
                                <td class="p-0">
                                    <table width="100%" class="table-inv" style="border-collapse: collapse; !important; font-size:10pt !important;">
                                        <tbody>
                                        <tr class="bg-light font-changable">
                                            <td width="8%" class="text-center">{{__('invoice.table_no')}}</td>
                                            <td class="text-center">{{__('invoice.form_description')}}</td>
                                            <td width="15%" class="text-center" style="width:110px !important;">{{__('invoice.form_qty')}}</td>
                                            <td width="15%" class="text-center" style="width:110px !important;">{{__('invoice.form_unit_price')}}</td>
                                        </tr>
                                        <?php $total = 0;?>
                                        @foreach($invoice->invoiceDetail as $k=>$invItem)
                                            <?php $total+= $invItem->unit_price;?>
                                            <tr>
                                                <td class=" text-center">{{$k+1}}</td>
                                                <td>{{$invItem->test_name}}</td>
                                                <td class="text-right ">{{$invItem->qty}}</td>
                                                <td class="text-right ">$ {{$invItem->unit_price}}</td>
                                            </tr>
                                        @endforeach

                                        <tr class="font-changable">
                                            <td class="text-left " colspan="4"><span style="padding-left: 10px !important;">{{$invoice->invoice_note}}</span></td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"><span style="padding-left: 30px !important;">{{__('invoice.table_invoice_date')}}: {{date('d-m-Y',strtotime($invoice->invoice_date))}}</span></td>
                                            <td class="text-right  border-0">{{__('invoice.table_total_cost')}} ($) :</td>
                                            <td class="text-right  bg-light"> {{number_format($invoice->total,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"></td>
                                            <td class="text-right  border-0">{{__('invoice.table_discount')}} ($) :</td>
                                            <td class="text-right  bg-light"> {{number_format($invoice->discount,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"></td>
                                            <td class="text-right  border-0">{{__('invoice.table_net_cost')}} :</td>
                                            <td class="text-right  bg-light"> {{number_format(($invoice->total - $invoice->discount) ,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"><span style="padding-left: 70px !important;">{{__('invoice.received_by')}}</span></td>
                                            <td class="text-right  border-0">{{__('invoice.table_net_cost_riel')}} :</td>
                                            <td class="text-right  bg-light"> {{number_format((($invoice->total - $invoice->discount) * $labSettings->exchange_rate),2)}}</td>
                                        </tr>

                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            <!-- Comment -->
                            </tbody>
                            <!-- Note -->
                        </table>
                        <table id="footer" width="100%" border="0" style="padding: 0 10px !important;">
                            <tbody>
                            <tr>
                                <td class="text-center text-no-wrap" style="width: 3cm">
                                </td>
                                <td style="width: 4cm"></td>
                                <td class="text-center text-no-wrap" style="width: 4cm; padding-left: 20px"></td>
                            </tr>
                            <tr>
                                <td colspan="3" style="padding-top: 15px; !important;">&nbsp;</td>
                            </tr>
                            <tr class="result-footer-signature">
                                <td class="text-center text-no-wrap" style="padding: 0 10px !important;">
                                </td>
                                <td class="text-center text-no-wrap"></td>
                                <td class="text-center text-no-wrap"></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div style="width: 49%;  display: inline-block; clear: both;  vertical-align: top;">
                        <table border="0" width="100%" style="font-size: 8pt !important;">
                            <thead>
                            <tr>
                                <td style="width:100%; text-align: center">
                                    @if(!empty($sample->physician->logo))
                                        <img width="100%" class="rounded-0" src="{{url(env("APP_URL").'storage/images/physician/'.$sample->physician->logo)}}"  />
                                    @else
                                        <table width="100%">
                                            <tr>
                                                <td style="width:70px; vertical-align: top;" class="text-center">
                                                    <img src="{{url(env("APP_URL").'storage/images/avatars/labs/'.$labSettings->logo)}}" alt="Logo" style="width: 70px;">
                                                </td>
                                                <td class="text-center">
                                                    <p style="line-height: 13px !important; font-size: 10pt; font-weight: bold;" class="KhmerMoulLight ">{{$labSettings->name_kh}}</p>
                                                    <p style="line-height: 13px !important; font-size: 9pt; font-weight: bold;" class="text-uppercase ">{{$labSettings->name_en}}</p>
                                                    <p class="font-changable" style="line-height: 20px !important;">{{ app()->getLocale()=='kh' ? $labSettings->address_kh : $labSettings->address_en}} </p>
                                                    <p style="line-height: 9px !important;">{{$labSettings->phone_number}} {{$labSettings->email}}</p>
                                                </td>
                                                <td style="width:80px; vertical-align: bottom;" >
                                                    <div class="visible-print text-center">
                                                        @if($labSettings->shareable_lab_result==1)
                                                            {!! QrCode::size(60)->generate(url('/shared/lab-result/'.$sample_id)); !!}
                                                        @endif
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    @endif
                                </td>
                            </tr>
                            <tr>
                                <td class="text-top text-center">
                                    <div style="font-size: 11.5pt; font-family: {{(App::isLocale('en') ? 'Times New Roman' : 'Khmer OS Siemreap')}}; font-weight: 700;">{{__('invoice.tittle')}}</div>
                                </td>
                            </tr>
                            <tr>
                                <th class="p-0">
                                    <table width="100%" class="patient-info font-changable" style="line-height: 15px !important;">
                                        <tbody>
                                        <tr>
                                            <td class="text-left" style="font-size:11pt !important;" width="20%">{{__('invoice.form_invoice_number')}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="30%">: {{$invoice->invoice_code}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="20%">{{__('sample.table_sample_number')}}</td>
                                            <td class="text-left" style="font-size:11pt !important;" width="30%">: {{$sample->sample_number}}</td>
                                        </tr>
                                        <tr>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('invoice.table_patient_name')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->patient->name_en}}</td>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('patient.form_age')}}</td>
                                            <td style="font-size:11pt !important;" class="text-no-wrap  text-left">
                                                : {{\App\Helpers\Helpers::getAge($sample->patient->dob, $sample->admission_date)}}, {{__('sample.form_patient_gender')}}: {{\App\Helpers\Helpers::getGender($sample->patient->gender)}}
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('patient.table_phon')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->patient->phone_number}}                                                                                                                                                 </td>
                                            <td style="font-size:11pt !important;" class="text-left  text-no-wrap">{{__('sample.physician_name')}}</td>
                                            <td style="font-size:11pt !important;" class="text-left ">: {{$sample->physician->name_en}}</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </th>
                            </tr>
                            </thead>
                            <tfoot>
                            <tr>
                                <td width="100%">
                                    <table width="100%" border="0">
                                        <tbody>
                                        <tr>
                                            <td colspan="4" style="height: 20px;">&nbsp;</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            </tfoot>
                            <tbody>
                            <tr>
                                <td class="p-0">
                                    <table width="100%" class="table-inv" style="border-collapse: collapse; !important; font-size:10pt !important;">
                                        <tbody>
                                        <tr class="bg-light font-changable">
                                            <td width="8%" class="text-center">{{__('invoice.table_no')}}</td>
                                            <td class="text-center">{{__('invoice.form_description')}}</td>
                                            <td width="15%" class="text-center" style="width:110px !important;">{{__('invoice.form_qty')}}</td>
                                            <td width="15%" class="text-center" style="width:110px !important;">{{__('invoice.form_unit_price')}}</td>
                                        </tr>
                                        <?php $total = 0;?>
                                        @foreach($invoice->invoiceDetail as $k=>$invItem)
                                            <?php $total+= $invItem->unit_price;?>
                                            <tr>
                                                <td class=" text-center">{{$k+1}}</td>
                                                <td>{{$invItem->test_name}}</td>
                                                <td class="text-right ">{{$invItem->qty}}</td>
                                                <td class="text-right ">$ {{$invItem->unit_price}}</td>
                                            </tr>
                                        @endforeach

                                        <tr class="font-changable">
                                            <td class="text-left " colspan="4"><span style="padding-left: 10px !important;">{{$invoice->invoice_note}}</span></td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"><span style="padding-left: 30px !important;">{{__('invoice.table_invoice_date')}}: {{date('d-m-Y',strtotime($invoice->invoice_date))}}</span></td>
                                            <td class="text-right  border-0">{{__('invoice.table_total_cost')}} ($) :</td>
                                            <td class="text-right  bg-light"> {{number_format($invoice->total,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"></td>
                                            <td class="text-right  border-0">{{__('invoice.table_discount')}} ($) :</td>
                                            <td class="text-right  bg-light"> {{number_format($invoice->discount,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"></td>
                                            <td class="text-right  border-0">{{__('invoice.table_net_cost')}} :</td>
                                            <td class="text-right  bg-light"> {{number_format(($invoice->total - $invoice->discount) ,2)}}</td>
                                        </tr>

                                        <tr class="font-changable">
                                            <td class="text-left border-0" colspan="2"><span style="padding-left: 70px !important;">{{__('invoice.received_by')}}</span></td>
                                            <td class="text-right  border-0">{{__('invoice.table_net_cost_riel')}} :</td>
                                            <td class="text-right  bg-light"> {{number_format((($invoice->total - $invoice->discount) * $labSettings->exchange_rate),2)}}</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            <!-- Comment -->
                            </tbody>
                            <!-- Note -->
                        </table>
                        <table id="footer" width="100%" border="0" style="padding: 0 10px !important;">
                            <tbody>
                            <tr>
                                <td class="text-center text-no-wrap" style="width: 3cm">
                                </td>
                                <td style="width: 4cm"></td>
                                <td class="text-center text-no-wrap" style="width: 4cm; padding-left: 20px"></td>
                            </tr>
                            <tr>
                                <td colspan="3" style="padding-top: 15px; !important;">&nbsp;</td>
                            </tr>
                            <tr class="result-footer-signature">
                                <td class="text-center text-no-wrap" style="padding: 0 10px !important;">
                                </td>
                                <td class="text-center text-no-wrap"></td>
                                <td class="text-center text-no-wrap"></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </page>
        </div>
    </div>
</div>
