Changeset 528


Ignore:
Timestamp:
Apr 21, 2013, 11:51:38 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Rychlé filtrování výpisu položek v tabulkách dle zadané hodnoty v jednotlivých sloupcích.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Version.php

    r527 r528  
    11<?php
    22
    3 $Revision = 527; // Subversion revision
     3$Revision = 528; // Subversion revision
    44$DatabaseRevision = 527; // SQL structure revision
    55$ReleaseTime = '2013-04-21';
  • trunk/Modules/IS/IS.php

    r527 r528  
    170170    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    171171      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    172     if($Filter != '') $Filter = ' WHERE '.$Filter;
    173172    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter);
    174173    $DbRow = $DbResult->fetch_row();
     
    191190    $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], 0);
    192191    $Output .= $Order['Output'];
    193 
     192   
     193    // Show search fields
     194    $UserFilter = '';
     195    if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
     196    {
     197      foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     198      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     199          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     200              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     201      {
     202        if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     203          $UserFilter .= ' AND (`'.$ItemIndex.'` LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
     204      }
     205    }     
     206    $Output .= '<tr><form action="?a=list&amp;filter=1" method="post">';
     207    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     208      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     209          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     210              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     211    {
     212      if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     213        $Value = $_POST['Filter'.$ItemIndex];
     214        else $Value = ''; 
     215      $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>';   
     216    }
     217    $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
     218
     219    if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
     220    if($Filter != '') $Filter = ' WHERE '.$Filter;
    194221    $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
    195222   
Note: See TracChangeset for help on using the changeset viewer.