@extends('admin.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? '' }}</h3>
    </div>


    <div class="border-item">
        <ul class="nav nav-pills bg-nav-pills nav-justified mb-3">
            <li class="nav-item">
                <a href="#details" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0 active">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('canteens.details')}}</span>
                </a>
            </li>

            <li class="nav-item">
                <a href="#user_info" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('canteens.user_info')}}</span>
                </a>
            </li>


        </ul>
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
            @if($canteen ?? ''  && $canteen->id)
                @method('PUT')
            @endif
            @csrf

            <div class="tab-content col-lg-12">
                <div class="tab-pane active" id="details">
                    <div class="row">
                        <div class="form-group col-lg-12">
                            <h3>{{  __('canteens.details') }} </h3>
                        </div>

                        @if($canteen ?? ''  && $canteen->id)
                            <div class="form-group col-lg-6">
                                <label>{{  __('canteens.code') }} </label>
                                <p class="form-control" style="height: auto">#{{$canteen->code}}</p>
                            </div>
                            <div class="form-group col-lg-6">
                                <label>{{  __('canteens.wallet') }} </label>
                                <p class="form-control" style="height: auto">{{$total ?? 0}}</p>
                            </div>
                        @endif

                        <div class="form-group col-lg-6">
                            <label>{{ __('canteens.school_id') }} </label>
                            <select class="form-control {{ $errors->has('school_id') ? 'is-invalid' : '' }}" name="school_id">
                                <option value="">{{__('dashboard.select')}}</option>
                                @foreach($schools as $row)
                                    <option {{ (isset($canteen) ? $canteen->school_id : null) == $row->id ? 'selected' : '' }} value="{{$row->id}}">{{$row->title}}</option>
                                @endforeach
                            </select>
                        </div>


                        @foreach($languages as $language)

                            <div class="form-group col-lg-6">
                                <label>{{ meta('title', $language->local) ?? __('cities.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                                <input type="text" class="form-control {{ $errors->has('title_'.$language->local) ? 'is-invalid' : '' }}" name="title_{{ $language->local }}" placeholder="{{ meta('title', $language->local) ?? __('cities.title') }}" value='{{ old("title_{$language->local}", $canteen[$language->local]->title ?? "") }}'/>
                            </div>

                        @endforeach

                        <div class="form-group col-lg-6">
                            <label>{{ __('canteens.account_name') }} </label>
                            <input type="text" class="form-control {{ $errors->has('account_name') ? 'is-invalid' : '' }}" name="account_name" placeholder="{{ __('canteens.account_name') }}" value='{{ old("account_name", $canteen->account_name ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('canteens.account_number') }} </label>
                            <input type="text" class="form-control {{ $errors->has('account_number') ? 'is-invalid' : '' }}" name="account_number" placeholder="{{ __('canteens.account_number') }}" value='{{ old("account_number", $canteen->account_number ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('canteens.bank_name') }} </label>
                            <input type="text" class="form-control {{ $errors->has('bank_name') ? 'is-invalid' : '' }}" name="bank_name" placeholder="{{ __('canteens.bank_name') }}" value='{{ old("bank_name", $canteen->bank_name ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('canteens.iban') }} </label>
                            <input type="text" class="form-control {{ $errors->has('iban') ? 'is-invalid' : '' }}" name="iban" placeholder="{{ __('canteens.iban') }}" value='{{ old("iban", $canteen->iban ?? "") }}'/>
                        </div>



                  

                    </div>

                </div>

                <div class="tab-pane " id="user_info">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('canteens.user_info')}}
                            </h3>
                            <hr>
                        </div>

                        <div class="form-group col-lg-6">
                            <label>{{ __('users.id_number') }} </label>
                            <input type="text" class="form-control {{ $errors->has('id_number') ? 'is-invalid' : '' }}" name="id_number" placeholder="{{ __('users.id_number') }}" value='{{ old("id_number", $user->id_number ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('users.email') }} </label>
                            <input type="email" class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" name="email" placeholder="{{ __('users.email') }}" value='{{ old("email", $user->email ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('users.phone') }} </label>
                            <input type="text" class="form-control {{ $errors->has('phone') ? 'is-invalid' : '' }}" name="phone" placeholder="{{ __('users.phone') }}" value='{{ old("phone", $user->phone ?? "") }}'/>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('users.password') }} </label>
                            <input type="password" class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}" name="password" placeholder="{{ __('users.password') }}" />
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('users.password_confirmation') }} </label>
                            <input type="password" class="form-control {{ $errors->has('password_confirmation') ? 'is-invalid' : '' }}" name="password_confirmation" placeholder="{{ __('users.password_confirmation') }}" />
                        </div>
                      <div class="form-group col-lg-12 image_container" >
                            <label>{{ meta('image', getCurrentLocale()) ?? __('canteens.image') }} </label>
                            <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="photo" value="{{old("photo", $user->photo ?? "")}}"/>

                            <div class="photos main_photo {{ old('photo', $user->photo ?? '') ? ' wow fadeInUp' : 'hide' }}">
                                <div class="col-md-4">
                                    <div class="items">
                                        <div class="img">
                                            <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".pick_button">
                                                <img src="{{asset(old('photo', $user->photo ?? ''))}} "  id="image_holder" class="image_holder"/>
                                            </a>
                                        </div>
                                        <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                                    </div>
                                </div>
                            </div>

                            <div class="clearfix"></div>
                            <span class="input-group-btn pick_button {{ old('photo', $user->photo ?? '') ? 'hide' : '' }} ">
                                <a id="lfm"  data-input=".image_thumbnail" data-preview=".image_holder" data-show=".main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                                    <i class="fas fa-camera-retro"></i> {{__('dashboard.choose')}}
                                </a>
                             </span>
                        </div>


                    </div>
                </div>



            </div>

                <div class="text-center mt-5 col-12">
                    <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
                </div>
        </form>
    </div>




@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/articles.js') }}"></script>
@endsection



