Author: zecas
Date: Fri May 20 17:34:46 2016
New Revision: 134

URL: http://svn.gna.org/viewcvs/zzzt?rev=134&view=rev
Log:
new mobile page for easier stats view on Android phones

Added:
    trunk/stats/mobile.php
Modified:
    trunk/inverter/index.php

Modified: trunk/inverter/index.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/inverter/index.php?rev=134&r1=133&r2=134&view=diff
==============================================================================
--- trunk/inverter/index.php    (original)
+++ trunk/inverter/index.php    Fri May 20 17:34:46 2016
@@ -19,15 +19,10 @@
   if(isset($error)) exit($error);
   session_start();// after the needed classes
   if(!isset($_SESSION['inverter'])) {$_SESSION['inverter']=new inverter();}
+  
+  htmlCommun($day);
 ?>
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8" >
-  <link rel="shortcut icon" href="../images/inverter.png" type="image/x-png"/>
-  <link rel="icon" href="../images/inverter.png" type="image/x-png"/>
-  <title><?php echo APPLICATION.' '.VERSION;?></title>
-</head>
+
 <BODY>
 
 <?php
@@ -38,10 +33,14 @@
           </form>';
     if($_SESSION['inverter']->config['db_use']){
       $db=new db($_SESSION['inverter']);
-      if($db->db_attempt)
-        echo '<form action="../stats/index.php" method="POST">
+      if($db->db_attempt) {
+          echo '<form action="../stats/index.php" method="POST">
                 <input type="submit"value="'.STATS.' : 
'.$_SESSION['inverter']->config['model'].'">
               </form>';
+          echo '<form action="../stats/mobile.php" method="POST">
+                <input type="submit"value="'.MOBILE.'">
+              </form>';
+      }
     }
     else echo STATS_NEED_DB.'<p>';
   }

