@extends('layouts.admin')

@php
    if($create){
        $title = __('adminforms.slides.title_insert');
        $formpar = array('route' =>'admin.slide.store');
    } else {
        $title = __('adminforms.slides.title_update');
        $formpar = array('route' => array('admin.slide.update', $slide->sl_id),'method' =>'PUT');
    }

    $tr = [
       'sl title'  => __('adminforms.slides.sl_title'),
       'sl src'    => __('adminforms.slides.sl_src'),
       'sl link'   => __('adminforms.slides.sl_link'),
    ];
@endphp

@section('title'){{$title}}@endsection
@section('header'){{$title}}@endsection
@section('header_desc') @endsection
@section('breadcumbs') @endsection

@section('content')
    <!-- Main content -->
    <section class="content">



        <div class="row">

            <div class="col-xs-12">
                @if (session('error'))
                    <div class="alert alert-danger alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <i class="icon fa fa-exclamation-triangle"></i> <strong>Info: </strong> &nbsp;  &nbsp;
                        {{ session('error') }}
                    </div>
                @endif
            </div>

            {!! Form::open($formpar) !!}

            <div class="col-xs-12">



                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list-alt"></i> {{$title}}</h3>
                    </div><!-- /. panel-heading -->

                    <div class="panel-body">
                        <div class="row">

                            

                            <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                {{Form::label('sl_act', ucfirst(__('adminforms.slides.sl_act').':'))}}<br>
                                @php
                                    $cv = old('sl_act', $slide->sl_act);
                                    $actval = !is_null($cv) ? $cv : 1;
                                @endphp
                                <label class="radio-inline"><input type="radio" name="sl_act" value="1" {{ $actval== 1 ?'checked':''}} > {{__('adminforms.common.true')}}</label>
                                <label class="radio-inline"><input type="radio" name="sl_act" value="0" {{ $actval== 0 ?'checked':''}} > {{__('adminforms.common.false')}}</label>
                                <small class="error">{{ strtr($errors->first('sl_act'),$tr) }}</small>
                            </div>

                            @foreach(config('app.languages') as $lang)

                                @php

                                    $t_sl_title = '';
                                    $t_sl_src   = '';
                                    $t_sl_link  = '';


                                    if($slide->translation($lang)){
                                        $t_sl_title = $slide->translation($lang)->sl_title;
                                        $t_sl_src   = $slide->translation($lang)->sl_src;
                                        $t_sl_link  = $slide->translation($lang)->sl_link;
                                    }

                                @endphp

                                <div class="col-xs-12"><label class="lang-intro" for="">{{ucfirst(__('adminforms.common.'.$lang.'_version').':')}}</label></div>

                                <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                    {{Form::label($lang.'_'.'sl_title', ucfirst(__('adminforms.slides.sl_title').':'))}}
                                    {{Form::text($lang.'_'.'sl_title', old($lang.'_'.'sl_title', $t_sl_title  ), ['class' =>'form-control'])}}
                                    <small class="error">{{ strtr($errors->first($lang.'_'.'sl_title'),$tr) }}</small>
                                </div>

                                <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                    {{Form::label($lang.'_'.'sl_src', ucfirst(__('adminforms.slides.sl_src').':'))}}
                                    {{Form::text($lang.'_'.'sl_src', old($lang.'_'.'sl_src', $t_sl_src  ), ['class' =>'form-control','onclick' => "openKCFinder('images',this,'images/slides')"])}}
                                    <small class="error">{{ strtr($errors->first($lang.'_'.'sl_src'),$tr) }}</small>
                                </div>


                                <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                    {{Form::label($lang.'_'.'sl_link', ucfirst(__('adminforms.slides.sl_link').':'))}}
                                    {{Form::text($lang.'_'.'sl_link', old($lang.'_'.'sl_link', $t_sl_link  ), ['class' =>'form-control'])}}
                                    <small class="error">{{ strtr($errors->first($lang.'_'.'sl_link'),$tr) }}</small>
                                </div>
                                
                                
                            @endforeach
                                <br clear="all">
                            <hr>
                            <div class="col-xs-12">
                                @php $btntext = ($create) ? __('adminforms.slides.btn_insert') : __('adminforms.slides.btn_update')@endphp
                                {{Form::submit($btntext, ['class' =>'btn btn-success pull-right'])}}
                            </div>

                        </div> <!-- /.row -->
                    </div> <!-- /.panel-body -->
                </div> <!-- /.panel panel-default-->

            </div> <!-- /.col -->



            {!! Form::close() !!}

        </div>
        <!-- /.row -->

    </section>
@endsection

@push('css')
@endpush


@push('scripts')
    <script src="{{asset('assets/js/equalpbb.js')}}"></script>

    <!-- KCFinder -->
    <script type="text/javascript">
        function openKCFinder(type,field,dir) {
            //field = document.getElementById(field);//type : files / images / flash
            window.KCFinder = {  callBack: function(url) {  window.KCFinder = null;   field.value = url;}};
            window.open("/ckeditor/kcfinder/browse.php?type="+type+"&dir="+dir, "kcfinder_textbox","status=0, toolbar=0, location=0, menubar=0, directories=1,  " + "resizable=1, scrollbars=0, width=800, height=600");}
    </script>
    <!-- / KCFinder -->
@endpush