<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
</head>
<body>
<div class="row" id="x" style="display: none;">
    <div class="col-12">
      <span class="d-flex align-items-center purchase-popup">
        <i class="typcn typcn-delete-outline" id="bannerClose"></i>
      </span>
    </div>
</div>
<div class="container-scroller">
@include('layout.navbar')
<!-- partial -->
    @include('layout.breadscrum')
    <div class="container-fluid page-body-wrapper">

    @include('layout.sidebar')

    <!-- partial -->
        <div class="main-panel">
            <div class="content-wrapper">
                <div class="row">
                    <div class="col-md-12 grid-margin stretch-card">
                        <div class="card" style="min-height: 80vh;">
                            <div class="card-body">
                                <h4 class="card-title"><i class="mdi text-info mdi-apps"></i> {{__('laboratory.table_title')}}</h4>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <form method="get" action="{{url('laboratory/search')}}">
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
                                                    <div class="input-group">
                                                        <input type="text" class="form-control form-control-md rounded-left-25 rounded-right-0" value="{{isset($_GET['kword']) ? $_GET['kword'] : ''}}" name="kword" id="kword" placeholder="{{__('laboratory.search_placeholder')}}">
                                                        <div class="input-group-append">
                                                            <button class="btn btn-md btn-inverse-secondary rounded-right-25 px-3" type="submit"><i class="fa fa-search"></i>&nbsp;{{__('general.btn_search')}}</button>
                                                            <button class="btn btn-md btn-inverse-success waves-effect rounded-25 px-4 ml-3" type="button" data-action="new" data-toggle="modal" data-target="#modal-laboratory" data-backdrop="static"><i class="typcn typcn-plus"></i> {{__('general.btn_add_new')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </form> <hr class="my-3 d-none">
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped table-hover" id="lab_dt">
                                                    <thead>
                                                    <tr class="bg-gradient-light">
                                                        <th class="py-2" width="50px">{{__('laboratory.table_no')}}</th>
                                                        <th class="py-2 text-center" width="100px">{{__('laboratory.table_action')}}</th>
                                                        <th class="py-2">{{__('laboratory.table_name_en')}}</th>
                                                        <th class="py-2">{{__('laboratory.table_name_kh')}}</th>
                                                        <th class="py-2">{{__('lab_profile.short_name')}}</th>
                                                        <th class="py-2 text-center">{{__('lab_profile.sample_numner_conf')}}</th>
                                                        <th class="py-2 text-center">{{__('lab_profile.patient_numner_conf')}}</th>
                                                        <th class="py-2 text-center" width="100px">{{__('laboratory.table_status')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($laboratories as $k=>$laboratory)
                                                        <tr>
                                                            <td class="py-1 text-center">{{($k+1) + (($_GET['page'] ?? 1) * 20) - 20}}</td>
                                                            <td  class="text-center py-1">
                                                                <div class="btn-group" role="group" aria-label="Basic example" >
                                                                    <button type="button" class="btn btn-sm btn-inverse-primary mr-2" title="Edit" data-action="edit" data-labid="{{$laboratory->id}}" data-toggle="modal" data-target="#modal-laboratory" data-backdrop="static"><i class="typcn typcn-edit"></i></button>
                                                                    @if($laboratory->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary" title="Restore"  onclick="restore_lab({{$laboratory->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger " title="Delete" onclick="delete_lab({{$laboratory->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$laboratory->name_en}}</td>
                                                            <td class="py-1">{{$laboratory->name_kh}}</td>
                                                            <td class="py-1">{{$laboratory->short_name}}</td>
                                                            <td class="text-center py-1">
                                                                <label class="badge badge-success">
                                                                    {{$laboratory->sample_number == 1 ? __('lab_profile.system_generate') : __('lab_profile.manual')}}
                                                                </label>
                                                            </td>
                                                            <td class="text-center py-1">
                                                                <label class="badge badge-success">
                                                                    {{$laboratory->patient_code == 1 ? __('lab_profile.system_generate') : __('lab_profile.manual')}}
                                                                </label>
                                                            </td>
                                                            <td class="py-1 text-center">
                                                                <i class="mdi {{$laboratory->record_status_id == 1 ? 'mdi-check-circle text-primary' : 'mdi-checkbox-blank-circle-outline'}}"></i>
                                                            </td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

                                        <div class="float-right mt-3">
                                            {!! $laboratories->links('pagination.custom') !!}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <!-- Modal Laboratory -->
            <div class="modal mt-5 fade modal-primary" id="modal-laboratory">
                <div class="modal-dialog modal-xl">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h6 class="modal-title">{{__('_')}}</h6>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="mdi mdi-close"></span></button>
                        </div>

                        <div class="modal-body">
                            <form method="post" action="#" id="form" onkeydown="return event.key != 'Enter';">
                                @csrf
                                <input type="hidden" class="form-control" name="lab_id" id="lab-id" value="0" />
                                <div class="form-vertical">
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('laboratory.table_name_en')}} <span class="text-danger">*</span></label>
                                                <input type="text" class="form-control form-control-sm" name="lab_name_en" id="lab-name-en" placeholder="{{__('laboratory.table_name_en')}}">
                                            </div>
                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('laboratory.table_name_kh')}} </label>
                                                <input type="text" class="form-control form-control-sm" name="lab_name_kh" id="lab-name-kh" placeholder="{{__('laboratory.table_name_kh')}}"/>
                                            </div>
                                            <div class="form-group mb-1">
                                                <label for="lab-code" class="control-label">{{__('lab_profile.short_name')}}&nbsp;<span class="text-danger">*</span></label>
                                                <input type="text" class="form-control form-control-sm" name="lab_code" id="lab-code" maxlength="5" placeholder="{{__('lab_profile.short_name')}}">
                                            </div>

                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('patient.table_phon')}} </label>
                                                <input type="text" class="form-control form-control-sm" name="phone_number" id="phone-number" placeholder="{{__('patient.table_phon')}}"/>
                                            </div>

                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('lab_profile.emial')}} </label>
                                                <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="{{__('lab_profile.emial')}}"/>
                                            </div>

                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('Laboratory Type')}} </label>
                                                <select name="lab_category_id" class="form-control form-control-sm" id="lab-category-id">
                                                    <option value="0">General Medical Laboratory</option>
                                                    <option value="1">Anapathology Laboratory</option>
                                                </select>
                                            </div>


                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('Fixed Comission Rate')}} </label>
                                                <input type="number" class="form-control form-control-sm" name="is_hide_comission_percentage" id="is_hide_comission_percentage" value="0"/>
                                            </div>


                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="address-en">{{__('laboratory.form_address_en')}}</label>
                                                <input type="text" class="form-control form-control-sm" name="address_en" id="address-en" placeholder="{{__('laboratory.form_address_en')}}">
                                            </div>

                                            <div class="row form-group mb-1">
                                                <div class="col-sm-12">
                                                    <label for="address-kh" class="control-label">{{__('laboratory.form_address_kh')}}</label>
                                                    <input type="text" class="form-control form-control-sm" name="address_kh" id="address-kh" placeholder="{{__('laboratory.form_address_kh')}}">
                                                </div>
                                            </div>

                                            <div class="form-group mb-1">
                                                <label for="lab-code" class="control-label">{{__('lab_profile.start_date') . ' & '.__('lab_profile.usage_period')}}&nbsp;</label>
                                                <div class="input-group">
                                                    <input class="form-control form-control-sm" name="start_date" onfocus="(this.type='date')" onblur="(this.type='text')" id="start-date" placeholder="{{__('general.type_date_placeholder')}}">
                                                    <input class="form-control form-control-sm" onfocus="(this.type='date')" onblur="(this.type='text')" name="end_date" id="end-date" placeholder="{{__('general.type_date_placeholder')}}">
                                                </div>
                                            </div>


                                            {{--                                        <div class="form-group mb-1">--}}
                                            {{--                                            <label for="lab-code" class="control-label">{{__('lab_profile.start_date') }} <span class="text-danger">*</span></label>--}}
                                            {{--                                            <input class="form-control form-control-sm" name="start_date" onfocus="(this.type='date')" onblur="(this.type='text')" id="start-date" placeholder="{{__('general.type_date_placeholder')}}">--}}
                                            {{--                                        </div>--}}

                                            {{--                                        <div class="form-group mb-1">--}}
                                            {{--                                            <label for="lab-code" class="control-label">{{__('lab_profile.usage_period')}}&nbsp;</label>--}}
                                            {{--                                            <input class="form-control form-control-sm" onfocus="(this.type='date')" onblur="(this.type='text')" name="end_date" id="end-date" placeholder="{{__('general.type_date_placeholder')}}">--}}
                                            {{--                                        </div>--}}

                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('lab_profile.sample_numner_conf')}} <span class="text-danger">*</span></label>
                                                <div class="form-group pl-3">
                                                    <div class="row">
                                                        <div class="form-check col-sm-3">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="sample_number" data-id="0" value="0"> {{__('lab_profile.manual')}}
                                                            </label>
                                                        </div>
                                                        <div class="form-check col-sm-9">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="sample_number" checked data-id="1" value="1"> {{__('lab_profile.system_generate')}}
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('lab_profile.patient_numner_conf')}} <span class="text-danger">*</span></label>
                                                <div class="form-group pl-3">
                                                    <div class="row">
                                                        <div class="form-check col-sm-3">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="patient_number" data-id="0" value="0"> {{__('lab_profile.manual')}}
                                                            </label>
                                                        </div>
                                                        <div class="form-check col-sm-9">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="patient_number" checked data-id="1" value="1"> {{__('lab_profile.system_generate')}}
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group mb-0">
                                                <label for="lab-name-en">{{__('Make Invoice')}} <span class="text-danger">*</span></label>
                                                <div class="form-group pl-3">
                                                    <div class="row">
                                                        <div class="form-check col-sm-3">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="is_auto_make_invoice" checked data-id="0" value="0"> {{__('lab_profile.manual')}}
                                                            </label>
                                                        </div>
                                                        <div class="form-check col-sm-9">
                                                            <label class="form-check-label">
                                                                <input type="radio" class="form-check-input" name="is_auto_make_invoice" data-id="1" value="1"> {{__('lab_profile.system_generate')}}
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group mb-1">
                                                <div class="row">
                                                    <div class="col-sm-6">
                                                        <div class="form-check form-check-flat form-check-primary mb-1 mt-1">
                                                            <div class="form-check form-check-primary">
                                                                <label class="form-check-label">
                                                                    <input type="checkbox" class="checkbox" data-id="1" name="shareable_lab_result" id="shareable_lab_result"> {{__('Share Laboratory Result')}}
                                                                </label>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-6">
                                                        <div class="form-check form-check-flat form-check-primary mb-1 mt-1">
                                                            <div class="form-check form-check-primary">
                                                                <label class="form-check-label">
                                                                    <input type="checkbox" class="checkbox" data-id="1" name="allow_external_request" id="allow_external_request"> {{__('Allow External Request Test')}}
                                                                </label>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-info" id="btnSave"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('lang.save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                            <button type="button" class="btn btn-light" data-dismiss='modal'>{{__('lang.cancel')}}</button>
                        </div>
                    </div>
                </div>
            </div>
            @include('layout.footer')
        </div>
    </div>
</div>
@include('layout.common_script')

<script>
    var save_lab_url = "{{url('laboratory.save')}}";
    var update_lab_url = "{{url('laboratory.update')}}";
    var delete_lab_url = "{{url('laboratory.delete')}}";
    var restore_lab_url = "{{url('laboratory.restore')}}";
    var get_lab_url = "{{url('laboratory.get')}}";

    let modal_add_title = "{{__('laboratory.form_add_tittle')}}";
    let modal_edit_title = "{{__('laboratory.form_edit_tittle')}}";

</script>
<script src="{{url(env("APP_URL").'storage/assets/js/admin/laboratory.js?_').time()}}"></script>
</body>

</html>