Added: trunk/stats/mobile.php
URL: http://svn.gna.org/viewcvs/zzzt/trunk/stats/mobile.php?rev=134&view=auto
==============================================================================
--- trunk/stats/mobile.php      (added)
+++ trunk/stats/mobile.php      Fri May 20 17:34:46 2016
@@ -0,0 +1,137 @@
+<?php
+/*    This file is part of Zzzt!.
+    Copyright (C) 2009-2016  Antonio Ho, José Jorge
+
+    Zzzt! is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Zzzt! is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Zzzt! .  If not, see <http://www.gnu.org/licenses/>.
+*/
+  require '../inverter/class_inverter.php';
+  session_start();// after the needed classes
+  $inverter=new inverter();
+  $db=new db($inverter);
+  $heure=array();
+  $values=array();
+  $champs=array('pac','pdc','kdy','tkk');
+  isset($_GET['day']) ? $day=$_GET['day'] : $day=date('Y-m-d');
+  $_GET['width']=465;
+  $_GET['height']=50;
+  $sql="SELECT ROUND(DATE_FORMAT(monitor_date,'%H%i'),0) AS md,
+              ROUND(AVG(pac),0) AS pac,
+              ROUND(AVG(pdc),0) AS pdc,
+              kdy, tkk FROM zzzt
+       WHERE DATE(`monitor_date`)='$day' GROUP BY md ORDER BY md ASC";
+  $db->query($sql);
+  while ($row = $db->fetch()) {
+    if(isset($prev) && !isset($_GET['detaille']) &&
+       ( ($prev<=$row['pdc'] && $prev*1.03>=$row['pdc']) || 
($prev>=$row['pdc'] && $prev*0.97<=$row['pdc']) ) 
+      ) {$skip+=1;} else {$skip=0;}
+    if($skip<1 || $skip>9) {
+      $prev=$row['pdc'];
+      $heure[]=$day.' 
'.implode(':',str_split(str_pad((int)$row['md'],4,"0",STR_PAD_LEFT),2));
+      
$values['rendement'][]=sprintf('%.2F',$row['pac']/($row['pdc']+0.0001)*100);
+      foreach($champs as $c) $values[$c][]=$row[$c];
+    }
+  }
+  htmlCommun($day);
+  $fixe="image_day.php?width={$_GET['width']}&amp;data=";
+
+?>
+
+<body>
+  <b><a href=../inverter/index.php><?php echo APPLICATION;?></a></b>
+  <?php echo DAY_PROD;?>
+  <a href=mobile.php><?php echo UPDATE;?></a></b>
+  
+  <table>
+    <tr><TD colspan=3>
+<?php
+  $sql="SELECT YEAR(date) AS year, production
+              FROM zzzt_daily
+       WHERE DAY(date) = DAY('$day')
+       AND MONTH(date) = MONTH('$day')
+       ORDER BY year DESC";
+  $db->query($sql);
+  $ap=strftime("%e %B %G", strtotime($day))."
+";
+  while ($row = $db->fetch()) $ap.=DYR." {$row['year']} : {$row['production']} 
kWh
+";
+
+  // Average for last 20 minutes
+  $db->query("SELECT MIN(kdy) FROM `zzzt` WHERE `monitor_date` BETWEEN 
SUBTIME(NOW(),'00:21:00') and SUBTIME(NOW(),'00:19:00')");
+  list($kdy20)= $db->fetch();
+  if ($kdy20 != NULL) {
+    $db->query("SELECT kdy FROM `zzzt` ORDER BY monitor_date DESC LIMIT 0,1");
+    list($kdynow)= $db->fetch();
+    $ap.=AVG.D20_MN. ($kdynow-$kdy20)*3000 ." W";
+  }
+
+  $sql="SELECT * FROM zzzt
+         WHERE DATE(monitor_date) = '{$day}'
+         ORDER BY monitor_date DESC
+         LIMIT 0,1";
+  $db->query($sql);
+  $titre='     <tr>
+                       <th>'.DYR.'-'.DMT.'-'.DDY.' '.THR.':'.TMI.'</th>
+                       <th>'.PDC.'</th>
+                       <th>'.KDY.'</th>
+                       <th>'.TKK.'</th>
+               </tr>';
+  echo '
+       <table border=1>';
+  $monitors=array();
+  while ($row = $db->fetch())
+  {
+    if(!array_key_exists($row[5],$monitors)) {
+      
$monitors[$row[5]]='#'.dechex(rand(106,254)).dechex(rand(106,254)).dechex(rand(106,254));
+    }
+       echo"<tr style='background-color:{$monitors[$row[5]]}'>
+               <td>$row[0]</td>
+               <td>$row[2]</td>
+               <td>$row[3]</td>
+               <td>$row[4]</td>
+       </tr>";
+  }
+  echo $titre;
+  $sql="SELECT * FROM (
+           SELECT * FROM zzzt WHERE DATE(monitor_date) = '{$day}' ORDER BY 
monitor_date ASC LIMIT 0,1 )
+           AS zzztdebut ORDER BY monitor_date DESC";
+  $db->query($sql);
+  while ($row = $db->fetch())
+  {
+    if(!array_key_exists($row[5],$monitors)) {
+      
$monitors[$row[5]]='#'.dechex(rand(106,254)).dechex(rand(106,254)).dechex(rand(106,254));
+    }
+       echo"<tr style='background-color:{$monitors[$row[5]]}'>
+               <td>$row[0]</td>
+               <td>$row[2]</td>
+               <td>$row[3]</td>
+               <td>$row[4]</td>
+       </tr>";
+  }
+  echo '</table>';
+?>
+    </TD></tr>
+    <tr><TD colspan=3>
+      <img src='<?php echo $fixe;?>pac&amp;height=150' title='<?php echo 
PAC;?>' alt='<?php echo PAC;?>'>
+    </TD></tr>
+    <tr><TD colspan=3>
+      <a href='image_day.php?width=480&amp;data=pac&amp;height=320'><?php echo 
PAC;?></a>
+      <a href='image_day.php?width=480&amp;data=kdy&amp;height=320'><?php echo 
KDY;?></a>
+      <a 
href='image_day.php?width=480&amp;data=rendement&amp;height=320'><?php echo 
EFFICIENCY;?></a>
+      <a href='image_day.php?width=480&amp;data=tkk&amp;height=320'><?php echo 
TKK;?></a>
+    </TD></tr>
+  </table>
+  
+  </body>
+    
+</html>


_______________________________________________
Zzzt-commits mailing list
Zzzt-commits@gna.org
https://mail.gna.org/listinfo/zzzt-commits

Reply via email to