<? $this -> values['name'] ? $g_table = $this -> values['name'] : $g_table = $this -> values[ 'table' ];?>
<? if ( $this -> values['include_plugins'] ):?>
  <script class="footer" type="text/javascript">
    var dir = '/plugins/grid';
  </script>
  <!-- iradio -->
  <link class="footer" rel='stylesheet' type='text/css' href='/plugins/grid/plugins/icheck/skins/minimal/minimal.css' />
  <link class="footer" rel='stylesheet' type='text/css' href='/plugins/grid/plugins/icheck/skins/minimal/blue.css' />
  <script class="footer" type="text/javascript" src="/plugins/grid/plugins/icheck/icheck.min.js"></script>
  <!-- ipromptu -->
  <link class="footer" rel='stylesheet' type='text/css' href='/plugins/grid/plugins/impromptu/jquery-impromptu.css' />
  <script class="footer" type='text/javascript' src='/plugins/grid/plugins/impromptu/jquery-impromptu.js'></script>
  <!-- tooltip -->
  <link class="footer" rel='stylesheet' type='text/css' href='/plugins/grid/plugins/tooltipster-master/css/tooltipster.css' />
  <link class="footer" rel='stylesheet' type='text/css' href='/plugins/grid/plugins/tooltipster-master/css/themes/tooltipster-punk.css' />
  <script class="footer" type='text/javascript' src='/plugins/grid/plugins/tooltipster-master/js/jquery.tooltipster.js'></script>
  <!-- context menu -->
  <link class="footer" rel="stylesheet" type="text/css" href="/plugins/grid/plugins/jq-context-menu/context.standalone.css" />
  <script class="footer" type="text/javascript" src="/plugins/grid/plugins/jq-context-menu/context.js"></script>
  <!-- grid -->
  <link rel="stylesheet" type="text/css" href="/plugins/grid/css/grid.css" />
  <script class="footer" type="text/javascript" src="/plugins/grid/js/grid.js"></script>
<? endif;?>
<div class="g-container col-12" id="g-<?= $g_table;?>" data="table:<?= $g_table;?>">
  <? 
  if ( 
          $this -> values['actions']['add'] === true 
        or 
          $this -> values['actions']['edit'] 
        or 
          is_array( $this -> values['buttons'] )
        or
          $this -> values['hide_columns']
        or
          $this -> values['csv']
        or
          $this -> values['print']
      ):?>
    <div class="row mb10" style="height: 50px;">
      <?
        if ( $this -> values['title'] )
          echo '<div id="g-title">' . $this -> values['title'] . '</div>';
      ?>
    <? if ( ( ( $this -> values['actions']['add'] === true or $this -> values['actions']['edit'] ) ) || is_array( $this -> values['buttons'] ) ):?>
      <div class="col-12 col-md-9" id="g-menu">
        <? if ( $this -> values['actions']['add'] === true ):?>
          <a href="#" id="g-add" class="btn btn-success btn-sm mr5">
            <i class="fa fa-plus-circle mr5"></i>Dodaj
          </a>
        <? endif;?>
        <a href="#" id="g-save" class="btn btn-success btn-sm mr5" url="<?= $this -> values['actions']['add_url'];?>" <? if ( $this -> values['actions']['back_url'] ):?>back_url="<?= $this -> values['actions']['back_url'];?>"<? endif;?>>
          <i class="fa fa-check-circle mr5"></i>Zatwierdź
        </a>
        <a href="#" id="g-cancel" class="btn btn-danger btn-sm mr5">
          <i class="fa fa-times-circle mr5"></i>Anuluj
        </a>
        <? if ( $this -> values['multiselect'] and $this -> values['actions']['delete'] ):?>
          <a href="#" id="g-multidelete" class="btn btn-danger btn-sm mr5" <? if ( $this -> values['multidelete_url'] ):?>url="<?= $this -> values['multidelete_url'];?>"<? endif;?>>
            <i class="fa fa-times-circle mr5"></i>Usuń wybrane
          </a>
        <? endif;?>
        <? 
          if ( is_array( $this -> values['buttons'] ) )
          {
            foreach ( $this -> values['buttons'] as $button )
            {
              echo \Html::button( [
                            'class' => $button['toggle'] === true ? $button['class'] . ' g-toggle btn btn-sm mr5' : $button['class'] . ' btn btn-sm mr5',
                            'url' => $button['url'] != '' ? $button['url'] : null,
                            'text' => $button['label'],
                            'icon' => $button['icon'],
                            'js' => $button['js'] != '' ? $button['js'] : null,
                            'style' => $button['toggle'] === true ? 'display: none; ' . $button['style'] : $button['style']
                          ] );
            }
          }
        ?>
      </div>
    <? endif;?>
      <div class="col col-12 pull-right">
        <div class="row mb10" style="position: relative;">
          <div class="col col-12">
            <? if ( $this -> values['hide_columns'] ):?>
              <a href="#" id="g-select-columns" class="btn btn-dark pull-right ml5" title="pokaż/ukryj kolumny">
                <i class="fa fa-bars"></i>
              </a>
              <a href="#" id='g-columns-list-close' class="btn btn-danger pull-right ml5" onclick="jQuery( '#g-columns-list' ).toggle(); return false;">
                <i class='fa fa-close fa-lg'></i>
              </a>
            <? endif;?>
            <? if ( $this -> values['csv'] ):?>
              <a href="#" class="btn btn-dark pull-right g-csv ml5" title="eksportuj do pliku csv">
                <i class="fa fa-save mr5"></i> csv
              </a>
            <? endif;?>
            <? if ( $this -> values['print'] ):?>
              <a href="#" class="btn btn-dark pull-right g-print ml5" title="drukuj">
                <i class="fa fa-print"></i>
              </a>
            <? endif;?>
          </div>
          <div id="g-columns-list" data="table:<?= $g_table;?>">
            <ul>
              <?
                if ( is_array( $this -> values['columns_view'] ) )
                {
                  $i = 0;
                  foreach ( $this -> values['columns_view'] as $column )
                  {
                    if ( $column['autoincrement'] === null and $column['action'] === null )
                    {
                      ?>
                        <li i="<?= $i;?>">
                          <input type="checkbox" class="g-column-toggle" <? if ( $this -> values['hidden_columns'][$i] !== 'true' ):?>checked="checked"<? endif;?> id="<?= $g_table . '-' . $i;?>" />
                          <span input="<?= $g_table . '-' . $i;?>"><?= $column['name'];?></span>
                        </li>
                      <?
                    }
                    $i++;
                  }
                }
              ?>
            </ul>
          </div>
        </div>
      </div>
    </div>
  <? endif;?>
  <div id="g-results">
    <?= $this -> values['content'];?>
  </div>
  <div id="g-loader"></div>
</div>
<script class="footer" type="text/javascript">
  jQuery( function() {
    context.init({
      preventDoubleContext: true,
      above: 'auto'
    });
    jQuery( '#g-columns-list input[type="checkbox"]' ).iCheck({
      checkboxClass: 'icheckbox_minimal-blue',
      radioClass: 'iradio_minimal-blue'
    });
  });
</script>