Changeset 529


Ignore:
Timestamp:
Apr 23, 2013, 7:12:53 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Výběr relací mezi tabulkami pomocí zobrazení samostatného okna s výběrovou tabulkou ve správě dat.
  • Přidáno: Možnost generovat jen základní HTML část stránky bez hlavičky a patičky.
Location:
trunk
Files:
1 added
9 edited

Legend:

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

    r502 r529  
    138138            array('Value' => $DbRow[$Index], 'Name' => $Index,
    139139            'Type' => $Item['Type'], 'Values' => $this->Values));
    140        
    141         //echo($DbRow[$Index].'='.$this->Values[$Index].'<br/>');
    142140    }
    143141  }
     
    172170        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);
    173171        if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
    174        
    175         //echo($DbRow[$Index].'='.$this->Values[$Index].'<br/>');
    176172    }
    177173    }
     
    182178    } else
    183179      $DbResult = $this->Database->update($this->Definition['Table'], 'Id='.$Id, $Values);
    184     //echo($Database->LastQuery);
    185180  }
    186181
     
    255250  var $Database;
    256251  var $Type;
     252  var $RootURL;
    257253 
    258254  function __construct($Database)
  • trunk/Common/Form/Types/OneToMany.php

    r502 r529  
    55class TypeOneToMany extends TypeBase
    66{
     7  var $EditActions;
     8 
    79  function OnView($Item)
    810  {
     
    2426  function OnEdit($Item)
    2527  {
    26     $Output = '<select name="'.$Item['Name'].'">';
     28    $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">';
    2729    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    2830    if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
     
    4244    }
    4345    $Output .= '</select>';
     46    $Output .=  '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '.
     47      'onclick="return popupwindow(&quot;'.$this->FormManager->Root.'/is/?a=select&amp;t='.$Table.'&amp;r='.$Item['Name'].'&quot;,&quot;test&quot;);" style="cursor:hand;cursor:pointer"/>';
    4448    return($Output);
    4549  }
  • trunk/Common/Global.php

    r525 r529  
    7272  $System->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];
    7373  $System->RootURLFolder = $Config['Web']['RootFolder'];
     74  $System->FormManager->Root = $Config['Web']['RootFolder'];
    7475 
    7576  // Check database persistence structure
  • trunk/Common/Page.php

    r525 r529  
    99  var $ShowRuntimeInfo = false;
    1010  var $ClearPage = false;
     11  var $BasicHTML = false;
    1112  var $ParentClass = '';
    1213  var $ShortTitle;
     
    6465    '<script type="text/javascript" src="'.$this->System->Link('/style/').$this->System->Config['Web']['Style'].'/global.js"></script>'.
    6566    '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title>
    66     </head><body'.$BodyParam.'>
    67     <div id="Title">'.$Title.'</div>
    68     <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
    69     if($this->System->Config['Web']['UserSupport'] == 1)
     67    </head><body'.$BodyParam.'>';
     68    if($this->BasicHTML == false)
    7069    {
    71       if($this->System->User->User['Id'] == null)
    72         $Output .= '<a href="'.$this->System->Link('/?Action=LoginForm').'">Přihlášení</a> <a href="'.$this->System->Link('/?Action=UserRegister').'">Registrace</a>';
    73         else $Output .= $this->System->User->User['Name'].' <a href="'.$this->System->Link('/?Action=Logout').'">Odhlásit</a>';
    74    } else $Output .= '&nbsp;';
    75 // <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';
    76     $Output .= '</div></div>';
     70      $Output .= '<div id="Title">'.$Title.'</div>
     71      <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
     72      if($this->System->Config['Web']['UserSupport'] == 1)
     73      {
     74        if($this->System->User->User['Id'] == null)
     75          $Output .= '<a href="'.$this->System->Link('/?Action=LoginForm').'">Přihlášení</a> <a href="'.$this->System->Link('/?Action=UserRegister').'">Registrace</a>';
     76          else $Output .= $this->System->User->User['Name'].' <a href="'.$this->System->Link('/?Action=Logout').'">Odhlásit</a>';
     77     } else $Output .= '&nbsp;';
     78//   <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';
     79      $Output .= '</div></div>';
     80    }
    7781    return($Output);
    7882  }
     
    8286    global $ScriptTimeStart;
    8387    $Time = round(GetMicrotime() - $ScriptTimeStart, 2);
    84     $Output = '<div id="Footer">
    85    <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |';
    86     if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
    87     $Output .= '</i></div></body></html>';
     88    $Output = '';
     89    if($this->BasicHTML == false)
     90    {
     91      $Output .= '<div id="Footer">
     92     <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |';
     93      if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
     94      $Output .= '</i></div>';
     95    }
     96    $Output .= '</body></html>';
    8897    return($Output);
    8998  }
  • trunk/Common/Version.php

    r528 r529  
    11<?php
    22
    3 $Revision = 528; // Subversion revision
     3$Revision = 529; // Subversion revision
    44$DatabaseRevision = 527; // SQL structure revision
    5 $ReleaseTime = '2013-04-21';
     5$ReleaseTime = '2013-04-23';
    66
    77?>
  • trunk/Modules/IS/IS.php

    r528 r529  
    99  var $ParentClass = 'PagePortal';
    1010  var $MenuItems = array();
     11  var $HideMenu = false;
    1112
    1213  function Show()
     
    2223    {
    2324      $this->MenuItems[$DbRow['Id']] = $DbRow;
    24     }
    25    
    26     $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
    27     $Output .= '<strong>Nabídka:</strong><br/>'.$this->ShowMenuItem('');
    28     $Output .= '</td><td style="width: 80%; vertical-align: top;">';
     25    }   
    2926   
    3027    if(array_key_exists('t', $_GET)) $_SESSION['Table'] = $_GET['t'];
    3128    if(array_key_exists('a', $_GET)) $_SESSION['Action'] = $_GET['a'];
    3229    if(array_key_exists('id', $_GET)) $_SESSION['Id'] = $_GET['id'];
    33        
     30    if(array_key_exists('r', $_GET)) $_SESSION['Ref'] = $_GET['r'];
     31   
    3432    if(!array_key_exists('Action', $_SESSION)) $_SESSION['Action'] = 'list';
    3533    if(!array_key_exists('Id', $_SESSION) or !array_key_exists('Table', $_SESSION) or
     
    3836      $_SESSION['Action'] = '';
    3937      $_SESSION['Table'] = '';
    40     }
    41    
    42     if($_SESSION['Action'] == 'list') $Output .= $this->ShowList($_SESSION['Table']);
    43     else if($_SESSION['Action'] == 'edit') $Output .= $this->ShowEdit($_SESSION['Table'], $_SESSION['Id']);
    44     else if($_SESSION['Action'] == 'add') $Output .= $this->ShowAdd($_SESSION['Table']);
    45     else if($_SESSION['Action'] == 'view') $Output .= $this->ShowView($_SESSION['Table'], $_SESSION['Id']);
    46     else if($_SESSION['Action'] == 'delete') $Output .= $this->ShowDelete($_SESSION['Table'], $_SESSION['Id']);
    47     $Output .= '</td></tr></table>';
     38      $_SESSION['Ref'] = '';
     39    }
     40   
     41    if($_SESSION['Action'] == 'list') $Content = $this->ShowList($_SESSION['Table']);
     42    else if($_SESSION['Action'] == 'select') $Content = $this->ShowSelect($_SESSION['Table']);
     43    else if($_SESSION['Action'] == 'edit') $Content = $this->ShowEdit($_SESSION['Table'], $_SESSION['Id']);
     44    else if($_SESSION['Action'] == 'add') $Content = $this->ShowAdd($_SESSION['Table']);
     45    else if($_SESSION['Action'] == 'view') $Content = $this->ShowView($_SESSION['Table'], $_SESSION['Id']);
     46    else if($_SESSION['Action'] == 'delete') $Content = $this->ShowDelete($_SESSION['Table'], $_SESSION['Id']);
     47    else $Content = '';
     48    if($this->HideMenu == false)
     49    {
     50      $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
     51      $Output .= '<strong>Nabídka:</strong><br/>'.$this->ShowMenuItem('');
     52      $Output .= '</td><td style="width: 80%; vertical-align: top;">';
     53      $Output .= $Content;
     54      $Output .= '</td></tr></table>';
     55    } else $Output = $Content;
    4856   
    4957    return($Output);
     
    7078      $Form->SetClass($Table);
    7179      $Form->LoadValuesFromDatabase($Id);
    72       $Form->OnSubmit = '?a=edit&amp;o=save';
     80      $Form->OnSubmit = '?a=edit&amp;t='.$Table.'&amp;o=save';
    7381      $Output .= $Form->ShowEditForm();
    7482      $Output .= '<ul class="ActionMenu">';
    75       $Output .= '<li><a href="?a=view"><img alt="Prohlížet" title="Prohlížet" src="'.
     83      $Output .= '<li><a href="?a=view&amp;t='.$Table.'"><img alt="Prohlížet" title="Prohlížet" src="'.
    7684      $this->System->Link('/images/view.png').'"/>Prohlížet</a></li>';
    77       $Output .= '<li><a href="?a=list"><img alt="Seznam" title="Seznam" src="'.
     85      $Output .= '<li><a href="?a=list&amp;t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
    7886        $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
    79       $Output .= '<li><a href="?a=delete" onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'.
     87      $Output .= '<li><a href="?a=delete&amp;t='.$Table.'" onclick="return confirmAction(\'Opravdu smazat položku?\');"><img alt="Odstranit" title="Odstranit" src="'.
    8088        $this->System->Link('/images/delete.png').'"/>Odstranit</a></li>';
    8189      $Output .= '</ul>';
     
    118126      $Form = new Form($this->System->FormManager);
    119127      $Form->SetClass($Table);
    120       $Form->OnSubmit = '?a=add&amp;o=save';
     128      $Form->OnSubmit = '?a=add&amp;t='.$Table.'&amp;o=save';
    121129      $Output .= $Form->ShowEditForm();
    122130      $Output .= '<ul class="ActionMenu">';
    123       $Output .= '<li><a href="?a=list"><img alt="Seznam" title="Seznam" src="'.
     131      $Output .= '<li><a href="?a=list&amp;t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
    124132        $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
    125133      $Output .= '</ul>';
     
    166174  }
    167175 
    168   function ShowList($Table, $Filter = '', $Title = '')
    169   {   
     176  function ShowSelect($Table, $Filter = '', $Title = '')
     177  {
     178    $this->BasicHTML = true;
     179    $this->HideMenu = true;
    170180    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    171181      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
     
    174184    $PageList = GetPageList($DbRow[0]);   
    175185
    176     $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
     186    $Output = '<script type="text/javascript">
     187    function set_return(id, obj)
     188    {
     189      window.opener.document.getElementById(obj).value = id;
     190    }
     191    </script>';
     192    $Output .= '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
    177193    $Output .= $PageList['Output'];
    178194    $Output .= '<table class="WideTable" style="font-size: small;">';
     
    204220      }
    205221    }     
    206     $Output .= '<tr><form action="?a=list&amp;filter=1" method="post">';
     222    $Output .= '<tr><form action="?a=select&amp;filter=1" method="post">';
    207223    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
    208224      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     
    252268        $Output .= '<td>'.$Value.'</td>';
    253269      }
     270      $Output .= '<td><a href="javascript:window.close();" onclick="set_return('.$Row['Id'].',&quot;'.$_SESSION['Ref'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
     271        $this->System->Link('/images/select.png').'"/></a>';
     272      $Output .= '</td></tr>';
     273    }
     274    $Output .= '</table>';
     275    $Output .= $PageList['Output'];
     276    return($Output);
     277  }
     278   
     279  function ShowList($Table, $Filter = '', $Title = '')
     280  {   
     281    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
     282      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
     283
     284    // Build user filter
     285    $UserFilter = '';
     286    if(array_key_exists('filter', $_GET) and ($_GET['filter'] == 1))
     287    {
     288      foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     289      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     290          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     291              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     292      {
     293        if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     294          $UserFilter .= ' AND (`'.$ItemIndex.'` LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
     295      }
     296    }     
     297    if(($Filter == '') and ($UserFilter != '')) $Filter = '1 '.$UserFilter;
     298    if($Filter != '') $Filter = ' WHERE '.$Filter;
     299   
     300    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$FormClass['Table'].'`'.$Filter);
     301    $DbRow = $DbResult->fetch_row();
     302    $PageList = GetPageList($DbRow[0]);   
     303
     304    $Output = '<div style="text-align: center;">'.$FormClass['Title'].'</div>';
     305    $Output .= $PageList['Output'];
     306    $Output .= '<table class="WideTable" style="font-size: small;">';
     307   
     308    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     309    if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     310      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     311      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     312    {
     313      $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']);
     314    }   
     315    $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
     316    if(!array_key_exists('DefaultSortColumn', $FormClass))
     317      $FormClass['DefaultSortColumn'] = 'Id';
     318    $Order = GetOrderTableHeader($TableColumns, $FormClass['DefaultSortColumn'], 0);
     319    $Output .= $Order['Output'];
     320   
     321    // Show search fields
     322    $Output .= '<tr><form action="?a=list&amp;filter=1" method="post">';
     323    foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     324      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     325          (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     326              ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     327    {
     328      if(array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     329        $Value = $_POST['Filter'.$ItemIndex];
     330        else $Value = ''; 
     331      $Output .= '<td><input type="text" name="Filter'.$ItemIndex.'" value="'.$Value.'" style="width: 100%"/></td>';   
     332    }
     333    $Output .= '<td><input type="Submit" value="Hledat"/></td></form></tr>';
     334
     335    $Query = 'SELECT * FROM `'.$FormClass['Table'].'`'.$Filter.' '.$Order['SQL'].$PageList['SQLLimit'];
     336   
     337    $DbResult = $this->Database->query($Query);
     338    while($Row = $DbResult->fetch_assoc())
     339    {
     340      $Output .= '<tr>';
     341      foreach($FormClass['Items'] as $ItemIndex => $FormItem)
     342      if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or
     343      (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and
     344      ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne')))
     345      {
     346        //$Output .= '<td>'.$Row[$ItemIndex].'</td>';
     347        $UseType = $UseType = $FormItem['Type'];
     348        if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes))
     349        {
     350          if(!array_key_exists($FormItem['Type'], $this->System->FormManager->Type->TypeDefinitionList))
     351            $this->System->FormManager->Type->RegisterType($FormItem['Type'], '',
     352              $this->System->FormManager->FormTypes[$FormItem['Type']]);
     353          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Reference')
     354          $UseType = 'OneToMany';
     355          else
     356          if($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] == 'Enumeration')
     357          $UseType = 'Enumeration';
     358        }
     359        $Row[$ItemIndex] = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb',
     360          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
     361          'Type' => $FormItem['Type']));
     362        $Value = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView',
     363          array('Value' => $Row[$ItemIndex], 'Name' => $ItemIndex,
     364          'Type' => $FormItem['Type']));
     365        if($Value == '') $Value = '&nbsp;';
     366        $Output .= '<td>'.$Value.'</td>';
     367      }
    254368      $Output .= '<td><a href="?a=view&amp;t='.$Table.'&amp;id='.$Row['Id'].'"><img alt="Ukázat" title="Ukázat" src="'.
    255369        $this->System->Link('/images/view.png').'"/></a>'.
  • trunk/Modules/Network/UserHosts.php

    r524 r529  
    33class PageNetworkHostList extends Page
    44{
    5   function __construct()
     5  function __construct($System)
    66  {
    7     parent::__construct();
     7    parent::__construct($System);
    88    $this->FullTitle = 'Registrované počítače';
    99    $this->ShortTitle = 'Registrované počítače';
  • trunk/form_classes.php

    r527 r529  
    627627    ),
    628628    'Actions' => array(
    629       array('Caption' => 'Dostupnost zařízení', 'URL' => '/network/dostupnost.php'),
     629      array('Caption' => 'Dostupnost zařízení', 'URL' => '/network/availability/'),
    630630    ),
    631631  ),
     
    648648      'LocalIP' => array('Type' => 'String', 'Caption' => 'IPv4', 'Default' => ''),
    649649      'IPv6' => array('Type' => 'String', 'Caption' => 'IPv6', 'Default' => ''),
    650       'ExternalIP' => array('Type' => 'String', 'Caption' => 'Veřejná IPv4', 'Default' => '0'),
     650      'ExternalIP' => array('Type' => 'String', 'Caption' => 'Veřejná IPv4', 'Default' => ''),
    651651      'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''),
    652652      'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true),
  • trunk/style/new/global.js

    r433 r529  
    3838  return is_confirmed;
    3939}
     40
     41function popupwindow(url, title)
     42{
     43  var e = document.documentElement;
     44  var g = document.getElementsByTagName('body')[0];
     45  var w = window.innerWidth || e.clientWidth || g.clientWidth;
     46  var h = window.innerHeight|| e.clientHeight|| g.clientHeight;         
     47  w = (w * 0.9).toFixed();
     48  h = (h * 0.6).toFixed();
     49  if(w < 640) w = 640;
     50  if(h < 480) h = 480;
     51  var left = (screen.width / 2) - (w / 2);
     52  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);
     54}
Note: See TracChangeset for help on using the changeset viewer.