<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span></button>
    <div class="container-fluid banner">
        <div class="row">
            @php
                $previous_advance = $trip->previous_advance->sum('amount');
                $trip_advance = $trip->trip_advances!=null ? $trip->trip_advances->sum('amount'):0;
           $trip_deposits =$trip->trip_deposits !=null ?$trip->trip_deposits->sum('amount'): 0;
           $actual_fregiths = $trip->trip_details !=null ?$trip->trip_details->sum('actual_freight'):0;
            @endphp
            <div class="col-md-2 d-flex">
                <div>
                    <i class="fa fa-plus-circle fa-3x text-success"></i>
                </div>
                <div class="ml-3">
                    <h3 class="font-weight-bold mb-0">
                        {{ number_format($previous_advance, 0) }}
                    </h3>
                    <small class="text-uppercase">سابقہ پیشگی</small>
                </div>
            </div>
            <div class="col-md-2 d-flex">
                <div class="">
                    <i class="fa fa-minus-circle fa-3x text-danger"></i>
                </div>
                <div class="ml-3">
                    <h3 class="font-weight-bold mb-0">
                        {{ number_format($trip_advance, 0) }}
                    </h3>
                    <small class="text-uppercase">پیشگی</small>
                </div>
            </div>
            <div class="col-md-2 d-flex">
                <div>
                    <i class="fa fa-plus-circle fa-3x text-success"></i>
                </div>
                <div class="ml-3">
                    <h3 class="font-weight-bold mb-0">
                        {{ number_format($trip_deposits, 0) }}
                    </h3>
                    <small class="text-uppercase">ڈپوزٹ</small>
                </div>
            </div>

            <div class="col-md-2 d-flex">
                <div>
                    <i class="fa fa-info-circle fa-3x text-info"></i>
                </div>
                <div class="ml-3">
                    <h3 class="font-weight-bold mb-0">
                        {{ number_format($actual_fregiths, 0) }}
                    </h3>
                    <small class="text-uppercase">کرایہ</small>
                </div>
            </div>
            <div class="col-md-2 d-flex">
                <div class="">
                    <i class="fa fa-minus-circle fa-3x text-danger"></i>
                </div>
                <div class="ml-3">
                    {{-- <h3 class="font-weight-bold mb-0">
                        {{ number_format($trip_total_expenses,0) }}
                    </h3> --}}
                    <small class="text-uppercase">اخراجات</small>
                </div>
            </div>
            <div class="col-md-2 d-flex mt-2">
                <div class="">
                    <i class="fa fa-info-circle fa-3x text-danger"></i>
                </div>
                <div class="ml-3">
                    <h3 class="font-weight-bold mb-0">
                        {{-- @php
                            $oils =$trip->trip_oils->sum('total_amount');
                        @endphp
                        {{ number_format($oils,0) }} --}}
                    </h3>
                    <small class="text-uppercase">آئل/ڈیزل</small>
                </div>
            </div>
            <div class="col-md-3">
                <!--<input id="tableFilter" type="text" placeholder="Search... (Ctrl)"
                                                                                                                                                                                                                           class="form-control">-->
            </div>
        </div>
    </div>
    <h4 class="modal-title">ٹرپ
        <span class="badge" id="receivedAcTripNo">{{ $trip->id }}</span>
        گاڑی:
        <span class="badge badge-color2" id="receivedAcVeh">{{ $trip->vehicle->vehicle_no }}</span>
        تاریخ:
        <span class="badge badge-color3"
              id="receivedAcDates">{{ date('F j,Y', strtotime($trip->starting_date)) }}</span>
        میں وصولی کی تفصیلات
    </h4>
