<?
if ( isset( $this -> _filtr ) )
  include 'templates/data/data-browse-filtr.php';
?>
<?= $this -> _menu;?>
<div class="browse">
  <form method="POST" action="./" id="sort_from">
    <input type="hidden" name="s" id="s" value="" />
  </form>
    <table class='table_browse' style='min-width:500px;'>
      <thead>
        <tr>
        <?
        if ( is_array( $this -> _table_headers ) ) foreach ( $this -> _table_headers as $key => $val )
        {
          if ( $i++ == 1 && $this -> _checkbox )
            echo '<th class="title" style="width: 20px;"></th>';
          ?>	
          <th class='title <? if ( $val['value'] == 'Lp.' ):?>center<? endif;?>' <? if ( !$val['value'] || $val['value'] == 'Raport' || $val['value'] == 'Lp.' || $val['value'] == 'Edytuj' || $val['value'] == 'Usuń' || $val['value'] == 'Pokaż' ) echo "style='width: 30px;'";?>
            <?
            if ( $val['sort'] )
            {
              ?>
              style='cursor: pointer;'
              onClick="$( '#s' ).val( '<?=$val['sort'];?>' ); $( '#sort_from' ).submit();">
              <?
              echo ucfirst( $val['value'] );
            }
            else
            {
              ?>><?=ucfirst( $val['value'] );?><?
            }
            ?>
          </th>
          <?
        }
        ?>
        </tr>
      </thead>
      <?
      if ( $this -> _row_count )
      {
        ?>
        <tbody>
          <?
          $i = 0;
          foreach ( $this -> _table_values as $key => $val )
          {
          ?>
            <ul class="contextMenu" id="context_menu_<?= $i;?>">
              <? if ( isset( $val[ 'edytuj' ] ) ):?>
                <li id="open" class="context_menu"><?= $val[ 'edytuj' ]['value'];?></li>
              <? endif;?>
              <? if ( isset( $val [ 'pokaż' ] ) ):?>
                <li id="show" class="context_menu"><?= $val[ 'pokaż' ]['value'];?></li>
              <? endif;?>
              <? if ( isset( $val[ 'usuń' ] ) ):?>
                <li id="delete" class="context_menu"><?= $val[ 'usuń' ]['value'];?></li>
              <? endif;?>
            </ul>
            <script type='text/javascript'>
              $( document ).ready( function() {
                $( '#tr_<?= $i;?>' ).contextMenu( { menu: "context_menu_<?= $i;?>" }, function( action ) {
                  if ( action != '' )
                    document.location.href='.' + action;
                });
              });
            </script>
            <tr id="tr_<?=$i;?>">
              <?
              foreach ( $val as $value )
              {
                ?>
                  <td class='cell' style='<?=$this -> eprint( $value['style'] );?>' <?= $value['js'];?>>
                    <?
                    if ( $value['value'] )
                      echo stripslashes( $value['value'] );
                    else
                      echo '-';
                    ?>
                  </td>
                <?
              }
              ?>
            </tr>
            <?
            $i++;
          }
          ?>
        </tbody>
        <?
      }
      else
      {
        ?>
        <tr>
          <td colspan='<?=count( $this -> _table_headers );?>' style='text-align:center;'>
            <div style='text-align: center; padding: 10px 0;'>Nie znaleziono żadnych wpisów.</div>
          </td>
        </tr>
        <?
      }
      ?>
    </table>

  <script type='text/javascript'>
    $(document).ready(function(){
      $("li").children("a").children("span.edit").parent('a').append( 'edytuj' );
      $("li").children("a").children("span.delete").parent('a').append( 'usuń' );
      $("li").children("a").children("span.show").parent('a').append( 'pokaż' );
      var cssObj = {
        'display' : 'block',
        'height' : '30px',
        'line-height' : '31px',
        'color' : '#000000',
        'font-size' : '10px',
        'text-transform' : 'uppercase',
        'font-family': 'Duru Sans, sans-serif'
      };
      $("li.context_menu").children("a").css( cssObj );
      var cssObj2 = {
        'float' : 'left',
        'margin' : '7px 5px 0 0',
        'color' : '#000000',
        'font-size' : '10px',
        'text-transform' : 'uppercase'
      };
      $("li.context_menu").children("a").children("span.edit").css( cssObj2 );
      $("li.context_menu").children("a").children("span.delete").css( cssObj2 );
      $("li.context_menu").children("a").children("span.show").css( cssObj2 );
    });
  </script>
</div>
<? include 'templates/data/data-browse-paging.php'; ?>