Ignore:
Timestamp:
Apr 7, 2020, 11:53:58 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Measure/Page.php

    r86 r92  
    6868    // Day selection
    6969    $Output .= '<select name="Day">';
    70     for($I = 1; $I < 32; $I++)
    71     {
    72       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
     70    for ($I = 1; $I < 32; $I++)
     71    {
     72      if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    7373      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    7474    }
     
    7777    // Month selection
    7878    $Output .= '<select name="Month">';
    79     foreach($this->Months as $Index => $Month)
    80     {
    81       if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    82       if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     79    foreach ($this->Months as $Index => $Month)
     80    {
     81      if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
     82      if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
    8383    }
    8484    $Output .= '</select>. ';
     
    8686    // Year selection
    8787    $Output .= '<select name="Year">';
    88     for($I = 2000; $I <= date("Y"); $I++)
    89     {
    90       if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
     88    for ($I = 2000; $I <= date("Y"); $I++)
     89    {
     90      if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    9191      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    9292    }
     
    9595    // Hour selection
    9696    $Output .= '<select name="Hour">';
    97     for($I = 0; $I < 24; $I++)
    98     {
    99       if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
     97    for ($I = 0; $I < 24; $I++)
     98    {
     99      if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    100100      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    101101    }
     
    104104    // Minute selection
    105105    $Output .= '<select name="Minute">';
    106     for($I = 0; $I < 60; $I++)
    107     {
    108       if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     106    for ($I = 0; $I < 60; $I++)
     107    {
     108      if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
    109109      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    110110    }
     
    117117    $Output .= '</form>';
    118118
    119     return($Output);
     119    return $Output;
    120120  }
    121121 
     
    123123  {
    124124    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` ASC LIMIT 1');
    125     if($Result2->num_rows > 0)
     125    if ($Result2->num_rows > 0)
    126126    {
    127127      $Row = $Result2->fetch_array();
     
    132132      $LastMeasureValue = 0;
    133133    }
    134     return(array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));
     134    return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue);
    135135  }
    136136
     
    138138  {
    139139    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1');
    140     if($Result2->num_rows > 0)
     140    if ($Result2->num_rows > 0)
    141141    {
    142142      $Row = $Result2->fetch_array();
     
    147147      $LastMeasureValue = 0;
    148148    }
    149     return(array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));
     149    return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue);
    150150  }
    151151 
     
    164164    $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small; margin: 0px auto;">';
    165165    $Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>';
    166     if(array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
     166    if (array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
    167167    $Output .= '</tr>';
    168168    $Result = $this->Database->select('Measure', '*', '( `Enabled`=1) AND ((`PermissionView`="all") OR (`PermissionView`="'.
    169169      gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) ORDER BY `Description`');
    170     while($Measure = $Result->fetch_array())
     170    while ($Measure = $Result->fetch_array())
    171171    {
    172172      $StopWatchStart = GetMicrotime();
    173       if(array_key_exists('Debug', $_GET))
     173      if (array_key_exists('Debug', $_GET))
    174174      {
    175175        $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', '`Measure`='.$Measure['Id']);
     
    179179      $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.
    180180        $Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1');
    181       if($Result2->num_rows > 0)
     181      if ($Result2->num_rows > 0)
    182182      {
    183183        $Row = $Result2->fetch_array();
     
    188188        $LastMeasureValue = '&nbsp;';
    189189      }
    190       if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
    191       if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
     190      if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
     191      if ($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    192192      $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    193193      $Output .= '<tr><td style="text-align: left"><a href="?Measure='.$Measure['Id'].
     
    195195        $LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.
    196196        $Interpolate.'</td><td>'.$Measure['Info'].'</td>';
    197       if(array_key_exists('Debug', $_GET))
     197      if (array_key_exists('Debug', $_GET))
    198198        $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    199199      $Output .= '</tr>';
    200200    }
    201201    $Output .= '</table>';
    202     return($Output);
     202    return $Output;
    203203  }
    204204
     
    214214      '&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].
    215215      '">Odkaz na vybraný graf</a><br/>';
    216     return($Output);
     216    return $Output;
    217217  }
    218218
     
    221221    $Output = '';
    222222
    223     if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
    224     switch($_GET['Operation'])
     223    if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     224    switch ($_GET['Operation'])
    225225    {
    226226      case 'SetTime':
    227         if(array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
     227        if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
    228228        array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST))
    229229        {
    230           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     230          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    231231          {
    232232            $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'],
     
    236236        break;
    237237      case 'SetTimeNow':
    238         if(array_key_exists('Time', $_GET))
     238        if (array_key_exists('Time', $_GET))
    239239        {
    240           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     240          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    241241          {
    242242            $_SESSION[$_GET['Time']] = $this->Time;
     
    249249
    250250    // Show graph time range menu
    251     if($_SESSION['TimeSpecify'] == 0)
     251    if ($_SESSION['TimeSpecify'] == 0)
    252252    {
    253253      $Output .= 'Délka úseku: ';
    254       foreach($this->GraphTimeRanges as $Index => $Item)
     254      foreach ($this->GraphTimeRanges as $Index => $Item)
    255255        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    256256      $Output .= '<br>';
     
    266266      '<a href="?Move=Right">&gt;</a> <a href="?Move=RightEnd">&gt;|</a> <a href="?Move=Now">Nyní</a><br>';
    267267    $Output .= '<br/>';
    268     return($Output);
     268    return $Output;
    269269
    270270  }
     
    277277    {
    278278      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
    279       //if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    280       //if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     279      //if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     280      //if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    281281      //$$Index = $_SESSION[$Index];
    282282    }
     
    370370      '((`PermissionView`="all") OR (`PermissionView`="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) '.
    371371      'AND (`Id`='.($_SESSION['Measure'] * 1).')');
    372     if($Result->num_rows == 0)
     372    if ($Result->num_rows == 0)
    373373      $_SESSION['Measure'] = $Config['DefaultVariables']['Measure'];
    374374
     
    378378    $Output .= $this->ShowMeasureTable();
    379379    $Output .= '</div>';
    380     return($Output);
     380    return $Output;
    381381  }
    382382}
Note: See TracChangeset for help on using the changeset viewer.