www-thermferm/archives.php

changeset 375
f707d22c72f8
parent 374
20999ef6d487
child 376
a5d215531f55
--- a/www-thermferm/archives.php	Sun Jun 14 22:48:45 2015 +0200
+++ b/www-thermferm/archives.php	Sun Jun 21 19:51:58 2015 +0200
@@ -83,6 +83,7 @@
     $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>'.PHP_EOL;
     $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>'.PHP_EOL;
     $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>'.PHP_EOL;
+    $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxdata.export.js"></script>'.PHP_EOL;
     $outstr .= ' </head>'.PHP_EOL;
 
     $outstr .= ' <body class="default">'.PHP_EOL;
@@ -119,7 +120,7 @@
     $outstr .= '             { name: "CoolUse", type: "int" },'.PHP_EOL;
     $outstr .= '             { name: "Room", type: "float" }'.PHP_EOL;
     $outstr .= '          ],'.PHP_EOL;
-    $outstr .= '          url: \'getalog.php?name='.urlencode($name).'\''.PHP_EOL;
+    $outstr .= '          url: \'getalog.php?name='.urlencode($name).'.log\''.PHP_EOL;
     $outstr .= '       };'.PHP_EOL;
 
     $outstr .= '       var dataAdapter = new $.jqx.dataAdapter(sourceA,'.PHP_EOL;
@@ -175,7 +176,6 @@
     $outstr .= '             ]'.PHP_EOL;
     $outstr .= '           }]'.PHP_EOL;
     $outstr .= '       };'.PHP_EOL;
-    /* Direct draw for the first time */
     $outstr .= '       $("#fermentor_chart").jqxChart(settings);'.PHP_EOL;
 
     $outstr .= '       $("#print").click(function () {'.PHP_EOL;
@@ -200,7 +200,11 @@
     $outstr .= '       $("#pngButton").click(function () {'.PHP_EOL;
     $outstr .= '            $("#fermentor_chart").jqxChart("saveAsPNG", "Chart_'.$name.'.png", getExportServer());'.PHP_EOL;
     $outstr .= '       });'.PHP_EOL;
+    $outstr .= '       $("#pdfButton").click(function () {'.PHP_EOL;
+    $outstr .= '            $("#fermentor_chart").jqxChart("saveAsPDF", "Chart_'.$name.'.pdf", getExportServer());'.PHP_EOL;
+    $outstr .= '       });'.PHP_EOL;
     $outstr .= '       $("#pngButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
+    $outstr .= '       $("#pdfButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
 
     $outstr .= '     });'.PHP_EOL;
     $outstr .= '    </script>'.PHP_EOL;
@@ -208,7 +212,8 @@
     $outstr .= '     <div id="fermentor_chart" style="width:720px; height:377px; float:left"></div>'.PHP_EOL;
     $outstr .= '     <div style="margin-top: 2px; margin-left: 10px;">'.PHP_EOL;
     $outstr .= '      <input style="float: left; margin-left: 15px;" id="print" type="button" value="Print Graph" />'.PHP_EOL;
-    $outstr .= '      <input style="float: left; margin-left: 15px;" id="pngButton" type="button" value="Save Graph" />'.PHP_EOL;
+    $outstr .= '      <input style="float: left; margin-left: 15px;" id="pngButton" type="button" value="Save as PNG" />'.PHP_EOL;
+    $outstr .= '      <input style="float: left; margin-left: 15px;" id="pdfButton" type="button" value="Save as PDF" />'.PHP_EOL;
     $outstr .= '     </div>'.PHP_EOL;
     $outstr .= '    </div> <!-- fermentor -->'.PHP_EOL;
 
@@ -229,7 +234,7 @@
  */
 function archive_dl() {
 
-    $name = urldecode($_GET['name']);
+    $name = urldecode($_GET['name']) . ".log";
 
     header('Content-Type: text/plain');
     header('Content-Disposition: attachment; filename="'.$name.'"');
@@ -254,7 +259,7 @@
 
 
 /*
- *
+ * Show directory
  */
 function archive_dir() {
 
@@ -280,13 +285,14 @@
 	    if (strcmp($reply[$j], ".") == 0)
 		break;
 	    $f = explode(",", $reply[$j]);
+	    $name = urlencode(basename($f[0], ".log"));
 	    $outstr .= '      <tr class="setup">'.PHP_EOL;
 	    $outstr .= '       <td class="setup">'.$f[0].'</td>'.PHP_EOL;
 	    $outstr .= '       <td class="setup">'.$f[1].'</td>'.PHP_EOL;
 	    $outstr .= '       <td class="setup">'.$f[2].'</td>'.PHP_EOL;
 	    $outstr .= '       <td class="setup">'.$f[3].'</td>'.PHP_EOL;
-	    $outstr .= '       <td class="setup"><a href="archives.php?action=dl&amp;name='.urlencode($f[0]).'">Download</a>';
-	    $outstr .= ' <a href="archives.php?action=view&amp;name='.urlencode($f[0]).'">View</a></td>'.PHP_EOL;
+	    $outstr .= '       <td class="setup"><a href="archives.php?action=dl&amp;name='.$name.'">Download</a>';
+	    $outstr .= ' <a href="archives.php?action=view&amp;name='.$name.'">View</a></td>'.PHP_EOL;
 	    $outstr .= '      </tr>'.PHP_EOL;
 	    $j++;
 	}

mercurial