Update report.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / report.php
index 2f26c9f..576d2d5 100644 (file)
@@ -19,6 +19,7 @@ if (isset($_GET['review'])){
 include_once('header.php');
 slack_general('ADMIN: Reports Loaded ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
 $group_id = $_COOKIE['group_id'];
+$javascript='';
 ?>
 <script>
   function checkAll(formname, checktoggle)
@@ -39,6 +40,97 @@ $group_id = $_COOKIE['group_id'];
   legend{ border: solid 1px blue; background-color:white; margin:10px; padding:10px; }
   td{ white-space: pre; }
 </style>
+<?PHP
+if($_COOKIE['level'] == 'admin'){
+    $q="SELECT * FROM petitions where admin_status = 'approved' ";
+}else{
+    $q="SELECT * FROM petitions where group_id = '$group_id' and admin_status = 'approved'";
+}
+$r = $petition->query($q);
+while($d = mysqli_fetch_array($r)){
+       echo "$d[petition_id] <div id=\"chartContainer$d[petition_id]\" style=\"height: 200px; width: 100%; margin: 0px auto;\"></div>";
+       $chart='';
+       $chart2='';
+       $q3 = "SELECT just_date FROM signatures where petition_id = '$pID' and just_date <> '0000-00-00' group by just_date";
+       $r3 = $core->query($q3);
+       $total=0;
+       while ($d3 = mysqli_fetch_array($r3)){
+         $q2 = "SELECT * FROM signatures where petition_id = '$pID' and just_date = '$d3[just_date]' ";
+         $r2 = $core->query($q2);
+         $count  = mysqli_num_rows($r2);
+         $chart .=  '{ label: "'.$d['just_date'].'", y: '.intval($count).' }, ';
+         $total = $total + intval($count);
+         $chart2 .=  '{ label: "'.$d['just_date'].'", y: '.intval($total).' }, ';
+       }
+       $chart = rtrim(trim($chart), ",");
+       $chart2 = rtrim(trim($chart2), ",");
+
+       ob_start(); ?>
+       var chart<?PHP echo $d['petition_id'];?> = new CanvasJS.Chart("chartContainer<?PHP echo $d['petition_id'];?>", {
+               theme:"light2",
+               animationEnabled: true,
+               exportEnabled: true,
+               title:{
+                       text: "<?PHP echo $d['petition_name'];?> MD-Petition.com Signature Tracker"
+               },
+               axisY :{
+                       includeZero: false,
+                       title: "Number of Signatures",
+                       suffix: "",
+           scaleBreaks: {
+                                       autoCalculate: true
+                               }
+               },
+               toolTip: {
+                       shared: "true"
+               },
+               legend:{
+                       cursor:"pointer",
+                       itemclick : toggleDataSeries
+               },
+               data: [{
+                       type: "spline",
+                       visible: true,
+                       showInLegend: true,
+                       yValueFormatString: "#####",
+                       name: "Total Signatures",
+                       dataPoints: [
+                               <?PHP echo $chart2; ?>
+                       ]
+               },{
+                       type: "column",
+                       visible: true,
+                       showInLegend: true,
+                       yValueFormatString: "#####",
+                       name: "New Signatures",
+                       dataPoints: [
+                               <?PHP echo $chart; ?>
+                       ]
+               }]
+       }
+
+
+                                     );
+       chart<?PHP echo $d['petition_id'];?>.render();
+
+       <?PHP $javascript .= ob_get_clean();
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 <form id='form3' name='form3' method='POST' action='printer.php'>
 <?PHP
   if($_COOKIE['level'] == 'admin'){
@@ -66,6 +158,9 @@ while($d = mysqli_fetch_array($r)){
     }
   }
   echo '</table></fieldset>';
+
+       
+       
 }
     ?>
 </form>
@@ -98,78 +193,20 @@ while($d = mysqli_fetch_array($r)){
     }
   }
   echo '</table></fieldset>';
+       
 }
 ?>
 </form>
 
 
-<?PHP
-$q = "SELECT just_date FROM signatures where just_date <> '0000-00-00' group by just_date";
-$r = $core->query($q);
-$total=0;
-while ($d = mysqli_fetch_array($r)){
-  $q2 = "SELECT * FROM signatures where just_date = '$d[just_date]' ";
-  $r2 = $core->query($q2);
-  $count  = mysqli_num_rows($r2);
-  $chart .=  '{ label: "'.$d['just_date'].'", y: '.intval($count).' }, ';
-  $total = $total + intval($count);
-  $chart2 .=  '{ label: "'.$d['just_date'].'", y: '.intval($total).' }, ';
-}
-$chart = rtrim(trim($chart), ",");
-$chart2 = rtrim(trim($chart2), ",");
 
-?>
 
 
 <script>
 window.onload = function () {
 
-var chart = new CanvasJS.Chart("chartContainer", {
-       theme:"light2",
-       animationEnabled: true,
-       exportEnabled: true,
-       title:{
-               text: "MD-Petition.com Signature Tracker"
-       },
-       axisY :{
-               includeZero: false,
-               title: "Number of Signatures",
-               suffix: "",
-    scaleBreaks: {
-                               autoCalculate: true
-                       }
-       },
-       toolTip: {
-               shared: "true"
-       },
-       legend:{
-               cursor:"pointer",
-               itemclick : toggleDataSeries
-       },
-       data: [{
-               type: "spline",
-               visible: true,
-               showInLegend: true,
-               yValueFormatString: "#####",
-               name: "Total Signatures",
-               dataPoints: [
-                       <?PHP echo $chart2; ?>
-               ]
-       },{
-               type: "bar",
-               visible: true,
-               showInLegend: true,
-               yValueFormatString: "#####",
-               name: "New Signatures",
-               dataPoints: [
-                       <?PHP echo $chart; ?>
-               ]
-       }]
-}
-                             
-                             
-                             );
-chart.render();
+<?PHP echo $javascript;?>
 
 function toggleDataSeries(e) {
        if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible ){
@@ -185,8 +222,7 @@ function toggleDataSeries(e) {
 
 
 
-<div id="chartContainer" style="height: 370px; width: 100%; margin: 0px auto;"></div>
-<script src="../canvasjs.min.js"></script>
+<script src="../files/canvasjs.min.js"></script>
 <?PHP
 include_once('footer.php');
 ?>