<?php
    if($create){
        $title = __('adminforms.categories.title_insert');
        $formpar = array('route' => 'admin.category.store');
    } else {
        $title = __('adminforms.categories.title_update');
        $formpar = array('route' => array('admin.category.update', $category->cat_id), 'method' => 'PUT');
    }

    $tr = [
        'cat name'         => __('adminforms.categories.cat_name'),
        'cg id'            => __('adminforms.categories.cg_id'),
        'cat feat'         => __('adminforms.categories.cat_feat'),
        'cat vat'          => __('adminforms.categories.cat_vat'),
        'cat filterable'   => __('adminforms.categories.cat_filterable'),
        'cat bold'         => __('adminforms.categories.cat_bold'),
        'cat desc type'    => __('adminforms.categories.cat_desc_type'),
        'cat vip disc'     => __('adminforms.categories.cat_reg_disc'),
        'cat sale disc'    => __('adminforms.categories.cat_sale_disc'),
        'cat sale sticker' => __('adminforms.categories.cat_sale_sticker'),
        'cat banner'       => __('adminforms.categories.cat_banner'),
        'cat bannerlink'   => __('adminforms.categories.cat_bannerlink'),
        'cat icon'         => __('adminforms.categories.cat_icon'),
        'cat title'        => __('adminforms.categories.cat_title'),
        'cat metadesc'     => __('adminforms.categories.cat_metadesc'),
        'cat keyw'         => __('adminforms.categories.cat_keyw'),
        'slug'             => __('adminforms.common.slug'),


    ];
?>

