<div id="window_categoryIndex" class="page-window">
    <input type="hidden" class="prev_window"/>
    <div class="row-fluid">
      <div class="grid simple">
          <div class="grid-title no-border">
            <h4><span class="semi-bold"><?php echo e(trans('resource.category.title')); ?></span></h4>
            <div class="tools"> <a href="javascript:;" class="collapse"></a> <a href="#grid-config" data-toggle="modal" class="config"></a> <a href="javascript:;" class="reload"></a> <a href="javascript:;" class="remove"></a> </div>
          </div>
            <div class="grid-body no-border"> <br>
              <div class="row-fluid">
              <form action="" id="category_action_form">
                <input type="hidden" name="id" value="<?php echo e((count($vw_category) > 0) ? $vw_category->ca_id : ''); ?>"/>
                <div class="span8">
                  <?php $__currentLoopData = $langs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getFirstLoop(); ?>
                    <div class="control-group">
                      <label class="control-label"><?php echo e(trans('resource.news.ntitle')); ?> <?php echo e($item->lang_name); ?></label>
                      <span class="help"></span>
                      <div class="controls">
                        <input class="span12 " type="text" value="<?php echo e((count($source->get($item->lang_key)) > 0) ? $source->get($item->lang_key)->source : ''); ?>" name="title[<?php echo e($item->lang_key); ?>]">
                      </div>
                    </div>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getFirstLoop(); ?>
                  <div class="control-group">
                    <label class="control-label"><?php echo e(trans('resource.category.parent')); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <select id="parent" name="parent" class="uselect2" style="width:100%">
                        <option value="0"></option>
                        <?php $__currentLoopData = $category; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getFirstLoop(); ?>
                            <?php if(count($vw_category) > 0): ?>
                                <?php if($item->ca_id == $vw_category->parent_id): ?>
                                    <option selected="selected" value="<?php echo e($item->ca_id); ?>"><?php echo e($item->source); ?></option>
                                <?php else: ?>
                                    <option value="<?php echo e($item->ca_id); ?>"><?php echo e($item->source); ?></option>
                                <?php endif; ?>
                            <?php else: ?>
                                <option value="<?php echo e($item->ca_id); ?>"><?php echo e($item->source); ?></option>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getFirstLoop(); ?>
                      </select>
                    </div>
                  </div>
                  <div class="control-group">
                    <label class="control-label"><?php echo e(trans('resource.category.target')); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <select id="linkAction" name="action" class="uselect2" style="width:100%">
                          <?php if(count($vw_category) > 0): ?>
                              <?php if($vw_category->url == '#$cat$#'): ?>
                                <option selected="selected" value="#$cat$#"><?php echo e(trans('resource.news.title')); ?></option>
                                <option value=""><?php echo e(trans('resource.weblinks.link')); ?></option>
                              <?php else: ?>
                                <option value="#$cat$#"><?php echo e(trans('resource.news.title')); ?></option>
                                <option selected="selected" value=""><?php echo e(trans('resource.weblinks.link')); ?></option>
                              <?php endif; ?>
                          <?php else: ?>
                            <option selected="selected" value="#$cat$#"><?php echo e(trans('resource.news.title')); ?></option>
                            <option value=""><?php echo e(trans('resource.weblinks.link')); ?></option>
                          <?php endif; ?>
                      </select>
                    </div>
                  </div>
                  <?php if(count($vw_category) > 0): ?>
                      <?php if($vw_category->url == '#$cat$#'): ?>
                        <div class="control-group" style="display:none;" id="linkCont">
                      <?php else: ?>
                        <div class="control-group" id="linkCont">
                      <?php endif; ?>
                  <?php else: ?>
                      <div class="control-group" style="display:none;" id="linkCont">
                  <?php endif; ?>
                    <label class="control-label"><?php echo e(trans('resource.category.link')); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <input class="span12 " type="text" value="<?php echo e((count($vw_category) > 0) ? $vw_category->url: ''); ?>" name="link">
                    </div>
                  </div>
                  <div class="control-group">
                    <label class="control-label"><?php echo e(trans('resource.category.action')); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <select id="target" name="target" class="uselect2" style="width:100%">
                          <?php if(count($vw_category) > 0): ?>
                              <?php if($vw_category->target == '_self'): ?>
                                <option selected="selected" value="_self"><?php echo e(trans('resource.category.self')); ?></option>
                                <option value="_blank"><?php echo e(trans('resource.category.blank')); ?></option>
                              <?php else: ?>
                                <option value="_self"><?php echo e(trans('resource.category.self')); ?></option>
                                <option selected="selected" value="_blank"><?php echo e(trans('resource.category.blank')); ?></option>
                              <?php endif; ?>
                          <?php else: ?>
                            <option selected="selected" value="_self"><?php echo e(trans('resource.category.self')); ?></option>
                            <option value="_blank"><?php echo e(trans('resource.category.blank')); ?></option>
                          <?php endif; ?>
                      </select>
                    </div>
                  </div>
                  <div class="control-group">
                    <div class="controls">
                      <div class="checkbox check-default checkbox-circle">
                          <?php if(count($vw_category) > 0): ?>
                            <?php if($vw_category->show_menu == 1): ?>
                                <input id="checkbox7" name="showmenu" value="1" checked="checked" type="checkbox">
                            <?php else: ?>
                              <input id="checkbox7" name="showmenu" value="1" type="checkbox">
                            <?php endif; ?>
                          <?php else: ?>
                              <input id="checkbox7" name="showmenu" value="1" checked="checked" type="checkbox">
                          <?php endif; ?>
                          <label for="checkbox7"><?php echo e(trans('resource.category.publish')); ?></label>
                      </div>
                    </div>
                  </div>
                  <div class="control-group">
                    <label class="control-label"><?php echo e(trans('resource.main.active')); ?> / <?php echo e(trans('resource.main.deactive')); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <select id="active" name="active" class="uselect2" style="width:100%">
                        <?php if(count($vw_category) > 0): ?>
                          <?php if($vw_category->active_flag == 0): ?>
                            <option value="1"><?php echo e(trans('resource.main.active')); ?></option>
                            <option selected="selected" value="0"><?php echo e(trans('resource.main.deactive')); ?></option>
                          <?php else: ?>
                            <option selected="selected" value="1"><?php echo e(trans('resource.main.active')); ?></option>
                            <option value="0"><?php echo e(trans('resource.main.deactive')); ?></option>
                          <?php endif; ?>
                        <?php else: ?>
                          <option selected="selected" value="1"><?php echo e(trans('resource.main.active')); ?></option>
                          <option value="0"><?php echo e(trans('resource.main.deactive')); ?></option>
                        <?php endif; ?>
                      </select>
                    </div>
                  </div>
                  <div class="control-group">
                    <label class="control-label"><?php echo e(trans('resource.category.order')); ?> <?php echo e($item->lang_name); ?></label>
                    <span class="help"></span>
                    <div class="controls">
                      <input class="span12 " type="text" value="<?php echo e((count($vw_category) > 0) ? $vw_category->order_num: ''); ?>" name="order_num">
                    </div>
                  </div>
                </div>
              </form>
              </div>
              <div style="padding-top: 10px;">
                <button class="btn" onclick="uPage.close('window_categoryIndex')"><?php echo e(trans('resource.buttons.close')); ?></button>
                <button class="btn btn-primary" onclick="ucategory.save();"><?php echo e(trans('resource.buttons.save')); ?></button>
              </div>
            </div>
        </div>
      </div>
      <script type="text/javascript">
          $(document).ready(function(){

            $(".uselect2").select2();

            $("#linkAction").change(function(){
                if($(this).val() == "#$cat$#"){
                    $("#linkCont").hide();
                    $("input[name='link']").val($(this).val());
                }else{
                  $("#linkCont").show();
                  $("input[name='link']").val($(this).val());
                }
            });

          });
      </script>
    </div>
</div>
