

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
    <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
</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> {{__('laboratory.info')}}
                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                    <button class="btn btn-sm btn-inverse-success waves-effect px-3 ml-2 rounded-25 float-right" type="button" data-action="new" data-toggle="modal" data-target="#modal-laboratory" data-backdrop="static"><i class="typcn typcn-pencil"></i> {{__('laboratory.form_edit_tittle')}}</button>
                                    @endif
                                </h4>

                                <div class="row px-3">
                                    <div class="col-lg-12 pr-4 border rounded-lg pt-3 pl-4 mt-2  bg-light">
                                        <h6 class="text-info">{{__('laboratory.info')}}</h6>
                                        <div class="py-2">
                                            <div class="row font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('laboratory.table_name_kh')}}</span>
                                                <span class="text-muted col-sm-10">{{$info->name_kh}}</span>
                                            </div>
                                            <div class="row  font-14  py-1">
                                                <span class="float-left col-sm-2">{{__('laboratory.table_name_en')}}</span>
                                                <span class="text-muted col-sm-10">{{$info->name_en}}</span>
                                            </div>
                                            <div class="row  font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('lab_profile.short_name')}}</span>
                                                <span class=" text-muted col-sm-10">{{$info->code}}</span>
                                            </div>
                                            <div class="row  font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('laboratory.phone')}}</span>
                                                <span class=" text-muted col-sm-10">{{$info->phone}}</span>
                                            </div>
                                            <div class="row  font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('lab_profile.emial')}}</span>
                                                <span class=" text-muted col-sm-10">{{$info->email}}</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-12 pr-4 border rounded-lg pt-3 pl-4 mt-3 bg-light">
                                        <h6 class="text-info">{{__('lab_profile.address')}}</h6>
                                        <div class="py-2">
                                            <div class="row font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('laboratory.form_address_kh')}}</span>
                                                <span class="text-muted col-sm-10">{{$info->address_kh}}</span>
                                            </div>
                                            <div class="row  font-14 py-1">
                                                <span class="float-left col-sm-2">{{__('laboratory.form_address_en')}}</span>
                                                <span class="text-muted col-sm-10">{{$info->address_en}}</span>
                                            </div>
                                        </div>
                                    </div>

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

                </div>
            </div>

            </div>

            <div class="modal mt-5 fade modal-primary" id="modal-laboratory">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h6 class="modal-title">{{__('laboratory.form_edit_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">
                            <form method="post" action="{{url('laboratory-profile/update')}}" 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="{{$info->name_kh}}" 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="{{$info->name_en}}" 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="{{$info->code}}" 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" id="phone-number" value="{{$info->phone}}" 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="{{$info->email}}" 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="{{$info->address_kh}}" 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="{{$info->address_en}}" placeholder="{{__('laboratory.form_address_en')}}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <button type="submit" class="d-none" id="submit-data"></button>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-inverse-success rounded-25" onclick="$('#submit-data').click()" 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 mx-3" data-dismiss='modal'>{{__('lang.cancel')}}</button>
                        </div>
                    </div>
                </div>
            </div>

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

@include('layout.common_script')

</body>

<script src="{{url(env("APP_URL").'storage/assets/vendors/js/org.vendor.bundle.base.js')}}"></script>

<script>

    let base_url = "{{url('laboratory-profile')}}";

    let phone = "{{$info->phone_number}}";
    let email = "{{$info->email}}";

    function generateSlug(text) {
        return text
            .trim()
            .split(/\s+/)
            .slice(0, 4)
            .map(word => word[0])
            .join('')
            .toUpperCase().padEnd(4, 'X');
    }

        document.getElementById('lab-name-en').addEventListener('input', function () {
        document.getElementById('lab-code').value = generateSlug(this.value);
    });



</script>

</html>

