
<!-- Modal Assign Test -->
<div class="modal fade modal-primary" id="modal-assign-test">
    <div class="modal-dialog modal-xxl">
        <div class="modal-content vh-100__" style="height:calc(100vh - 80px)">
            <div class="modal-header">
                <h6 class="modal-title">{{__('sample.assign_test_modal_title')}}</h6>
                <span class="pl-3 text-muted font-13 text-uppercase">{{__('sample.form_sample_number')}}: <b class="pl-1 sample-number text-info">-</b></span>
                <span class="pl-3 text-muted text-uppercase">{{__('sample.form_patient_name')}}: <b class="pl-1 patient-name text-info">-</b></span>
                <span class="pl-4 text-muted text-uppercase">{{__('sample.form_patient_code')}}: <b class="pl-1 patient-code text-info">-</b></span>
                <span class="pl-3 text-muted text-uppercase">{{__('sample.physician_name')}}: <b class="pl-1 sample-source text-info">-</b></span>


                <div class="col-sm-2 autocomplete p-0 float-right">
                    <div class=" input-group">
                        <input type="text" id="mySearchTest" placeholder="{{__('sample.assign_test_modal_title')}}" class="form-control rounded-0 form-control-sm">
                        <div class="input-group-append">
                            <button type="button" class="btn btn-sm btn-white"><i class="mdi mdi-checkbox-marked-outline"></i></button>
                        </div>
                    </div>
                </div>

                <button type="button" style="margin-left: 20px !important;" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="mdi mdi-close"></span></button>
            </div>

            <div class="modal-body bg-white" style="padding-top: 5px !important;">
                <div class="row mt-0">
                    <div class="col-sm-12" id="test-group-slot">
                        @foreach($testGroups as $group)
                            <div class="btn-group btn-xs mr-2" id="tsg-{{$group->id}}" role="group">
                                <button onclick="useTemplate({{$group->id}})" class="btn btn-xs rounded-right-0 rounded-top-left-25 rounded-bottom-left-25 btn-light rounded-0 my-1" type="button">{{$group->group_name}}</button>
                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['delete_test_group']))
                                <button onclick="deleteGroupTemplate({{$group->id}})" type="button" title="Delete group tests" class="btn rounded-left-0 btn-xs rounded-bottom-right-25 rounded-top-right-25 btn-light my-1">
                                    <i class="mdi mdi-close"></i>
                                </button>
                                @else
                                    <button type="button" disabled title="Delete group tests" class="btn rounded-left-0 btn-xs rounded-bottom-right-25 rounded-top-right-25 btn-light my-1">
                                        <i class="mdi mdi-close"></i>
                                    </button>
                                @endif
                            </div>
                        @endforeach
                        <button onclick="clearAllSelection()" type="button" class="btn btn-xs btn-inverse-warning rounded-25 float-right">
                            {{__('sample.clear_selection')}}
                        </button>
                    </div>
                </div>
                <form id="form-assign-test" class="mb-5">
                    @csrf
                    <input type="hidden" class="form-control" name="sample_id" id="sample-id" value="0" />
                    <div class="form-vertical">
                        <div class="row" id="test-item-list"></div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <div class="row footer_fixed">
                    <div class="col-sm-12 " >
                        <div class="row">
                            <div class="col-lg-6">
                                @if(!isset($sample->invoice))
                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_invoice']))
                                        @if(isset($sample))
                                            <button type="button" class="btn btn-inverse-info rounded-25 ml-5 mr-2" data-toggle="modal" id="btnShowInvoice" data-target="#modal-invoice" data-backdrop="static"><i class="typcn typcn-plus"></i>&nbsp;&nbsp;<span class="save">{{__('sample.assign_test_make_invoice')}}</span></button>
                                        @else
                                            <button type="button" class="btn btn-inverse-info rounded-25 mr-2" onclick="redirectMakeInvoice()" ><span class="save" > <i class="typcn typcn-plus"></i> {{__('sample.assign_test_make_invoice')}}</span></button>
                                        @endif
                                    @endif
                                @else

                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_invoice','update_invoice']))
                                    <a href="{{url('invoice/edit/'.$sample->invoice->id)}}" class="btn btn-inverse-info rounded-25 mr-2"><span class="save" >{{__('invoice.form_edit_title')}}</span></a>
                                     @endif

                                @endif
                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_test_group']))
                                    <button onclick="saveTestGroup()" class="btn btn-inverse-info rounded-25 px-3 " type="button"><i class="typcn typcn-plus"></i> {{__('sample.assign_test_save_template')}}</button>
                                @endif

								<span class="pl-3">{{__('sample.assign_test_total_test')}} : <b id="total-test">0</b></span>
                                <span class="pl-3">{{__('sample.assign_test_total_fee_text')}} : <b id="total-test-payment">$ 0.00</b></span>
								<span class="pl-3">{{__('អត្រាប្តូរប្រាក់')}} : <b id="exchange_rate">{{$labSettings->exchange_rate}}</b></span>
                            </div>
                            <div class="col-lg-6 text-right pr-4">
                                @if(isset($sample))
                                <button type="button" class="btn btn-inverse-info mr-2 rounded-25" id="print-label" data-toggle="modal" data-target="#print_sample_label_modal" data-backdrop="static"><span class="update" ><i class="mdi mdi-printer"></i> {{__('sample.print_label')}}</span></button>
                                @else
                                <button type="button" class="btn btn-inverse-info mr-2 rounded-25" onclick="redirectPrintLabel()" ><span class="update" ><i class="mdi mdi-printer"></i> {{__('sample.print_label')}}</span></button>
                                @endif

                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_sample']))
                                <button type="button" class="btn btn-info rounded-25 mr-2 btnAssignTest" id="save-assign-test" value="save_test_only"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('sample.assign_test_btn_save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                                @endif
                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['add_result','update_result']))
                                <button type="button" class="btn btn-inverse-info rounded-25 mr-2 btnAssignTest save-assign-test-popup-result" data-uri="" value="save_test_and_add_result"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('sample.assign_test_btn_save_add_result')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                                @endif
                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_sample']))
                                    <a href="{{url('sample/new')}}" class="btn btn-inverse-success rounded-25 mr-2"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="save">{{__('sample.form_add_title')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></a>
                                @endif
                                <button type="button" class="btn btn-secondary rounded-25 mr-5" data-dismiss='modal'>{{__('lang.cancel')}}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
