<!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">{{__('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" 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->code}}</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="organization_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-kh">{{__('laboratory.table_name_kh')}} <span class="text-danger">*</span> </label>
                                                <input type="text" class="form-control form-control-sm" name="name_kh" id="lab-name-kh" value="" placeholder="{{__('laboratory.table_name_kh')}}"/>
                                            </div>
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('laboratory.table_name_en')}} <span class="text-danger">*</span></label>

                                                <div class="input-group" id="testItem">
                                                    <div class="form-group" style="flex:1 !important;">
                                                        <input type="text" class="form-control form-control-sm rounded-right-0" name="name_en" id="lab-name-en" value="" placeholder="{{__('laboratory.table_name_en')}}">
                                                    </div>
                                                    <div class="input-group-append">
                                                        <input type="text" class="form-control form-control-sm rounded-left-0" style="width: 100px !important;" name="code" id="lab-code" value="" maxlength="10" placeholder="{{__('lab_profile.short_name')}}">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-sm-6">

                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('laboratory.phone')}} </label>
                                                <input type="text" class="form-control form-control-sm" name="phone_number" id="phone-number" value="" placeholder="{{__('laboratory.phone')}}"/>
                                            </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" value="" placeholder="{{__('lab_profile.emial')}}"/>
                                            </div>

                                        </div>

                                        <div class="col-sm-12">

                                            <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" value="" placeholder="{{__('laboratory.form_address_kh')}}">
                                                </div>
                                            </div>

                                            <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" value="" placeholder="{{__('laboratory.form_address_en')}}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-inverse-success rounded-25" 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-secondary  rounded-25 ml-2" 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>

