@extends('layout')
@section('title', 'تنخواہ کے واؤچرز')
@section('page_title', 'تنخواہ کے واؤچرز')
@section('content')
    <div class="row">
        @if(auth()->user()->hasPermissionTo('create salary voucher'))
            <div class="col-md-4">
                <div class="panel panel-card margin-b-30">
                    <div class="panel-body">

                        <form id="add_salary_form">
                            <div class="row ">
                                <div class="col-md-6">
                                    <label for="">تاریخ:</label>
                                    <input type="date" name="date" value="{{ date('Y-m-d') }}"
                                           class="form-control change_focus" data-id="amount" id="date" autofocus>
                                    <span class="text-danger error" id="date_error"></span>
                                </div>
                                <div class="col-md-6">
                                    <label for="">رقم:</label>
                                    <input type="text" name="amount" id="amount" class="form-control change_focus"
                                           data-id="employee">
                                    <span class="text-danger error" id="amount_error"></span>
                                </div>
                            </div>
                            <div class="row mt-2">
                                <div class="col-md-12">
                                    <label for="">ملازم:</label>
                                    <select name="employee" id="employee" onchange="get_driver_vehicle()"
                                            class="form-control change_focus"
                                            data-id="description">
                                        <option value="">----Select Employee----</option>
                                        @forelse ($employees as $employee)
                                            <option value="{{ $employee->id }}"
                                                    data-table="employee">{{ $employee->name }}</option>
                                        @empty
                                        @endforelse
                                        @forelse ($drivers as $driver)
                                            <option value="{{ $driver->id }}"
                                                    data-table="driver">{{ $driver->name }}</option>
                                        @empty
                                        @endforelse
                                    </select>

                                </div>

                            </div>
                            <div class="row mt-3" id="vehicle_dev">

                            </div>

                            <div class="row mt-2">
                                <div class="col-md-12">
                                    <label for="">تفصیل:</label>
                                    <textarea name="description" id="description" class="form-control" cols="10"
                                              rows="2"></textarea>
                                    <span class="text-danger error" id="description_error"></span>
                                </div>
                            </div>
                            <div class="row mt-2">

                                <div class="col-md-12">
                                    <div class="">
                                        @csrf
                                        <input type="hidden" name="user_type" id="user_type">
                                        <button name="createCitySubmit" id="submit_btn" class="btn btn-sm btn-primary"
                                                type="submit">
                                            محفوظ
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
        @endif

        <div class="{{ auth()->user()->hasPermissionTo('create salary voucher')?'col-md-8':'col-md-12' }}">
            <div class="panel panel-card ">
                <div class="panel-body">
                    <table id="salary_table" class="table table-bordered" cellspacing="0" width="100%">
                        <thead class="bg-gold text-white">
                        <tr style="white-space: nowrap">
                            <th>#</th>
                            <th>قسم</th>
                            <th>ملازم</th>
                            <th>تاریخ</th>
                            <th>رقم</th>
                            <th>ایکشن</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    {{-- Edit Voucher Modal--}}
    <div class="modal fade" id="editVoucherModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg">
            <div class="modal-content panel-card" id="editVoucherData">

            </div>
        </div>
    </div>
@endsection
   
@section('javascript')
    @include('salaries.js')
@endsection
