<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
    <style>
        #search-area .select2-container--default .select2-selection--single, #search-area .select2-container--default .select2-selection--single .select2-search__field {
            border-radius: 0px !important;
        }
    </style>
</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 id="search-area" method="get" action="{{url('equipment/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">
                                                            <select class="form-control select2 rounded-left-0 rounded-right-0" name="concept_category_code" style="width: 250px !important;">
                                                                <option></option>
                                                                @foreach($rooms as $room)
                                                                    <option {{@$_GET['room_id']==$room->id? 'selected':''}} value="{{$room->id}}">{{$room->building->name . ' / ' . $room->name}}</option>
                                                                @endforeach
                                                            </select>
                                                            <select class="form-control rounded-left-0 rounded-right-0" name="concept_category_code" style="width: 150px !important;">
                                                                <option>Status</option>
                                                                <option>Active</option>
                                                                <option>Maintenance</option>
                                                                <option>Out of Service</option>

                                                            </select>
                                                            <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-equipment" 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">{{__('ឈ្មោះ')}}</th>
                                                        <th class="py-2">{{__('ប្រភេទ')}}</th>
                                                        <th class="py-2">{{__('ទីតាំងបន្ទប់')}}</th>
                                                        <th class="py-2">{{__('ចំណុះផ្ទុក (ប្រអប់)')}}</th>
                                                        <th class="py-2 text-center" width="100px">{{__('laboratory.table_status')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($equipments as $k=>$equipment)
                                                        <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-equipment_id="{{$equipment->id}}" data-toggle="modal" data-target="#modal-equipment" data-backdrop="static"><i class="typcn typcn-edit"></i></button>
                                                                    @if($equipment->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary" title="Restore"  onclick="restore_lab({{$equipment->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger " title="Delete" onclick="delete_lab({{$equipment->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$equipment->code}}</td>
                                                            <td class="py-1">{{$equipment->name}}</td>
                                                            <td class="py-1">{{$equipment->type->name}}</td>
                                                            <td class="py-1">{{$equipment->room->building->name . ' / ' . $equipment->room->name}}</td>
                                                            <td class="py-1">{{$equipment->capacity}}</td>
                                                            <td class="py-1 text-center">
                                                                <i class="mdi {{$equipment->status == 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">
                                            {!! $equipments->links('pagination.custom') !!}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <!-- Modal Laboratory -->
            <div class="modal mt-5 fade modal-primary" id="modal-equipment">
                <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="equipment_id" id="equipment_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">{{__('លេខកូដ')}} <span class="text-danger">*</span> </label>
                                                <input type="text" class="form-control" name="code" id="code" value="" />
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ឈ្មោះទូបង្កក')}} <span class="text-danger">*</span></label>
                                                <input type="text" class="form-control" name="name_en" id="name-en" value="" placeholder="ឈ្មោះទូបង្កក">
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ប្រភេទ')}} <span class="text-danger">*</span></label>
                                                <select class="form-control select2" name="equipment_type_concept_id" id="equipment_type_concept_id" style="width: 100% !important;">
                                                    <option></option>
                                                    @foreach(collect($concepts)->where('concept_category_code', 'EQUIPMENT') as $concept)
                                                        <option value="{{$concept->id}}">{{$concept->name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ម៉ាកយីហោ')}} <span class="text-danger"></span></label>
                                                <input type="text" class="form-control" name="model" id="model" value="">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('លេខស៊េរី')}} <span class="text-danger"></span></label>
                                                <input type="text" class="form-control" name="serial_number" id="serial_number" value="">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ចំណុះផ្ទុក(គិតជាប្រអប់)')}} <span class="text-danger">*</span></label>
                                                <input type="number" class="form-control" name="capacity" id="capacity" value="" placeholder="">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('កម្រិតស៊ីតុណ្ហភាពទាបបំផុត')}} <span class="text-danger">*</span></label>
                                                <input type="number" class="form-control" name="min_temperature" id="min_temperature" value="" placeholder="-80">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('កម្រិតស៊ីតុណ្ហភាពខ្ពស់បំផុត')}} <span class="text-danger">*</span></label>
                                                <input type="number" class="form-control" name="max_temperature" id="max_temperature" value="" placeholder="-70">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ថ្ងៃចាប់ផ្តើមដំណើរការ')}} <span class="text-danger">*</span></label>
                                                <input type="date" class="form-control" name="installed_date" id="installed_date" value="">
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-en">{{__('ទីតាំងបន្ទប់')}} <span class="text-danger">*</span></label>
                                                <select class="form-control select2" name="room_id" id="room_id" style="width: 100% !important;">
                                                    <option></option>
                                                    @foreach($rooms as $room)
                                                        <option value="{{$room->id}}">{{$room->building->name. ' / ' . $room->name}}</option>
                                                    @endforeach
                                                </select>
                                            </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('equipment.save')}}";
    var update_url = "{{url('equipment.update')}}";
    var delete_url = "{{url('equipment.delete')}}";
    var restore_url = "{{url('equipment.restore')}}";
    var get_url = "{{url('equipment.get')}}";

    let modal_add_title = "Add Equipment";
    let modal_edit_title = "Add Equipment";

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

</html>

