<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/adapters/jquery.js"></script>
<?php
global $db;
ob_start();
?>
  <div id="settings-tabs">
    <ul class="resp-tabs-list settings-tabs">
      <li><i class="fa fa-file"></i>Treść</li>
      <li><i class="fa fa-wrench"></i>Ustawienia</li>
    </ul>
    <div class="resp-tabs-container settings-tabs">
      <div>
        <div id="languages-main">
          <ul class="resp-tabs-list languages-main htabs">
            <?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
              <?php if ($lg['status']) : ?>
                <li><?php echo $lg['name']; ?></a></li>
              <?php endif; ?>
            <?php endforeach; endif; ?>
          </ul>
          <div class="resp-tabs-container languages-main">
            <?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
              <?php if ($lg['status']) : ?>
                <div>
                  <?= \Html::input( [
                      'label' => 'Tytuł',
                      'name' => 'name[' . $lg['id'] . ']',
                      'id' => 'name_' . $lg['id'],
                      'value' => $this -> attribute['languages'][ $lg['id'] ]['name'],
                      'inline' => true,
                    ] ); ?>
                </div>
              <?php endif; ?>
            <?php endforeach; endif; ?>
          </div>
          <div class="clear"></div>
        </div>
      </div>
      <div>
        <?= \Html::input_switch( [
            'label' => 'Aktywny',
            'name' => 'status',
            'checked' => $this -> attribute['status'] || !$this -> attribute['id'] ? true : false,
          ] );?>
        <?= \Html::select( [
            'label' => 'Typ',
            'name' => 'type',
            'values' => [0 => 'tekst'],//, 1 => 'kolor', 2 => 'wzór'],
            'value' => $this -> attribute['type'],
          ] );?>
        <?= \Html::input( [
            'label' => 'Kolejność',
            'name' => 'o',
            'id' => 'o',
            'value' => $this -> attribute['o'],
          ] );?>
      </div>
    </div>
  </div>
<?php
$out = ob_get_clean();

$grid = new \gridEdit();
$grid -> id = 'attribute-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Edycja cechy';
$grid -> fields = [
  [
    'db' => 'id',
    'type' => 'hidden',
    'value' => $this -> attribute['id'],
  ],
];
$grid -> actions = [
  'save' => ['url' => '/admin/shop_attribute/attribute_save/', 'back_url' => '/admin/shop_attribute/view_list/'],
  'cancel' => ['url' => '/admin/shop_attribute/view_list/'],
                            ];
$grid -> external_code = $out;
$grid -> persist_edit = true;
$grid -> id_param = 'id';

echo $grid -> draw();
?>
<script type="text/javascript">
  $( function()
  {
    disable_menu();

    $( '#settings-tabs' ).easyResponsiveTabs({
      width: 'auto',
      fit: true,
      tabidentify: 'settings-tabs',
      type: 'vertical'
    });

    $( '#languages-main' ).easyResponsiveTabs({
      width: 'auto',
      fit: true,
      tabidentify: 'languages-main'
    });

  });
</script>
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