<?php $__env->startSection('title'); ?><?php echo e($title); ?><?php $__env->stopSection(); ?>
<?php $__env->startSection('header'); ?><i class="fa fa-sitemap"></i> <?php echo e($title); ?><?php $__env->stopSection(); ?>
<?php $__env->startSection('header_desc'); ?> <?php $__env->stopSection(); ?>
<?php $__env->startSection('breadcumbs'); ?> <?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <!-- Main content -->
    <section class="content">



        <div class="row">

            <div class="col-xs-12">
                <?php 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;
                        <?php echo e(session('error')); ?>

                    </div>
                <?php endif; ?>
            </div>

            <?php echo Form::open($formpar); ?>


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


                <!-- /.box-header -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title"><i class="fa fa-list-alt"></i> <?php echo e(__('adminforms.categories.general_block')); ?></h3>
                        </div>
                        <div class="panel-body">


                            <div class="row">




                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php $cgId = old('cg_id', $category->cg_id); ?>
                                <?php echo e(Form::label('cg_id', ucfirst(__('adminforms.categories.cg_id').':'))); ?>

                                <?php echo e(Form::select('cg_id', $cgroups, $cgId, ['placeholder' => 'Odaberite grupu kategorija', 'class' => 'form-control', 'id' => 'group-select'])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cg_id'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_vat', ucfirst(__('adminforms.categories.cat_vat').':'))); ?>

                                <?php echo e(Form::text('cat_vat', old('cat_vat', $category->cat_vat), ['class' => 'form-control'])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cat_vat'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php $descType = old('cat_desc_type', $category->cat_desc_type); ?>
                                <?php echo e(Form::label('cat_desc_type', ucfirst(__('adminforms.categories.cat_desc_type').':'))); ?>

                                <?php echo e(Form::select('cat_desc_type', $descTypes, $descType, ['class' => 'form-control', 'id' => 'desctype-select'])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cat_desc_type'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_feat', ucfirst(__('adminforms.categories.cat_feat').':'))); ?><br>
                                <?php
                                    $cv = old('cat_feat', $category->cat_feat);
                                    $actval = !is_null($cv) ? $cv : 0;
                                ?>
                                <label class="radio-inline"><input type="radio" name="cat_feat" value="1" <?php echo e($actval== 1 ? 'checked': ''); ?> > Da</label>
                                <label class="radio-inline"><input type="radio" name="cat_feat" value="0" <?php echo e($actval== 0 ? 'checked': ''); ?> > Ne</label>
                                <small class="error"><?php echo e(strtr($errors->first('cat_feat'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_bold', ucfirst(__('adminforms.categories.cat_bold').':'))); ?><br>
                                <?php
                                    $cv = old('cat_bold', $category->cat_bold);
                                    $actval = !is_null($cv) ? $cv : 0;
                                ?>
                                <label class="radio-inline"><input type="radio" name="cat_bold" value="1" <?php echo e($actval== 1 ? 'checked': ''); ?> > Da</label>
                                <label class="radio-inline"><input type="radio" name="cat_bold" value="0" <?php echo e($actval== 0 ? 'checked': ''); ?> > Ne</label>
                                <small class="error"><?php echo e(strtr($errors->first('cat_bold'),$tr)); ?></small>
                            </div>



                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_reg_disc', ucfirst(__('adminforms.categories.cat_reg_disc').':'))); ?>

                                <?php echo e(Form::text('cat_reg_disc', old('cat_reg_disc', $category->cat_reg_disc), ['class' => 'form-control'])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cat_reg_disc'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_sale_disc', ucfirst(__('adminforms.categories.cat_sale_disc').':'))); ?>

                                <?php echo e(Form::text('cat_sale_disc', old('cat_sale_disc', $category->cat_sale_disc), ['class' => 'form-control'])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cat_sale_disc'),$tr)); ?></small>
                            </div>




                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                <?php echo e(Form::label('cat_icon', ucfirst(__('adminforms.categories.cat_icon').':'))); ?>

                                <?php echo e(Form::text('cat_icon', old('cat_icon', $category->cat_icon), ['class' => 'form-control', 'onclick' => "openKCFinder('images',this, 'images/icons')"])); ?>

                                <small class="error"><?php echo e(strtr($errors->first('cat_icon'),$tr)); ?></small>
                            </div>

                            <?php $__currentLoopData = config('app.languages'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                    <?php

                                    $t_cat_name         = '';
                                    $t_cat_sale_sticker = '';
                                    $t_cat_banner       = '';
                                    $t_cat_bannerlink   = '';
                                    $t_cat_title        = '';
                                    $t_cat_metadesc     = '';
                                    $t_cat_keyw         = '';
                                    $t_slug             = '';

                                    $translation = $category->translation($lang);

                                    if($translation){
                                        $t_cat_name         = $translation->cat_name;
                                        $t_cat_sale_sticker = $translation->cat_sale_sticker;
                                        $t_cat_banner       = $translation->cat_banner;
                                        $t_cat_bannerlink   = $translation->cat_bannerlink;
                                        $t_cat_title        = $translation->cat_title;
                                        $t_cat_metadesc     = $translation->cat_metadesc;
                                        $t_cat_keyw         = $translation->cat_keyw;
                                    }

                                    $route = $category->route($lang);

                                    if($route){
                                        $t_slug             = $route->slug;
                                    }

                                    ?>
                                    <div class="col-xs-12"><label class="lang-intro" for=""><?php echo e(ucfirst(__('adminforms.common.'.$lang.'_version').':')); ?></label></div>

                                    <div class="col-xs-12 col-sm-6 col-md-6 pbb">
                                        <?php echo e(Form::label($lang.'_'.'cat_name', $lang.' '.ucfirst(__('adminforms.categories.cat_name').':'))); ?>

                                        <?php echo e(Form::text($lang.'_'.'cat_name', old($lang.'_'.'cat_name', $t_cat_name), ['class' => 'form-control',  'id' => $lang.'name'])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_name'),$tr)); ?></small>
                                    </div>


                                    <div class="col-xs-12 col-sm-6 col-md-6 pbb">
                                        <?php echo e(Form::label($lang.'_'.'slug', ucfirst(__('adminforms.common.slug').__('adminforms.common.slug_info').':'))); ?>

                                        <?php echo e(Form::text($lang.'_'.'slug', old($lang.'_'.'slug', $t_slug ), ['class' => 'form-control', 'id' => $lang.'slug'])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'slug'),$tr)); ?></small>
                                    </div>

                                    <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                        <?php echo e(Form::label($lang.'_'.'cat_sale_sticker', $lang.' '.ucfirst(__('adminforms.categories.cat_sale_sticker').':'))); ?>

                                        <?php echo e(Form::text($lang.'_'.'cat_sale_sticker', old($lang.'_'.'cat_sale_sticker', $t_cat_sale_sticker), ['class' => 'form-control', 'onclick' => "openKCFinder('images',this, 'images/stickers')"])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_sale_sticker'),$tr)); ?></small>
                                    </div>


                                    <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                        <?php echo e(Form::label($lang.'_'.'cat_banner', $lang.' '.ucfirst(__('adminforms.categories.cat_banner').':'))); ?>

                                        <?php echo e(Form::text($lang.'_'.'cat_banner', old($lang.'_'.'cat_banner', $t_cat_banner), ['class' => 'form-control', 'onclick' => "openKCFinder('images',this, 'images/banners')"])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_banner'),$tr)); ?></small>
                                    </div>


                                    <div class="col-xs-12 col-sm-6 col-md-4 pbb">
                                        <?php echo e(Form::label($lang.'_'.'cat_bannerlink', $lang.' '.ucfirst(__('adminforms.categories.cat_bannerlink').':'))); ?>

                                        <?php echo e(Form::text($lang.'_'.'cat_bannerlink', old($lang.'_'.'cat_bannerlink', $t_cat_bannerlink), ['class' => 'form-control'])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_bannerlink'),$tr)); ?></small>
                                    </div>

                                    <div class="col-xs-12"><hr></div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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

                    </div>  <!-- /.box-body -->
                </div>  <!-- /.box -->

                <div class="box">

                    <div class="panel panel-default">

                        <div class="panel-heading">
                            <h3 class="panel-title"><i class="fa fa-cog"></i> <?php echo e(__('adminforms.categories.meta_block')); ?></h3>
                        </div>

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

                                <?php $__currentLoopData = config('app.languages'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>


                                    <div class="col-xs-12"><label class="lang-intro" for=""><?php echo e(ucfirst(__('adminforms.common.'.$lang.'_version').':')); ?></label></div>

                                    <div class="col-xs-12 col-sm-6 col-md-4">
                                        <?php echo e(Form::label($lang.'_'.'cat_title', $lang.' '.ucfirst(__('adminforms.categories.cat_title').':'))); ?>

                                        <?php echo e(Form::textarea ($lang.'_'.'cat_title', old($lang.'_'.'cat_title', $t_cat_title), ['class' => 'form-control', 'rows' => 3])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_title'),$tr)); ?></small>
                                    </div>




                                    <div class="col-xs-12 col-sm-6 col-md-4">
                                        <?php echo e(Form::label($lang.'_'.'cat_metadesc', $lang.' '.ucfirst(__('adminforms.categories.cat_metadesc').':'))); ?>

                                        <?php echo e(Form::textarea ($lang.'_'.'cat_metadesc', old($lang.'_'.'cat_metadesc', $t_cat_metadesc), ['class' => 'form-control', 'rows' => 3])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_metadesc'),$tr)); ?></small>
                                    </div>


                                    <div class="col-xs-12 col-sm-6 col-md-4">
                                        <?php echo e(Form::label($lang.'_'.'cat_keyw', $lang.' '.ucfirst(__('adminforms.categories.cat_keyw').':'))); ?>

                                        <?php echo e(Form::textarea ($lang.'_'.'cat_keyw', old($lang.'_'.'cat_keyw', $t_cat_keyw), ['class' => 'form-control', 'rows' => 3])); ?>

                                        <small class="error"><?php echo e(strtr($errors->first($lang.'_'.'cat_keyw'),$tr)); ?></small>
                                    </div>

                                    <div class="col-xs-12"><hr></div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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


                </div><!-- /.panel -->
            </div> <!-- /.box -->


            <div class="box">

                <div class="panel panel-default">

                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list"></i></i> <?php echo e(__('adminforms.categories.attributes_block')); ?></h3>
                    </div>

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

                            <div class="col-xs-12 col-md-2 pbb">
                                <?php echo e(Form::label('cat_filterable', ucfirst(__('adminforms.categories.cat_filterable').':'))); ?><br>
                                <?php
                                    $cv = old('cat_filterable', $category->cat_filterable);
                                    $actval = !is_null($cv) ? $cv : 0;
                                ?>
                                <label class="radio-inline"><input type="radio" name="cat_filterable" value="1" <?php echo e($actval== 1 ? 'checked': ''); ?> > Da</label>
                                <label class="radio-inline"><input type="radio" name="cat_filterable" value="0" <?php echo e($actval== 0 ? 'checked': ''); ?> > Ne</label>
                                <small class="error"><?php echo e(strtr($errors->first('cat_filterable'),$tr)); ?></small>
                            </div>


                            <div class="col-xs-12 col-md-10"  id="attributes">
                                <label>Odaberi filtere grupe:</label>
                                <?php $oldValues = session()->getOldInput(); ?>
                                <?php if(isset($oldValues['atr_id'])): ?>
                                    <?php $__currentLoopData = $oldValues['atr_id']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <input type="text" name="atr_id[<?php echo e($i); ?>]" value="<?php echo e($v); ?>" class="atr_id" />
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php elseif(count($attributes)): ?>
                                    <?php $__currentLoopData = $attributes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <input type="text" name="atr_id[<?php echo e($a->atr_id); ?>]" value="<?php echo e($a->ctranslation->atr_name); ?>" class="atr_id" />
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php else: ?>

                                    <input class="atr_id" type="text" value=""  name="atr_id[]">
                                <?php endif; ?>

                            </div>

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


                </div><!-- /.panel -->
            </div> <!-- /.box -->



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

            <div class="col-xs-12">
                <?php $btntext = ($create) ? __('adminforms.categories.btn_insert') : __('adminforms.categories.btn_update')?>
                <?php echo e(Form::submit($btntext, ['class' => 'btn btn-success pull-right'])); ?>

            </div>

            <?php echo Form::close(); ?>


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

    </section>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('css'); ?>
    <!-- tags -->
    <link rel="stylesheet" href="<?php echo e(asset('assets/tags/jquery-ui-1.10.0.custom.css')); ?>">
    <link rel="stylesheet" href="<?php echo e(asset('assets/tags/jquery.tageditp.css')); ?>">
    <!-- /tags -->
<?php $__env->stopPush(); ?>


<?php $__env->startPush('scripts'); ?>
    <script src="<?php echo e(asset('assets/js/equalpbb.js')); ?>"></script>

    <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>


    <!-- tags -->

    <script src="<?php echo e(asset('assets/tags/jquery-ui.js')); ?>"></script>
    
    <script src="<?php echo e(asset('assets/tags/jquery.auto-grow-input.min.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/tags/jquery.tagedit.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/tags/jquery.tageditupdt.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/tags/jquery.tageditwp.js')); ?>"></script>




    <script type="text/javascript" >
        $(function() {

            $("#attributes").find("input.atr_id").tagedit({
                autocompleteURL: "/panel/ajax-attributesidname",
                additionalListClass: "form-control",
                allowEdit: false,
                allowAdd: false,
                autocompleteOptions: { minLength: 2 }
            });

            /*$("#spec").find("input.specs").tageditupdt({
                additionalListClass: "form-control",
                autocompleteURL: "/panel/ajax-retesame",
                allowEdit: true,
                allowAdd: true ,
                addedPostfix: "n"
            });*/


            $("#lproducts").find("input.lprod_id").tageditwp({
                autocompleteURL: "/panel/ajax-productsidname",
                additionalListClass: "form-control",
                allowEdit: false,
                allowAdd: false,
                autocompleteOptions: { minLength: 2 }
            });

        });

        $(".atr_id, .specs, .lprod_id").autoGrowInput({ minWidth: 100, maxWidth: 20000, comfortZone: 15 }); // klase tagedit polja ne vrapera


    </script>


    <!-- /tags -->

    <script>
        $(document).ready(function(){
            <?php $__currentLoopData = config('app.languages'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            $('#<?php echo e($lang); ?>name').keyup(function () {
                var cval = $.trim($(this).val());
                var cslug = cval.replace(/\s/g, '-').toLowerCase();
                $('#<?php echo e($lang); ?>slug').val(cslug);
            });
            $('#<?php echo e($lang); ?>name').blur(function () {
                var cval = $.trim($(this).val());
                var cslug = cval.replace(/\s/g, '-').toLowerCase();
                $('#<?php echo e($lang); ?>slug').val(cslug);
            });
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        });
    </script>

<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>