<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title">Edit Opening Balance</h4>
</div>

<form id="update_balance_form">
    <div class="modal-body">
        <div class="row">
            <div class="col-md-6">
                <label for="">تاریخ:</label>
                <input type="date" value="{{ date('Y-m-d', strtotime($balance->date)) }}" class="form-control"
                       name="date"
                       id="u_date">
                <span class="text-danger error" id="u_date_error"></span>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="city_name">پارٹی:: <span class="text-danger">*</span></label>
                    <select name="party" id="u_party" onchange="party_change('yes')" class="form-control"
                            autofocus>
                        <option value="">----منتخب پارٹی----</option>
                        @forelse ($brokers as $broker)
                            <option value="{{ $broker->id }}"
                                    data-table="broker" @selected($balance->ref_type == 'broker' && $broker->id == $balance->ref_id)>{{ $broker->name }}</option>
                        @empty
                        @endforelse

                        {{-- @forelse ($customers as $customer)
                            <option value="{{ $customer->id }}"
                                    data-table="customer" @selected($balance->ref_type == 'customer' && $broker->id == $balance->ref_id)>{{ $customer->name }}</option>
                        @empty
                        @endforelse --}}

                        @forelse ($vehicles as $vehicle)
                            <option value="{{ $vehicle->id }}"
                                    data-table="vehicle" @selected($balance->ref_type == 'vehicle' && $broker->id == $balance->ref_id)>{{ $vehicle->vehicle_no }}</option>
                        @empty
                        {{-- @endforelse @forelse ($drivers as $driver)
                            <option value="{{ $driver->id }}"
                                    data-table="driver" @selected($balance->ref_type == 'driver' && $driver->id == $balance->ref_id)>{{ $driver->name }}</option>
                        @empty --}}
                        @endforelse

                        @forelse ($vehicles as $vehicle)
                            <option value="{{ $vehicle->id }}"
                                    data-table="vehicle" @selected($balance->ref_type == 'vehicle' && $broker->id == $balance->ref_id)>{{ $vehicle->vehicle_no }}</option>
                        @empty

                        @endforelse

                        @forelse ($banks as $bank)
                            <option value="{{ $bank->id }}"
                                    data-table="bank" @selected($balance->ref_type == 'bank' && $broker->id == $balance->ref_id)>{{ $bank->name }}</option>
                        @empty
                        @endforelse
                    </select>
                    <span class="text-danger error" id="u_party_error"></span>
                </div>
            </div>


        </div>
        <div class="row mt-2">
            <div class="col-md-6">
                <label for="">بیلنس قسم:</label><br>
                <label for="u_debit_balance"><input type="radio" id="u_debit_balance" name="balance_type"
                                                    value="debit" @checked($balance->balance_type=='debit')>
                    ڈیبٹ </label>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <label for="u_credit_balance"><input type="radio" id="u_credit_balance" name="balance_type"
                                                     value="credit" @checked($balance->balance_type=='credit')>
                    کریڈٹ </label><br>
                <span class="text-danger error" id="u_balance_type_error"></span>
            </div>
            <div class="col-md-6">
                <label for="">رقم:</label>
                <input type="text" class="form-control" name="amount" value="{{ $balance->amount }}" id="u_amount">
                <span class="text-danger error" id="u_amount_error"></span>
            </div>

        </div>
        <div class="row mt-2">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="city_name">وضاحت:</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>
    <div class="modal-footer">
        @csrf
        <input type="hidden" id="u_hidden_party_table" name="party_table" value="{{ $balance->ref_type }}">

        <button id="update_btn" class="btn btn-sm btn-info" type="submit">
            اپ ڈیٹ

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