Ignore:
Timestamp:
Apr 6, 2020, 9:19:50 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: Show DateTime form field type with null value as unchecked checkbox.
  • Fixed: Add form action error for fields with default null value.
  • Added: Show Service form field NetworkSubnet.
  • Modified: Code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/IS/IS.php

    r864 r871  
    2222  function Show()
    2323  {
    24     if(!$this->System->User->CheckPermission('IS', 'Manage'))
    25       return('Nemáte oprávnění');
     24    if (!$this->System->User->CheckPermission('IS', 'Manage'))
     25      return 'Nemáte oprávnění';
    2626    $this->System->FormManager->ShowRelation = true;
    2727
    2828    // a - action
    29     if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
     29    if (array_key_exists('a', $_GET)) $Action = $_GET['a'];
    3030      else $Action = '';
    3131    // t - table
    32     if(array_key_exists('t', $_GET)) $Table = $_GET['t'];
     32    if (array_key_exists('t', $_GET)) $Table = $_GET['t'];
    3333      else $Table = '';
    3434    // i - index of item
    35     if(array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
     35    if (array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
    3636      else $ItemId = 0;
    3737    // fc - preset colum
    38     if(array_key_exists('fn', $_GET)) $FilterName = $_GET['fn'];
     38    if (array_key_exists('fn', $_GET)) $FilterName = $_GET['fn'];
    3939      else $FilterName = '';
    40     if(array_key_exists('fv', $_GET)) $FilterValue = $_GET['fv'];
     40    if (array_key_exists('fv', $_GET)) $FilterValue = $_GET['fv'];
    4141      else $FilterValue = '';
    42     if(array_key_exists('menutype', $_COOKIE)) $MenuType = $_COOKIE['menutype'];
     42    if (array_key_exists('menutype', $_COOKIE)) $MenuType = $_COOKIE['menutype'];
    4343      else $MenuType = 0;
    44     if(array_key_exists('menutype', $_GET)) $MenuType = $_GET['menutype'] * 1;
     44    if (array_key_exists('menutype', $_GET)) $MenuType = $_GET['menutype'] * 1;
    4545    setcookie('menutype', $MenuType, time() + 60 * 60 * 24 * 365);
    4646
    47     if($Action == 'list') {
    48       if($FilterName == '') $Content = $this->ShowList($Table);
     47    if ($Action == 'list') {
     48      if ($FilterName == '') $Content = $this->ShowList($Table);
    4949        else $Content = $this->ShowList($Table, '', '', $FilterName, $FilterValue);
    5050    }
    51     else if($Action == 'select') $Content = $this->ShowSelect($Table);
    52     else if($Action == 'mapselect') $Content = $this->ShowMapSelect($Table);
    53     else if($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
    54     else if($Action == 'add') $Content = $this->ShowAdd($Table);
    55     else if($Action == 'addsub') $Content = $this->ShowAddSub($Table);
    56     else if($Action == 'view') $Content = $this->ShowView($Table, $ItemId);
    57     else if($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId);
    58     else if($Action == 'fav_add') $Content = $this->ShowFavoriteAdd($Table, $ItemId);
    59     else if($Action == 'fav_del') $Content = $this->ShowFavoriteDel($Table, $ItemId);
     51    else if ($Action == 'select') $Content = $this->ShowSelect($Table);
     52    else if ($Action == 'mapselect') $Content = $this->ShowMapSelect($Table);
     53    else if ($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
     54    else if ($Action == 'add') $Content = $this->ShowAdd($Table);
     55    else if ($Action == 'addsub') $Content = $this->ShowAddSub($Table);
     56    else if ($Action == 'view') $Content = $this->ShowView($Table, $ItemId);
     57    else if ($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId);
     58    else if ($Action == 'fav_add') $Content = $this->ShowFavoriteAdd($Table, $ItemId);
     59    else if ($Action == 'fav_del') $Content = $this->ShowFavoriteDel($Table, $ItemId);
    6060    else $Content = $this->Dashboard();
    61     if($this->HideMenu == false)
     61    if ($this->HideMenu == false)
    6262    {
    6363      $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
    6464      $MenuTypeText = '<a href="?menutype=0">Nabídka</a>';
    65       if($MenuType == 0) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
     65      if ($MenuType == 0) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
    6666      $Output .= $MenuTypeText.' ';
    6767      $MenuTypeText = '<a href="?menutype=1">Oblíbené</a>';
    68       if($MenuType == 1) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
     68      if ($MenuType == 1) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
    6969      $Output .= $MenuTypeText.' ';
    70       if($MenuType == 0) $Output .= $this->ShowMenu();
    71       if($MenuType == 1) $Output .= $this->ShowFavorites();
     70      if ($MenuType == 0) $Output .= $this->ShowMenu();
     71      if ($MenuType == 1) $Output .= $this->ShowFavorites();
    7272      $Output .= '</td><td style="width: 80%; vertical-align: top;">';
    7373      $Output .= $Content;
     
    7575    } else $Output = $Content;
    7676
    77     return($Output);
     77    return $Output;
    7878  }
    7979
     
    8181  {
    8282    $Output = '<strong>Nástěnka:</strong><br/>';
    83     foreach($this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)
    84     {
    85       if(is_string($Item['Callback'][0]))
     83    foreach ($this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)
     84    {
     85      if (is_string($Item['Callback'][0]))
    8686      {
    8787        $Class = new $Item['Callback'][0]($this->System);
     
    9696  {
    9797    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
    98     if($DbResult->num_rows > 0)
     98    if ($DbResult->num_rows > 0)
    9999    {
    100100      $Output = $this->SystemMessage('Oblíbené', 'Již existuje v oblíbených');
    101     } else {
     101    } else
     102    {
    102103      $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));
    103104      $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených');
    104105    }
    105106    $Output .= $this->ShowList($Table);
    106     return($Output);
     107    return $Output;
    107108  }
    108109
     
    110111  {
    111112    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
    112     if($DbResult->num_rows > 0)
     113    if ($DbResult->num_rows > 0)
    113114    {
    114115      $DbRow = $DbResult->fetch_assoc();
    115116      $this->Database->delete('MenuItemFavorite', '`Id`= '.$DbRow['Id']);
    116117      $Output = $this->SystemMessage('Oblíbené', 'Odstraněno z oblíbených');
    117     } else {
     118    } else
     119    {
    118120      $Output = $this->SystemMessage('Oblíbené', 'Nenalezeno v oblíbených');
    119121    }
    120122    $Output .= $this->ShowList($Table);
    121     return($Output);
     123    return $Output;
    122124  }
    123125
     
    127129    // Compare old values loaded from database with new values in Form variable
    128130    $NewValues = $Form->Values;
    129     if($OldId != 0)
     131    if ($OldId != 0)
    130132    {
    131133      $FormOld = new Form($this->System->FormManager);
     
    134136      $OldValues = $FormOld->Values;
    135137      // Keep only changes values
    136       foreach($NewValues as $Index => $Value)
    137       {
    138         if($OldValues[$Index] != $NewValues[$Index])
     138      foreach ($NewValues as $Index => $Value)
     139      {
     140        if ($OldValues[$Index] != $NewValues[$Index])
    139141        {
    140142          $Values .= $Index.': '.$FormOld->GetValue($Index);
    141           if($NewId != 0) $Values .= ' => '.$Form->GetValue($Index);
     143          if ($NewId != 0) $Values .= ' => '.$Form->GetValue($Index);
    142144          $Values .= "\n";
    143145        }
    144146      }
    145     } else {
    146       foreach($NewValues as $Index => $Value)
     147    } else
     148    {
     149      foreach ($NewValues as $Index => $Value)
    147150      {
    148151        $Values .= $Index.': '.$Form->GetValue($Index)."\n";
     
    155158  {
    156159    $Output = '';
    157     if(!array_key_exists($Table, $this->System->FormManager->Classes))
    158       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
    159     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    160       return($this->SystemMessage('Oprávnění', 'Nemáte oprávnění'));
    161     if(array_key_exists('o', $_GET))
    162     {
    163       if($_GET['o'] == 'save')
    164       {
    165         if(!array_key_exists('submit', $_POST))
    166           return($this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.'));
     160    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     161      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
     162    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     163      return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění');
     164    if (array_key_exists('o', $_GET))
     165    {
     166      if ($_GET['o'] == 'save')
     167      {
     168        if (!array_key_exists('submit', $_POST))
     169          return $this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.');
    167170        $Form = new Form($this->System->FormManager);
    168171        $Form->SetClass($Table);
    169172        $Form->LoadValuesFromForm();
    170173        $this->ShortTitle .= ' - '.$Form->Definition['Title'].' úprava';
    171         try {
     174        try
     175        {
    172176          $Form->Validate();
    173           if(array_key_exists('BeforeModify', $Form->Definition))
     177          if (array_key_exists('BeforeModify', $Form->Definition))
    174178          {
    175179            $Class = $Form->Definition['BeforeModify'][0];
     
    181185          $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
    182186          $Output .= $this->ShowView($Table, $Id);
    183           if(array_key_exists('AfterModify', $Form->Definition))
     187          if (array_key_exists('AfterModify', $Form->Definition))
    184188          {
    185189            $Class = $Form->Definition['AfterModify'][0];
     
    219223      $Output .= '</ul>';
    220224    }
    221     return($Output);
     225    return $Output;
    222226  }
    223227
     
    225229  {
    226230    $Output = '';
    227     if(!array_key_exists($Table, $this->System->FormManager->Classes))
    228       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
     231    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     232      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    229233    $FormClass = $this->System->FormManager->Classes[$Table];
    230     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    231       return('Nemáte oprávnění');
     234    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     235      return 'Nemáte oprávnění';
    232236    $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id);
    233     if($DbResult->num_rows > 0)
     237    if ($DbResult->num_rows > 0)
    234238    {
    235239      $DbRow = $DbResult->fetch_assoc();
    236       try {
     240      try
     241      {
    237242        $Form = new Form($this->System->FormManager);
    238243        $Form->SetClass($Table);
    239244        $Form->LoadValuesFromDatabase($Id);
    240245        $this->ShortTitle .= ' - '.$Form->Definition['Title'].' odstranění';
    241         if(array_key_exists('BeforeDelete', $Form->Definition))
     246        if (array_key_exists('BeforeDelete', $Form->Definition))
    242247        {
    243248          call_user_func($Form->Definition['BeforeDelete'], $Form, $Id);
     
    246251        $this->Database->delete($Table, '`Id`='.$Id);
    247252        $Output .= $this->SystemMessage('Smazání položky', 'Položka odstraněna');
    248         if(array_key_exists('AfterDelete', $Form->Definition))
     253        if (array_key_exists('AfterDelete', $Form->Definition))
    249254        {
    250255          $Class = $Form->Definition['AfterDelete'][0];
     
    258263    } else $Output .= $this->SystemMessage('Smazání položky', 'Položka nenalezena');
    259264    $Output .= $this->ShowList($Table);
    260     return($Output);
     265    return $Output;
    261266  }
    262267
     
    264269  {
    265270    $Output = '';
    266     if(!array_key_exists($Table, $this->System->FormManager->Classes))
    267       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
    268     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    269       return('Nemáte oprávnění');
    270     if(array_key_exists('o', $_GET))
    271     {
    272       if($_GET['o'] == 'save')
     271    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     272      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
     273    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     274      return 'Nemáte oprávnění';
     275    if (array_key_exists('o', $_GET))
     276    {
     277      if ($_GET['o'] == 'save')
    273278      {
    274279        $Form = new Form($this->System->FormManager);
     
    276281        $Form->LoadValuesFromForm();
    277282        $this->ShortTitle .= ' - '.$Form->Definition['Title'].' přidání';
    278         try {
     283        try
     284        {
    279285          $Form->Validate();
    280           if(array_key_exists('BeforeInsert', $Form->Definition))
     286          if (array_key_exists('BeforeInsert', $Form->Definition))
    281287          {
    282288            $Class = $Form->Definition['BeforeInsert'][0];
     
    290296          $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
    291297          $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub');
    292           if(array_key_exists('AfterInsert', $Form->Definition))
     298          if (array_key_exists('AfterInsert', $Form->Definition))
    293299          {
    294300            $Class = $Form->Definition['AfterInsert'][0];
     
    297303          }
    298304          // Add action to update caller form
    299           if($_GET['a'] == 'addsub')
     305          if ($_GET['a'] == 'addsub')
    300306          {
    301307            $Type = $this->System->FormManager->FormTypes[$_GET['rt']];
     
    326332      $this->ShortTitle .= ' - '.$Form->Definition['Title'].' přidání';
    327333      // Load presets from URL
    328       foreach($_GET as $Key => $Value)
    329       if(substr($Key, 0, 6) == 'preset')
    330       {
    331         $Key = substr($Key, 6);
    332         if(($Key != '') and array_key_exists($Key, $Form->Values))
    333           $Form->Values[$Key] = $Value;
    334       }
    335       if(array_key_exists('r', $_GET)) $URL = '&amp;r='.$_GET['r'].'&amp;rt='.$_GET['rt'];
     334      foreach ($_GET as $Key => $Value)
     335      {
     336        if (substr($Key, 0, 6) == 'preset')
     337        {
     338          $Key = substr($Key, 6);
     339          if (($Key != '') and array_key_exists($Key, $Form->Values))
     340            $Form->Values[$Key] = $Value;
     341        }
     342      }
     343      if (array_key_exists('r', $_GET)) $URL = '&amp;r='.$_GET['r'].'&amp;rt='.$_GET['rt'];
    336344        else $URL = '';
    337345      $Form->OnSubmit = '?a='.$_GET['a'].'&amp;t='.$Table.'&amp;o=save'.$URL;
     
    341349    }
    342350    $Output .= '<ul class="ActionMenu">';
    343     foreach($Actions as $Action)
     351    foreach ($Actions as $Action)
    344352    {
    345353      $Output .= '<li>'.$Action.'</li>';
    346354    }
    347355    $Output .= '</ul>';
    348     return($Output);
     356    return $Output;
    349357  }
    350358
    351359  function ShowAddSub($Table, $Filter = '', $Title = '')
    352360  {
    353     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    354       return('Nemáte oprávnění');
     361    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     362      return 'Nemáte oprávnění';
    355363    $this->BasicHTML = true;
    356364    $this->HideMenu = true;
    357365    $Output = $this->ShowAdd($Table);
    358     return($Output);
     366    return $Output;
    359367  }
    360368
     
    364372    $QueryItems['a'] = 'view';
    365373
    366     if(array_key_exists($QueryParamName, $_GET)) $TabIndex = $_GET[$QueryParamName];
     374    if (array_key_exists($QueryParamName, $_GET)) $TabIndex = $_GET[$QueryParamName];
    367375      else $TabIndex = 0;
    368376
    369377    $Output = '<div class="Tab">'.
    370378      '<ul>';
    371     foreach($Tabs as $Index => $Tab)
     379    foreach ($Tabs as $Index => $Tab)
    372380    {
    373381      $QueryItems[$QueryParamName] = $Index;
    374       if($Index == $TabIndex) $Selected = ' id="selected"';
     382      if ($Index == $TabIndex) $Selected = ' id="selected"';
    375383        else $Selected = '';
    376384      $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>';
    377385    }
    378386    $Output .= '</ul></div><div class="TabContent">'.$TabContent.'</div>';
    379     return($Output);
     387    return $Output;
    380388  }
    381389
    382390  function ShowView($Table, $Id, $WithoutActions = false)
    383391  {
    384     if(!array_key_exists($Table, $this->System->FormManager->Classes))
    385       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
     392    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     393      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    386394    $FormClass = $this->System->FormManager->Classes[$Table];
    387     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    388       return('Nemáte oprávnění');
     395    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     396      return 'Nemáte oprávnění';
    389397
    390398    $FormClass = $this->System->FormManager->Classes[$Table];
    391     if(array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable'];
     399    if (array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable'];
    392400      else $TableModify = $Table;
    393401
     
    398406    $Form->OnSubmit = '?a=view';
    399407    $Output = $Form->ShowViewForm();
    400     if($WithoutActions == false)
     408    if ($WithoutActions == false)
    401409    {
    402410      $Actions = array(
     
    410418          $this->System->Link('/images/add.png'))
    411419      );
    412       if(array_key_exists('ItemActions', $FormClass))
    413       {
    414         foreach($FormClass['ItemActions'] as $Action)
     420      if (array_key_exists('ItemActions', $FormClass))
     421      {
     422        foreach ($FormClass['ItemActions'] as $Action)
    415423        {
    416424          $URL = str_replace('#RowId', $Id, $this->System->Link($Action['URL']));
     
    420428      }
    421429      $Output .= '<ul class="ActionMenu">';
    422       foreach($Actions as $Action)
     430      foreach ($Actions as $Action)
    423431      {
    424432        $Output .= '<li>'.$Action.'</li>';
     
    429437    // Show ManyToOne relations
    430438    $Tabs = array();
    431     foreach($Form->Definition['Items'] as $Index => $Item)
    432     if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
     439    foreach ($Form->Definition['Items'] as $Index => $Item)
     440    if ((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
    433441    ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
    434442    {
     
    436444    }
    437445    $Tabs[] = 'Vše';
    438     if(array_key_exists('tab', $_GET)) $TabIndex = $_GET['tab'];
     446    if (array_key_exists('tab', $_GET)) $TabIndex = $_GET['tab'];
    439447      else $TabIndex = 0;
    440448
    441449    $TabContent = '';
    442450    $I = 0;
    443     foreach($Form->Definition['Items'] as $Index => $Item)
    444     if((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
     451    foreach ($Form->Definition['Items'] as $Index => $Item)
     452    if ((array_key_exists($Item['Type'], $this->System->FormManager->FormTypes) and
    445453    ($this->System->FormManager->FormTypes[$Item['Type']]['Type'] == 'ManyToOne')))
    446454    {
     
    462470
    463471    $Output .= $this->ShowTabs($Tabs, 'tab', $TabContent);
    464     return($Output);
     472    return $Output;
    465473  }
    466474
    467475  function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')
    468476  {
    469     if(!array_key_exists($Table, $this->System->FormManager->Classes))
    470       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
     477    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     478      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    471479    $FormClass = $this->System->FormManager->Classes[$Table];
    472480
    473     if(array_key_exists('SQL', $FormClass))
     481    if (array_key_exists('SQL', $FormClass))
    474482      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
    475483      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
     
    480488    // Build form type filter
    481489    $TypeFilter = '';
    482     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    483     if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     490    foreach ($FormClass['Items'] as $ItemIndex => $FormItem)
     491    if (!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    484492    (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    485493    ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    486     if(array_key_exists('Filter', $FormItem) and ($FormItem['Filter'] == true))
    487     {
    488       if($TypeFilter != '') $TypeFilter .= ' AND ';
     494    if (array_key_exists('Filter', $FormItem) and ($FormItem['Filter'] == true))
     495    {
     496      if ($TypeFilter != '') $TypeFilter .= ' AND ';
    489497      $TypeFilter .= '(`'.$ItemIndex.'` = "'.$FormItem['Default'].'")';
    490498    }
    491     if($TypeFilter != '')
    492     {
    493       if($HavingFilter != '') $HavingFilter = ' AND';
     499    if ($TypeFilter != '')
     500    {
     501      if ($HavingFilter != '') $HavingFilter = ' AND';
    494502      $HavingFilter .= ' '.$TypeFilter;
    495503    }
     
    498506    $UserFilter = '';
    499507    $Columns = array('Id' => '`Id`');
    500     if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
    501     {
    502       foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    503       if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
    504       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     508    if (array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
     509    {
     510      foreach ($FormClass['Items'] as $ItemIndex => $FormItem)
     511      if (!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
     512      if (!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    505513      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    506514      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    507515      {
    508516        $UseType = $UseType = $FormItem['Type'];
    509         if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
    510         {
    511           if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     517        if (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     518        {
     519          if (!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
    512520            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
    513521              $this->System->FormManager->FormTypes[$FormItem['Type']]);
    514           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     522          if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
    515523          $UseType = 'OneToMany';
    516524          else
    517           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     525          if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
    518526          $UseType = 'Enumeration';
    519527        }
    520528        $FilterName = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterName',
    521529          array('Name' => $ItemIndex, 'Type' => $FormItem['Type']));
    522         if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    523         {
    524           if($UserFilter != '') $UserFilter .= ' AND ';
     530        if (array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     531        {
     532          if ($UserFilter != '') $UserFilter .= ' AND ';
    525533          $UserFilter .= '('.$FilterName.' LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
    526534        }
    527535      }
    528536    }
    529     if($UserFilter != '')
    530     {
    531       if($HavingFilter != '') $HavingFilter .= ' AND';
     537    if ($UserFilter != '')
     538    {
     539      if ($HavingFilter != '') $HavingFilter .= ' AND';
    532540      $HavingFilter .= ' '.$UserFilter;
    533541    }
    534     if($WhereFilter != '') $Filter = ' WHERE '.$WhereFilter;
    535     if($HavingFilter != '') $Filter = ' HAVING '.$HavingFilter;
    536 
    537 
    538     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    539       if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     542    if ($WhereFilter != '') $Filter = ' WHERE '.$WhereFilter;
     543    if ($HavingFilter != '') $Filter = ' HAVING '.$HavingFilter;
     544
     545
     546    foreach ($FormClass['Items'] as $ItemIndex => $FormItem)
     547      if (!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    540548      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    541549      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
    542550      {
    543         if($ExcludeColumn != $ItemIndex)
    544         if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
    545         if(!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
     551        if ($ExcludeColumn != $ItemIndex)
     552        if (!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
     553        if (!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
    546554          $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
    547555        $UseType = $UseType = $FormItem['Type'];
    548         if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
    549         {
    550           if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     556        if (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     557        {
     558          if (!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
    551559            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
    552560                $this->System->FormManager->FormTypes[$FormItem['Type']]);
    553           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     561          if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
    554562            $UseType = 'OneToMany';
    555563          else
    556             if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     564            if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
    557565            $UseType = 'Enumeration';
    558566        }
    559         if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     567        if (array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    560568          $Value = $_POST['Filter'.$ItemIndex];
    561569          else $Value = '';
    562         if($ItemIndex == 'Id') unset($Columns['Id']);
    563 
    564         if(!array_key_exists('SQL', $FormItem)) $FormItem['SQL'] = '';
     570        if ($ItemIndex == 'Id') unset($Columns['Id']);
     571
     572        if (!array_key_exists('SQL', $FormItem)) $FormItem['SQL'] = '';
    565573          else $FormItem['SQL'] = str_replace('#Id', '`TX`.`Id`', $FormItem['SQL']);
    566574        $Columns[] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
     
    577585    // Get total filtered item count in database
    578586    $Columns = implode(',', $Columns);
    579     if($Filter != '')
     587    if ($Filter != '')
    580588    {
    581589      $Query = 'SELECT COUNT(*) FROM (SELECT '.$Columns.' FROM '.$SourceTable.' '.$Filter.') AS `TS`';
     
    590598
    591599    $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
    592     if(!array_key_exists('DefaultSortColumn', $FormClass))
     600    if (!array_key_exists('DefaultSortColumn', $FormClass))
    593601      $FormClass['DefaultSortColumn'] = 'Id';
    594     if(!array_key_exists('DefaultSortOrder', $FormClass))
     602    if (!array_key_exists('DefaultSortOrder', $FormClass))
    595603      $FormClass['DefaultSortOrder'] = 0;
    596604    $Order = GetOrderTableHeader($Table, $TableColumns, $FormClass['DefaultSortColumn'], $FormClass['DefaultSortOrder']);
     
    598606
    599607    // Show search fields
    600     if(array_key_exists('r', $_GET)) $Addition = '&amp;r='.$_GET['r'];
     608    if (array_key_exists('r', $_GET)) $Addition = '&amp;r='.$_GET['r'];
    601609      else $Addition = '';
    602610    $Output .= '<tr><form action="?a='.$_GET['a'].'&amp;t='.$Table.'&amp;filter=1'.$Addition.'" method="post">';
    603     foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    604     if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
    605     if(!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
    606     if((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     611    foreach ($FormClass['Items'] as $ItemIndex => $FormItem)
     612    if (!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
     613    if (!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
     614    if ((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    607615    (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    608616    ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) and
    609617    ($ExcludeColumn != $ItemIndex))
    610618    {
    611       if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     619      if (array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
    612620        $Value = $_POST['Filter'.$ItemIndex];
    613621        else $Value = '';
     
    621629    $VisibleItemCount = 0;
    622630    $DbResult = $this->Database->query($Query);
    623     while($Row = $DbResult->fetch_assoc())
     631    while ($Row = $DbResult->fetch_assoc())
    624632    {
    625633      $Output .= '<tr>';
    626       foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    627       if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
    628       if(!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
    629       if((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     634      foreach ($FormClass['Items'] as $ItemIndex => $FormItem)
     635      if (!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false))
     636      if (!array_key_exists('NotInList', $FormItem) or ($FormItem['NotInList'] == false))
     637      if ((!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
    630638      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
    631639      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) and
     
    634642        //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
    635643        $UseType = $UseType = $FormItem['Type'];
    636         if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
    637         {
    638           if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     644        if (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     645        {
     646          if (!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
    639647            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
    640648              $this->System->FormManager->FormTypes[$FormItem['Type']]);
    641           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     649          if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
    642650          $UseType = 'OneToMany';
    643651          else
    644           if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     652          if ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
    645653          $UseType = 'Enumeration';
    646654        }
     
    651659          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
    652660          'Type' => $FormItem['Type'], 'Filter' => $Row[$ItemIndex.'_Filter']));
    653         if($Value == '') $Value = '&nbsp;';
     661        if ($Value == '') $Value = '&nbsp;';
    654662        $Output .= '<td>'.$Value.'</td>';
    655663      }
     
    658666    }
    659667    $Output .= '<tr><td colspan="'.count($TableColumns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>';
    660     if($UserFilter != '') $Output .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
     668    if ($UserFilter != '') $Output .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
    661669    $Output .= ' z celkem <strong>'.$TotalCount.'</strong></td></tr>';
    662670    $Output .= '</table>';
    663671    $Output .= $PageList['Output'];
    664     return($Output);
     672    return $Output;
    665673  }
    666674
    667675  function ShowSelect($Table, $Filter = '', $Title = '')
    668676  {
    669     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    670       return('Nemáte oprávnění');
     677    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     678      return 'Nemáte oprávnění';
    671679    $this->BasicHTML = true;
    672680    $this->HideMenu = true;
     
    675683      $this->System->Link('/images/select.png').'"/></a>';
    676684    $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);
    677     return($Output);
     685    return $Output;
    678686  }
    679687
    680688  function ShowMapSelect($Table, $Filter = '', $Title = '')
    681689  {
    682     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    683       return('Nemáte oprávnění');
     690    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     691      return 'Nemáte oprávnění';
    684692    $Map = new MapOpenStreetMaps($this->System);
    685693    $Map->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'],
     
    690698    //$MapApi->ShowMarker = true;
    691699    $Output = $Map->ShowPage($this);
    692     return($Output);
     700    return $Output;
    693701  }
    694702
     
    696704  {
    697705    $Output = '';
    698     if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    699       return('Nemáte oprávnění');
     706    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     707      return 'Nemáte oprávnění';
    700708    if(!array_key_exists($Table, $this->System->FormManager->Classes))
    701       return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
     709      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    702710    $FormClass = $this->System->FormManager->Classes[$Table];
    703     if(array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable'];
     711    if (array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable'];
    704712      else $TableModify = $Table;
    705713
     
    710718      '<a href="?a=delete&amp;t='.$Table.'&amp;i=#RowId"><img alt="Smazat" title="Smazat" src="'.
    711719      $this->System->Link('/images/delete.png').'" onclick="return confirmAction(\'Opravdu smazat položku?\');"/></a>';
    712     if(($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
     720    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
    713721      $FormClass = $this->System->FormManager->Classes[$Table];
    714       else return($this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'));
    715     if($ExcludeColumn == '') $this->ShortTitle .= ' - '.$FormClass['Title'];
    716     if(array_key_exists('ItemActions', $FormClass))
    717     {
    718       foreach($FormClass['ItemActions'] as $Action)
     722      else return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
     723    if ($ExcludeColumn == '') $this->ShortTitle .= ' - '.$FormClass['Title'];
     724    if (array_key_exists('ItemActions', $FormClass))
     725    {
     726      foreach ($FormClass['ItemActions'] as $Action)
    719727      {
    720728        $URL = $this->System->Link($Action['URL']);
     
    728736    $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&amp;t='.$Table, $this->System->Link('/images/list.png')).'</li>';
    729737    $MI = 0;
    730     if(array_key_exists('mi', $_GET))
     738    if (array_key_exists('mi', $_GET))
    731739    {
    732740      $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
    733       if($DbResult->num_rows > 0)
     741      if ($DbResult->num_rows > 0)
    734742      {
    735743        $DbRow = $DbResult->fetch_assoc();
     
    740748          $this->System->Link('/images/Favorite-Add.png')).'</li>';
    741749    }
    742     if(array_key_exists('Actions', $FormClass))
    743     {
    744       foreach($FormClass['Actions'] as $Action)
     750    if (array_key_exists('Actions', $FormClass))
     751    {
     752      foreach ($FormClass['Actions'] as $Action)
     753      {
    745754        $Output .= '<li>'.$this->ShowAction($Action['Caption'], $this->System->Link($Action['URL']),
    746             $this->System->Link('/images/action.png')).'</li>';
     755          $this->System->Link('/images/action.png')).'</li>';
     756      }
    747757    }
    748758    $Output .= '</ul>';
    749759    $Output .= $this->ShowTable($Table, $Filter, $Title, $RowActions, $ExcludeColumn);
    750     return($Output);
     760    return $Output;
    751761  }
    752762
     
    760770      'WHERE `MenuItemFavorite`.`User`='.$this->System->User->User['Id'].' '.
    761771      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    762     while($DbRow = $DbResult->fetch_assoc())
    763     {
    764       //if($DbRow['Permission'] != '')
     772    while ($DbRow = $DbResult->fetch_assoc())
     773    {
     774      //if ($DbRow['Permission'] != '')
    765775      $this->MenuItems[$DbRow['Id']] = $DbRow;
    766776    }
    767     return($this->ShowMenuItem('', true));
     777    return $this->ShowMenuItem('', true);
    768778  }
    769779
     
    776786      'WHERE `MenuItem`.`Menu`=1 '.
    777787      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    778     while($DbRow = $DbResult->fetch_assoc())
    779     {
    780       //if($DbRow['Permission'] != '')
     788    while ($DbRow = $DbResult->fetch_assoc())
     789    {
     790      //if ($DbRow['Permission'] != '')
    781791      $this->MenuItems[$DbRow['Id']] = $DbRow;
    782792    }
    783     return($this->ShowMenuItem(''));
     793    return $this->ShowMenuItem('');
    784794  }
    785795
     
    787797  {
    788798    $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
    789     foreach($this->MenuItems as $MenuItem)
    790     if(($MenuItem['Parent'] == $Parent) or $All)
    791     {
    792       $LinkTitle = $MenuItem['Name'];
    793       if($MenuItem['URL'] != '')
    794       {
    795         $Icon = 'Device.png';
    796         if(substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']);
    797         $LinkTitle = MakeLink($MenuItem['URL'].'&amp;mi='.$MenuItem['Id'], $LinkTitle);
    798       } else $Icon = 'Folder.png';
    799       if($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/>&nbsp;';
    800         else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/>&nbsp;';
    801       //if($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
    802         $Output .= '<li>'.$Image.$LinkTitle.'</li>';
    803       if($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
     799    foreach ($this->MenuItems as $MenuItem)
     800    {
     801      if (($MenuItem['Parent'] == $Parent) or $All)
     802      {
     803        $LinkTitle = $MenuItem['Name'];
     804        if ($MenuItem['URL'] != '')
     805        {
     806          $Icon = 'Device.png';
     807          if (substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']);
     808          $LinkTitle = MakeLink($MenuItem['URL'].'&amp;mi='.$MenuItem['Id'], $LinkTitle);
     809        } else $Icon = 'Folder.png';
     810        if ($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/>&nbsp;';
     811          else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/>&nbsp;';
     812        //if ($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
     813          $Output .= '<li>'.$Image.$LinkTitle.'</li>';
     814        if ($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
     815      }
    804816    }
    805817    $Output .= '</ul>';
    806     return($Output);
     818    return $Output;
    807819  }
    808820
     
    811823    $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '.
    812824      'WHERE `Module`.`Id`=`Model`.`Module`) AS `Name` FROM `Model` WHERE `Name`="'.$Table.'"');
    813     if($DbResult->num_rows == 1)
     825    if ($DbResult->num_rows == 1)
    814826    {
    815827      $DbRow = $DbResult->fetch_assoc();
    816       return($DbRow['Name']);
    817     } else return('');
     828      return $DbRow['Name'];
     829    } else return '';
    818830  }
    819831
     
    822834    $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'.
    823835      $Icon.'"/>';
    824     if($this->ShowActionName) $Output .= $Name;
    825     if($Confirm != '')
     836    if ($this->ShowActionName) $Output .= $Name;
     837    if ($Confirm != '')
    826838      $Confirm = ' onclick="return confirmAction(\''.$Confirm.'\');"';
    827839    $Output = '<a href="'.$Target.'"'.$Confirm.'>'.$Output.'</a>';
    828     return($Output);
     840    return $Output;
    829841  }
    830842}
Note: See TracChangeset for help on using the changeset viewer.