<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
    <link href="{{url(env("APP_URL").'storage/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css')}}" rel="stylesheet" type="text/css" />
    <style>
        .datepicker{
            border-radius: 0px !important;
            padding: 0.875rem 1.375rem !important;
        }
        .patient-sample-mark-color {
            display: inline-block;
            margin-right: 5px;
            width: 15px;
            height: 15px;
            border: 1px solid #f8f8f8;
        }

    </style>

</head>
<body>


<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 mdi-dots-vertical menu-icon"></i> {{__('sample.table_title')}}</h4>

                                <div class="row">
                                    <div class="col-sm-12">
                                        <form method="get" action="{{url('sample/search')}}">
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-9">
                                                    <div class="input-group">

                                                        <input type="text" class="form-control rounded-top-left-25 rounded-bottom-left-25 rounded-right-0" value="{{isset($_GET['kword']) ? $_GET['kword'] : ''}}" name="kword" id="kword" placeholder="{{__('sample.search_placeholder')}}">
                                                        <input id="start-invoice-date" value="{{isset($_GET['sample_date']) ? $_GET['sample_date']  : ''}}" name="sample_date" class="form-control rounded-0 rounded-right-0 rounded-left-0" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="mm/dd/yyyy" type="text">
                                                        <button class="btn btn-sm btn-inverse-secondary rounded-0 px-3" type="submit"><i class="fa fa-search"></i> {{__('general.btn_search')}} </button>
                                                        <a class="btn btn-sm btn-inverse-secondary rounded-0 px-3 pt-3"  href="{{url('sample/search/?kword=&view=all')}}" class="btn {{(!isset($_GET['sample_status']) && !isset($_GET['sample_date']) ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0  ml-4 preview-item-content"></span>{{__('sample.filter_all')}}</a>
                                                        <button class="btn btn-sm btn-inverse-secondary dropdown show pl-0 ml-0 rounded-left-0 rounded-top-right-25 rounded-bottom-right-25" type="button">
                                                            <span style="padding-left: 9px !important; padding-right: 9px !important;" class="count-indicator dropdown-toggle d-flex justify-content-center align-items-center rounded-0 px-5" data-toggle="dropdown" aria-expanded="true">
                                                                {{__('sample.sample_status')}}
                                                            </span>
                                                            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list rounded" aria-labelledby="messageDropdown">
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&view=all')}}" class="btn {{(!isset($_GET['sample_status']) && !isset($_GET['sample_date']) ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0  ml-4 preview-item-content"></span>{{__('sample.filter_all')}}</a>
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&sample_status=5')}}" class="btn {{(isset($_GET['sample_status']) && $_GET['sample_status']==5 ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0"><span class='patient-sample-mark-color "preview-item-content' style='border: 2px solid #f9a50b; border-radius: 6px; '></span> {{__('sample.filter_rejected')}}</a>
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&sample_status=1')}}" class="btn {{(isset($_GET['sample_status']) && $_GET['sample_status']==1 ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0"><span class='patient-sample-mark-color "preview-item-content' style='border: 2px solid red; border-radius: 6px; '></span> {{__('sample.filter_pending')}}</a>
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&sample_status=2')}}" class="btn {{(isset($_GET['sample_status']) && $_GET['sample_status']==2 ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0"><span class='patient-sample-mark-color "preview-item-content' style='border: 2px solid yellow; border-radius: 6px; '></span> {{__('sample.filter_processing')}}</a>
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&sample_status=3')}}" class="btn {{(isset($_GET['sample_status']) && $_GET['sample_status']==3 ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0"><span class='patient-sample-mark-color "preview-item-content' style='border: 2px solid #0faf0f; border-radius: 6px; '></span> {{__('sample.filter_completed')}}</a>
                                                                <a class="dropdown-item preview-item py-2"  href="{{url('sample/search/?kword=&sample_status=4')}}" class="btn {{(isset($_GET['sample_status']) && $_GET['sample_status']==4 ? 'active':'')}} btn-sm btn-light pt-md-3 rounded-0"><span class='patient-sample-mark-color "preview-item-content' style='border: 2px solid #1e88e5; border-radius: 6px; '></span> {{__('sample.filter_printed')}}</a>
                                                            </div>
                                                        </button>

                                                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_sample']))
                                                            <a class="btn btn-sm btn-inverse-success rounded-25 waves-effect pt-3 ml-3 px-3" href="{{url('sample/new')}}"><i class="typcn typcn-plus"></i> {{__('general.btn_add_new')}} </a>
                                                        @endif
                                                        <div class="input-group-append">

                                                        </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-hover" id="department_dt">
                                                    <thead>
                                                    <tr class="bg-gradient-light">
                                                        <th class="py-2 px-1 text-center" width="">{{__('sample.table_no')}}</th>
                                                        <th class="py-2  px-1 text-center" width="">{{__('sample.table_action')}}</th>
                                                        <th class="py-2  px-1" width="">{{__('sample.table_patient_name')}}</th>
                                                        <th class="py-2  px-1 text-right" width="">{{__('patient.form_age')}}</th>
                                                        <th class="py-2  px-1 text-center" width="">{{__('patient.table_sex')}}</th>
                                                        <th class="py-2  px-1" width="">{{__('patient.table_phon')}}</th>
														<th class="py-2  px-1" width="">{{__('ប្រភពសំណាក')}}</th>
{{--                                                        <th class="py-2  px-1" width="">{{__('sample.physician_name')}}</th>--}}
                                                        <th class="py-2  px-1" width="">{{__('sample.table_sample_number')}}</th>
                                                        <th class="py-2  px-1" width="">{{__('sample.table_patient_code')}}</th>
                                                        <th class="py-2  px-1 text-center" width="">{{__('sample.table_collected_date')}}</th>
                                                        <th class="py-2  px-1 text-center" width="">{{__('sample.table_status')}}</th>
{{--                                                    <th class="py-2  px-1 text-center" width="">{{__('sample.table_action')}}</th>--}}
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($samples as $k=>$sample)
                                                        <tr>
                                                            <td class="py-1 px-1 text-center">{{($k+1) + (($_GET['page'] ?? 1) * 20) - 20}}</td>
                                                            <td class="py-1 px-1 text-center">
                                                                <div class="btn-group" role="group" aria-label="Basic example" >
                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['add_result','update_result']))
                                                                        <a href="{{url('sample/edit/'.$sample->id.'?add-result')}}" class="btn btn-sm btn-inverse-success mr-2 py-1" title="{{__('sample.form_btn_add_result')}}">
                                                                            <i class="mdi mdi-table-plus"></i>
                                                                        </a>
                                                                    @endif
                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_sample']))
                                                                        <a href="{{url('sample/edit/'.$sample->id)}}" class="btn btn-sm btn-inverse-info mr-2 py-1" title="{{__('general.btn_edit')}}"><i class="typcn typcn-edit"></i></a>
                                                                    @endif
                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['view_result']))
                                                                        <a href="{{url('sample/edit/'.$sample->id.'?print-result')}}" class="btn btn-sm btn-inverse-warning mr-2 py-1" title="{{__('sample.btn_print')}}">
                                                                            <i class="mdi mdi-printer"></i>
                                                                        </a>
                                                                    @endif
                                                                    @if($sample->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary " onclick="restoreSample({{$sample->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['delete_sample']))
                                                                            <button type="button" class="btn btn-sm btn-inverse-danger py-1" title="{{__('general.btn_delete')}}" onclick="deleteSample({{$sample->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                        @endif
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1 px-1">{{$sample->patient->name_en}}</td>
                                                            <td class="py-2 px-1 text-right">{{\App\Helpers\Helpers::getAge($sample->patient->dob, date('d-m-Y h:i A',strtotime($sample->collected_date)))}}</td>
                                                            <td class="py-1 px-1 text-center">{{$sample->patient->gender == 1 ? 'M' : 'F'}}</td>
                                                            <td class="py-1 px-1 text-left">{{$sample->patient->phone_number}}</td>
															<td class="py-1 px-1 text-left">{{@$sample->sample_source->name_en}}</td>
{{--                                                            <td class="py-1 px-1 text-left">{{@$sample->physician->name_en}}</td>--}}
                                                            <td class="py-1 px-1">{{$sample->sample_number}}</td>
                                                            <td class="py-1 px-1">{{$sample->patient->patient_uuid}}</td>
                                                            <td class="py-1 px-1 text-center">{{date('d-m-Y h:i A',strtotime($sample->collected_date))}}</td>
                                                            <td class="py-1 px-1 text-right">
                                                                <label class="badge badge-outline-info rounded-25" style="border-color: {{$sample->state}}; color: {{$sample->state}};">
                                                                    {{$sample->progress}}
                                                                </label>
{{--                                                                <input type="color" disabled readonly value="{{ $sample->state}}" style="border: none !important;  outline: none; width: 25px !important;">--}}
                                                            </td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

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

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

            @include('layout.footer')
        </div>
    </div>
</div>
@include('layout.common_script')


<script>

    $("#routine-sample-type").select2({
        minimumResultsForSearch: -1,
        templateResult: function (state) {
            if (!state.id) return state.text;
            var formatState = "<span>";
            formatState += "<span class='patient-sample-mark-color' style='background-color: "+ $(state.element).data("color") +"'></span>";
            formatState += state.text;
            formatState += "</span>";
            return $(formatState);
        }
    });

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

</html>

