Ignore:
Timestamp:
May 18, 2013, 6:51:10 PM (11 years ago)
Author:
chronos
Message:
  • Opraveno: Položky nabídky ve Správě dat se opakovaně všechny načítaly z databáze pro každou skupinu.
  • Opraveno: Nyní funguje také rychlé filtrování tabulek ve Správě dat dle sloupců s typem OneToMany.
  • Upraveno: Optimalizace načítání textových názvů položek typu OneToMany. Dříve se načítaly samostatným SQL dotazem pro každý řádek zvlášť. Nyní se načítají jako jeden SELECT.
  • Přidáno: Modul TimeMeasure pro měření a zobrazování časových grafů veličin.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Form/Form.php

    r529 r536  
    99  var $Definition;
    1010  var $Values;
     11  var $ValuesFilter;
    1112  var $OnSubmit;
    1213  var $Database;
     
    1819    $this->Definition = array();
    1920    $this->Values = array();   
     21    $this->ValuesFilter = array();   
    2022    $this->OnSubmit = '';
    2123  }
     
    4951      $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
    5052        array('Value' => $this->Values[$Index], 'Name' => $Index,
    51         'Type' => $Item['Type'], 'Values' => $this->Values));
     53        'Type' => $Item['Type'], 'Values' => $this->Values,             
     54        'Filter' => $this->ValuesFilter[$Index]));
    5255      if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
    5356      if(!$this->FormManager->Type->IsHidden($UseType))
     
    116119
    117120  function LoadValuesFromDatabase($Id)
    118   {
    119     $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id);
     121  {   
     122    foreach($this->Definition['Items'] as $Index => $Item)
     123    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     124    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     125    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     126    {
     127      if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     128        if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     129        {           
     130          if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     131            $this->FormManager->Type->RegisterType($Item['Type'], '',
     132              $this->FormManager->FormTypes[$Item['Type']]);
     133          if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     134            $UseType = 'OneToMany';
     135          else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     136            $UseType = 'Enumeration';
     137        } else $UseType = $Item['Type'];
     138      $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
     139        array('Name' => $Index, 'Type' => $Item['Type']));
     140    }
     141    $Columns = implode(',', $Columns);
     142    $DbResult = $this->Database->query('SELECT '.$Columns.' FROM `'.$this->Definition['Table'].'` AS `T` WHERE `T`.`Id`='.$Id);
    120143    $DbRow = $DbResult->fetch_array();
    121144    foreach($this->Definition['Items'] as $Index => $Item)
     
    138161            array('Value' => $DbRow[$Index], 'Name' => $Index,
    139162            'Type' => $Item['Type'], 'Values' => $this->Values));
     163        $this->ValuesFilter[$Index] = $DbRow[$Index.'_Filter'];
    140164    }
    141165  }
Note: See TracChangeset for help on using the changeset viewer.