

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
    <style>
        .item-config {
            background: #feffff;
            border-radius: 8px;
            border: 1px solid #e1edfc;
        }
    </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">
                            <div class="card-body">
                                <h4 class="card-title"><i class="mdi mdi-dots-vertical menu-icon"></i> {{__('general.laboratory_settings')}}</h4>

                                <div class="col-sm-12">
                                    <h6 class="text-muted"><span class="mdi mdi-square-rounded text-muted"></span> {{__('general.general_settings')}}</h6>
                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.sample_numner_conf')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.sample-number-mode-setter','.sample-number-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="sample-number-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$info->sample_number==0? __('lab_profile.manual') :__('lab_profile.system_generate')}}</label>
                                                </div>
                                                <div class="sample-number-mode-setter" style="display: none">
                                                    <div class="form-check col-sm-9">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->sample_number==0? 'checked':''}} data-id="0" name="sample_number"> {{__('lab_profile.manual')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-9">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->sample_number==1? 'checked':''}} data-id="1" name="sample_number"> {{__('lab_profile.system_generate')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <button class="btn btn-xs btn-inverse-info rounded-25 px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.patient_numner_conf')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.patient-number-mode-setter','.patient-number-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="patient-number-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$info->patient_code==0? __('lab_profile.manual'):__('lab_profile.system_generate')}}</label>
                                                </div>
                                                <div class="patient-number-mode-setter" style="display: none">
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->patient_code==0? 'checked':''}} data-id="0" name="patient_number"> {{__('lab_profile.manual')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->patient_code==1? 'checked':''}} data-id="1" name="patient_number"> {{__('lab_profile.system_generate')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <button class="btn btn-xs btn-inverse-info rounded-25 px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.based_currency')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.base-currency-mode-setter','.base-currency-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="base-currency-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$info->currency==0? __('USD ($)') :__('Riel (៛)')}}</label>
                                                </div>
                                                <div class="base-currency-mode-setter" style="display: none">
                                                    <div class="form-check col-sm-3">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->currency==0? 'checked':''}} data-id="0" name="currency"> {{__('USD ($)')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-9">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->currency==1? 'checked':''}} data-id="1" name="currency"> {{__('Riel (៛)')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <button class="btn btn-xs btn-inverse-info rounded-25 px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.type_of_discount_conf')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.discount-type-setter','.discount-type-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="discount-type-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$info->discount_type == 1 ? '(%) '.__('lab_profile.percentage'):'($) '.__('lab_profile.price')}}</label>
                                                </div>
                                                <div class="discount-type-setter" style="display: none">
                                                    <div class="form-check col-sm-3">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->discount_type==1? 'checked':''}} data-id="1" name="discount_type"> (%) {{__('lab_profile.percentage')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-9">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->discount_type==2? 'checked':''}} data-id="2" name="discount_type"> ($) {{__('lab_profile.price')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <button class="btn btn-xs btn-inverse-info rounded-25 px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.exchange_rate')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.exchange-rate-setter','.exchange-rate-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="exchange-rate-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">1 USD = {{$info->exchange_rate}} </label>
                                                </div>
                                                <div class="exchange-rate-setter" style="display: none">
                                                    <div class="input-group">
                                                        <input type="number" class="form-control rounded-right-0 form-control-sm" id="exchange-rate" value="{{$info->exchange_rate}}" placeholder="{{__('Exchange Rate')}}">
                                                        <div class="input-group-append">
                                                            <button class="btn btn-xs btn-inverse-info px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('sidebar.invoice')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.invoice-template-mode-setter','.invoice-template-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="invoice-template-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25"> {{$info->is_auto_make_invoice==0? __('lab_profile.manual'):__('lab_profile.system_generate')}}</label>

                                                    <label class="badge badge-outline-secondary rounded-25"> {{$info->invoice_template_id==1? __('lab_profile.invoice_detail'): ($info->invoice_template_id==2 ? __('lab_profile.invoice_summary') : ($info->invoice_template_id==3 ? __('lab_profile.detail_with_panel') : ''))}}</label>
                                                </div>
                                                <div class="invoice-template-mode-setter" style="display: none">
                                                    <p class="text-muted">{{__('invoice.form_btn_generate_invoice')}}</p>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->is_auto_make_invoice==0? 'checked':''}} data-id="0" name="is_auto_make_invoice"> {{__('lab_profile.manual')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->is_auto_make_invoice==1? 'checked':''}} data-id="1" name="is_auto_make_invoice"> {{__('lab_profile.system_generate')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>

                                                    <p class="text-muted">{{__('lab_profile.invoice_template')}}</p>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->invoice_template_id==1? 'checked':''}} data-id="1" name="invoice_template_id"> {{__('lab_profile.invoice_detail')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->invoice_template_id==3? 'checked':''}} data-id="3" name="invoice_template_id"> {{__('lab_profile.detail_with_panel')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>
                                                    <div class="form-check col-sm-12">
                                                        <label class="form-check-label">
                                                            <input type="radio" class="form-check-input" {{$info->invoice_template_id==2? 'checked':''}} data-id="2" name="invoice_template_id"> {{__('lab_profile.invoice_summary')}}
                                                            <i class="input-helper"></i></label>
                                                    </div>

                                                    <button class="btn btn-xs btn-inverse-info rounded-25 px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabSettingSetter()"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}} </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <h6 class="mt-3 text-muted"><span class="mdi mdi-square-rounded text-muted"></span> {{__('general.result_settings')}}</h6>

                                    @php
                                        $configures = collect($info->labConfigures);

                                        $fontNameHeader =  ($configures->where('atrribute_code', 'FONT_NAME_FOR_RESULT_HEADER')->pluck('assigned_attribute_value')->first());
                                        $fontSizeHeader =  ($configures->where('atrribute_code', 'FONT_SIZE_FOR_RESULT_HEADER')->pluck('assigned_attribute_value')->first());
                                        $resultColorHeader = ($configures->where('atrribute_code', 'COLOR_FOR_RESULT_HEADER')->pluck('assigned_attribute_value')->first());

                                        $fontName =  ($configures->where('atrribute_code', 'FONT_NAME_FOR_RESULT')->pluck('assigned_attribute_value')->first());
                                        $fontSize =  ($configures->where('atrribute_code', 'FONT_SIZE_FOR_RESULT')->pluck('assigned_attribute_value')->first());
                                        $resultColor = ($configures->where('atrribute_code', 'COLOR_FOR_RESULT')->pluck('assigned_attribute_value')->first());
                                        $lineHeight = ($configures->where('atrribute_code', 'LINE_HEIGHT_FOR_RESULT_HEADER')->pluck('assigned_attribute_value')->first());

                                        $resultTemplateId = ($configures->where('atrribute_code', 'RESULT_TEMPLATE')->pluck('assigned_attribute_value')->first());

                                    @endphp

                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.header_font_name')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.header-font-name-mode-setter','.header-font-name-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="header-font-name-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$fontNameHeader}}</label>
                                                </div>
                                                <div class="header-font-name-mode-setter" style="display: none">
                                                    <div class="input-group ml-1">
                                                        <select class="form-control form-control-sm rounded-right-0" id="result-font-name-header">
                                                            <option {{$fontNameHeader=='Times New Roman'?'selected' : ''}} value="Times New Roman">Times New Roman</option>
                                                            <option {{$fontNameHeader=='Nimbus Mono'?'selected' : ''}} value="Nimbus Mono">Nimbus Mono</option>
                                                            <option {{$fontNameHeader=='Calibri'?'selected' : ''}} value="Calibri">Calibri</option>
                                                            <option {{$fontNameHeader=='Courier New'?'selected' : ''}} value="Courier New">Courier New</option>
                                                        </select>
                                                        <div class="input-group-append">
                                                            <button class="btn btn-xs btn-inverse-info px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabConfigure('FONT_NAME_FOR_RESULT_HEADER', $('#result-font-name-header').val())"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.header_font_size')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.header-font-size-mode-setter','.header-font-size-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="header-font-size-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$fontSizeHeader}}</label>
                                                </div>
                                                <div class="header-font-size-mode-setter" style="display: none">
                                                    <div class="input-group ml-1">
                                                        <select class="form-control form-control-sm rounded-right-0" id="result-font-size-header">
                                                            <option {{$fontSizeHeader=='8.5pt' ? 'selected':''}} value="8.5pt">8.5pt</option>
                                                            <option {{$fontSizeHeader=='9pt' ? 'selected':''}} value="9pt">9pt</option>
                                                            <option {{$fontSizeHeader=='10pt' ? 'selected':''}} value="10pt">10pt</option>
                                                            <option {{$fontSizeHeader=='11pt' ? 'selected':''}} value="11pt">11pt</option>
                                                            <option {{$fontSizeHeader=='12pt' ? 'selected':''}} value="12pt">12pt</option>
                                                            <option {{$fontSizeHeader=='13pt' ? 'selected':''}} value="13pt">13pt</option>
                                                            <option {{$fontSizeHeader=='14pt' ? 'selected':''}} value="14pt">14pt</option>
                                                            <option {{$fontSizeHeader=='15pt' ? 'selected':''}} value="15pt">15pt</option>
                                                        </select>
                                                        <div class="input-group-append">
                                                            <button class="btn btn-xs btn-inverse-info px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabConfigure('FONT_SIZE_FOR_RESULT_HEADER', $('#result-font-size-header').val())"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.body_font_name')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.body-font-name-mode-setter','.body-font-name-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="body-font-name-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$fontName}}</label>
                                                </div>
                                                <div class="body-font-name-mode-setter" style="display: none">
                                                    <div class="input-group ml-1">
                                                        <select class="form-control form-control-sm rounded-right-0" id="result-font-name">
                                                            <option {{$fontName=='Times New Roman'?'selected' : ''}} value="Times New Roman">Times New Roman</option>
                                                            <option {{$fontName=='Nimbus Mono'?'selected' : ''}} value="Nimbus Mono">Nimbus Mono</option>
                                                            <option {{$fontName=='Calibri'?'selected' : ''}} value="Calibri">Calibri</option>
                                                            <option {{$fontName=='Courier New'?'selected' : ''}} value="Courier New">Courier New</option>
                                                        </select>
                                                        <div class="input-group-append">
                                                            <button class="btn btn-xs btn-inverse-info px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabConfigure('FONT_NAME_FOR_RESULT', $('#result-font-name').val())"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.body_font_size')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.body-font-size-mode-setter','.body-font-size-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="body-font-size-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$fontSize}}</label>
                                                </div>
                                                <div class="body-font-size-mode-setter" style="display: none">
                                                    <div class="input-group ml-1">
                                                        <select class="form-control form-control-sm rounded-right-0" id="result-font-size">
                                                            <option {{$fontSize=='8.5pt' ? 'selected':''}} value="8.5pt">8.5pt</option>
                                                            <option {{$fontSize=='9pt' ? 'selected':''}} value="9pt">9pt</option>
                                                            <option {{$fontSize=='10pt' ? 'selected':''}} value="10pt">10pt</option>
                                                            <option {{$fontSize=='11pt' ? 'selected':''}} value="11pt">11pt</option>
                                                            <option {{$fontSize=='12pt' ? 'selected':''}} value="12pt">12pt</option>
                                                            <option {{$fontSize=='13pt' ? 'selected':''}} value="13pt">13pt</option>
                                                            <option {{$fontSize=='14pt' ? 'selected':''}} value="14pt">14pt</option>
                                                            <option {{$fontSize=='15pt' ? 'selected':''}} value="15pt">15pt</option>
                                                        </select>
                                                        <div class="input-group-append">
                                                            <button class="btn btn-xs btn-inverse-info px-3" type="button" style="font-size: 12px; padding: 5px" onclick="postLabConfigure('FONT_SIZE_FOR_RESULT', $('#result-font-size').val())"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.abnormal_result')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.abr-font-weight-mode-setter','.abr-font-weight-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="abr-font-weight-mode-getter">
                                                    <label class="badge badge-outline-secondary rounded-25">{{$info->abnormal_result_font_weight == 1 ? __('lab_profile.font_bold') : __('lab_profile.font_normal') }}</label>
                                                    <label class="badge badge-outline-secondary rounded-25"><span class="rounded-25" style="width: 50px; height: 10px; background: {{$info->abnormal_text_color}}; float: left;"></span>.</label>
                                                </div>
                                                <div class="abr-font-weight-mode-setter" style="display: none">
                                                    <p>{{__('lab_profile.font_weight')}}</p>
                                                    <div class="form-check form-check-primary d-flex ml-1">
                                                        <label class="form-check-label ">
                                                            <input onclick="postLabSettingSetter()" {{$info->abnormal_result_font_weight==1 ? 'checked':''}} type="radio" class="checkbox" data-id="1" value="1" name="abnormal_result_font_weight" id="font-weight-bold"> {{__('lab_profile.font_bold')}}
                                                        </label>
                                                    </div>
                                                    <div class="form-check form-check-primary d-flex ml-1">
                                                        <label class="form-check-label">
                                                            <input onclick="postLabSettingSetter()" {{$info->abnormal_result_font_weight==0 ? 'checked':''}} type="radio" class="checkbox" data-id="0" value="0" name="abnormal_result_font_weight" id="font-weight-normal"> {{__('lab_profile.font_normal')}}
                                                        </label>
                                                    </div>
                                                    <p>{{__('lab_profile.text_color')}}</p>
                                                    <div class="input-group ml-1">
                                                        <input type="color" id="abnormal-text-color" class="rounded-right-0 form-control form-control-sm p-0" value="{{$info->abnormal_text_color}}">
                                                        <div class="input-group-append">
                                                            <button onclick="postLabSettingSetter()" type="button" class="btn btn-xs btn-inverse-info px-3" style="font-size: 12px; padding: 5px"><i class="fa fa-save"></i> {{__('lab_profile.btn_save')}}</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 p-2">
                                            <div class="col-sm-12 py-3 item-config">
                                                <p class="font-weight-bold mb-3">{{__('lab_profile.verify_label')}}
                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                        <button type="button" class="btn btn-xs btn-light rounded-25 text-info float-right" style="font-size: 12px !important; padding: 5px;" onclick="toggleElements('.verify-label-mode-setter','.verify-label-mode-getter')"><i class="fa fa-gear text-muted"></i> {{__('lab_profile.btn_change')}}</button>
                                                    @endif
                                                </p>
                                                <div class="verify-label-mode-getter">
                                                    <img style="height: 33px !important;" src="{{!empty($info->verify_label) ? url(env("APP_URL").'storage/images/avatars/labs/'.$info->verify_label) :''}}">
                                                </div>
                                                <div class="verify-label-mode-setter" style="display: none">
                                                    <form id="verify-image-upload-form" method="POST" enctype="multipart/form-data">
                                                        @csrf
                                                        <div class="center_">
                                                            <div class="form-input">
                                                                <div class="preview" style="width: 120px;">
                                                                    <img id="verify-image-preview" src="{{!empty($info->verify_label) ? url(env("APP_URL").'storage/images/avatars/labs/'.$info->verify_label) :''}}">
                                                                </div>
                                                                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information']))
                                                                    <label for="verify-image" class="rounded btn-light">
                                                                        <i class="mdi mdi-image-filter"></i> <span style="font-size: 12px">{{__('physician.form_logo_upload')}}</span>
                                                                    </label>
                                                                    <button type="button" id="btn-remove-verify-label" class="btn btn-xs btn-danger ml-2" style="padding: 2px !important; margin-top: -3px !important;"><i class="mdi mdi-close-circle"></i></button>
                                                                @endif
                                                                <input type="file" name="image" id="verify-image" accept="image/*" onchange="showPreviewVerifyImage(event);">
                                                            </div>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                </div>


                            </div>
                        </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 sample_number = "{{$info->sample_number}}";
    let patient_code = "{{$info->patient_code}}";
    let technician_label = "{{$info->technician_label}}";
    let discount_type = "{{$info->discount_type}}";
    let phone_number = "{{$info->phone_number}}";
    let email = "{{$info->email}}";

    let currency = "{{$info->currency}}";

    let exchange_rate = "{{$info->exchange_rate}}";
    let abnormal_text_color = "{{$info->abnormal_text_color}}";
    let show_result_footer = "{{$info->show_result_footer}}";
    let abnormal_result_font_weight = "{{$info->abnormal_result_font_weight}}";
    let result_header_id = "{{$info->result_header_id}}";
    let invoice_template_id = "{{$info->invoice_template_id}}";
    let is_auto_make_invoice = "{{$info->is_auto_make_invoice}}";

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


    function showPreview(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("file-ip-1-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#image-upload-form').submit();
        }
    }


    /* alternative logo start */

    function showAlternativeLogo(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("file-ip-2-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#alternative-logo-upload-form').submit();
        }
    }


    $('#alternative-logo-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/alternative-logo/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    $('#btn-remove-alternative-logo').click(function(e) {
        $.ajax({
            url: '{{'laboratory-profile/alternative-logo/remove'}}',
            type: 'POST',
            data: {"_token": "{{ csrf_token() }}"},
            success:function(res){
                $('#file-ip-2-preview').attr('src',"")
                handleMessage(res.success, res.message)
            }
        });
    });
    /* alterntive logo end */

    /* default_footer start */

    function showDefaultFooter(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("file-ip-4-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#default-footer-upload-form').submit();
        }
    }


    $('#default-footer-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/default-footer/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    $('#btn-remove-default-footer').click(function(e) {
        $.ajax({
            url: '{{'laboratory-profile/default-footer/remove'}}',
            type: 'POST',
            data: {"_token": "{{ csrf_token() }}"},
            success:function(res){
                $('#file-ip-4-preview').attr('src',"")
                handleMessage(res.success, res.message)
            }
        });
    });

    /* default_footer end */

    /* alternative footer start */

    function showAlternativeFooter(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("file-ip-3-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#alternative-footer-upload-form').submit();
        }
    }

    $('#alternative-footer-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/alternative-footer/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    $('#btn-remove-alternative-footer').click(function(e) {
        $.ajax({
            url: '{{'laboratory-profile/alternative-footer/remove'}}',
            type: 'POST',
            data: {"_token": "{{ csrf_token() }}"},
            success:function(res){
                $('#file-ip-3-preview').attr('src',"")
                handleMessage(res.success, res.message)
            }
        });
    });

    /* alternative footer end */


    function showPreviewAlterVerifyImage(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("alter-verify-image-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#alter-verify-image-upload-form').submit();
        }
    }

    $('#alter-verify-image-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/alter-verify-sign/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    $('#btn-remove-alter-verify-label').click(function(e) {
        $.ajax({
            url: '{{'laboratory-profile/alter-verify-sign/remove'}}',
            type: 'POST',
            data: {"_token": "{{ csrf_token() }}"},
            success:function(res){
                $('#alter-verify-image-preview').attr('src',"")
                handleMessage(res.success, res.message)
            }
        });
    });

    $('#image-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/avatar/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    function postLabConfigure(attr_code, attr_value) {
        let url = base_url + '/configure/save';
        $.ajax({
            url: url,
            type:"POST",
            data :{
                "_token": csrf_token,
                attribute_code : attr_code,
                attribute_value: attr_value
            },
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    }


    function postLabSettingSetter() {
        let url = base_url + '/save';

        technician_label = $('#technician-label').val()
        sample_number = $("input[name='sample_number']:checked").attr('data-id')
        patient_code = $("input[name='patient_number']:checked").attr('data-id')
        discount_type = $("input[name='discount_type']:checked").attr('data-id')
        exchange_rate = $('#exchange-rate').val()
        abnormal_text_color = $('#abnormal-text-color').val()
        show_result_footer = 1
        abnormal_result_font_weight = $('input[name="abnormal_result_font_weight"]:checked').attr('data-id')
        result_header_id = 1 //$('input[name="result_header_id"]:checked').attr('data-id')
        invoice_template_id = $('input[name="invoice_template_id"]:checked').attr('data-id')
        is_auto_make_invoice = $('input[name="is_auto_make_invoice"]:checked').attr('data-id')

        if($('#phone-number').val()!='') phone_number = $('#phone-number').val()
        if($('#email').val()!='') email = $('#email').val()

        currency = $("input[name='currency']:checked").attr('data-id')

        $.ajax({
            url: url,
            type:"POST",
            data :{
                "_token": csrf_token,
                sample_number : sample_number,
                patient_code: patient_code,
                discount_type: discount_type,
                technician_label: technician_label,
                phone_number: phone_number,
                email: email,
                exchange_rate: exchange_rate,
                abnormal_text_color: abnormal_text_color,
                show_result_footer: show_result_footer,
                abnormal_result_font_weight: abnormal_result_font_weight,
                result_header_id: result_header_id,
                currency:currency,
                invoice_template_id: invoice_template_id,
                is_auto_make_invoice: is_auto_make_invoice
            },
            success:function(res){
                handleMessage(res.success, res.message)
                if(res.success) setTimeout(function () {location.reload()}, messageDuration)
            }
        });
    }

    /** verify label image */

    $('#verify-image-upload-form').submit(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        $.ajax({
            url: '{{'laboratory-profile/verifies/upload'}}',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success:function(res){
                handleMessage(res.success, res.message)
            }
        });
    });

    function showPreviewVerifyImage(event){
        if(event.target.files.length > 0){
            var src = URL.createObjectURL(event.target.files[0]);
            var preview = document.getElementById("verify-image-preview");
            preview.src = src;
            preview.style.display = "block";
            $('#verify-image-upload-form').submit();
        }
    }

    $('#btn-remove-verify-label').click(function(e) {
        $.ajax({
            url: '{{'laboratory-profile/verifies/remove'}}',
            type: 'POST',
            data: {"_token": "{{ csrf_token() }}"},
            success:function(res){
                $('#verify-image-preview').attr('src',"")
                handleMessage(res.success, res.message)
            }
        });
    });

</script>

</html>

