<!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 mdi-dots-vertical menu-icon"></i> ប្រភេទឧប្បត្តិហេតុ</h4>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <form method="get" action="{{url('incident-type/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-incident-type" 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" width="120px">{{__('general.code')}}</th>
                                                        <th class="py-2">{{__('laboratory.table_name_kh')}}</th>
                                                        <th class="py-2">{{__('laboratory.table_name_en')}}</th>
                                                        <th class="py-2" width="300px">{{__('បរិយាយ')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($incidentTypes as $k=>$incidentType)
                                                        <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-incident_type_id="{{$incidentType->id}}" data-toggle="modal" data-target="#modal-incident-type" data-backdrop="static"><i class="typcn typcn-edit"></i></button>
                                                                    @if($incidentType->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary" title="Restore"  onclick="restore_lab({{$incidentType->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger " title="Delete" onclick="delete_lab({{$incidentType->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$incidentType->code}}</td>
                                                            <td class="py-1">{{$incidentType->name_kh}}</td>
                                                            <td class="py-1">{{$incidentType->name_en}}</td>
                                                            <td class="py-1">
                                                                {{$incidentType->description}}
                                                            </td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

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

                </div>
            </div>
            <!-- Modal Laboratory -->
            <div class="modal mt-5 fade modal-primary" id="modal-incident-type">
                <div class="modal-dialog modal-lg">
                    <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="incident_type_id" id="incident_type_id" value="0" />
                                <div class="form-vertical">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('លេខកូដ')}} <span class="text-danger"></span> </label>
                                                <input type="text" class="form-control form-control-sm" name="code" id="code" value="" />
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <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="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>
                                                <input type="text" class="form-control form-control-sm rounded-right-0" name="name_en" id="name-en" value="" placeholder="{{__('laboratory.table_name_en')}}">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('បរិយាយ')}} </label>
                                                <textarea class="form-control" name="description" id="description"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-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_url = "{{url('incident-type.save')}}";
    var update_url = "{{url('incident-type.update')}}";
    var delete_url = "{{url('incident-type.delete')}}";
    var restore_url = "{{url('incident-type.restore')}}";
    var get_url = "{{url('incident-type.get')}}";

    let modal_add_title = "Add Incident Type";
    let modal_edit_title = "Add Incident Type";

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

</html>

