|
21 | 21 | >ype=curve - тип графика (может быть: curve, bar, line -- плавная линия, столбцы, ступенчатый) |
22 | 22 | &type=8h - Период (8h = 8 часов, 8d = 8 дней, 8m = 8 месяцев) |
23 | 23 | &start=2014/09/25 - дата с которой берется начало графика в формате (гггг/мм/дд) |
| 24 | + &end=2014/09/25 - дата с которой берется конец графика в формате (гггг/мм/дд) |
24 | 25 | &interval= секунд в интервале |
25 | 26 | &width=610 - ширина графика в пикселях |
26 | 27 | &height=210 - высота графика в пикселях |
|
41 | 42 | $w_delta = 80; |
42 | 43 | $px_per_point = 6; |
43 | 44 | $unit = "°C"; |
44 | | -$end_time = time(); |
| 45 | + |
| 46 | +if (preg_match('/(\d+)\/(\d+)\/(\d+)/', $_GET['end'], $m)) { |
| 47 | + $end_time = mktime(23, 59, 59, $m[2], $m[3], $m[1]); |
| 48 | +} else { |
| 49 | + $end_time = time(); |
| 50 | +} |
| 51 | + |
| 52 | + |
45 | 53 | $approx = 'avg'; |
46 | 54 | $fil01 = 0; |
47 | 55 |
|
|
208 | 216 | $data = SQLSelect("SELECT * FROM $history_table WHERE VALUE_ID='" . $pvalue['ID'] . "' ORDER BY ADDED"); |
209 | 217 | //dprint($data); |
210 | 218 |
|
211 | | - $csv = implode("\t", array('ADDED','VALUE')) . PHP_EOL; |
| 219 | + $csv = implode("\t", array('ADDED', 'VALUE')) . PHP_EOL; |
212 | 220 | foreach ($data as $row) { |
213 | | - $csv .= $row['ADDED']."\t".$row['VALUE']; |
| 221 | + $csv .= $row['ADDED'] . "\t" . $row['VALUE']; |
214 | 222 | $csv .= PHP_EOL; |
215 | 223 | } |
216 | 224 |
|
217 | | - $filename = 'data_'.date('Y-m-d-H_i_s').'.txt'; |
| 225 | + $filename = 'data_' . date('Y-m-d-H_i_s') . '.txt'; |
218 | 226 | $now = gmdate("D, d M Y H:i:s"); |
219 | 227 | //header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); |
220 | 228 | //header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); |
|
239 | 247 |
|
240 | 248 | echo "<html><head>"; |
241 | 249 | $roothtml = ROOTHTML; |
| 250 | + $url = str_replace('&end=', '&', $_SERVER['REQUEST_URI']); |
242 | 251 | echo <<<FF |
243 | 252 | <meta name="apple-mobile-web-app-capable" content="yes"> |
244 | 253 | <meta name="apple-mobile-web-app-status-bar-style" content="black"/> |
|
248 | 257 | <script type="text/javascript" src="{$roothtml}3rdparty/jquery/jquery-migrate-3.0.0.min.js"></script> |
249 | 258 | <link rel="stylesheet" href="{$roothtml}3rdparty/bootstrap/css/bootstrap.min.css" type="text/css"> |
250 | 259 | <script type="text/javascript" src="{$roothtml}3rdparty/bootstrap/js/bootstrap.min.js"></script> |
| 260 | +<link rel="stylesheet" type="text/css" href="{$roothtml}3rdparty/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css"/> |
| 261 | +<script type="text/javascript" src="{$roothtml}3rdparty/moment/moment.min.js"></script> |
| 262 | +<script type="text/javascript" src="{$roothtml}3rdparty/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script> |
| 263 | +<script type="text/javascript"> |
| 264 | + $(document).ready(function() { |
| 265 | + $('.datepicker').datetimepicker({ |
| 266 | + format:'YYYY/MM/DD', |
| 267 | + }).on('dp.change',function(e) { |
| 268 | + var formatedValue = e.date.format(e.date._f); |
| 269 | + dateChanged(formatedValue); |
| 270 | + }); |
| 271 | + }); |
| 272 | + function dateChanged(dt) { |
| 273 | + let url = "{$url}"; |
| 274 | + window.location.href = url + '&end='+encodeURI(dt); |
| 275 | + } |
| 276 | +</script> |
251 | 277 | FF; |
252 | 278 | echo "</head><body><div>"; |
253 | 279 | //echo "<table width=100%><tr><td width='99%'>"; |
254 | 280 |
|
255 | 281 | $_SERVER['REQUEST_URI'] = preg_replace('/&subop=(\w+)/', '', $_SERVER['REQUEST_URI']); |
256 | | - echo "<ul class='nav nav-tabs'>"; |
257 | | - echo '<li'.($_GET['subop']==''?' class="active"':'').'><a href="' . $_SERVER['REQUEST_URI'] . '&subop=">H</a></li>'; |
258 | | - echo '<li'.($_GET['subop']=='1h'?' class="active"':'').'><a href="' . $_SERVER['REQUEST_URI'] . '&subop=1h">1h</a></li>'; |
259 | | - echo '<li'.($_GET['subop']=='24h'?' class="active"':'').'><a href="' . $_SERVER['REQUEST_URI'] . '&subop=24h">24h</a></li>'; |
260 | | - echo '<li'.($_GET['subop']=='7d'?' class="active"':'').'><a href="' . $_SERVER['REQUEST_URI'] . '&subop=7d">7d</a></li>'; |
261 | | - echo '<li'.($_GET['subop']=='31d'?' class="active"':'').'><a href="' . $_SERVER['REQUEST_URI'] . '&subop=31d">31d</a></li>'; |
| 282 | + echo "<div class='row'><div class='col-md-10'><ul class='nav nav-tabs'>"; |
| 283 | + echo '<li' . ($_GET['subop'] == '' ? ' class="active"' : '') . '><a href="' . $_SERVER['REQUEST_URI'] . '&subop=">H</a></li>'; |
| 284 | + echo '<li' . ($_GET['subop'] == '1h' ? ' class="active"' : '') . '><a href="' . $_SERVER['REQUEST_URI'] . '&subop=1h">1h</a></li>'; |
| 285 | + echo '<li' . ($_GET['subop'] == '24h' ? ' class="active"' : '') . '><a href="' . $_SERVER['REQUEST_URI'] . '&subop=24h">24h</a></li>'; |
| 286 | + echo '<li' . ($_GET['subop'] == '7d' ? ' class="active"' : '') . '><a href="' . $_SERVER['REQUEST_URI'] . '&subop=7d">7d</a></li>'; |
| 287 | + echo '<li' . ($_GET['subop'] == '31d' ? ' class="active"' : '') . '><a href="' . $_SERVER['REQUEST_URI'] . '&subop=31d">31d</a></li>'; |
262 | 288 | if (!$_GET['minimal']) { |
263 | 289 | echo '<li><a href="' . $_SERVER['REQUEST_URI'] . '&subop=clear" onClick="return confirm(\'' . LANG_ARE_YOU_SURE . '\')">' . LANG_CLEAR_ALL . '</a></li>'; |
264 | 290 | echo '<li><a href="' . $_SERVER['REQUEST_URI'] . '&subop=optimize" onClick="return confirm(\'' . LANG_ARE_YOU_SURE . '\')">' . LANG_OPTIMIZE_LOG . '</a></li>'; |
265 | 291 | } |
266 | 292 | echo "</ul>"; |
267 | | - //echo "</td>"; |
268 | | - /* |
269 | | - if (!$_GET['minimal']) { |
270 | | - echo "<td>"; |
271 | | - echo '<a href="javascript:window.close();">X</a>'; |
272 | | - echo "</td>"; |
273 | | - } |
274 | | - */ |
275 | | - //echo "</tr></table>"; |
276 | | - //echo '<br/>'; |
| 293 | + echo "</div><div class='col-md-2'><form class='form' method='get'>"; |
| 294 | + echo '<input type="text" id="end" name="end" value="' . date('Y-m-d', $end_time) . '" class="form-control datepicker">'; |
| 295 | + echo "</form></div></div>"; |
277 | 296 |
|
278 | 297 | if (preg_match('/^\d+\w$/', $_GET['subop'])) { |
279 | 298 |
|
|
285 | 304 | } |
286 | 305 |
|
287 | 306 | if (!is_array($_GET['p'])) { |
288 | | - $properties=array($_GET['p']); |
| 307 | + $properties = array($_GET['p']); |
289 | 308 | } else { |
290 | 309 | $properties = $_GET['p']; |
291 | 310 | $p_url .= '&height=' . $height; |
292 | 311 | } |
293 | 312 | $p_url = ''; |
294 | 313 | foreach ($properties as $p) { |
295 | 314 | $p_url .= '&properties[]=' . urlencode($p); |
296 | | - if (preg_match('/^(\w+)\.(\w+)$/',$p,$m)) { |
| 315 | + if (preg_match('/^(\w+)\.(\w+)$/', $p, $m)) { |
297 | 316 | $object = getObject($m[1]); |
298 | 317 | if ($object->description) { |
299 | | - $p_url .= '&legend[]=' . urlencode($object->description.' ('.$m[2].')'); |
| 318 | + $p_url .= '&legend[]=' . urlencode($object->description . ' (' . $m[2] . ')'); |
300 | 319 | } else { |
301 | 320 | $p_url .= '&legend[]=' . urlencode($p); |
302 | 321 | } |
303 | 322 | } |
304 | 323 | } |
305 | | - $code = ' <iframe allowfullscreen="true" border="0" frameborder="0" src="' . ROOTHTML . 'module/charts.html?id=config&enable_fullscreen=1&period=' . $_GET['subop'] . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . $p_url . '&theme=grid-light&frameBorder=0" style="height:80% !important" width=100% ></iframe>';//height=' . $height . ' |
| 324 | + $code = ' <iframe allowfullscreen="true" border="0" frameborder="0" src="' . ROOTHTML . 'module/charts.html?id=config&enable_fullscreen=1&period=' . $_GET['subop'] . '&end=' . urlencode($_GET['end']) . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . $p_url . '&theme=grid-light&frameBorder=0" style="height:80% !important" width=100% ></iframe>';//height=' . $height . ' |
306 | 325 | } else { |
307 | | - $code = ' <img src="' . ROOTHTML . '3rdparty/jpgraph/?p=' . $p . '&type=' . $_GET['subop'] . '&width=500&"/>'; |
| 326 | + $code = ' <img src="' . ROOTHTML . '3rdparty/jpgraph/?p=' . $p . '&type=' . $_GET['subop'] . '&end=' . urlencode($_GET['end']) . '&width=500&"/>'; |
308 | 327 | } |
309 | 328 | echo $code; |
310 | 329 | /* |
|
325 | 344 | $total_values = count($history); |
326 | 345 | } |
327 | 346 | */ |
328 | | - require(ROOT.'3rdparty/Paginator/Paginator.php'); |
329 | | - $page=(int)$_GET['page']; |
330 | | - if (!$page) $page=1; |
| 347 | + require(ROOT . '3rdparty/Paginator/Paginator.php'); |
| 348 | + $page = (int)$_GET['page']; |
| 349 | + if (!$page) $page = 1; |
331 | 350 |
|
332 | | - $on_page=20; |
| 351 | + $on_page = 20; |
333 | 352 | //$limit=(($page-1)*$on_page).','.$on_page; |
334 | | - $start_offset = (($page-1)*$on_page); |
| 353 | + $start_offset = (($page - 1) * $on_page); |
335 | 354 | //$urlPattern='?page=(:num)'; |
336 | 355 | $url = $_SERVER['REQUEST_URI']; |
337 | | - $url = preg_replace('/&page=\d+/','',$url); |
338 | | - $urlPattern=$url.'&page=(:num)'; |
| 356 | + $url = preg_replace('/&page=\d+/', '', $url); |
| 357 | + $urlPattern = $url . '&page=(:num)'; |
339 | 358 | $paginator = new JasonGrimes\Paginator($total_values, $on_page, $page, $urlPattern); |
340 | 359 |
|
341 | | - $history = array_slice($history,$start_offset,$on_page); |
| 360 | + $history = array_slice($history, $start_offset, $on_page); |
342 | 361 | $total_values = count($history); |
343 | 362 |
|
344 | 363 | echo "<div class='row'><div class='col-md-1'> </div>"; |
345 | 364 | echo "<div class='col-md-5'>"; |
346 | 365 | echo $paginator; |
347 | 366 | echo "</div>"; |
348 | 367 | echo "<div class='col-md-5 text-right pagination'>"; |
349 | | - echo "<a href=\"".$_SERVER['REQUEST_URI'] . "&type=1&export=1\" class='btn btn-default'><i class='glyphicon glyphicon-export'></i> ".LANG_EXPORT."</a>"; |
| 368 | + echo "<a href=\"" . $_SERVER['REQUEST_URI'] . "&type=1&export=1\" class='btn btn-default'><i class='glyphicon glyphicon-export'></i> " . LANG_EXPORT . "</a>"; |
350 | 369 | echo "</div>"; |
351 | 370 | echo "<div class='col-md-1'> </div></div>"; |
352 | 371 |
|
353 | 372 | echo "<table class='table table-striped'>"; |
354 | | - echo "<thead><tr><th>".LANG_ADDED."</th><th>".LANG_VALUE."</th><th>Src</th><th> </th></tr></thead>"; |
| 373 | + echo "<thead><tr><th>" . LANG_ADDED . "</th><th>" . LANG_VALUE . "</th><th>Src</th><th> </th></tr></thead>"; |
355 | 374 | for ($i = 0; $i < $total_values; $i++) { |
356 | 375 | //echo date('Y-m-d H:i:s', $history[$i]['UNX']); |
357 | 376 | echo "<tr><td>"; |
|
361 | 380 | if ($property['DATA_TYPE'] == 5) { |
362 | 381 | echo "<a href='" . ROOTHTML . "cms/images/" . $history[$i]['VALUE'] . "' target='_blank'><img src='" . ROOTHTML . "cms/images/" . $history[$i]['VALUE'] . "' height=100></a>"; |
363 | 382 | } else { |
364 | | - echo "<b>".htmlspecialchars($history[$i]['VALUE']) . "</b>"; |
| 383 | + echo "<b>" . htmlspecialchars($history[$i]['VALUE']) . "</b>"; |
365 | 384 | } |
366 | 385 | echo "</td>"; |
367 | 386 | echo "<td>"; |
|
733 | 752 |
|
734 | 753 | //������� ��������� ������� |
735 | 754 |
|
736 | | -if (IsSet($_GET['title'])) { |
| 755 | +if (isset($_GET['title'])) { |
737 | 756 | $_GET['title'] = strip_tags($_GET['title']); |
738 | 757 | } |
739 | 758 |
|
|
0 commit comments