@extends('admin.layouts.container')

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

<div class="border-item">
    <form class="form-row add_about_form" method="post" action="{{ $action }}" enctype="multipart/form-data">
        @if($about ?? ''  && $about->id)
            @method('PUT')
        @endif
        @csrf

        <div class="form-group col-lg-12">
            <label>{{ meta('video_url', $lang) ?? __('abouts.video_url') }} </label>
            <input type="url"  class="form-control {{ $errors->has('video_url') ? 'is-invalid' : '' }}" name="video_url" placeholder="{{ meta('video_url', $lang) ?? __('abouts.video_url') }}" value='{{ old("video_url", $about->video_url ?? "") }}'/>
        </div>
        <div class="form-group col-lg-3">
            <label>{{ meta('client_numbers', $lang) ?? __('abouts.client_numbers') }} </label>
            <input type="number" min="1"  class="form-control {{ $errors->has('client_numbers') ? 'is-invalid' : '' }}" name="client_numbers" placeholder="{{ meta('client_numbers', $lang) ?? __('abouts.client_numbers') }}" value='{{ old("client_numbers", $about->client_numbers ?? "") }}'/>
        </div>
        <div class="form-group col-lg-3">
            <label>{{ meta('consulting_numbers', $lang) ?? __('abouts.consulting_numbers') }} </label>
            <input type="number" min="1"  class="form-control {{ $errors->has('consulting_numbers') ? 'is-invalid' : '' }}" name="consulting_numbers" placeholder="{{ meta('consulting_numbers', $lang) ?? __('abouts.consulting_numbers') }}" value='{{ old("consulting_numbers", $about->consulting_numbers ?? "") }}'/>
        </div>
        <div class="form-group col-lg-3">
            <label>{{ meta('cases_numbers', $lang) ?? __('abouts.cases_numbers') }} </label>
            <input type="number" min="1" class="form-control {{ $errors->has('cases_numbers') ? 'is-invalid' : '' }}" name="cases_numbers" placeholder="{{ meta('cases_numbers', $lang) ?? __('abouts.cases_numbers') }}" value='{{ old("cases_numbers", $about->cases_numbers ?? "") }}'/>
        </div>
        <div class="form-group col-lg-3">
            <label>{{ meta('documentation_numbers', $lang) ?? __('abouts.documentation_numbers') }} </label>
            <input type="number" min="1" class="form-control {{ $errors->has('documentation_numbers') ? 'is-invalid' : '' }}" name="documentation_numbers" placeholder="{{ meta('documentation_numbers', $lang) ?? __('abouts.documentation_numbers') }}" value='{{ old("documentation_numbers", $about->documentation_numbers ?? "") }}'/>
        </div>

        @foreach($languages as $language)
        <div class="form-group col-lg-6">
            <label>{{ meta('about_title', $language->local) ?? __('abouts.about_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('about_title_'.$language->local) ? 'is-invalid' : '' }}" name="about_title_{{ $language->local }}" placeholder="{{ meta('about_title', $language->local) ?? __('abouts.about_title') }}" value='{{ old("about_title_{$language->local}", $about[$language->local]->about_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('vision_title', $language->local) ?? __('abouts.vision_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('vision_title_'.$language->local) ? 'is-invalid' : '' }}" name="vision_title_{{ $language->local }}" placeholder="{{ meta('vision_title', $language->local) ?? __('abouts.vision_title') }}" value='{{ old("vision_title_{$language->local}", $about[$language->local]->vision_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('mission_title', $language->local) ?? __('abouts.mission_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('mission_title_'.$language->local) ? 'is-invalid' : '' }}" name="mission_title_{{ $language->local }}" placeholder="{{ meta('mission_title', $language->local) ?? __('abouts.mission_title') }}" value='{{ old("mission_title_{$language->local}", $about[$language->local]->mission_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('message_title', $language->local) ?? __('abouts.message_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('message_title_'.$language->local) ? 'is-invalid' : '' }}" name="message_title_{{ $language->local }}" placeholder="{{ meta('message_title', $language->local) ?? __('abouts.message_title') }}" value='{{ old("message_title_{$language->local}", $about[$language->local]->message_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('video_title', $language->local) ?? __('abouts.video_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('video_title_'.$language->local) ? 'is-invalid' : '' }}" name="video_title_{{ $language->local }}" placeholder="{{ meta('video_title', $language->local) ?? __('abouts.video_title') }}" value='{{ old("video_title_{$language->local}", $about[$language->local]->video_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('client_title', $language->local) ?? __('abouts.client_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('client_title_'.$language->local) ? 'is-invalid' : '' }}" name="client_title_{{ $language->local }}" placeholder="{{ meta('client_title', $language->local) ?? __('abouts.client_title') }}" value='{{ old("client_title_{$language->local}", $about[$language->local]->client_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('cases_title', $language->local) ?? __('abouts.cases_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('cases_title_'.$language->local) ? 'is-invalid' : '' }}" name="cases_title_{{ $language->local }}" placeholder="{{ meta('cases_title', $language->local) ?? __('abouts.cases_title') }}" value='{{ old("cases_title_{$language->local}", $about[$language->local]->cases_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('consulting_title', $language->local) ?? __('abouts.consulting_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('consulting_title_'.$language->local) ? 'is-invalid' : '' }}" name="consulting_title_{{ $language->local }}" placeholder="{{ meta('consulting_title', $language->local) ?? __('abouts.consulting_title') }}" value='{{ old("consulting_title_{$language->local}", $about[$language->local]->consulting_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('documentation_title', $language->local) ?? __('abouts.documentation_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('documentation_title_'.$language->local) ? 'is-invalid' : '' }}" name="documentation_title_{{ $language->local }}" placeholder="{{ meta('documentation_title', $language->local) ?? __('abouts.documentation_title') }}" value='{{ old("documentation_title_{$language->local}", $about[$language->local]->documentation_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('achieve_title', $language->local) ?? __('abouts.achieve_title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('achieve_title_'.$language->local) ? 'is-invalid' : '' }}" name="achieve_title_{{ $language->local }}" placeholder="{{ meta('achieve_title', $language->local) ?? __('abouts.achieve_title') }}" value='{{ old("achieve_title_{$language->local}", $about[$language->local]->achieve_title ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('slug', $language->local) ?? __('abouts.slug') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('slug_'.$language->local) ? 'is-invalid' : '' }}" name="slug_{{ $language->local }}" placeholder="{{ meta('slug', $language->local) ?? __('abouts.slug') }}" value='{{ old("slug_{$language->local}", $about[$language->local]->slug ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('keywords', $language->local) ?? __('abouts.keywords') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('keywords_'.$language->local) ? 'is-invalid' : '' }}" name="keywords_{{ $language->local }}" placeholder="{{ meta('keywords', $language->local) ?? __('abouts.keywords') }}" value='{{ old("keywords_{$language->local}", $about[$language->local]->keywords ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('meta_description', $language->local) ?? __('abouts.meta_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('meta_description_'.$language->local) ? 'is-invalid' : '' }}" name="meta_description_{{ $language->local }}" placeholder="{{ meta('meta_description', $language->local) ?? __('abouts.meta_description') }}" value='{{ old("meta_description_{$language->local}", $about[$language->local]->meta_description ?? "") }}'/>
        </div>

        <div class="form-group col-lg-12">
            <label>{{ meta('about_description', $language->local) ?? __('abouts.about_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="about_description_{{ $language->local }}" class="form-control  {{ $errors->has('about_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('about_description', $language->local) ?? __('abouts.about_description') }}">{{ old("about_description_{$language->local}", $about[$language->local]->about_description ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('video_description', $language->local) ?? __('abouts.video_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="video_description_{{ $language->local }}" class="form-control  {{ $errors->has('video_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('video_description', $language->local) ?? __('abouts.video_description') }}">{{ old("video_description_{$language->local}", $about[$language->local]->video_description ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('vision_description', $language->local) ?? __('abouts.vision_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="vision_description_{{ $language->local }}" class="form-control  {{ $errors->has('vision_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('vision_description', $language->local) ?? __('abouts.vision_description') }}">{{ old("vision_description_{$language->local}", $about[$language->local]->vision_description ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('mission_description', $language->local) ?? __('abouts.mission_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="mission_description_{{ $language->local }}" class="form-control  {{ $errors->has('mission_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('mission_description', $language->local) ?? __('abouts.mission_description') }}">{{ old("mission_description_{$language->local}", $about[$language->local]->mission_description ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('message_description', $language->local) ?? __('abouts.message_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="message_description_{{ $language->local }}" class="form-control  {{ $errors->has('message_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('message_description', $language->local) ?? __('abouts.message_description') }}">{{ old("message_description_{$language->local}", $about[$language->local]->message_description ?? "") }}</textarea>
        </div>
        <div class="form-group col-lg-12">
            <label>{{ meta('achieve_description', $language->local) ?? __('abouts.achieve_description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <textarea rows="7" name="achieve_description_{{ $language->local }}" class="form-control  {{ $errors->has('achieve_description_'.$language->local) ? 'is-invalid' : '' }}" placeholder="{{ meta('achieve_description', $language->local) ?? __('abouts.achieve_description') }}">{{ old("achieve_description_{$language->local}", $about[$language->local]->achieve_description ?? "") }}</textarea>
        </div>
        @endforeach

            {{--Start about_image_1 container--}}
            <div class="form-group col-lg-4">
                <label>{{ meta('about_image_1', $lang) ?? __('abouts.about_image_1') }} </label>
                <input id="about_image_1_thumbnail" class="about_image_1_thumbnail" type="hidden" name="about_image_1" value="{{old("about_image_1", $about->about_image_1 ?? "")}}"/>

                <div class="photos about_image_1_main_photo {{ old('about_image_1', $about->about_image_1 ?? '') ? ' wow fadeInUp' : 'hide' }}">
                    <div class="col-lg-12">
                        <div class="items">
                            <div class="img">
                                <a href="#" id="lfm" data-input=".about_image_1_thumbnail" data-preview=".about_image_1_holder" class="lfm" data-hide=".about_image_1_pick_button">
                                    <img src="{{asset(old('about_image_1', $about->about_image_1 ?? ''))}} "  id="about_image_1_holder" class="about_image_1_holder"/>
                                </a>
                            </div>
                            <a href="#" class="showHide resetImage close" data-empty=".about_image_1_thumbnail" data-hide=".about_image_1_main_photo" data-show=".about_image_1_pick_button"><i class="fas fa-times"></i></a>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>
                <span class="input-group-btn about_image_1_pick_button {{ old('about_image_1', $about->about_image_1 ?? '') ? 'hide' : '' }} ">
                <a id="lfm" data-input=".about_image_1_thumbnail" data-preview=".about_image_1_holder" data-show=".about_image_1_main_photo" data-hide=".about_image_1_pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> Choose
                </a>
            </span>
            </div>
            {{--End about_image_1 container--}}

            {{--Start about_image_2 container--}}
{{--            <div class="form-group col-lg-4">--}}
{{--                <label>{{ meta('about_image_2', $lang) ?? __('abouts.about_image_2') }} </label>--}}
{{--                <input id="about_image_2_thumbnail" class="about_image_2_thumbnail" type="hidden" name="about_image_2" value="{{old("about_image_2", $about->about_image_2 ?? "")}}"/>--}}

{{--                <div class="photos about_image_2_main_photo {{ old('about_image_2', $about->about_image_2 ?? '') ? ' wow fadeInUp' : 'hide' }}">--}}
{{--                    <div class="col-lg-12">--}}
{{--                        <div class="items">--}}
{{--                            <div class="img">--}}
{{--                                <a href="#" id="lfm" data-input=".about_image_2_thumbnail" data-preview=".about_image_2_holder" class="lfm" data-hide=".about_image_2_pick_button">--}}
{{--                                    <img src="{{asset(old('about_image_2', $about->about_image_2 ?? ''))}} "  id="about_image_2_holder" class="about_image_2_holder"/>--}}
{{--                                </a>--}}
{{--                            </div>--}}
{{--                            <a href="#" class="showHide resetImage close" data-empty=".about_image_2_thumbnail" data-hide=".about_image_2_main_photo" data-show=".about_image_2_pick_button"><i class="fas fa-times"></i></a>--}}
{{--                        </div>--}}
{{--                    </div>--}}
{{--                </div>--}}

{{--                <div class="clearfix"></div>--}}
{{--                <span class="input-group-btn about_image_2_pick_button {{ old('about_image_2', $about->about_image_2 ?? '') ? 'hide' : '' }} ">--}}
{{--                <a id="lfm" data-input=".about_image_2_thumbnail" data-preview=".about_image_2_holder" data-show=".about_image_2_main_photo" data-hide=".about_image_2_pick_button" class="lfm btn btn-primary text-light">--}}
{{--                    <i class="fas fa-camera-retro"></i> Choose--}}
{{--                </a>--}}
{{--            </span>--}}
{{--            </div>--}}
            {{--End about_image_2 container--}}

            {{--Start video_image container--}}
            <div class="form-group col-lg-4">
                <label>{{ meta('video_image', $lang) ?? __('abouts.video_image') }} </label>
                <input id="video_image_thumbnail" class="video_image_thumbnail" type="hidden" name="video_image" value="{{old("video_image", $about->video_image ?? "")}}"/>

                <div class="photos video_image_main_photo {{ old('video_image', $about->video_image ?? '') ? ' wow fadeInUp' : 'hide' }}">
                    <div class="col-lg-12">
                        <div class="items">
                            <div class="img">
                                <a href="#" id="lfm" data-input=".video_image_thumbnail" data-preview=".video_image_holder" class="lfm" data-hide=".video_image_pick_button">
                                    <img src="{{asset(old('video_image', $about->video_image ?? ''))}} "  id="video_image_holder" class="video_image_holder"/>
                                </a>
                            </div>
                            <a href="#" class="showHide resetImage close" data-empty=".video_image_thumbnail" data-hide=".video_image_main_photo" data-show=".video_image_pick_button"><i class="fas fa-times"></i></a>
                        </div>
                    </div>
                </div>

                <div class="clearfix"></div>
                <span class="input-group-btn video_image_pick_button {{ old('video_image', $about->video_image ?? '') ? 'hide' : '' }} ">
                <a id="lfm" data-input=".video_image_thumbnail" data-preview=".video_image_holder" data-show=".video_image_main_photo" data-hide=".video_image_pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> Choose
                </a>
            </span>
            </div>
            {{--End video_image container--}}

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

@endsection

@section('inner_js')
    <!-- Editor JS files -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
    {{--    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>--}}
    <script>
        var route_prefix = "{{ url(config('lfm.prefix')) }}";
        var url = "{{url('/')}}/",
            currentLanguage = "{{$lang}}",
            inputName = null;
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>

    <script>
        $('.add_about_button').click(async function (e) {
            e.preventDefault();
            $(this).prop('disabled', true);

            let form = $('.add_about_form'),
                data = new FormData(form[0]),
                url = form.attr('action'),
                method = form.attr('method');


            const response=await ajax({
                url,
                data,
                dataType: 'json',
                method
            });

            if (response.url){
                window.location.href = response.url;
            }

            if (response.errors){
                $(this).prop('disabled', false);
                toasterError(response.errors);
            }


        });
    </script>

@endsection



