@extends('layout')
@section('title', 'بروکرز')
@section('page_title', 'بروکرز')
@section('content')
    <div class="row">
        @if(auth()->user()->hasPermissionTo('create broker'))

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

                        <form id="add_broker_form">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="city_name">نام <span class="text-danger">*</span></label>
                                        <input type="text" id="broker_name" autofocus class="form-control"
                                               name="broker_name">
                                        <span class="text-danger error" id="broker_name_error"></span>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <label for="">شناختی کارڈ نمبر:</label>
                                    <input type="text" class="form-control" name="cnic"
                                           data-inputmask="'mask': '99999-9999999-9'">
                                    <span class="text-danger error" id="cnic_error"></span>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <label for="">فون:</label>
                                    <input type="text" class="form-control" name="phone"
                                           data-inputmask="'mask': '9999-9999999'">
                                    <span class="text-danger error" id="phone_error"></span>
                                </div>
                            </div>
                            <div class="row mt-2">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="city_name">شہر <span class="text-danger">*</span></label>
                                        <select name="city" id="city" class="form-control">
                                            <option value="">----منتخب شہر---</option>
                                            @forelse ($cities as $city)
                                                <option value="{{ $city->id }}">{{ $city->name }}</option>
                                            @empty
                                                <option value="">No City Available</option>
                                            @endforelse
                                        </select> <span class="text-danger error" id="city_error"></span>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="">
                                        @csrf
                                        <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 broker')?'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>
                            <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('brokers.js')
@endsection
