<!DOCTYPE html>
<html>
<title>Customer Profile</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="{{ url(env("APP_URL").'storage/assets/vendors/typicons/typicons.css') }}">
<link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/vendors/mdi/css/materialdesignicons.min.css')}}">
<link rel="stylesheet" href="{{ url(env("APP_URL").'storage/assets/vendors/css/vendor.bundle.base.css') }}">
<link rel="stylesheet" href="{{ url(env("APP_URL").'storage/assets/css/vertical-layout-light/style.css') }}">
<link rel="stylesheet" href="{{ url(env("APP_URL").'storage/assets/css/overwrite.css') }}">
<link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/vendors/select2/select2.min.css')}}">
<link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/libs/alertifyjs/build/css/alertify.min.css')}}" type="text/css" />
<link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/libs/sweetalert2/sweetalert2.min.css')}}" type="text/css" />
    <link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/css/overwrite.select2.css')}}">

<style>
    body,h1,h2,h3,h4,h5,h6 {font-family: "Arial", sans-serif; font-size: 25px;}
    .py-2{
        padding: 5px 0;
    }
    .table tr td, .table tr th{
        padding: 5px;
        font-size: 25px !important;
    }
    .text-center{
        text-align: center;
    }
    .font-12{
        font-size: 15px !important;
    }
    .font-13{
        font-size: 20px !important;
    }
    .footer_fixed {
        padding-top: 7px !important;
    }
    .modal-content {
        border-top: 0px !important
    }
    .modal-content::before {
        content: "";
        position: absolute;
        left: 0px;
        top: 0px;
        display: block;
        width: 0px;
        height: 0px;
        z-index: 1;
    }
    .font-weight-normal .form-check span{
        font-size: 15px !important;
    }

</style>
<body class="w3-white w3-content" style="max-width:1600px">

<!-- !PAGE CONTENT! -->
<div class="w3-main" style="margin-left:000px">


    <!-- Header -->
    <header id="portfolio">
        <br>
        <div class="w3-container" style="overflow: auto">
            <table cellpadding="0" cellspacing="0" style="min-width: 100%">
                <tr>
                    <th style="width:100%" class="text-center">
						@if(!empty($labSettings->alternative_logo))
							<img width="98%" height="140px" class="rounded-0" src="{{ url(env("APP_URL").'storage/images/avatars/labs/alternative_logo/'.$labSettings->alternative_logo) }}"  />
                        @else

                        <table width="100%" cellpadding="0" cellspacing="0" style="min-width: 100%">
                            <tr>
                                <td style="vertical-align: top;" class="text-center">
                                    <img src="{{url(env("APP_URL").'storage/images/avatars/labs/'.$labSettings->logo)}}" alt="Logo" style="width: 70px;">
                                </td>
                            </tr>
                            <tr>
                                <td class="text-center" align="center">
                                    <p style="line-height: 13px !important; font-size: 11pt; font-weight: bold; color: #3b86d1;" class="KhmerMoulLight py-1">{{$labSettings->name_kh}}</p>
                                    <p style="line-height: 13px !important; font-size: 9pt; font-weight: bold; color: #3b86d1;" class="text-uppercase py-1">{{$labSettings->name_en}}</p>
                                </td>
                            </tr>
                        </table>
						@endif
                    </th>
                </tr>
            </table>
            <hr style="margin: 10px 0;">
            <h6 style="font-size:20px"><b>{{$patient->name_en}}</b></h6>
            <small style="color: #909090;">{{$patient->patient_uuid}} . {{\App\Helpers\Helpers::getAge($patient->dob, date('Y-m-d'))}} . {{\App\Helpers\Helpers::getGender($patient->gender)}}</small>
            <div class="w3-section w3-bottombar w3-padding-10" style="margin: 8px 0 !important;">
                <span class="w3-margin-right" style="font-size: 20px">ប្រវត្តិអ្នកជំងឺ:</span>
                <span style="float: right"><a style="text-decoration: none; color: #007bff; font-size: 20px;" href="{{url('customer/logout/'.md5($labSettings->id))}}">ចាកចេញ</a></span>
            </div>
        </div>
    </header>

    <!-- First Photo Grid-->

        <div class=" w3-container w3-margin-bottom" style="overflow-x: auto; margin-bottom: 20px">
            <button data-toggle="modal" data-target="#modal-assign-test" data-backdrop="static" id="btn-new-test" style="font-size:20px" class="btn btn-sm btn-success my-2"><i class="mdi mdi-plus"></i> សំណើថ្មី​</button>
            <table class="table table-bordered table-striped" cellspacing="0" cellpadding="0" width="100%" border="1" id="department_dt" style="border-collapse: collapse">
                <thead>
                <tr class="" style="background: #dbebf5 !important;">
                    <th class="py-2 text-center" width="30px">{{__('ល.រ')}}</th>
                    <th class="py-2" width="120px">{{__('លេខកូដសំណាក')}}</th>
                    <th class="py-2 text-center" width="70px">{{__('ស្ថានភាព')}}</th>
                    <th class="py-2 text-center" width="70px"></th>
                </tr>
                </thead>
                <tbody>
                @foreach($samples as $k=>$sample)
                    <tr>
                        <td class="py-1 text-center">{{($k+1) + (($_GET['page'] ?? 1) * 20) - 20}}</td>
                        <td class="py-1 text-center">{{$sample->sample_number}}</td>
                        <td class="py-1 text-center">{{ $sample->progress}}</td>
                        <td class="py-1 text-center" style="font-size: 14px">
                            <a href="{{url('customer/result/'.md5($sample->lab_id).'/'.md5($sample->id))}}" class="btn btn-sm btn-info mr-1 pt-1 rounded" ><i class="mdi mdi-printer"></i></a> |
                            <a href="javascript:void(0)" onclick="cloneLabRequest('{{url('customer/clone/'.md5($sample->lab_id).'/'.md5($sample->id))}}')" class="btn btn-sm btn-inverse-warning ml-1 pt-1 rounded" >
                                <i class="mdi mdi-content-copy"></i>
                            </a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            <div class="float-right mt-3">
                {!! $samples->links('pagination.custom') !!}
            </div>
        </div>

    <!-- End modal content -->
        <div class="modal slide 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"> ជ្រើសរើសសេវាមន្ទីរពិសោធន៍ </h6>

                    <div class="col-sm-5 p-0 float-right">
                        <div class="row">
                            <div class="col-sm-3" style="font-size:19px;">
                                គ្រូពេទ្យ/Physician
                            </div>
                            <div class="col-sm-9">
                                <select class="form-control select2" id="physician_id" style="width:350px !important;">
                                    @foreach($physicians as $physician)
                                        <option {{$physician->is_default==1? 'selected':''}} value="{{$physician->id}}">{{$physician->name_en}}</option>
                                    @endforeach
                                </select>
                            </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="/*min-height: 650px*/">
                    <div class="row">
                        <div class="col-sm-10" id="test-group-slot">
                            @foreach($testGroups as $group)
                                <div class="btn-group mr-2" id="tsg-{{$group->id}}" role="group">
                                    <button onclick="useTemplate({{$group->id}})" class="btn btn-sm btn-info rounded-0" type="button"><i class="mdi mdi-checkbox-marked-outline"></i>&nbsp;{{$group->group_name}}</button>
                                </div>
                            @endforeach
                        </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 col-sm-12 border-bottom font-13 py-0">
                                    <span class="pl-5">{{__('ចំនួនតេស្តស្នើសុំ')}} : <b id="total-test">0</b></span>
                                    <span class="pl-5">{{__('ចំនួនទឹកប្រាក់')}} : <b id="total-test-payment">$ 0.00</b></span>
									<span class="pl-5">{{__('អត្រាប្តូរប្រាក់')}} : <b id="exchange_rate">{{$labSettings->exchange_rate}}</b></span>
                                </div>
                                <div class="col-lg-6 col-sm-12 text-right pt-2" style="padding-right: 5rem !important">
                                    <button type="button" class="btn btn-md btn-info mr-2 btnAssignTest" style="font-size: 20px;" id="save-assign-test" value="save_test_only"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('រក្សាទុក')}}</span></button>
                                    <button type="button" class="btn btn-md btn-light ml-2" style="font-size: 20px;" data-dismiss='modal'>{{__('បោះបង់')}}</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End modal content -->

    <div class="w3-light-gray w3-center" style="font-size: 13px; position: fixed; bottom: 0; width: 100%; padding: 10px 0;">{{$labSettings->name_kh}}</div>

    <!-- End page content -->
