
@extends("layouts.metor.admin")
@section("content")
@section("title","Update Payrolls")

<div class="row">
    <div class="col-xl-12 col-lg-12">
        <div class="alert alert-success my-3" style="display:none;" id="success"></div>
        
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="card-title mb-0">Update Payrolls</h4>
                <a href="javascript:history.back()" class="btn btn-sm btn-light">
                    <i class="ri-arrow-left-line"></i> Back
                </a>
            </div>
            
            <div class="card-body">
                <form accept-charset="utf-8" name="update-form" id="update-form" >
                    @csrf
                    <div class="row">

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['client_id_req'];}}{{ $dbs_payrolls['client_id_title']}}:</label>
        <input type = '{{$dbs_payrolls['client_id_html5_type'] }}' name = "client_id" id = "update-client_id" data-maxlen='{{ $dbs_payrolls['client_id_max'] }}' data-scale='{{ $dbs_payrolls['client_id_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->client_id}}' @if($dbs_payrolls['client_id_html5_req']!='') {{ $dbs_payrolls['client_id_html5_req'] }} = {{$dbs_payrolls['client_id_html5_req']}} @endif class= 'form-control'   onkeydown='validateNumericInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['client_id_max'] }})' />
        <span class='text-danger' id='update-client_idError'></span>
    </div>
</div>

<div class="mt-2 col-xs-12 col-sm-12 col-md-4 col-lg-4">        
<label class='form-label'>{{ $dbs_payrolls['employee_id_req'];}}{{ $dbs_payrolls['employee_id_title']}}: </label>
 <select name="employee_id" id="update-employee_id"  class="chosen-select form-control form-select">
    <option value="">{{ $dbs_payrolls['employee_id_req'];}}Select {{ $dbs_payrolls['employee_id_title'] }} </option>
    @foreach($employee_id as $id => $name)
        @php
    $selected = ($id == $row->employee_id) ? 'selected="selected"' : '';
@endphp
        <option value="{{ $id }}"  {{ $selected }}>{{ $name }}</option>
    @endforeach
</select>
<script>
    $(function() {
        $('#update-employee_id').chosen({
              width: '100%',
              search_contains: true
            });
        });
