@extends('layout')
@section('title', ' رسید واؤچرز')
@section('page_title', ' رسید واؤچرز')


@section('content')
    <div class="row">
        @if(auth()->user()->hasPermissionTo('create receipt voucher'))

            <div class="col-md-4">
                <div class="panel panel-card margin-b-30">
                    <div class="panel-body">

                        <form id="add_receipt_form">

                            <div class="row mt-2">
                                <div class="col-md-6">
                                    <label for="">تاریخ:</label>
                                    <input type="date" id="date" class="form-control change_focus" data-id="amount"
                                           name="date" value="{{ date('Y-m-d') }}" autofocus>
                                    <span class="text-danger error" id="date_error"></span>
                                </div>
                                <div class="col-md-6">
                                    <label for="">رقم:</label>
                                    <input type="text" class="form-control change_focus" data-id="cash" name="amount"
                                           id="amount">
                                    <span class="text-danger error" id="amount_error"></span>
                                </div>
                            </div>

                            <div class="row mt-2">
                                <div class="col-md-12">

                                    <label for="">ادائیگی کی قسم:</label>
                                </div>
                            </div>
                            <div class="row mt-2">
                                <div class="col-md-12">
                                    <label for="cash"><input type="radio" id="cash" name="payment_type" class="change_focus"
                                                             data-id="bank"
                                                             onchange="payment_type_change('cash')" value="cash">
                                        کیش</label>
                                        &nbsp; &nbsp;
                                    <label for="bank"><input type="radio" id="bank" name="payment_type" class="change_focus"
                                                             data-id="all_bank"
                                                             onchange="payment_type_change('bank')" value="bank">
                                        بینک</label>

                                    <label for="in-account"><input type="radio" id="in-account" name="payment_type" class="change_focus"
                                                             data-id="in-account"
                                                             onchange="payment_type_change('in-account')" value="in-account">
                                                             ان اکاؤنٹ</label>
                                                             &nbsp; &nbsp;
                                                             <label for="bank"><input type="radio" id="bank" name="payment_type"
                                                             class="change_focus"
                                                             data-id="party"
                                                             onchange="payment_type_change('bank')" value="bank">
                                        بینک</label><br>

                                    <span class="text-danger error" id="payment_type_error"></span>
                                </div>
                            </div>
                            <div class="row mt-2" id="bank_dev">

                            </div>
                            <div class="row mt-2" id="workshop_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="broker" id="broker" class="form-control change_focus"
                                                data-id="description">
                                            <option value="">----Select Party----</option>
                                            @forelse ($brokers as $broker)
                                                <option value="{{ $broker->id }}"
                                                        data-table="broker">{{ $broker->name }}</option>
                                            @empty
                                            @endforelse
                                            {{-- @forelse ($customers as $customer)
                                                <option value="{{ $customer->id }}"
                                                        data-table="customer">{{ $customer->name }}</option>
                                            @empty
                                            @endforelse --}}
                                            @forelse ($other_accounts as $account)
                                                <option value="{{ $account->id }}"
                                                        data-table="other">{{ $account->category->name }} {{ $account->name }}
                                                </option>
                                            @empty
                                            @endforelse

                                            @forelse ($vehicles  as $v)
                                                <option value="{{ $v->id }}"
                                                        data-table="vehicle">{{ $v->vehicle_no }}
                                                </option>
                                            @empty
                                            @endforelse

                                            @forelse ($drivers   as $d)
                                                <option value="{{ $d->id }}"
                                                        data-table="driver">{{ $d->name }}
                                                </option>
                                            @empty
                                            @endforelse
                                            @forelse ($banks   as $b)
                                                <option value="{{ $b->id }}"
                                                        data-table="bank">{{ $b->name }}
                                                </option>
                                            @empty

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

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

                            <div class="row mt-2">
                                <div class="col-md-12">
                                    <label for="">تفصیل:</label>
                                    <textarea name="description" id="description" cols="10" rows="2"
                                              class="form-control"></textarea>
                                    <span class="text-danger error" id="description_error"></span>
                                </div>

                            </div>

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="">
                                        @csrf
                                        <input type="hidden" name="user_type" id="user_type">
                                        <button name="createCitySubmit" id="submit_btn"
                                                class="btn btn-sm btn-primary btn-lg"
                                                type="submit">
                                            محفوظ
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
        @endif

        <div class="{{ auth()->user()->hasPermissionTo('create receipt voucher')?'col-md-8':'col-md-12' }}">
            <div class="panel panel-card ">
                <div class="panel-body">
                    <table id="driver_table" class="table table-bordered" cellspacing="0" width="100%">
                        <thead class="bg-gold text-white">
                        <tr style="white-space: nowrap">
                            <th>#</th>
                            <th>ادائیگی کی قسم</th>
                            <th>تاریخ</th>
                            <th>رقم</th>
                            <th>پارٹی</th>
                            <th>ایکشن</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>
    {{-- Edit Voucher Modal--}}
    <div class="modal fade" id="editVoucherModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg">
            <div class="modal-content panel-card" id="editVoucherData">

            </div>
        </div>
    </div>
@endsection
@section('javascript')
    @include('receipt_vouchers.js')
@endsection
