<? global $lang; ?>

<script type="text/javascript">
  $( document ).ready( function()
  {
    $( '.toggle_filtr' ).click( function()
    {
      if ( $( '#filtr' ).css( 'display' ) == 'none' )
      {
        $( '#filtr' ).show();
        $( '.toggle_filtr' ).html( 'ukryj filtr' );
      }
      else
      {
        $( '#filtr' ).hide();
        $( '.toggle_filtr' ).html( 'pokaż filtr' );
      }
    })
  })
</script>

<p class="toggle_filtr">pokaż filtr</p>
<div id="filtr">
  <form method='POST' id='db_filtr_yes' action='index.php'>
    <input type='hidden' name='set_db_filtr' value='yes'>
    <?
    if ( is_array ( $this -> _filtr_combo ) ) foreach ( $this -> _filtr_combo as $combo )
    {
      ?>
      <div class="edit_line">
        <label><?=ucfirst( $combo['name'] );?>:</label>
        <div class="input">
          <select name="<?=$combo['seo_name'];?>">
            <option value=''>&nbsp;</option>
            <?
            if ( is_array ( $combo['value'] ) ) foreach ( $combo['value'] as $key => $val )
            {
              ?>
              <option value='<?=$key;?>'
                <?
                if ( isset( $combo['val'] ) && $key == $combo['val'] )
                {
                  ?>selected='selected'<?
                }
                ?>
              ><?=$val;?></option>
              <?
            }
            ?>
          </select>
        </div>
      </div>
      <?
    }

    if ( is_array( $this -> _filtr_text ) ) foreach ( $this -> _filtr_text as $text )
    {
      ?>
      <div class="edit_line">
        <label><?=ucfirst( $text['name'] );?>:</label>
        <div class="input">
          <input type='text' name="<?=$text['seo_name'];?>" value="<? if ( isset( $text['value'] ) ) echo $text['value'];?>">
        </div>
      </div>
      <?
    }

    if ( is_array( $this -> _filtr_ttext ) ) foreach ( $this -> _filtr_ttext as $text )
    {
      ?>
      <div class="edit_line">
        <label><?=ucfirst( $text['name'] );?>:</label>
        <div class="input">
          <input type='text' name="<?=$text['seo_name'];?>" value="<? if ( isset( $text['value'] ) ) echo $text['value'];?>">
          <?
          if ( is_array( $text['select'] ) ) foreach ( $text['select'] as $key => $val )
          {
            ?><input type='hidden' name="<?=$text['seo_name'];?>_trans[]" value="<?=htmlspecialchars( $key );?>[]<?=htmlspecialchars( $val );?>"><?
          }
          ?>
        </div>
      </div>
      <?
    }
    ?>
      <div class="edit_line" style="text-align: left; padding-left: 180px;">
        <div class="btn" onClick='$("#db_filtr_yes").submit();' style="display: inline-block;"><?=$lang -> getTrans( 'T_ZASTOSUJ' );?></div>
        <div class='btn' onClick='$("#fdb_filtr_no").submit();' style="display: inline-block;"><?=$lang -> getTrans( 'T_ANULUJ' );?></div>
      </div>
  </form>
  <form method='POST' id='fdb_filtr_no'>
    <input type='hidden' name='set_db_filtr' value='no'>
  </form>
</div>