1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 
   4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 
   5   <meta name="GENERATOR" content="Mozilla/4.72 (X11; U; Linux 2.2.12-20smp i686) [Netscape]">    
 
   6   <title>WeatherMon (архив)</title>                      
 
   7   <link rel="icon" href="favicon.png" />
 
   8   <style type="text/css">
 
  12         border:2px solid darkgrey;
 
  24     a:visited { text-decoration: none; color:darkblue; }
 
  25     a:link { text-decoration: none; color:blue; }
 
  26     a:hover { text-decoration: none; color:navy; }  
 
  29 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">         
 
  32 include('config_local.php');
 
  33 include('calendar.php');
 
  35 $year = $_REQUEST['year']; 
 
  36 $month = $_REQUEST['month'];
 
  37 $day = $_REQUEST['day'];
 
  39 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
 
  43 $db -> exec('SET CHARACTER SET utf8');
 
  49        date_format(day,\'%Y\') as year
 
  56 <h1>Архив метеоданных</h1>
 
  58   while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
 
  60   <a class="year" href="?year=<?php echo $row['year']; ?>">Данные за <?php echo $row['year']; ?> год</a><br>
 
  69     $year      = sprintf('%04d',$year);
 
  70     $next_year = sprintf('%04d',$next_year);
 
  73              date_format(day,\'%m\') as month,
 
  74              date_format(day,\'%d\') as day
 
  78              day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and 
 
  79              day<str_to_date(\''.$next_year.'-01-01\',\'%Y-%m-%d\')
 
  85 <h1 align="center"><?php echo $year; ?> год</h1>
 
  87     $data = $q -> fetchAll(PDO::FETCH_ASSOC);
 
  89     foreach ($data as $row) {
 
  90       $days [$year.$row['month'].$row['day']] = '&month='.$row['month'].'&day='.$row['day'];
 
  91       $months[$row['month']]=1;
 
  94     echo '<table align="center">';
 
  95     for ($i=1; $i<=3; $i++) {
 
  97       for ($j=1; $j<=4; $j++) {
 
  98         echo '<td valign="top">';
 
  99         $month=sprintf('%02d',$m);
 
 100         $month_name = strftime('%B',mktime(0,0,0,$month,1,$year));
 
 101         if (!empty($months[$month])) {
 
 102           echo '<h3 align="center"><a class="month" href="?year='.$year.'&month='.$month.'">'.$month_name.'</a></h3>';
 
 104           echo '<h3 align="center">'.$month_name.'</h3>';
 
 106         calendar($year,$month,$days,'?year='.$year.'%s',0);
 
 114     $next_year = $year+1;
 
 116     $q = $db -> prepare (
 
 118          s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
 
 119          count(distinct day) cnt,
 
 120          round(min(v.min),1) min_value,
 
 121          round(max(v.max),1) max_value,
 
 124          sensors_ranges v,sensors s,st_parameters p,units u
 
 129          v.day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and 
 
 130          v.day<str_to_date(\''.$next_year.'-01-01\',\'%Y-%m-%d\')
 
 131       group by s.id,p.id,s.s_description,p.st_description
 
 136     $sensors = $q -> fetchAll(PDO::FETCH_ASSOC);
 
 138     foreach ($sensors as $sensor) {
 
 140       echo '<h3 align="center">'.$sensor['param_name'].'('.$sensor['sensor_name'].')</h3>';
 
 141       echo '<table align="center">';
 
 143       echo 'Минимальное значение за год <b>'.$sensor['min_value'].' '.$sensor['unit'].'</b><br>';
 
 144       echo 'Максимальное значение за год <b>'.$sensor['max_value'].' '.$sensor['unit'].'</b><br>';
 
 148       if ($sensor['cnt']>1) {
 
 150         echo '<center><img src="image_minmax.php?sensor='.$sensor['sensor'].'¶m='.$sensor['param'].
 
 151           '&type=year&year='.$year.'"></center>';
 
 163       $next_month = $month+1;
 
 165       if ($next_month == 13) {
 
 167         $next_year = $next_year+1;
 
 170       $next_month = sprintf('%02d',$next_month); 
 
 171       $next_year  = sprintf('%04d',$next_year);
 
 172       $month      = sprintf('%02d',$month);
 
 173       $year      = sprintf('%04d',$year);
 
 177              date_format(day,\'%d\') as day
 
 181              day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and 
 
 182              day<str_to_date(\''.$next_year.'-'.$next_month.'-01\',\'%Y-%m-%d\')
 
 188       $data = $q -> fetchAll(PDO::FETCH_ASSOC);
 
 190       $month_name = strftime('%B %Y',mktime(0,0,0,$month,1,$year));
 
 193 <h1 align="center"><?php echo 'Данные за '.$month_name; ?></h1>
 
 195       foreach ($data as $row) {
 
 196         $days [$year.$month.$row['day']] = $row['day'];
 
 199       calendar($year,$month,$days,'?year='.$year.'&month='.$month.'&day=%s',3);
 
 201       $q = $db -> prepare (
 
 203              s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
 
 204              count(distinct day) cnt,
 
 205              round(min(v.min),1) min_value,
 
 206              round(max(v.max),1) max_value,
 
 209              sensors_ranges v,sensors s,st_parameters p,units u
 
 214              v.day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and 
 
 215              v.day<str_to_date(\''.$next_year.'-'.$next_month.'-01\',\'%Y-%m-%d\')
 
 216            group by s.id,p.id,s.s_description,p.st_description
 
 221       $sensors = $q -> fetchAll(PDO::FETCH_ASSOC);
 
 223       foreach ($sensors as $sensor) {
 
 225         echo '<h3 align="center">'.$sensor['param_name'].'('.$sensor['sensor_name'].')</h3>';
 
 226         echo '<table align="center">';
 
 228         echo 'Минимальное значение за месяц <b>'.$sensor['min_value'].' '.$sensor['unit'].'</b><br>';
 
 229         echo 'Максимальное значение за месяц <b>'.$sensor['max_value'].' '.$sensor['unit'].'</b><br>';
 
 233         if ($sensor['cnt']>1) {
 
 235           echo '<center><img src="image_minmax.php?sensor='.$sensor['sensor'].'¶m='.$sensor['param'].
 
 236             '&type=month&year='.$year.'&month='.$month.'"></center>';
 
 244       $month      = sprintf('%02d',$month);
 
 245       $year      = sprintf('%04d',$year);
 
 246       $day       = sprintf('%02d',$day);
 
 250                 distinct v.sensor as sensor_id,s.s_description,p.id as param_id,p.st_description 
 
 252                 sensors_ranges v,st_parameters p,sensors s 
 
 254                 v.day=str_to_date(\''.$year.'-'.$month.'-'.$day.'\',\'%Y-%m-%d\')
 
 256                 and v.parameter=p.id'
 
 260       while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
 
 262         echo '<h3 align="center">'.$row['s_description'].'/'.$row['st_description'].'</h3>';
 
 264 <center><img src="image.php?sensor=<?php echo $row['sensor_id']; ?>¶m=<?php echo $row['param_id']?>&type=range&fromdate=<?php echo $year.$month.$day.'000000'; ?>&todate=<?php echo $year.$month.$day.'235959'?>"></center>