@extends('layout')
@section('title', 'Opening Balance')
@section('page_title', 'اوپنینگ بیلنس')
@section('content')
    <div class="row">
        @if(auth()->user()->hasPermissionTo('create opening balance'))
            <div class="col-md-4">
                <div class="panel panel-card margin-b-30">
                    <div class="panel-body">
                        <form id="add_opening_balance_form">

                            <div class="row">
                                <div class="col-md-6">
                                    <label for="">:تاریخ</label>
                                    <input type="date" value="{{ date('Y-m-d') }}" class="form-control" name="date"
                                           id="date" autofocus>
                                    <span class="text-danger error" id="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="party" onchange="party_change()" class="form-control"
                                                autofocus>
                                            <option value="">----منتخب پارٹی----</option>
                                            <option value="0" data-table="cash">Cash</option>

                                            @forelse ($otherAccounts as $otherAccount)
                                            <option value="{{ $otherAccount->id }}"
                                                    data-table="other_account">{{ $otherAccount->name }}</option>
                                        @empty

                                        @endforelse

                                            @forelse ($brokers as $broker)
                                                <option value="{{ $broker->id }}"
                                                        data-table="broker">{{ $broker->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="party_error"></span>
                                    </div>
                                </div>


                            </div>
                            <div class="row mt-2">
                                <div class="col-md-6">
                                    <label for="">بیلنس قسم:</label><br>
                                    <label for="debit_balance"><input type="radio" id="debit_balance" name="balance_type" value="debit"> ڈیبٹ </label>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <label for="credit_balance"><input type="radio" id="credit_balance" name="balance_type" value="credit"> کریڈٹ </label><br>
                                    <span class="text-danger error" id="balance_type_error"></span>
                                </div>
                                <div class="col-md-6">
                                    <div>

                                        <label for="">رقم:</label>
                                    </div>
                                    <input type="text" class="form-control" 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">
                                    <div class="form-group">
                                        <label for="city_name">وضاحت:</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>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="">
                                        @csrf
                                        <input type="hidden" id="hidden_party_table" name="party_table">
                                        <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 opening balance')?'col-md-8':'col-md-12' }}">
            <div class="panel panel-card ">
                <div class="panel-body">
                    <table id="cities_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>
                        </tr>
                        </thead>
                        <tbody>

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

    </div>

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

            </div>
        </div>
    </div>
@endsection

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