</script>
<span class='text-danger' id='update-employee_idError'></span>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['payroll_month_req'];}}{{ $dbs_payrolls['payroll_month_title']}}:</label>
        <input type = '{{$dbs_payrolls['payroll_month_html5_type'] }}' name = "payroll_month" id = "update-payroll_month" data-maxlen='{{ $dbs_payrolls['payroll_month_max'] }}' data-scale='{{ $dbs_payrolls['payroll_month_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->payroll_month}}' @if($dbs_payrolls['payroll_month_html5_req']!='') {{ $dbs_payrolls['payroll_month_html5_req'] }} = {{$dbs_payrolls['payroll_month_html5_req']}} @endif class= 'form-control'   onkeydown='validateNumericInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['payroll_month_max'] }})' />
        <span class='text-danger' id='update-payroll_monthError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['payroll_year_req'];}}{{ $dbs_payrolls['payroll_year_title']}}:</label>
        <input type = '{{$dbs_payrolls['payroll_year_html5_type'] }}' name = "payroll_year" id = "update-payroll_year" data-maxlen='{{ $dbs_payrolls['payroll_year_max'] }}' data-scale='{{ $dbs_payrolls['payroll_year_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->payroll_year}}' @if($dbs_payrolls['payroll_year_html5_req']!='') {{ $dbs_payrolls['payroll_year_html5_req'] }} = {{$dbs_payrolls['payroll_year_html5_req']}} @endif class= 'form-control'   onkeydown='validateNumericInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['payroll_year_max'] }})' />
        <span class='text-danger' id='update-payroll_yearError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['basic_salary_req'];}}{{ $dbs_payrolls['basic_salary_title']}}:</label>
        <input type = '{{$dbs_payrolls['basic_salary_html5_type'] }}' name = "basic_salary" id = "update-basic_salary" data-maxlen='{{ $dbs_payrolls['basic_salary_max'] }}' data-scale='{{ $dbs_payrolls['basic_salary_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->basic_salary}}' @if($dbs_payrolls['basic_salary_html5_req']!='') {{ $dbs_payrolls['basic_salary_html5_req'] }} = {{$dbs_payrolls['basic_salary_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['basic_salary_max'] }})' />
        <span class='text-danger' id='update-basic_salaryError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['allowances_req'];}}{{ $dbs_payrolls['allowances_title']}}:</label>
        <input type = '{{$dbs_payrolls['allowances_html5_type'] }}' name = "allowances" id = "update-allowances" data-maxlen='{{ $dbs_payrolls['allowances_max'] }}' data-scale='{{ $dbs_payrolls['allowances_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->allowances}}' @if($dbs_payrolls['allowances_html5_req']!='') {{ $dbs_payrolls['allowances_html5_req'] }} = {{$dbs_payrolls['allowances_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['allowances_max'] }})' />
        <span class='text-danger' id='update-allowancesError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['deductions_req'];}}{{ $dbs_payrolls['deductions_title']}}:</label>
        <input type = '{{$dbs_payrolls['deductions_html5_type'] }}' name = "deductions" id = "update-deductions" data-maxlen='{{ $dbs_payrolls['deductions_max'] }}' data-scale='{{ $dbs_payrolls['deductions_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->deductions}}' @if($dbs_payrolls['deductions_html5_req']!='') {{ $dbs_payrolls['deductions_html5_req'] }} = {{$dbs_payrolls['deductions_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['deductions_max'] }})' />
        <span class='text-danger' id='update-deductionsError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['overtime_amount_req'];}}{{ $dbs_payrolls['overtime_amount_title']}}<sup>{{ $getSettings['site_currency']}}</sup>:</label>
        <input type = '{{$dbs_payrolls['overtime_amount_html5_type'] }}' name = "overtime_amount" id = "update-overtime_amount" data-maxlen='{{ $dbs_payrolls['overtime_amount_max'] }}' data-scale='{{ $dbs_payrolls['overtime_amount_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->overtime_amount}}' @if($dbs_payrolls['overtime_amount_html5_req']!='') {{ $dbs_payrolls['overtime_amount_html5_req'] }} = {{$dbs_payrolls['overtime_amount_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['overtime_amount_max'] }})' />
        <span class='text-danger' id='update-overtime_amountError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['bonus_req'];}}{{ $dbs_payrolls['bonus_title']}}:</label>
        <input type = '{{$dbs_payrolls['bonus_html5_type'] }}' name = "bonus" id = "update-bonus" data-maxlen='{{ $dbs_payrolls['bonus_max'] }}' data-scale='{{ $dbs_payrolls['bonus_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->bonus}}' @if($dbs_payrolls['bonus_html5_req']!='') {{ $dbs_payrolls['bonus_html5_req'] }} = {{$dbs_payrolls['bonus_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['bonus_max'] }})' />
        <span class='text-danger' id='update-bonusError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['tax_req'];}}{{ $dbs_payrolls['tax_title']}}:</label>
        <input type = '{{$dbs_payrolls['tax_html5_type'] }}' name = "tax" id = "update-tax" data-maxlen='{{ $dbs_payrolls['tax_max'] }}' data-scale='{{ $dbs_payrolls['tax_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->tax}}' @if($dbs_payrolls['tax_html5_req']!='') {{ $dbs_payrolls['tax_html5_req'] }} = {{$dbs_payrolls['tax_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['tax_max'] }})' />
        <span class='text-danger' id='update-taxError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['gross_salary_req'];}}{{ $dbs_payrolls['gross_salary_title']}}:</label>
        <input type = '{{$dbs_payrolls['gross_salary_html5_type'] }}' name = "gross_salary" id = "update-gross_salary" data-maxlen='{{ $dbs_payrolls['gross_salary_max'] }}' data-scale='{{ $dbs_payrolls['gross_salary_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->gross_salary}}' @if($dbs_payrolls['gross_salary_html5_req']!='') {{ $dbs_payrolls['gross_salary_html5_req'] }} = {{$dbs_payrolls['gross_salary_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['gross_salary_max'] }})' />
        <span class='text-danger' id='update-gross_salaryError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['net_salary_req'];}}{{ $dbs_payrolls['net_salary_title']}}:</label>
        <input type = '{{$dbs_payrolls['net_salary_html5_type'] }}' name = "net_salary" id = "update-net_salary" data-maxlen='{{ $dbs_payrolls['net_salary_max'] }}' data-scale='{{ $dbs_payrolls['net_salary_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->net_salary}}' @if($dbs_payrolls['net_salary_html5_req']!='') {{ $dbs_payrolls['net_salary_html5_req'] }} = {{$dbs_payrolls['net_salary_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payrolls['net_salary_max'] }})' />
        <span class='text-danger' id='update-net_salaryError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['payment_status_req'];}}{{ $dbs_payrolls['payment_status_title']; }}:</label><br/>
        <div class="mt-2">
            @php
            $options = $dbs_payrolls['payment_status_array'];
            @endphp

            @foreach ($options as $key => $value)
                @php
                $checked = ($key == $row->payment_status) ? 'checked="checked"' : '';
                @endphp

                <label class="btn btn-outline-primary">
                    <input type="radio" name="payment_status" value="{{ $key }}" id="update-payment_status" {{ $checked }}/> {{ $value }}
                </label>
            @endforeach
        </div>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['payment_date_req'];}}{{ $dbs_payrolls['payment_date_title']; }}:</label>
        <input type = '{{$dbs_payrolls['payment_date_html5_type'] }}' name = "payment_date" id = "update-payment_date" autocomplete = 'off' @if($dbs_payrolls['payment_date_html5_req']!='') {{ $dbs_payrolls['payment_date_html5_req'] }} = {{$dbs_payrolls['payment_date_html5_req']}} @endif class= 'form-control dateBox' >
        <span class='text-danger' id='update-payment_dateError'></span>
        
        <script>
            $(function() {
                $( '#update-payment_date' ).datepicker({
                    changeMonth: true,
                    changeYear: true
                });
                $( '#update-payment_date' ).datepicker( 'option', 'yearRange', 'c-100:c+10' );
                $( '#update-payment_date' ).datepicker( 'option', 'dateFormat', 'yy-mm-dd' );
                $('#update-payment_date').datepicker('setDate', '{{$row->payment_date}}' );                
            });
        </script>
    </div>
