@extends('layout')
@section('title', 'جرنل واؤچرز')
@section('page_title', 'جرنل واؤچرز')
@section('content')
    <div class="row">
        @if(auth()->user()->hasPermissionTo('create general voucher'))
            <div class="col-md-4">
                <div class="panel panel-card margin-b-30">
                    <div class="panel-body">
                        <form id="add_journal_voucher_form">

                            <div class="row mt-2">
                                <div class="col-md-6">
                                    <label for="">تاریخ:</label>
                                    <input type="date" class="form-control change_focus" data-id="amount" id="date"
                                           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="debit_account"
                                           id="amount" name="amount">
                                    <span class="text-danger error" id="amount_error"></span>
                                </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="debit_account" id="debit_account"
                                                class="form-control change_focus" data-id="credit_account">
                                            <option value="">----Select Party----</option>
                                            <option value="cash" data-table="cash">Cash</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 ($vehicles as $vehicle)
                                                <option value="{{ $vehicle->id }}"
                                                        data-table="vehicle">{{ $vehicle->vehicle_no }}</option>
                                            @empty
                                            @endforelse

                                            @forelse ($banks as $bank)
                                                <option value="{{ $bank->id }}"
                                                        data-table="bank">{{ $bank->name }}</option>
                                            @empty
                                            @endforelse
                                        </select>
                                        <span class="text-danger error" id="debit_account_error"></span>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="name">کریڈٹ اکاؤنٹ: <span class="text-danger">*</span></label>
                                        <select name="credit_account" id="credit_account"
                                                class="form-control change_focus" data-id="description">
                                            <option value="">----Select Party----</option>
                                            <option value="cash" data-table="cash">Cash</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 ($vehicles as $vehicle)
                                                <option value="{{ $vehicle->id }}"
                                                        data-table="vehicle">{{ $vehicle->vehicle_no }}</option>
                                            @empty
                                            @endforelse

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

                                        </select>
                                        <span class="text-danger error" id="credit_account_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 mt-2">
                                <div class="col-md-12">
                                    <div class="">
                                        @csrf
                                        <input type="hidden" name="credit_table" id="credit_table">
                                        <input type="hidden" name="debit_table" id="debit_table">
                                        <button name="createCitySubmit" id="submit_btn"
                                                class="btn btn-sm btn-primary "
                                                type="submit">
                                            محفوظ
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>

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

        <div class="{{ auth()->user()->hasPermissionTo('create general voucher')?'col-md-8':'col-md-12' }}">
            <div class="panel panel-card ">
                <div class="panel-body">
                    <table id="journal_voucher_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>


    <div class="modal fade" id="editJournalVoucherModal" tabindex="-1" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content panel-card" id="editJournalVoucherData">

            </div>
        </div>
    </div>

@endsection
@section('javascript')
    @include('journal_vouchers.js')
@endsection
