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

<form id="update_broker_reach_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($brokerReach->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_broker" name="amount"
                       value="{{ $brokerReach->amount }}"
                       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="party">پاڑٹی: <span class="text-danger">*</span></label>
                    <select name="party" id="u_party" class="form-control change_focus"
                            data-id="u_cash">
                        <option value="">----Select Party----</option>
                        @forelse ($brokers as $broker)
                            <option value="{{ $broker->id }}"
                                    data-table="party"
                                    @selected($brokerReach->broker_id == $broker->id)>{{ $broker->name }}</option>
                        @empty
                        @endforelse
                    </select>
                    <span class="text-danger error" id="u_party_error"></span>
                </div>
            </div>

        </div>
        <div class="row">
            <div class="col-md-4">
                <label for="">ادائیگی کی قسم:</label><br>
                <label for="u_cash">
                    <input type="radio" id="u_cash" name="payment_type" class="change_focus" data-id="u_bank"
                           onchange="payment_type_change('cash', 'yes')"
                           value="cash" @checked($brokerReach->payment_type== 'cash')>
                    کیش</label>
                &nbsp; &nbsp;
                <label for="u_bank">
                    <input type="radio" id="u_bank" name="payment_type" class="change_focus" data-id="all_bank"
                           onchange="payment_type_change('bank', 'yes')"
                           value="bank" @checked($brokerReach->payment_type=='bank')>
                    بینک</label><br>
                <span class="text-danger error" id="payment_type_error"></span>
            </div>
            <div class="col-md-8" id="u_bank_dev">
                @if($brokerReach->payment_type=='bank')
                    <div class="col-md-12">
                        <label for="">بینکس</label>
                        <select name="bank" id="all_bank" class="form-control change_focus" data-id="broker">
                            <option value="">---Select Bank---</option>
                            @forelse ($banks as $bank)
                                <option
                                    value="{{ $bank->id }}" @selected($bank->id == $brokerReach->bank_id)>{{ $bank->name }}</option>
                            @empty
                            @endforelse
                        </select>
                        <span class="text-danger error" id="bank_error"></span>
                    </div>
                @endif
            </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
        <button id="update_btn" class="btn btn-sm btn-info" type="submit">
            اپ ڈیٹ
        </button>
        <input type="hidden" name="user_type" id="u_user_type" value="{{ $brokerReach->ref_type }}">

        <input type="hidden" name="update_id" value="{{ $brokerReach->id }}">
        <input type="hidden" name="vehicle_id" value="{{ $brokerReach->vehicle_id }}">
        <input type="hidden" name="trip_id" value="{{ $brokerReach->trip_id }}">
        <input type="hidden" name="brokerReach_id" value="{{ $brokerReach->trip_oil_id }}">
        <input type="hidden" name="old_amount" value="{{ $brokerReach->amount }}">
        <input type="hidden" name="total_amount" value="{{ $pump_payable->remainder_amount }}">
        @php
        $short_amount = $pump_payable->short_amount ?? 0;
        $remainder_amount = $pump_payable->remainder_amount ?? 0;

        $actual_amount = ($short_amount != 0) ? $short_amount : $remainder_amount;
    @endphp
    <input type="hidden" name="hidden_total_amount_reach" value="{{ $actual_amount }}">

    </div>
</form>
