
@extends("layouts.metor.admin")
@section("content")
@section("title","Add Payroll Items")

<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 Payroll items</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" >
                    @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_payroll_items['client_id_req'];}}{{ $dbs_payroll_items['client_id_title']}}: </label>
 <select name="client_id" id="add-client_id"  class="chosen-select form-control form-select">
    <option value="">{{ $dbs_payroll_items['client_id_req'];}}Select {{ $dbs_payroll_items['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_payroll_items['payroll_id_req'];}}{{ $dbs_payroll_items['payroll_id_title']}}: </label>
 <select name="payroll_id" id="add-payroll_id"  class="chosen-select form-control form-select">
    <option value="">{{ $dbs_payroll_items['payroll_id_req'];}}Select {{ $dbs_payroll_items['payroll_id_title'] }} </option>
    @foreach($payroll_id as $id => $name)
        @php
    $selected = ($id == '') ? 'selected="selected"' : '';
@endphp
        <option value="{{ $id }}"  {{ $selected }}>{{ $name }}</option>
    @endforeach
</select>
<script>
    $(function() {
        $('#add-payroll_id').chosen({
              width: '100%',
              search_contains: true
            });
        });
</script>
<span class='text-danger' id='add-payroll_idError'></span>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payroll_items['item_type_req'];}}{{ $dbs_payroll_items['item_type_title']; }}:</label><br/>
        <div class="mt-2">
            @php
            $options = $dbs_payroll_items['item_type_array'];
            @endphp

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

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


<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payroll_items['title_req'];}}{{ $dbs_payroll_items['title_title']; }}:</label>
        <input type = '{{$dbs_payroll_items['title_html5_type'] }}' name = "title" id = "add-title" autocomplete = 'off' maxlength ='{{  $dbs_payroll_items['title_max'] }}'  value='' @if($dbs_payroll_items['title_html5_req']!='') {{ $dbs_payroll_items['title_html5_req'] }} = {{$dbs_payroll_items['title_html5_req']}} @endif class= 'form-control'  >
        <span class='text-danger' id='add-titleError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payroll_items['amount_req'];}}{{ $dbs_payroll_items['amount_title']}}:</label>
        <input type = '{{$dbs_payroll_items['amount_html5_type'] }}' name = "amount" id = "add-amount" data-maxlen='{{ $dbs_payroll_items['amount_max'] }}' data-scale='{{ $dbs_payroll_items['amount_scale'] ?? '' }}' autocomplete = 'off'   value='' @if($dbs_payroll_items['amount_html5_req']!='') {{ $dbs_payroll_items['amount_html5_req'] }} = {{$dbs_payroll_items['amount_html5_req']}} @endif class= 'form-control'   onkeydown='validateFloatInput(event)'  oninput='validateInput(this,{{  $dbs_payroll_items['amount_max'] }})' />
        <span class='text-danger' id='add-amountError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_payroll_items['status_req'];}}{{ $dbs_payroll_items['status_title']; }}:</label><br/>
        <div class="mt-2">
            @php
            $options = $dbs_payroll_items['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("payroll-items.store") }}' data-args2='admin/payroll-items' onclick='addUpdate(event, "add")'>
                                    <i class="ri-save-line"></i> Save 
                                </button>
                            </div>
                            <div class="col-lg-2">
                                <a href="{{ route('payroll-items.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

