<!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">
                            <div class="card-body">
                                <h4 class="card-title"><i class="mdi mdi-dots-vertical menu-icon"></i> {{__('patient_type.table_title')}}</h4>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <form method="get" action="{{url('patient-type/search')}}">
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                                                    <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="{{__('patient_type.search_placeholder')}}">
                                                        <div class="input-group-append">
                                                            <button class="btn btn-inverse-secondary px-3 rounded-top-right-25 rounded-bottom-right-25" type="submit"><i class="fa fa-search"></i> {{__('general.btn_search')}}</button>
                                                            @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_patient_type']))
                                                            <button class="btn btn-inverse-success waves-effect px-3 ml-2 rounded-25" type="button" data-action="new" data-toggle="modal" data-target="#modal-patient-type" data-backdrop="static"><i class="typcn typcn-plus"></i> {{__('general.btn_add_new')}}</button>
                                                            @endif
                                                        </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="patient-type-dt">
                                                    <thead>
                                                    <tr class="bg-gradient-light">
                                                        <th class="py-2" width="50px">{{__('patient_type.table_no')}}</th>
                                                        <th class="py-2 text-center" width="100px">{{__('patient_type.table_action')}}</th>
                                                        <th class="py-2">{{__('patient_type.table_name')}}</th>
                                                        <th class="py-2" width="200px">{{__('patient_type.table_gender')}}</th>
                                                        <th class="py-2">{{__('patient_type.table_age_from')}}</th>
                                                        <th class="py-2">{{__('patient_type.table_age_to')}}</th>
{{--                                                        <th class="py-2 text-center" width="100px">{{__('patient_type.table_status')}}</th>--}}
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($patientTypes as $k=>$patientType)
                                                        <tr>
                                                            <td class="py-1 text-center">{{($k+1) + (($_GET['page'] ?? 1) * 20) - 20}}</td>
                                                            <td class="py-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, ['update_patient_type']))
                                                                    <button type="button" class="btn btn-sm btn-inverse-info mr-2 py-1" title="{{__('general.btn_edit')}}" data-action="edit" data-uid="{{$patientType->id}}" data-toggle="modal" data-target="#modal-patient-type" data-backdrop="static">
                                                                        <i class="typcn typcn-edit"></i>
                                                                    </button>
                                                                    @endif
                                                                    @if($patientType->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary " title="Restore"  onclick="restore_data({{$patientType->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['delete_patient_type']))
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger py-1" title="{{__('general.btn_delete')}}" onclick="delete_data({{$patientType->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                        @endif
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$patientType->name_en}}</td>
                                                            <td class="py-1">{{($patientType->gender == 1 ? 'Male' : ($patientType->gender == 2 ? 'Female' : 'Male & Female'))}}</td>
                                                            <td class="py-1">{{$patientType->range_start_sign . ' ' . $patientType->range_start . ($patientType->range_start_unit == 1 ? ' Day(s)' : ($patientType->range_start_unit == 30 ? ' Month(s)' : ' Year(s)'))}}</td>
                                                            <td class="py-1">{{$patientType->range_end_sign . ' ' . $patientType->range_end . ($patientType->range_end_unit == 1 ? ' Day(s)' : ($patientType->range_end_unit == 30 ? ' Month(s)' : ' Year(s)'))}}</td>
{{--                                                            <td class="py-1 text-center">--}}
{{--                                                                <i class="mdi {{$patientType->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">
                                            {!! $patientTypes->links('pagination.custom') !!}
                                        </div>

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

                </div>
            </div>

            <!-- Modal Laboratory -->
            <div class="modal fade modal-primary" id="modal-patient-type">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h6 class="modal-title new">{{__('patient_type.form_add_tittle')}}</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" style="padding: 1.7rem !important;">
                            <form method="post" action="#" id="form" onkeydown="return event.key != 'Enter';">
                                @csrf
                                <input type="hidden" class="form-control" name="uid" id="data-id" value="0" />
                                <div class="form-vertical">
                                    <div class="form-group mb-1">
                                        <label for="name-en">{{__('patient_type.form_name')}} <span class="text-danger">*</span></label>
                                        <input type="text" class="form-control " name="name_en" id="name-en" />
                                    </div>
                                    <div class="form-group mb-1">
                                        <label for="lab-name-en">{{__('patient_type.table_gender')}} <span class="text-danger">*</span></label>
                                        <div class="form-group pl-2">
                                            <div class="row">
                                                <div class="form-check col-sm-12 col-md-12 col-lg-3">
                                                    <label class="form-check-label">
                                                        <input type="radio" class="form-check-input" name="gender" data-id="1" value="1"> {{__('patient.form_sex_male')}}
                                                    </label>
                                                </div>
                                                <div class="form-check col-sm-12 col-md-12 col-lg-3">
                                                    <label class="form-check-label">
                                                        <input type="radio" class="form-check-input" name="gender" data-id="2" value="2"> {{__('patient.form_sex_female')}}
                                                    </label>
                                                </div>
                                                <div class="form-check col-sm-12 col-md-12 col-lg-3">
                                                    <label class="form-check-label">
                                                        <input type="radio" class="form-check-input" name="gender" data-id="3" value="3"> {{__('patient.form_sex_male')}} & {{__('patient.form_sex_female')}}
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group mb-1">
                                        <div class="row">
                                            <div class="col-sm-12 col-md-12 col-lg-12">
                                                <div class="form-group mb-1">
                                                    <label for="lab-name-kh">{{__('patient_type.form_min_age')}} <span class="text-danger">*</span></label>
                                                    <div class="input-group">
                                                        <div class="input-group-append">
                                                            <select class="form-control rounded-right-0" name="age_from_sign" id="age-from-sign" style="width: 90px; border-right: none !important;">
                                                                <option value=">">></option>
                                                                <option value=">=">>=</option>
                                                            </select>
                                                        </div>
                                                        <input type="number" class="form-control rounded-left-0 rounded-right-0" value="0" min="0" name="age_from" id="age-from" />
                                                        <div class="input-group-append">
                                                            <select class="form-control rounded-left-0" name="age_from_unit" id="age-from-unit">
                                                                <option value="1">{{__('patient_type.form_input_day')}}</option>
                                                                <option value="30">{{__('patient_type.form_input_month')}}</option>
                                                                <option value="365">{{__('patient_type.form_input_year')}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-12 col-md-12 col-lg-12">
                                                <div class="form-group mb-1">
                                                    <label for="lab-name-kh">{{__('patient_type.form_max_age')}} <span class="text-danger">*</span></label>
                                                    <div class="input-group">
                                                        <div class="input-group-append">
                                                            <select class="form-control rounded-right-0 border-right-0" name="age_to_sign" id="age-to-sign" style="width: 90px; border-right: none !important;">
                                                                <option value="<"><</option>
                                                                <option value="<="><=</option>
                                                            </select>
                                                        </div>
                                                        <input type="number" class="form-control rounded-left-0 rounded-right-0" value="0" min="0" name="age_to" id="age-to" />
                                                        <div class="input-group-append">
                                                            <select class="form-control rounded-left-0" name="age_to_unit" id="age-to-unit">
                                                                <option value="1">{{__('patient_type.form_input_day')}}</option>
                                                                <option value="30">{{__('patient_type.form_input_month')}}</option>
                                                                <option value="365">{{__('patient_type.form_input_year')}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-info rounded-25" id="btnSave"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('general.btn_save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                            <button type="button" class="btn btn-secondary rounded-25 mx-3" data-dismiss='modal'>{{__('general.btn_cancel')}}</button>
                        </div>
                    </div>
                </div>
            </div>

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

<script>

    var save_url = "{{url('patient-type.save')}}";
    var update_url = "{{url('patient-type.update')}}";
    var delete_url = "{{url('patient-type.delete')}}";
    var restore_url = "{{url('patient-type.restore')}}";
    var get_url = "{{url('patient-type.get')}}";

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

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

</html>

