Changeset 536


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.
Location:
trunk
Files:
10 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Database.php

    r524 r536  
    7272      if(($this->Error != '') and ($this->ShowSQLError == true))
    7373        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    74         throw new Exception('SQL Error: </strong>'.$this->Error.', Query: '.$Query);
     74        throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query);
    7575    }
    7676    return($Result); 
  • 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  }
  • trunk/Common/Form/Types/Base.php

    r501 r536  
    4444    return(addslashes($Value));
    4545  }
     46 
     47  function OnFilterName($Item)
     48  {
     49    return('`'.$Item['Name'].'`');
     50  }
     51
     52  function OnFilterNameQuery($Item)
     53  {
     54    return('`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`');
     55  }
    4656}
    4757
  • trunk/Common/Form/Types/OneToMany.php

    r531 r536  
    1212    if($Item['Value'] != '')
    1313    {
    14       if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     14      /*if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    1515        else $Table = $Type['Parameters']['Table'];
    1616      $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].
    17         ' AS `Name` FROM '.$Table.' WHERE `'.
     17        ' AS `Name` FROM `'.$Table.'` WHERE `'.
    1818        $Type['Parameters']['Id'].'`='.$Item['Value']);
    1919      $DbRow = $DbResult->fetch_assoc();
    2020      $Output = '<a href="?t='.$Type['Parameters']['Table'].'&amp;a='.
    21         'view'.'&amp;i='.$Item['Value'].'">'.$DbRow['Name'].'</a>';
    22     } else $Output = '';
     21        'view'.'&amp;i='.$Item['Value'].'">'.$DbRow['Name'].'</a>';*/
     22      $Output = '<a href="?t='.$Type['Parameters']['Table'].'&amp;a='.
     23        'view'.'&amp;i='.$Item['Value'].'">'.$Item['Filter'].'</a>';
     24    } else $Output = '';   
    2325    return($Output);
    2426  }
     
    6062      else return($Item['Value']);
    6163  }
     64 
     65  function OnFilterName($Item)
     66  {
     67    return('`'.$Item['Name'].'_Filter`');
     68  }
     69   
     70  function OnFilterNameQuery($Item)
     71  {
     72    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
     73    //if($Item['Value'] != '')
     74    //{
     75      if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     76        else $Table = $Type['Parameters']['Table'];
     77      $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].
     78        ' AS `Name` FROM `'.$Table.'` WHERE `'.
     79        $Type['Parameters']['Id'].'`=`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`';
     80    //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
     81    return($Output);   
     82  }
    6283}
    6384
  • trunk/Common/Global.php

    r533 r536  
    4646include_once(dirname(__FILE__).'/../Modules/NetworkConfigLinux/NetworkConfigLinux.php');
    4747include_once(dirname(__FILE__).'/../Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php');
     48include_once(dirname(__FILE__).'/../Modules/TimeMeasure/TimeMeasure.php');
    4849
    4950function GlobalInit()
     
    109110  $System->ModuleManager->RegisterModule(new ModuleNetworkConfigRouterOS($System));
    110111  $System->ModuleManager->RegisterModule(new ModuleNetworkConfigLinux($System));
     112  $System->ModuleManager->RegisterModule(new ModuleTimeMeasure($System));
    111113  $System->ModuleManager->StartAll();
    112114}
  • trunk/Common/Version.php

    r535 r536  
    11<?php
    22
    3 $Revision = 535; // Subversion revision
     3$Revision = 536; // Subversion revision
    44$DatabaseRevision = 535; // SQL structure revision
    5 $ReleaseTime = '2013-05-12';
     5$ReleaseTime = '2013-05-18';
    66
    77?>
  • trunk/FormClasses.php

    r533 r536  
    99Default - výchozí hodnota
    1010Null - hodnota nemusí být zadána
    11 InList - sloupec viditelný v seznamu
     11NoInList - sloupec viditelný v seznamu
    1212Suffix - text za hodnotou
    1313Description - popis významu položky
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r524 r536  
    2626  var $FullTitle = 'Import plateb přes API';
    2727  var $ShortTitle = 'Import plateb přes API';
     28  var $ParentClass = 'PageFinance';
    2829
    2930  function Show()
    3031  {   
     32    $Output = '';
    3133    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    3234     
    33     $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['id']);
     35    $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['i']);
    3436    $BankAccount = $DbResult->fetch_assoc();
    3537   
     
    4143      else if($Bank['Code'] == '0300') $Import = new ImportPS($this->Database);
    4244      else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován');
    43     $Import->BankAccountId = $BankAccount['Id'];
    44     $Output .= $Import->Import();
    45    
     45    if(isset($Import))
     46    {
     47      $Import->BankAccountId = $BankAccount['Id'];
     48      $Output .= $Import->Import();
     49    }
    4650    return($Output);
    4751  }
     
    5256  var $FullTitle = 'Import plateb ze souboru';
    5357  var $ShortTitle = 'Import plateb ze souboru';
    54 
     58  var $ParentClass = 'PageFinance';
     59 
    5560  function Show()
    5661  {
  • trunk/Modules/FinanceBankAPI/FioAPI.php

    r500 r536  
    2020 
    2121    // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format}
     22    echo('1');
    2223    $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30);
     24    echo('2');
    2325    if(!$fp)
    2426    {
     
    3739 
    3840      // Read response
     41      echo('3');
    3942      $Response = array();
    4043      while(!feof($fp))
    4144        $Response .= trim(fgets($fp, 1024))."\n";
    4245      fclose($fp);     
     46      echo('4');
    4347      $Response = iconv('windows-1250', $this->Encoding, $Response);
    4448      $Response = explode("\n", $Response);
     
    5458      foreach($Response as $Index => $Line)
    5559      {
    56         if(($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
     60        if(($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
    5761        $GPCLine = $GPC->ParseLine($Line);
    5862        if($GPCLine != NULL) $Result[] = $GPCLine;
     
    6670    // Try to get error message
    6771    // If something go wrong fio show HTML login page and display error message
    68         $Response = implode('', $Response);
     72    $Response = implode('', $Response);
    6973    $ErrorMessageStart = '<div id="oldform_warning">';
    7074    if(strpos($Response, $ErrorMessageStart) !== false)
    71         {
    72           $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
    73           $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));
    74         } else $ErrorMessage = '';
    75         throw new Exception('No valid GPC data: '.$ErrorMessage);
     75    {
     76      $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
     77      $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));
     78    } else $ErrorMessage = '';
     79    throw new Exception('No valid GPC data: '.$ErrorMessage);
    7680  }
    7781}
  • trunk/Modules/IS/IS.php

    r533 r536  
    99  var $ParentClass = 'PagePortal';
    1010  var $MenuItems = array();
     11  var $MenuItemsLoaded = false;
    1112  var $HideMenu = false;
    1213
     
    8889      $Output .= $Form->ShowEditForm();
    8990      $Output .= '<ul class="ActionMenu">';
    90       $Output .= '<li><a href="?a=view&amp;t='.$Table.'"><img alt="Prohlížet" title="Prohlížet" src="'.
     91      $Output .= '<li><a href="?a=view&amp;t='.$Table.'&amp;i='.$Id.'"><img alt="Prohlížet" title="Prohlížet" src="'.
    9192      $this->System->Link('/images/view.png').'"/>Prohlížet</a></li>';
    9293      $Output .= '<li><a href="?a=list&amp;t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
     
    178179  }
    179180 
    180   function ShowSelect($Table, $Filter = '', $Title = '')
    181   {
    182     $this->BasicHTML = true;
    183     $this->HideMenu = true;
     181  function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array())
     182  {   
    184183    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    185184      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    186     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter);
    187     $DbRow = $DbResult->fetch_row();
    188     $PageList = GetPageList($DbRow[0]);   
    189 
    190     $Output = '<script type="text/javascript">
    191     function set_return(id, obj)
    192     {
    193       window.opener.document.getElementById(obj).value = id;
    194     }
    195     </script>';
    196     $Output .= '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
     185
     186    // Build user filter
     187    $UserFilter = '';
     188    $Columns = array('Id' => '`Id`');
     189    if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
     190    {
     191      foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     192      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     193          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     194              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     195      {
     196        $UseType = $UseType = $FormItem['Type'];
     197        if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     198        {
     199          if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     200            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
     201              $this->System->FormManager->FormTypes[$FormItem['Type']]);
     202          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     203          $UseType = 'OneToMany';
     204          else
     205          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     206          $UseType = 'Enumeration';
     207        }
     208        $FilterName = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterName',
     209          array('Name' => $ItemIndex, 'Type' => $FormItem['Type']));
     210        if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     211          $UserFilter .= ' AND ('.$FilterName.' LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
     212      }
     213    }     
     214    if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
     215    if($Filter != '') $Filter = ' WHERE '.$Filter;
     216   
     217    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     218      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     219          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     220              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     221      {
     222        $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
     223        $UseType = $UseType = $FormItem['Type'];
     224        if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     225        {
     226          if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     227            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
     228                $this->System->FormManager->FormTypes[$FormItem['Type']]);
     229          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     230            $UseType = 'OneToMany';
     231          else
     232            if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     233            $UseType = 'Enumeration';
     234        }
     235        if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     236          $Value = $_POST['Filter'.$ItemIndex];
     237          else $Value = '';       
     238        if($ItemIndex == 'Id') unset($Columns['Id']);
     239        $Columns[] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
     240          array('Value' => $Value, 'Name' => $ItemIndex,
     241              'Type' => $FormItem['Type']));
     242      }
     243     
     244    // Get total item count in database
     245    $Query = 'SELECT COUNT(*) FROM `'.$FormClass['Table'].'`';
     246    $DbResult = $this->Database->query($Query);
     247    $DbRow = $DbResult->fetch_assoc();
     248    $TotalCount = $DbRow['COUNT(*)'];
     249   
     250    // Get total filtered item count in database
     251    $Columns = implode(',', $Columns);
     252    if($UserFilter != '')
     253    {
     254      $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.$Filter;
     255      $DbResult = $this->Database->query($Query);
     256      $DbRow = $DbResult->fetch_row();
     257      $TotalFilteredCount = $DbRow[0];
     258    } else $TotalFilteredCount = $TotalCount;
     259    $PageList = GetPageList($TotalFilteredCount);   
     260
     261    $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
    197262    $Output .= $PageList['Output'];
    198263    $Output .= '<table class="WideTable" style="font-size: small;">';
    199264   
    200     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    201     if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    202       (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    203       ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    204     {
    205       $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
    206     }   
    207265    $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
    208266    if(!array_key_exists('DefaultSortColumn', $FormClass))
     
    212270   
    213271    // Show search fields
    214     $UserFilter = '';
    215     if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
    216     {
    217       foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    218       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    219           (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    220               ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    221       {
    222         if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    223           $UserFilter .= ' AND (`'.$ItemIndex.'` LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
    224       }
    225     }     
    226     $Output .= '<tr><form action="?a=select&amp;t='.$Table.'&amp;r='.$_GET['r'].'&amp;filter=1" method="post">';
     272    $Output .= '<tr><form action="?a=list&amp;t='.$Table.'&amp;filter=1" method="post">';
    227273    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    228274      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     
    236282    }
    237283    $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
    238 
    239     if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
    240     if($Filter != '') $Filter = ' WHERE '.$Filter;
    241     $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
    242    
     284   
     285    // Load and show items
     286    $Query = 'SELECT * FROM (SELECT '.$Columns.' FROM `'.$FormClass['Table'].'`) AS `TS` '.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];   
     287    $VisibleItemCount = 0;
    243288    $DbResult = $this->Database->query($Query);
    244289    while($Row = $DbResult->fetch_assoc())
     
    268313        $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
    269314          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    270           'Type' => $FormItem['Type']));
     315          'Type' => $FormItem['Type'], 'Filter' => $Row[$ItemIndex.'_Filter']));
    271316        if($Value == '') $Value = '&nbsp;';
    272317        $Output .= '<td>'.$Value.'</td>';
    273318      }
    274       $Output .= '<td><a href="javascript:window.close();" onclick="set_return('.$Row['Id'].',&quot;'.$_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
    275         $this->System->Link('/images/select.png').'"/></a>';
    276       $Output .= '</td></tr>';
    277     }
    278     $Output .= '</table>';
    279     $Output .= $PageList['Output'];
    280     return($Output);
    281   }
    282    
    283   function ShowList($Table, $Filter = '', $Title = '')
    284   {   
    285     if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    286       else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    287 
    288     // Build user filter
    289     $UserFilter = '';
    290     if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
    291     {
    292       foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    293       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    294           (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    295               ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    296       {
    297         if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    298           $UserFilter .= ' AND (`'.$ItemIndex.'` LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
    299       }
    300     }     
    301     if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
    302     if($Filter != '') $Filter = ' WHERE '.$Filter;
    303    
    304     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter);
    305     $DbRow = $DbResult->fetch_row();
    306     $PageList = GetPageList($DbRow[0]);   
    307 
    308     $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
    309     $Output .= $PageList['Output'];
    310     $Output .= '<table class="WideTable" style="font-size: small;">';
    311    
    312     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    313     if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    314       (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    315       ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    316     {
    317       $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
    318     }   
    319     $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
    320     if(!array_key_exists('DefaultSortColumn', $FormClass))
    321       $FormClass['DefaultSortColumn'] = 'Id';
    322     $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], 0);
    323     $Output .= $Order['Output'];
    324    
    325     // Show search fields
    326     $Output .= '<tr><form action="?a=list&amp;t='.$Table.'&amp;filter=1" method="post">';
    327     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    328       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    329           (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    330               ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    331     {
    332       if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    333         $Value = $_POST['Filter'.$ItemIndex];
    334         else $Value = ''; 
    335       $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>';   
    336     }
    337     $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
    338 
    339     // Get total item count in database
    340     $Query = 'SELECT COUNT(*) FROM `'.$FormClass['Table'].'`';
    341     $DbResult = $this->Database->query($Query);
    342     $DbRow = $DbResult->fetch_assoc();
    343     $TotalCount = $DbRow['COUNT(*)'];
    344    
    345     // Get total filtered item count in database
    346     if($UserFilter != '')
    347     {
    348       $Query = 'SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter;
    349       $DbResult = $this->Database->query($Query);
    350       $DbRow = $DbResult->fetch_assoc();
    351       $TotalFilteredCount = $DbRow['COUNT(*)'];
    352     }   
    353    
    354     // Load and show items
    355     $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];   
    356     $VisibleItemCount = 0;
    357     $DbResult = $this->Database->query($Query);
    358     while($Row = $DbResult->fetch_assoc())
    359     {
    360       $Output .= '<tr>';
    361       foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    362       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    363       (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    364       ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    365       {
    366         //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
    367         $UseType = $UseType = $FormItem['Type'];
    368         if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
    369         {
    370           if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
    371             $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
    372               $this->System->FormManager->FormTypes[$FormItem['Type']]);
    373           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
    374           $UseType = 'OneToMany';
    375           else
    376           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
    377           $UseType = 'Enumeration';
    378         }
    379         $Row[$ItemIndex] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
    380           array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    381           'Type' => $FormItem['Type']));
    382         $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
    383           array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    384           'Type' => $FormItem['Type']));
    385         if($Value == '') $Value = '&nbsp;';
    386         $Output .= '<td>'.$Value.'</td>';
    387       }
    388       $Output .= '<td><a href="?a=view&amp;t='.$Table.'&amp;i='.$Row['Id'].'"><img alt="Ukázat" title="Ukázat" src="'.
    389         $this->System->Link('/images/view.png').'"/></a>'.
    390         '<a href="?a=edit&amp;t='.$Table.'&amp;i='.$Row['Id'].'"><img alt="Upravit" title="Upravit" src="'.
    391         $this->System->Link('/images/edit.png').'"/></a>'.
    392         '<a href="?a=delete&amp;t='.$Table.'&amp;i='.$Row['Id'].'"><img alt="Smazat" title="Smazat" src="'.
    393         $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
    394       if(array_key_exists('ItemActions', $FormClass))
    395       {
    396         foreach($FormClass['ItemActions'] as $Action)
    397           $Output .= '<a href="'.$this->System->Link($Action['URL']).'&amp;i='.$Row['Id'].'"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
    398             $this->System->Link('/images/action.png').'"/></a>';
    399       }
    400       $Output .= '</td></tr>';
     319      $Output .= '<td>'.str_replace('#RowId', $Row['Id'], $RowActions).'</td></tr>';
    401320      $VisibleItemCount = $VisibleItemCount + 1;
    402321    }
     
    406325    $Output .= '</table>';
    407326    $Output .= $PageList['Output'];
     327    return($Output);
     328  }
     329 
     330  function ShowSelect($Table, $Filter = '', $Title = '')
     331  {
     332    $this->BasicHTML = true;
     333    $this->HideMenu = true;
     334    $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,&quot;'.$_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
     335      $this->System->Link('/images/select.png').'"/></a>';
     336    $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);   
     337    return($Output);
     338  }   
     339 
     340  function ShowList($Table, $Filter = '', $Title = '') 
     341  {
     342    $RowActions = '<a href="?a=view&amp;t='.$Table.'&amp;i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
     343      $this->System->Link('/images/view.png').'"/></a>'.
     344      '<a href="?a=edit&amp;t='.$Table.'&amp;i=#RowId"><img alt="Upravit" title="Upravit" src="'.
     345      $this->System->Link('/images/edit.png').'"/></a>'.
     346      '<a href="?a=delete&amp;t='.$Table.'&amp;i=#RowId"><img alt="Smazat" title="Smazat" src="'.
     347      $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
     348    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
     349      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
     350    if(array_key_exists('ItemActions', $FormClass))
     351    {
     352      foreach($FormClass['ItemActions'] as $Action)
     353        $RowActions .= '<a href="'.$this->System->Link($Action['URL']).'&amp;i=#RowId"><img alt="'.$Action['Caption'].'" title="'.$Action['Caption'].'" src="'.
     354          $this->System->Link('/images/action.png').'"/></a>';
     355    }   
     356    $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);
    408357    $Output .= '<ul class="ActionMenu">';
    409358    $Output .= '<li><a href="?a=add&amp;t='.$Table.'"><img alt="Přidat" title="Přidat" src="'.
     
    418367    }
    419368    $Output .= '</ul>';
    420     return($Output);
     369    return($Output);   
    421370  }
    422371 
    423372  function ShowMenuItem($Parent)
    424373  {
    425     $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`  FROM `MenuItem` '.
    426       'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
    427       'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    428       'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    429     while($DbRow = $DbResult->fetch_assoc())
    430     {
    431       $this->MenuItems[$DbRow['Id']] = $DbRow;
     374    if($this->MenuItemsLoaded == false)
     375    {
     376      $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`  FROM `MenuItem` '.
     377        'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
     378        'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
     379        'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
     380      while($DbRow = $DbResult->fetch_assoc())
     381      {
     382        $this->MenuItems[$DbRow['Id']] = $DbRow;
     383      }
     384      $this->MenuItemsLoaded = true;
    432385    }   
    433386   
  • trunk/Modules/News/NewsPage.php

    r533 r536  
    104104    {
    105105      // Process uploaded file
     106      // TODO: Make upload using general File class
    106107      $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
    107108      $Enclosures = '';
     
    193194      if($this->System->User->User['Id'] == $Row['User'])
    194195      {
     196        // TODO: Make upload using general File class
    195197        if($Row['Enclosure'] != '')
    196198        {
  • trunk/ToDo.txt

    r534 r536  
    22======
    33
    4 - Čtení dat z meteostanice
    5 - Automatický import plateb z Fio banky
     4- Meteostation: Čtení dat z meteostanice
     5- FinanceImportFio: Automatický import plateb z Fio banky
     6- Finance: umožnit uzavření účetního roku
    67- Automatické blokování internetu při vyčerpání kreditu
    7 - Modul pro správu VPS hostingu
    8 - Osamostatnit web jídelny
    9 - Funkce pro rozesílání hromadných emailů
    10 - Převést frontu mailů na samostatný modul
     8- ServiceVPS: Modul pro správu VPS hostingu
     9- Meals: Osamostatnit web jídelny
     10- Mail: Funkce pro rozesílání hromadných emailů
     11- Mail: Převést frontu mailů na samostatný modul
    1112- Podpora pro inventůru
    12 - Podpora IPv6
    13 - Evidovat IP adresy v samostatné tabulce.
     13- Network: Podpora IPv6
    1414- Fulltextové vyhledávání v obsahu
    15 - Automatické zálohování nastavení z routerů
    16 - Vytvořit solidní speedtest se záznamem měření
     15- SpeedTest: Vytvořit solidní speedtest se záznamem měření
    1716- Přepracovat na modulární systém.
    1817  * Volitelná instalace modulů
    1918  * Každý modul si řeší aktualizace databáze a perzistenci
    2019  * Umožnit dědičnost modelů (tabulek)
     20  * Moduly si při instalaci registrují:
     21    # datové struktury
     22    # datové položky.
     23    # položky globálního nastavení
     24    # akce
     25    # soubory, ikony
     26- IS: 
    2127  * Obecný export/import dat
    2228  * Nastavení oprávnění uživatelů
     
    2430  * Oblíbené položky nabídky uživatelů
    2531  * Předvolené sestavy filtrů, řazení, pořadí sloupců
    26 - Udělat fond IP adres, zobrazit jejich užití, umožnit automatické přiřazení volných
    27 - Vytvořit třídy pro práci s Mikrotik RouterOS API
    28 - Automatické zasílání SMS informací
    29 - Vytvořit modul pro záznam a vykreslování časových grafů
    30 - V modulu News předělat přílohy na odkazy do tabulky File
    31 - Opravit v automaticky generovaných aktualitách zapisování uživatele automatu
    32 - Přidat podporu pro překlad do jiných jazyků (angličtiny)
     32- Network: Udělat fond IP adres, zobrazit jejich užití, umožnit automatické přiřazení volných
     33- Network: Vytvořit třídy pro práci s Mikrotik RouterOS API
     34- Network: Automatické zálohování nastavení z routerů
     35- TrafficFlow: Přidat prohlížeč záznamu spojení
     36- SMS: Automatické zasílání SMS informací
     37- Chart: Vytvořit modul pro záznam a vykreslování časových grafů
     38- News: Předělat přílohy na odkazy do tabulky File
     39- News: Opravit v automaticky generovaných aktualitách zapisování uživatele automatu
     40- System: Přidat podporu pro překlad do jiných jazyků (angličtiny)
     41- User: Řešit nějak lépe obecně systém oprávnění.
    3342
    3443==Pro zveřejnění přepracovat==
    35 - chybějící kontrola oprávnění pro stahování souborů
     44- chybějící kontrola oprávnění pro stahování souborů.
    3645- anti-bot kontrolu pro registrace
    3746- u modulů jako tv, networkshare podporu pro volitelné lokální položky. Nebo přidat novou skupinu oprávnění místní uživatelé.
  • trunk/style/new/global.js

    r529 r536  
    5151  var left = (screen.width / 2) - (w / 2);
    5252  var top = (screen.height / 2) - (h / 2);
    53   return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
     53  return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    5454}
     55
     56function set_return(id, obj)
     57{
     58  window.opener.document.getElementById(obj).value = id;
     59}
  • trunk/temp/Bills.php

    r486 r536  
    11<?php
     2
     3die();
    24
    35include('../Common/Global.php');
     
    3739  {
    3840    $System->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $Invoice['Id'],
    39       'Price' => ));
     41      'Price' => 0));
    4042  }
    4143  echo($Invoice['Text'].' '.$Bill['Id'].'<br>');
Note: See TracChangeset for help on using the changeset viewer.