</div>


<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['payslip_req'];}}{{ $dbs_payrolls['payslip_title']; }}:</label>
        <input type = '{{$dbs_payrolls['payslip_html5_type'] }}' name = "payslip" id = "update-payslip" autocomplete = 'off' maxlength ='{{  $dbs_payrolls['payslip_max'] }}'  value='{{$row->payslip}}' @if($dbs_payrolls['payslip_html5_req']!='') {{ $dbs_payrolls['payslip_html5_req'] }} = {{$dbs_payrolls['payslip_html5_req']}} @endif class= 'form-control'  >
        <span class='text-danger' id='update-payslipError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payrolls['status_req'];}}{{ $dbs_payrolls['status_title']; }}:</label><br/>
        <div class="mt-2">
            @php
            $options = $dbs_payrolls['status_array'];
            @endphp

            @foreach ($options as $key => $value)
                @php
                $checked = ($key == $row->status) ? 'checked="checked"' : '';
                @endphp

                <label class="btn btn-outline-primary">
                    <input type="radio" name="status" value="{{ $key }}" id="update-status" {{ $checked }}/> {{ $value }}
                </label>
            @endforeach
        </div>
    </div>
</div>

    
                    </div>
                    

                    <div class="p-3 mb-3 rounded">
                        <div class="row justify-content-end g-2">
                            <div class="col-lg-3">
                                <div id="edit-mode">
                                    <button type='submit' name='update-submit' id='update-submit' class='btn btn-outline-secondary w-100' data-args1='{{ route("payrolls.update", $row->id) }}' data-args2='admin/payrolls' onclick='addUpdate(event,"update")'>
                                        <i class="ri-save-line"></i> Save 
                                    </button>
                                </div>
                            </div>
                            <div class="col-lg-2">
                                <a href="{{ route('payrolls.index') }}" class="btn btn-primary w-100">
                                    <i class="ri-close-circle-line"></i> Cancel
                                </a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

@endsection

