
@extends("layouts.metor.admin")
@section("content")
@section("title","Add 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">Add 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="add-form" id="add-form" enctype="multipart/form-data">
                    @csrf
                    <div class="row">

<div class="mt-2 col-xs-12 col-sm-12 col-md-4 col-lg-4">        
<label class='form-label'>{{ $dbs_payrolls['client_id_req'];}}{{ $dbs_payrolls['client_id_title']}}: </label>
 <select name="client_id" id="add-client_id"  class="chosen-select form-control form-select">
    <option value="">{{ $dbs_payrolls['client_id_req'];}}Select {{ $dbs_payrolls['client_id_title'] }} </option>
    @foreach($client_id as $id => $name)
        @php
    $selected = ($id == '') ? 'selected="selected"' : '';
@endphp
        <option value="{{ $id }}"  {{ $selected }}>{{ $name }}</option>
    @endforeach
</select>
<script>
    $(function() {
        $('#add-client_id').chosen({
              width: '100%',
              search_contains: true
            });
        });
</script>
<span class='text-danger' id='add-client_idError'></span>
</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="add-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 == '') ? 'selected="selected"' : '';
@endphp
        <option value="{{ $id }}"  {{ $selected }}>{{ $name }}</option>
    @endforeach
</select>
<script>
    $(function() {
        $('#add-employee_id').chosen({
              width: '100%',
              search_contains: true
            });
        });
</script>
<span class='text-danger' id='add-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="add-payroll_month" autocomplete="off" class="form-control" value='' @if($dbs_payrolls['payroll_month_html5_req']!='') {{ $dbs_payrolls['payroll_month_html5_req'] }} = {{$dbs_payrolls['payroll_month_html5_req']}} @endif>
        <span class='text-danger' id='add-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="add-payroll_year" autocomplete="off" class="form-control" min="1000" max="9999" step="1" value='' @if($dbs_payrolls['payroll_year_html5_req']!='') {{ $dbs_payrolls['payroll_year_html5_req'] }} = {{$dbs_payrolls['payroll_year_html5_req']}} @endif>
        <span class='text-danger' id='add-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 = "add-basic_salary" data-maxlen='{{ $dbs_payrolls['basic_salary_max'] }}' data-scale='{{ $dbs_payrolls['basic_salary_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-allowances" data-maxlen='{{ $dbs_payrolls['allowances_max'] }}' data-scale='{{ $dbs_payrolls['allowances_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-deductions" data-maxlen='{{ $dbs_payrolls['deductions_max'] }}' data-scale='{{ $dbs_payrolls['deductions_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-overtime_amount" data-maxlen='{{ $dbs_payrolls['overtime_amount_max'] }}' data-scale='{{ $dbs_payrolls['overtime_amount_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-bonus" data-maxlen='{{ $dbs_payrolls['bonus_max'] }}' data-scale='{{ $dbs_payrolls['bonus_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-tax" data-maxlen='{{ $dbs_payrolls['tax_max'] }}' data-scale='{{ $dbs_payrolls['tax_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-gross_salary" data-maxlen='{{ $dbs_payrolls['gross_salary_max'] }}' data-scale='{{ $dbs_payrolls['gross_salary_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-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 = "add-net_salary" data-maxlen='{{ $dbs_payrolls['net_salary_max'] }}' data-scale='{{ $dbs_payrolls['net_salary_scale'] ?? '' }}' autocomplete = 'off'   value='' @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='add-net_salaryError'></span>
    </div>
</div>

<div class="col-lg-6">
    <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 == 'pending') ? 'checked="checked"' : '';
                @endphp

                <label class="btn btn-outline-primary">
                    <input type="radio" name="payment_status" value="{{ $key }}" id="add-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 = "add-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='add-payment_dateError'></span>
        
        <script>
            $(function() {
                $( '#add-payment_date' ).datepicker({
                    changeMonth: true,
                    changeYear: true
                });
                $( '#add-payment_date' ).datepicker( 'option', 'yearRange', 'c-100:c+10' );
                $( '#add-payment_date' ).datepicker( 'option', 'dateFormat', 'yy-mm-dd' );
                $('#add-payment_date').datepicker('setDate', '{{date("y-m-d")}}' );                
            });
        </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="file" name="payslip" id="add-payslip" class="form-control" @if($dbs_payrolls['payslip_html5_req']!='') {{ $dbs_payrolls['payslip_html5_req'] }} = {{$dbs_payrolls['payslip_html5_req']}} @endif >
        <div class="mt-1">{{ $getSettings['allowed_attachment_formats'] ?? '' }}</div>
        
        
        <span class='text-danger' id='add-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 == 'Active') ? 'checked="checked"' : '';
                @endphp

                <label class="btn btn-outline-primary">
                    <input type="radio" name="status" value="{{ $key }}" id="add-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">
                                <button type='submit' name='add-submit' id='add-submit' class='btn btn-outline-secondary w-100' data-args1='{{ route("payrolls.store") }}' data-args2='admin/payrolls' onclick='addUpdate(event, "add")'>
                                    <i class="ri-save-line"></i> Save 
                                </button>
                            </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