</div>
</body>
<script>
        let choose_option ='ជ្រើសរើស';
</script>
<script src="{{url(env("APP_URL").'storage/assets/vendors/js/vendor.bundle.base.js')}}"></script>
<script src="{{url(env("APP_URL").'storage/assets/libs/alertifyjs/build/alertify.min.js')}}"></script>
<script src="{{url(env("APP_URL").'storage/assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script src="{{url(env("APP_URL").'storage/assets/js/admin/global_funs.js')}}"></script>

<script src="{{url(env("APP_URL").'storage/assets/vendors/select2/select2.min.js')}}"></script>
<script src="{{url(env("APP_URL").'storage/assets/js/select2.js')}}"></script>

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

<script>

     var is_request_test = "{{isset($_GET['request-test'])? true : false}}";
    if(is_request_test){
            setTimeout(function() {
                $('#btn-new-test').trigger('click');
            }, 1500);

        }



    var get_test_base_url = "{{url('lab-test')}}";
    let request_sample_base_url = "{{url('lab-request')}}";
    let sample_id = 0;

    function cloneLabRequest(url){
        var success = false
        Swal.fire({
            text: 'តើអ្នកពិតជាចង់ស្នើសេវានេះម្តងទៀតមែនឬទេ?',
            icon: 'question',
            showCancelButton: true,
            cancelButtonClass:'danger btn-sm',
            confirmButtonText: 'បាទ/ចាស',
            confirmButtonClass: 'btn-sm',
            cancelButtonText: 'ទេ'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: url,
                    method:'get',
                    dataType:"JSON",
                    success:function(response){
                        handleMessage(response.success, response.message)
                        setTimeout(function () {location.reload()}, '3000')
                        success = true
                    }
                })

            }
        });
        return success
    }

    function useTemplate(group_id){
        $.ajax({
            url: get_test_base_url + '/test-group/get/'+group_id+'/{{$labSettings->id}}',
            method:'get',
            dataType:'json',
            success:function(r)
            {
                if(r.success){
                    $(".sample-type-wrapper input:checkbox").prop('checked', false);
                    const templateItems = r.data
                    var checkboxes = document.getElementsByClassName('sample-test');
                    for (var i = 0; i < checkboxes.length; i++) {
                        if(templateItems.includes(parseInt(checkboxes[i].getAttribute('value')))){
                        //if(templateItems.includes(checkboxes[i].getAttribute('value'))){
                            let sugg_id = checkboxes[i].getAttribute('value');
                            $('.st-'+sugg_id).click();
                        }
                    }
                }
            }
        })
    }

</script>

</html>