</div>
<div class="modal-body" id="trip_amount_receiving_modal_body">
  @if(auth()->user()->hasPermissionTo('create trip receiving'))
        <form id="addReceivevAccountFormRandomId">
            <div class="row">
                <div class="col-md-4">
                    <div class="form-group">
                        <label for="received_date">تاریخ: <span class="text-danger">*</span></label>
                        <input type="date" id="received_date" name="received_date" class="form-control change_focus"
                               data-id="adv_cash"
                               value="{{ date('Y-m-d') }}">
                        <span class="text-danger r_error" id="received_date_error"></span>
                    </div>
                </div>
                <div class="col-md-4">
                    <label for="">ادائیگی قسم:</label><br>
                    <label for="adv_cash"><input type="radio" name="payment_type"
                                                 onchange="receiving_payment_change('cash')" class="change_focus"
                                                 data-id="adv_bank_payment"
                                                 id="adv_cash" value="cash">
                        کیش</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label for="adv_bank_payment"><input type="radio" name="payment_type" class="change_focus"
                                                         data-id="adv_broker_payment"
                                                         onchange="receiving_payment_change('bank')"
                                                         id="adv_bank_payment" value="bank">
                        بینک</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label for="adv_broker_payment">
                        <input type="radio" name="payment_type" data-id="received_amount" class="change_focus"
                               onchange="receiving_payment_change('broker')"
                               id="adv_broker_payment" value="on_account">
                        ان اکاوؑنٹ</label>
                    <br>
                    <span class="text-danger error" id="payment_type_error"></span>
                </div>
                <div class="col-md-4" id="adv_bank_dev">

                </div>

                {{-- <div class="col-md-4">
                     <div class="form-group">
                         <label for="received_from_id">موصول:<span class="text-danger">*</span></label>
                         <select id="received_from_id" name="received_from" class="form-control select2 change_focus"
                                 data-id="rec_note">
                             <option value="">-----SELECT PARTY-----</option>
                             @forelse ($brokers as $item)
                                 <option value="{{ $item->id }}" data-table="brokers">{{ $item->name }}</option>
                             @empty

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

                             @endforelse
                         </select>
                         <span class="text-danger r_error" id="received_from_error"></span>
                     </div>
                 </div>--}}


            </div>
            <div class="row mt-2">
                <div class="col-md-4">
                    <div class="form-group">
                        <label for="received_amount">رقم: <span class="text-danger">*</span></label>
                        <input type="number" min="0" id="received_amount" name="received_amount"
                               class="form-control change_focus" data-id="received_date">
                        <span class="text-danger r_error" id="received_amount_error"></span>
                    </div>
                </div>

            </div>
            <div class="row mt-2">
                <div class="col-md-12">
                    <div class="form-group">
                        <label for="rec_note">ریمارکس:</label>
                        <textarea rows="2" id="rec_note" name="rec_note" class="form-control"></textarea>
                        <span class="text-danger r_error" id="rec_note_error"></span>

                    </div>
                </div>
            </div>
            @csrf
            <input type="hidden" name="trip_id" value="{{ $trip->id }}">
            <input type="hidden" name="received_party_table" id="received_party_table">
            <button type="submit" class="btn btn-success btn-sm" name="receivedAcSubmit" id="receivedAcSubmit">
                محفوظ
            </button>
        </form>
    @endif
    <div class="row mt-3">
        <div class="col-md-12">
            <h3 class="text-center"> ٹرپ# {{ $trip->id }} میں وصولی </h3>
        </div>
        <div class="col-md-12">
            <hr>
            <table class="table table-bordered" id="received-details-table">
                <thead>
                <tr class="bg-info text-center">
                    <th>#</th>
                    <th>وصولی طریقہ کار</th>
                    <th>تاریخ</th>
                    <th>نوٹ</th>
                    <th>رقم</th>
                    <th>ایکشن</th>
                </tr>

                </thead>
                <tbody id="received_accounts_table">
                @forelse ($received_accounts as $ra)
                    <tr class=" text-center">
                        <td class="bg-warning">{{ $loop->iteration }}</td>
                        <td>
                            @if($ra->payment_type=='cash')
                                <span class="badge badge-info"> کیش</span>

                            @endif
                            @if($ra->payment_type=='opening_balance')
                            <span class=""> اوپنینگ بیلنس
                            </span>

                            @endif
                            @if($ra->payment_type=='bank')
                                    <span class="badge badge-warning">  بینک</span>

                                    {{ $ra->bank->name }}
                            @endif
                            @if($ra->payment_type=='on_account')
                                <span class="badge badge-info"> ان اکاؤنٹ</span>
                                @if($ra->party_name == 'broker')
                                    {{ $ra->broker->name }}
                                @endif
                                @if($ra->party_name =='pump')
                                    {{ $ra->pump->name }}
                                @endif
                                @if($ra->party_name =='cusomer')
                                    {{ $ra->pump->name }}
                                @endif
                            @endif
                        </td>
                        <td>{{ date('F j,Y', strtotime($ra->received_date)) }}</td>

                        <td>{{ $ra->description }}</td>
                        <td>{{ number_format($ra->amount, 0) }}</td>
                        <td>
                            @if (auth()->user()->hasPermissionTo('edit trip oil'))

                                <button type="button" class="btn-link edit_trip_receivings"
                                        data-id="{{ $ra->id }}"><span>
                                            اپڈیٹ</span></button>
                            @endif
                            @if (auth()->user()->hasPermissionTo('delete trip oil'))

                                    <button type="button" class="btn-link delete_trip_receivings"
                                            data-id="{{ $ra->id }}"><span class="text-danger">
                                            ڈیلیٹ</span></button>
                                @endif
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="5" class="text-center">
                            No Data Available
                        </td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
    </div>
</div>
