<!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('sample-container/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-sample-container" 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" width="100px">{{__('ចំណុះ (គិតជាមីលីលីត្រ)')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($containerTypes as $k=>$containerType)
                                                        <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-container_type_id="{{$containerType->id}}" data-toggle="modal" data-target="#modal-sample-container" data-backdrop="static"><i class="typcn typcn-edit"></i></button>
                                                                    @if($containerType->record_status_id==0)
                                                                        <button type="button" class="btn btn-sm btn-inverse-primary" title="Restore"  onclick="restore_lab({{$containerType->id}})"><i class="typcn typcn-plus"></i></button>
                                                                    @else
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger " title="Delete" onclick="delete_lab({{$containerType->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$containerType->containerName->code}}</td>
                                                            <td class="py-1">{{$containerType->containerName->name}}</td>
                                                            <td class="py-1">{{$containerType->sampleType->name}}</td>
                                                            <td class="py-1">{{$containerType->additive}}</td>
                                                            <td class="py-1">{{$containerType->volume_ml}}</td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

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

                </div>
            </div>
            <!-- Modal Laboratory -->
            <div class="modal mt-5 fade modal-primary" id="modal-sample-container">
                <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="container_type_id" id="container_type_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-en">{{__('ឧបករណ៍ផ្ទុកសំណាក')}} <span class="text-danger">*</span></label>
                                                <select class="form-control select2" name="container_type_concept_id" id="container_type_concept_id" style="width: 100% !important;">
                                                    <option></option>
                                                    @foreach(collect($concepts)->where('concept_category_code', 'CONTAINER_TYPE') 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>
                                                <select class="form-control select2" name="sample_type_concept_id" id="sample_type_concept_id" style="width: 100% !important;">
                                                    <option></option>
                                                    @foreach(collect($concepts)->where('concept_category_code', 'SAMPLE_TYPE') 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-kh">{{__('សារធាតុបន្ថែម')}} <span class="text-danger"></span> </label>
                                                <input type="text" class="form-control" name="additive" id="additive" 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" name="cap_color" id="cap_color" style="width: 100% !important;">
                                                    <option></option>
                                                    <option value="Red">Red</option>
                                                    <option value="Yellow">Yellow</option>
                                                    <option value="Purple">Purple</option>
                                                    <option value="Pink">Pink</option>
                                                    <option value="Green">Green</option>
                                                    <option value="Light Green">Light Green</option>
                                                    <option value="Gray">Gray</option>
                                                    <option value="Black">Black</option>
                                                    <option value="Blue">Blue</option>
                                                    <option value="White">White</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <label for="lab-name-kh">{{__('បរិមាណ(គិតជាមីលីលីត)')}} <span class="text-danger">*</span> </label>
                                                <input type="number" class="form-control" name="volume_ml" id="volume_ml" 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="storage_temp" id="storage_temp" value="" placeholder="">
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-group mb-1">
                                                <div class="form-check col-sm-12">
                                                    <label class="form-check-label">
                                                        <input type="checkbox" class="form-check-input" name="sterile" data-id="1"> {{__('ស្ទេរីល')}}
                                                    </label>
                                                </div>
                                            </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('sample-container.save')}}";
    var update_url = "{{url('sample-container.update')}}";
    var delete_url = "{{url('sample-container.delete')}}";
    var restore_url = "{{url('sample-container.restore')}}";
    var get_url = "{{url('sample-container.get')}}";

    let modal_add_title = "Add Sample Container";
    let modal_edit_title = "Add Sample Container";

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

</html>

