Changeset 873 for trunk/Modules/TimeMeasure/Main.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/TimeMeasure/Main.php
r825 r873 62 62 // Day selection 63 63 $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 = ''; 67 67 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 68 68 } … … 71 71 // Month selection 72 72 $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>'; 77 77 } 78 78 $Output .= '</select>. '; … … 80 80 // Day selection 81 81 $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 = ''; 85 85 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 86 86 } … … 89 89 // Hour selection 90 90 $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 = ''; 94 94 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 95 95 } … … 98 98 // Minute selection 99 99 $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 = ''; 103 103 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 104 104 } … … 111 111 $Output .= '</form>'; 112 112 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Debug = 0; 119 119 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]; 125 125 //$$Index = $_SESSION[$Index]; 126 126 } 127 127 128 if ($_SESSION['TimeSpecify'] == 0)128 if ($_SESSION['TimeSpecify'] == 0) 129 129 { 130 130 $_SESSION['TimeEnd'] = time() - 60; … … 134 134 $Output = '<div style="text-align: center;">'; 135 135 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']) 138 138 { 139 139 case 'SetTime': 140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and 141 141 array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST)) 142 142 { 143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 144 144 { 145 145 $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'], … … 150 150 break; 151 151 case 'SetTimeNow': 152 if (array_key_exists('Time', $_GET))152 if (array_key_exists('Time', $_GET)) 153 153 { 154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 155 155 { 156 156 $_SESSION[$_GET['Time']] = time(); … … 162 162 $Output .= '<strong>Časový úsek:</strong><br>'; 163 163 // Show graf time range menu 164 if ($_SESSION['TimeSpecify'] == 0)164 if ($_SESSION['TimeSpecify'] == 0) 165 165 { 166 166 $Output .= 'Délka úseku: '; 167 foreach ($this->GraphTimeRanges as $Index => $Item)167 foreach ($this->GraphTimeRanges as $Index => $Item) 168 168 $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a> '; 169 169 $Output .= '<br/>'; … … 179 179 180 180 $Output .= '<br/>'.$this->MeasureTable(); 181 return ($Output);181 return ($Output); 182 182 } 183 183 … … 191 191 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='. 192 192 $_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 212 212 array('Name' => 'Description', 'Title' => 'Popis'), 213 213 ); 214 if (array_key_exists('Debug', $_GET))214 if (array_key_exists('Debug', $_GET)) 215 215 { 216 216 $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek'); … … 221 221 222 222 $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']); 223 while ($Measure = $Result->fetch_array())223 while ($Measure = $Result->fetch_array()) 224 224 { 225 225 $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']); 226 226 $MeasureMethod = $DbResult2->fetch_assoc(); 227 227 $StopWatchStart = GetMicrotime(); 228 if (array_key_exists('Debug', $_GET))228 if (array_key_exists('Debug', $_GET)) 229 229 { 230 230 $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']); … … 233 233 } 234 234 $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) 236 236 { 237 237 $Row = $Result2->fetch_array(); … … 243 243 $LastMeasureValue = ' '; 244 244 } 245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano';245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 246 246 else $Interpolate = 'Ne'; 247 //if ($Measure['Description'] == '') $Measure['Description'] = ' ';247 //if ($Measure['Description'] == '') $Measure['Description'] = ' '; 248 248 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 249 249 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&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>'; 251 251 $Output .= '</tr>'; 252 252 } … … 260 260 //echo($PrefixMultiplier->Add('-0.000000071112345', 'B')); 261 261 $Output .= '</div>'; 262 return ($Output);262 return ($Output); 263 263 } 264 264 } … … 271 271 272 272 $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.'); 275 275 $Measure = new Measure($this->System); 276 276 $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.'); 278 278 $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value'])); 279 return ($Output);279 return ($Output); 280 280 } 281 281 }
Note:
See TracChangeset
for help on using the changeset viewer.