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

<form id="update_journal_voucher_form">
    <div class="modal-body">
        <div class="row mt-2">
            <div class="col-md-6">
                <label for="">تاریخ:</label>
                <input type="date" class="form-control change_focus" data-id="u_amount" id="u_date" name="date"
                       value="{{ date('Y-m-d', strtotime($voucher->date)) }}" autofocus>
                <span class="text-danger error" id="u_date_error"></span>
            </div>
            <div class="col-md-6">
                <label for="">رقم:</label>
                <input type="text" class="form-control change_focus" data-id="u_debit_account" id="u_amount"
                       name="amount" value="{{ $voucher->amount }}">
                <span class="text-danger error" id="amount_error"></span>
            </div>
        </div>
        <div class="row mt-2">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="name">ڈیبٹ اکاؤنٹ: <span class="text-danger">*</span></label>
                    <select name="debit_account" id="u_debit_account" class="form-control change_focus"
                            data-id="u_credit_account">
                        <option value="">----Select Party----</option>
                        <option value="cash" data-table="cash" @selected($voucher->debit_account_name=='cash')>Cash
                        </option>
                        @forelse ($brokers as $broker)
                            <option value="{{ $broker->id }}"
                                    data-table="broker" @selected($voucher->debit_account_name=='broker' && $voucher->debit_account_id==$broker->id)>{{ $broker->name }}</option>
                        @empty
                        @endforelse

                        @forelse ($customers as $customer)
                            <option value="{{ $customer->id }}"
                                    data-table="customer" @selected($voucher->debit_account_name=='customer' && $voucher->debit_account_id==$customer->id)>{{ $customer->name }}</option>
                        @empty
                        @endforelse

                        @forelse ($vehicles as $vehicle)
                            <option value="{{ $vehicle->id }}"
                                    data-table="vehicle" @selected($voucher->debit_account_name=='vehicle' && $voucher->debit_account_id==$vehicle->id)>{{ $vehicle->vehicle_no }}</option>
                        @empty
                        @endforelse

                        @forelse ($banks as $bank)
                            <option value="{{ $bank->id }}"
                                    data-table="bank" @selected($voucher->debit_account_name=='bank' && $voucher->debit_account_id==$bank->id)>{{ $bank->name }}</option>
                        @empty
                        @endforelse
                    </select>
                    <span class="text-danger error" id="u_debit_account_error"></span>
                </div>
            </div>

        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="name">کریڈٹ اکاؤنٹ: <span class="text-danger">*</span></label>
                    <select name="credit_account" id="u_credit_account" class="form-control change_focus"
                            data-id="u_description">
                        <option value="">----Select Party----</option>
                        <option value="cash" data-table="cash" @selected($voucher->credit_account_name=='cash')>Cash
                        </option>
                        @forelse ($brokers as $broker)
                            <option value="{{ $broker->id }}"
                                    data-table="broker" @selected($voucher->credit_account_name=='broker' && $voucher->credit_account_id== $broker->id)>{{ $broker->name }}</option>
                        @empty
                        @endforelse

                        @forelse ($customers as $customer)
                            <option value="{{ $customer->id }}"
                                    data-table="customer" @selected($voucher->credit_account_name=='customer' && $voucher->credit_account_id== $customer->id)>{{ $customer->name }}</option>
                        @empty
                        @endforelse

                        @forelse ($vehicles as $vehicle)
                            <option value="{{ $vehicle->id }}"
                                    data-table="vehicle" @selected($voucher->credit_account_name=='vehicle' && $voucher->credit_account_id== $vehicle->id)>{{ $vehicle->vehicle_no }}</option>
                        @empty
                        @endforelse

                        @forelse ($banks as $bank)
                            <option value="{{ $bank->id }}"
                                    data-table="bank" @selected($voucher->credit_account_name=='bank' && $voucher->credit_account_id== $bank->id)>{{ $bank->name }}</option>
                        @empty
                        @endforelse

                    </select>
                    <span class="text-danger error" id="u_credit_account_error"></span>
                </div>
            </div>

        </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
        <input type="hidden" name="credit_table" id="u_credit_table" value="{{ $voucher->credit_account_name }}">
        <input type="hidden" name="debit_table" id="u_debit_table" value="{{ $voucher->debit_account_name }}">
        <button id="update_btn" class="btn btn-sm btn-info" type="submit">
            Update
        </button>
        <input type="hidden" name="update_id" value="{{ $voucher->id }}">
    </div>
</form>
