Changeset 29


Ignore:
Timestamp:
Dec 9, 2008, 1:24:32 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Hledání položek v seznamu dle zadaného filtru.
Files:
6 added
18 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r28 r29  
    11<?php
    22
    3 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '')
     3function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '', $Filter = '')
    44{
    55  global $Database, $Config;
     
    3333    $FullListLink = '';
    3434  }
     35  if($Filter != '') $Where .= ' AND '.$Filter;
    3536
    3637  // Handle ordering
     
    5354  //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))';
    5455  $Where .= ' '.$Order;
    55   $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'` WHERE 1'.$Where);
     56  $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'` WHERE '.$Where);
    5657  $DbRow = $DbResult->fetch_row();
    5758  $TotalItemCount = $DbRow[0];
     
    177178  (
    178179    'Title' => '',
    179     'SubmitBuffonText' => 'Uložit',
     180    'SubmitButtonText' => 'Uložit',
    180181    'Items' => $DefinitionItems,
    181182  );
     
    214215  (
    215216    'Title' => '',
    216     'SubmitBuffonText' => 'Uložit',
     217    'SubmitButtonText' => 'Uložit',
    217218    'Items' => $DefinitionItems,
    218219  );
     
    258259  (
    259260    'Title' => '',
    260     'SubmitBuffonText' => 'Přidat',
     261    'SubmitButtonText' => 'Přidat',
    261262    'Items' => $DefinitionItems,
    262263  );
     
    299300  (
    300301    'Title' => '',
    301     'SubmitBuffonText' => 'Přidat',
     302    'SubmitButtonText' => 'Přidat',
    302303    'Items' => $DefinitionItems,
    303304  );
     
    404405  (
    405406    'Title' => 'Hledání',
    406     'SubmitBuffonText' => 'Vyhledat',
     407    'SubmitButtonText' => 'Vyhledat',
    407408    'Items' => $DefinitionItems,
    408409  );
     
    417418
    418419  if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    419   $System->Modules['Log']->Add($List['Id'], $Id, $LogActionType['Delete']);
    420   $System->Modules['DatabaseList']->DeleteItem($List['Id'], $Id);
    421   $Output = 'Položka smazána.';
    422   $Output .= ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />';
    423   ExecuteListEvent($List['Id'], 'OnDelete', $Id);
    424   return($Output);
    425 
    426   $Output = ShowList($List);
     420  $DefinitionItems = array();
     421  $AfterTableOutput = '';
     422  foreach($List['Items'] as $Item)
     423  {
     424    //echo($Item['Name'].',');
     425    $Type = GetTypeDefinition($Item['Type']);
     426    if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column))
     427    {
     428      if($Item['Required'] == 1) $Required = '*'; else $Required = '';
     429      $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0);
     430    } else
     431    if($Item['Name'] == $Column)
     432    {
     433      $DefinitionItems[] = array('Name' => $Column, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $ColumnValue);
     434    }
     435  }
     436
     437  $Form = new Form();
     438  $Form->Definition = array
     439  (
     440    'Title' => '',
     441    'SubmitButtonText' => 'Přidat',
     442    'Items' => $DefinitionItems,
     443  );
     444  $Form->LoadValuesFromForm();
     445  $Filter = '1';
     446  print_r($Form);
     447  foreach($Form->Definition['Items'] as $Item)
     448  {
     449    //if($Item['Editable'] == 1)
     450    {
     451      //echo($Item['Name'].',');
     452      $Type = GetTypeDefinition($Item['Type']);
     453      $TypeObject = $Type['Class'];
     454      $Filter .= ' AND (`'.$Item['Name'].'` LIKE '.$TypeObject->DatabaseEscape($Form->Values[$Item['Name']]).')';
     455    }
     456  }
     457  echo('d'.$Filter.'d');
     458  $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue'], '', $Filter).'<br /><br />';
    427459  return($Output);
    428460}
     
    476508        case 'ShowSearch':
    477509          $Output = ShowSearch($List);
     510          break;
     511        case 'Search':
     512          $Output = Search($List);
    478513          break;
    479514        case 'EditItem':
     
    620655
    621656  $Result = FALSE;
    622   //return(TRUE);
     657  return(TRUE);
    623658  $DbResult = $Database->query('SELECT t1.* FROM `Permission` AS t1 WHERE t1.PermissionGroup = (SELECT PermissionGroup.Id FROM PermissionGroup WHERE PermissionGroup.Id=(SELECT User.PermissionGroup FROM User WHERE User.Id='.$System->Modules['User']->User['Id'].')) AND t1.List='.$ListId);
    624659  if($DbResult->num_rows > 0)
  • forms.php

    r21 r29  
    1313    $Output = '<center><form enctype="multipart/form-data" action="'.$this->OnSubmit.'" method="post"><div align="center">';
    1414    $Table = $this->ShowEditBlock();
    15     $Output .= $this->Definition['Title'].Table($Table).$this->ShowHiddenBlock().'<input type="submit" value="'.$this->Definition['SubmitBuffonText'].'"></div></form>';
     15    $Output .= $this->Definition['Title'].Table($Table).$this->ShowHiddenBlock().'<input type="submit" value="'.$this->Definition['SubmitButtonText'].'"></div></form>';
    1616    return($Output);
    1717  }
  • lists/SystemListItem.php

    r28 r29  
    33class ListSystemListItem
    44{
    5   function RebuildOrder()
     5  function RebuildOrder($List)
    66  {
    77    global $Database;
    88
    9     $Database->query('UPDATE SystemListItem AS Table1 SET Sequence = (SELECT COUNT(*) FROM (SELECT * FROM SystemListItem) AS Table2 WHERE ((Table2.Sequence < Table1.Sequence) OR ((Table1.Sequence = Table2.Sequence) AND (Table2.Id < Table1.Id))))');
     9    $Database->query('SET @I = 0;');
     10    $Database->query('UPDATE `SystemListItem` SET `Sequence` = (@I := @I + 1) WHERE `List`='.$List.' ORDER BY `Sequence`;');
    1011  }
    1112
     
    1516
    1617    //print_r($Parameters);
    17     $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE Id='.$Parameters['Type']);
     18    $DbResult = $Database->query('SELECT `DbDataType` FROM `SystemType` WHERE Id='.$Parameters['Type']);
    1819    //echo($Database->LastQuery);
    1920    $DbRow = $DbResult->fetch_assoc();
    20     $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE Id='.$Parameters[$Parameters['Column']]);
     21    $DbResult = $Database->query('SELECT `TableName` FROM `SystemList` WHERE Id='.$Parameters[$Parameters['Column']]);
    2122    //echo($Database->LastQuery);
    2223    $DbRow2 = $DbResult->fetch_assoc();
     
    2425    //echo($Database->LastQuery);
    2526
    26     $this->RebuildOrder();
     27    $this->RebuildOrder($Parameters['List']);
    2728  }
    2829
    2930  function OnEdit($Parameters)
    3031  {
    31     $this->RebuildOrder();
     32    $this->RebuildOrder($Parameters['List']);
    3233  }
    3334
    3435  function OnDelete($Parameters)
    3536  {
    36     $this->RebuildOrder();
     37    $this->RebuildOrder($Parameters['List']);
    3738  }
    3839}
  • types/Boolean.php

    r22 r29  
    11<?php
    22
    3 class TypeBoolean
     3class TypeBoolean extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
     6
    57  function OnView($Item)
    68  {
  • types/Date.php

    r22 r29  
    11<?php
    22
    3 class TypeDate
     3class TypeDate extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     6
    57  function OnView($Item)
    68  {
     
    5052    return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']);
    5153  }
     54
     55  function DatabaseEscape($Value)
     56  {
     57    return('"'.addslashes($Value).'"');
     58  }
    5259}
    5360
  • types/DateTime.php

    r22 r29  
    11<?php
    22
    3 class TypeDateTime
     3class TypeDateTime extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     6
    57  function OnView($Item)
    68  {
     
    7981      $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']);
    8082  }
     83
     84  function DatabaseEscape($Value)
     85  {
     86    return('"'.addslashes($Value).'"');
     87  }
    8188}
    8289
  • types/Enumeration.php

    r22 r29  
    11<?php
    22
    3 class TypeEnumeration
     3class TypeEnumeration extends TypeBase
    44{
    55  function OnView($Item)
  • types/Float.php

    r22 r29  
    11<?php
    22
    3 class TypeFloat
     3class TypeFloat extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     6
    57  function OnView($Item)
    68  {
  • types/GPS.php

    r22 r29  
    11<?php
    22
    3 class TypeGPS
     3class TypeGPS extends TypeBase
    44{
    55  function OnView($Item)
  • types/Hidden.php

    r22 r29  
    11<?php
    22
    3 class TypeHidden
     3class TypeHidden extends TypeBase
    44{
    55  function OnView($Item)
  • types/Hyperlink.php

    r22 r29  
    11<?php
    22
    3 class TypeHyperlink
     3class TypeHyperlink extends TypeBase
    44{
    55  function OnView($Item)
  • types/IPv4Address.php

    r22 r29  
    11<?php
    22
    3 class TypeIPv4Address
     3class TypeIPv4Address extends TypeBase
    44{
    55  function OnView($Item)
  • types/Integer.php

    r22 r29  
    11<?php
    22
    3 class TypeInteger
     3class TypeInteger extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     6
    57  function OnView($Item)
    68  {
  • types/Password.php

    r22 r29  
    33// SHA1 hash used
    44
    5 class TypePassword
     5class TypePassword extends TypeBase
    66{
    77  function OnView($Item)
  • types/PointerOneToMany.php

    r22 r29  
    11<?php
    22
    3 class TypePointerOneToMany
     3class TypePointerOneToMany extends TypeBase
    44{
    55  function OnView($Item)
  • types/PointerOneToOne.php

    r28 r29  
    11<?php
    22
    3 class TypePointerOneToOne
     3class TypePointerOneToOne extends TypeBase
    44{
    55  function GetTablePointerName($Type, $Item)
  • types/String.php

    r22 r29  
    11<?php
    22
    3 class TypeString
     3class TypeString extends TypeBase
    44{
     5  var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     6
    57  function OnView($Item)
    68  {
     
    1921    return($_POST[$Item['Name']]);
    2022  }
     23
     24  function DatabaseEscape($Value)
     25  {
     26    return('"'.addslashes($Value).'"');
     27  }
    2128}
    2229
  • types/include.php

    r26 r29  
    22
    33// Include type definitions
     4include('types/Base.php');
    45include('types/Enumeration.php');
    56include('types/Boolean.php');
Note: See TracChangeset for help on using the changeset viewer.