<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title">تنخواہ کے واؤچر کی تبدیلی</h4>
</div>

<form id="update_voucher_form">
    <div class="modal-body">
        <div class="row mt-2">
            <div class="col-md-4">
                <label for="">تاریخ:</label>
                <input type="date" id="u_date" class="form-control change_focus" data-id="u_amount"
                       name="date" value="{{ date('Y-m-d', strtotime($voucher->date)) }}">
                <span class="text-danger error" id="u_date_error"></span>
            </div>
            <div class="col-md-4">
                <label for="">رقم:</label>
                <input type="text" class="form-control change_focus" data-id="u_employee" name="amount"
                       value="{{ $voucher->debit }}"
                       id="u_amount">
                <span class="text-danger error" id="u_amount_error"></span>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label for="name">پارٹی: <span class="text-danger">*</span></label>
                    <select name="employee" id="u_employee" onchange="get_driver_vehicle('yes')"
                            class="form-control change_focus"
                            data-id="u_description">
                        <option value="">----Select Party----</option>
                        @forelse ($employees as $employee)
                            <option value="{{ $employee->id }}"
                                    data-table="employee" @selected($voucher->given_to=='employee' && $voucher->employee_id == $employee->id)>{{ $employee->name }}</option>
                        @empty
                        @endforelse
                        @forelse ($drivers as $driver)
                            <option value="{{ $driver->id }}"
                                    data-table="driver" @selected($voucher->given_to=='driver' && $voucher->driver_id == $driver->id)>{{ $driver->name }}</option>
                        @empty
                        @endforelse
                    </select>
                    <span class="text-danger error" id="u_employee_error"></span>
                </div>
            </div>
        </div>
        <div class="row mt-2" id="u_vehicle_dev">
            @if($voucher->given_to=='driver')
                <div class="col-md-12">
                    <label for="">گاڑی:</label>
                    <select name="vehicle" id="u_vehicle" class="form-control">
                        <option value="">----Select Vehicle----</option>
                        @forelse($vehicles as $vehicle)
                            <option value="{{ $vehicle->id }}" @selected($vehicle->id == $voucher->vehicle_id)>{{ $vehicle->vehicle_no }}</option>
                        @empty
                        @endforelse
                    </select>
                    <span class="text-danger error u_error"
                          id="u_vehicle_error"></span>
                </div>
            @endif
        </div>
        <div class="row mt-2">
            <div class="col-md-12">
                <label for="">تفصیل:</label>
                <textarea name="description" id="u_description" cols="10" rows="2"
                          class="form-control"></textarea>
                <span class="text-danger error" id="u_description_error"></span>
            </div>

        </div>
    </div>
    <div class="modal-footer">
        @csrf
        <button id="update_btn" class="btn btn-sm btn-info" type="submit">
            اپ ڈیٹ
        </button>
        <input type="hidden" name="user_type" id="u_user_type" value="{{ $voucher->given_to }}">

        <input type="hidden" name="update_id" value="{{ $voucher->id }}">
    </div>
</form>
