Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/TimeMeasure/Main.php

    r825 r873  
    6262    // Day selection
    6363    $Output .= '<select name="Day">';
    64     for($I = 1; $I < 32; $I++)
    65     {
    66       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
     64    for ($I = 1; $I < 32; $I++)
     65    {
     66      if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    6767      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6868    }
     
    7171    // Month selection
    7272    $Output .= '<select name="Month">';
    73     foreach($MonthNames as $Index => $Month)
    74     {
    75       if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    76       if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     73    foreach ($MonthNames as $Index => $Month)
     74    {
     75      if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
     76      if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
    7777    }
    7878    $Output .= '</select>. ';
     
    8080    // Day selection
    8181    $Output .= '<select name="Year">';
    82     for($I = 2000; $I < 2010; $I++)
    83     {
    84       if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
     82    for ($I = 2000; $I < 2010; $I++)
     83    {
     84      if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    8585      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    8686    }
     
    8989    // Hour selection
    9090    $Output .= '<select name="Hour">';
    91     for($I = 0; $I < 24; $I++)
    92     {
    93       if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
     91    for ($I = 0; $I < 24; $I++)
     92    {
     93      if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    9494      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    9595    }
     
    9898    // Minute selection
    9999    $Output .= '<select name="Minute">';
    100     for($I = 0; $I < 60; $I++)
    101     {
    102       if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     100    for ($I = 0; $I < 60; $I++)
     101    {
     102      if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
    103103      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    104104    }
     
    111111    $Output .= '</form>';
    112112
    113     return($Output);
     113    return ($Output);
    114114  }
    115115
     
    118118    $Debug = 0;
    119119
    120     foreach($this->DefaultVariables as $Index => $Variable)
    121     {
    122       if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
    123       if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    124       if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     120    foreach ($this->DefaultVariables as $Index => $Variable)
     121    {
     122      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     123      if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     124      if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    125125      //$$Index = $_SESSION[$Index];
    126126    }
    127127
    128     if($_SESSION['TimeSpecify'] == 0)
     128    if ($_SESSION['TimeSpecify'] == 0)
    129129    {
    130130      $_SESSION['TimeEnd'] = time() - 60;
     
    134134    $Output = '<div style="text-align: center;">';
    135135
    136     if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
    137     switch($_GET['Operation'])
     136    if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     137    switch ($_GET['Operation'])
    138138    {
    139139      case 'SetTime':
    140         if(array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
     140        if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
    141141          array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST))
    142142        {
    143           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     143          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    144144          {
    145145            $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'],
     
    150150        break;
    151151      case 'SetTimeNow':
    152         if(array_key_exists('Time', $_GET))
     152        if (array_key_exists('Time', $_GET))
    153153        {
    154           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     154          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    155155          {
    156156            $_SESSION[$_GET['Time']] = time();
     
    162162    $Output .= '<strong>Časový úsek:</strong><br>';
    163163    // Show graf time range menu
    164     if($_SESSION['TimeSpecify'] == 0)
     164    if ($_SESSION['TimeSpecify'] == 0)
    165165    {
    166166      $Output .= 'Délka úseku: ';
    167       foreach($this->GraphTimeRanges as $Index => $Item)
     167      foreach ($this->GraphTimeRanges as $Index => $Item)
    168168        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    169169      $Output .= '<br/>';
     
    179179
    180180    $Output .= '<br/>'.$this->MeasureTable();
    181     return($Output);
     181    return ($Output);
    182182  }
    183183
     
    191191    $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.
    192192      $_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
    193     return($Output);
     193    return ($Output);
    194194  }
    195195
     
    212212      array('Name' => 'Description', 'Title' => 'Popis'),
    213213    );
    214     if(array_key_exists('Debug', $_GET))
     214    if (array_key_exists('Debug', $_GET))
    215215    {
    216216      $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek');
     
    221221
    222222    $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']);
    223     while($Measure = $Result->fetch_array())
     223    while ($Measure = $Result->fetch_array())
    224224    {
    225225      $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']);
    226226      $MeasureMethod = $DbResult2->fetch_assoc();
    227227      $StopWatchStart = GetMicrotime();
    228       if(array_key_exists('Debug', $_GET))
     228      if (array_key_exists('Debug', $_GET))
    229229      {
    230230        $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']);
     
    233233      }
    234234      $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1');
    235       if($Result2->num_rows > 0)
     235      if ($Result2->num_rows > 0)
    236236      {
    237237        $Row = $Result2->fetch_array();
     
    243243        $LastMeasureValue = '&nbsp;';
    244244      }
    245       if($Measure['Continuity'] == 1) $Interpolate = 'Ano';
     245      if ($Measure['Continuity'] == 1) $Interpolate = 'Ano';
    246246        else $Interpolate = 'Ne';
    247       //if($Measure['Description'] == '') $Measure['Description'] = '&nbsp;';
     247      //if ($Measure['Description'] == '') $Measure['Description'] = '&nbsp;';
    248248      $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    249249      $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>';
    250       if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
     250      if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    251251      $Output .= '</tr>';
    252252    }
     
    260260    //echo($PrefixMultiplier->Add('-0.000000071112345', 'B'));
    261261    $Output .= '</div>';
    262     return($Output);
     262    return ($Output);
    263263  }
    264264}
     
    271271
    272272    $Output = '';
    273     if(!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');
    274     if(!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');
     273    if (!array_key_exists('MeasureId', $_GET)) return ('Nebylo zadáno Id měření.');
     274    if (!array_key_exists('Value', $_GET)) return ('Nebyla zadána hodnota.');
    275275    $Measure = new Measure($this->System);
    276276    $Measure->Load($_GET['MeasureId']);
    277     if(!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
     277    if (!isset($Measure->Data['Id'])) return ('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
    278278    $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value']));
    279     return($Output);
     279    return ($Output);
    280280  }
    281281}
Note: See TracChangeset for help on using the changeset viewer.