<form id="updateAdvanceInTripForm">
    <div class="row">
        <div class="col-md-6">
            <div class="form-group">
                <label for="adv_amount">رقم<span class="text-danger">*</span></label>
                <input type="number" min="1" id="adv_amount" name="adv_amount" class="form-control change_focus"
                       value="{{ $advance->amount }}"
                       data-id="adv_date">
                <span class="text-danger advance_error" id="adv_amount_error"></span>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label for="adv_date">تاریخ<span class="text-danger">*</span></label>
                <input type="date" id="adv_date" name="adv_date" class="form-control change_focus"
                       data-id="adv_note"
                       value="{{ date('Y-m-d',strtotime($advance->date)) }}">
                <span class="text-danger advance_error" id="adv_date_error"></span>

            </div>
        </div> 

    </div>
    <div class="row mt-2">
        <div class="col-md-4">
            <label for="">ادائیگی قسم:</label><br>
            <label for="adv_cash">
                <input type="radio" name="payment_type" onchange="adv_payment_change('cash')"
                       @checked($advance->payment_type=='cash')
                       id="adv_cash" value="cash">
                کیش</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label for="adv_bank_payment">
                <input type="radio" name="payment_type"
                       onchange="adv_payment_change('bank')"
                       @checked($advance->payment_type=='bank')
                       id="adv_bank_payment" value="bank">
                بینک</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label for="adv_broker_payment">
                <input type="radio" name="payment_type"
                       onchange="adv_payment_change('broker')" @checked($advance->payment_type=='on_account')
                       id="adv_broker_payment" value="on_account">
                ان اکاوؑنٹ</label>
            <br>
            <span class="text-danger error" id="payment_type_error"></span>
        </div>
        <div class="col-md-8" id="adv_bank_dev">
            @if($advance->payment_type=='bank')
                <label for="">بینک:</label><br>

                <select name="bank" id="adv_bank" class="from-control">
                    <option value="">----Select Bank----</option>
                    @forelse($banks as $bank)
                        <option
                            value="{{ $bank->id }}" @selected($advance->bank_id == $bank->id)>{{ $bank->name }}</option>
                    @empty
                        <option value="">NO BANK AVAILABLE</option>
                    @endforelse
                </select><br>

                <span class="text-danger error" id="bank_error"></span>

            @endif
            @if($advance->payment_type=='on_account')
                <label for="">اکاوؑنٹ:</label><br>

                <select name="party" onchange="advance_amount_change()"
                        id="adv_broker" class="from-control">
                    <option value="">----Select Account----</option>
                    @forelse($brokers as $broker)
                        <option value="{{ $broker->id }}"
                                @selected($advance->on_account_id == $broker->id && $advance->on_account_type=='broker') data-table="broker">{{ $broker->name }}</option>
                    @empty
                    @endforelse
                    @forelse($pumps as $pump)
                        <option value="{{ $pump->id }}"
                                data-table="pump" @selected($advance->on_account_id == $pump->id && $advance->on_account_type=='pump')>{{ $pump->name }}</option>
                    @empty
                    @endforelse
                </select><br>

                <span class="text-danger error" id="party_error"></span>

            @endif
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <div class="form-group">
                <label for="adv_note">نوٹ</label>
                <textarea id="adv_note" name="adv_note" class="form-control"></textarea>
            </div>
        </div>
    </div>
    @csrf
    <input type="hidden" name="trip_id" id="advance_trip_id" value="{{ $trip->id }}">
    <input type="hidden" name="update_id" id="" value="{{$advance->id }}">
    <input type="hidden" name="party_title" id="adv_party_table" value="{{ $advance->on_account_type }}">
    <button type="submit" class="btn btn-success" name="addAdvanceInTripSubmit" id="addAdvanceInTripSubmit">
        اپڈیٹ
    </button>
    <button type="button" class="btn btn-sm btn-info" onclick="cancel_update_advance_form()">کینسل
    </button>

</form>

