Update report.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / report.php
CommitLineData
e3599ddc
PM
1<?PHP
2include_once('security.php');
3d88cafe
PM
3include_once('/var/www/secure.php'); //outside webserver
4if (isset($_GET['override'])){
5 $id = $_GET['override'];
6 $petition->query("update signatures set signature_status = 'verified' where id = '$id' ");
7 header('Location: report.php');
8}
9if (isset($_GET['delete'])){
10 $id = $_GET['delete'];
11 $petition->query("update signatures set signature_status = 'deleted' where id = '$id' ");
12 header('Location: report.php');
13}
dddebd21
PM
14if (isset($_GET['review'])){
15 $id = $_GET['review'];
16 $petition->query("update signatures set signature_status = 'review_requested' where id = '$id' ");
17 header('Location: report.php');
18}
e3599ddc 19include_once('header.php');
9970efb3 20slack_general('ADMIN: Reports Loaded ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
f1f9b284 21$group_id = $_COOKIE['group_id'];
6865119a 22$javascript='';
3f627365
PM
23?>
24<script>
25 function checkAll(formname, checktoggle)
26{
27 var checkboxes = new Array();
28 checkboxes = document[formname].getElementsByTagName('input');
29
30 for (var i=0; i<checkboxes.length; i++) {
31 if (checkboxes[i].type == 'checkbox') {
32 checkboxes[i].checked = checktoggle;
33 }
34 }
35}
36</script>
a8545882
PM
37<style>
38 body { background-color:lightgrey; }
3f6d2be7
PM
39 fieldset{ border: solid 1px lightblue; background-color:white; margin:10px; padding:10px; }
40 legend{ border: solid 1px blue; background-color:white; margin:10px; padding:10px; }
ecd65c5a 41 td{ white-space: pre; }
a8545882 42</style>
fbdd1785
PM
43<?PHP
44if($_COOKIE['level'] == 'admin'){
45 $q="SELECT * FROM petitions where admin_status = 'approved' ";
46}else{
47 $q="SELECT * FROM petitions where group_id = '$group_id' and admin_status = 'approved'";
48}
7daacef3 49//echo "<li>$q</li>";
fbdd1785
PM
50$r = $petition->query($q);
51while($d = mysqli_fetch_array($r)){
7ff158cf 52 $pID = $d['petition_id'];
7daacef3 53 echo "<div id=\"chartContainer$d[petition_id]\" style=\"height: 200px; width: 100%; margin: 0px auto;\"></div>";
fbdd1785
PM
54 $chart='';
55 $chart2='';
74236c17 56 $q3 = "SELECT just_date FROM signatures where petition_id = '$pID' and just_date <> '0000-00-00' group by just_date";
7a955ef7
PM
57 echo "<li>$q3</li>";
58 $r3 = $core->query($q3) or die(mysqli_error($core));
fbdd1785 59 $total=0;
74236c17 60 while ($d3 = mysqli_fetch_array($r3)){
10815476 61 $q2 = "SELECT * FROM signatures where petition_id = '$pID' and just_date = '$d3[just_date]' and signature_status = 'verified' ";
b3712021 62 echo "<li>$q2</li>";
fbdd1785
PM
63 $r2 = $core->query($q2);
64 $count = mysqli_num_rows($r2);
65 $chart .= '{ label: "'.$d['just_date'].'", y: '.intval($count).' }, ';
66 $total = $total + intval($count);
67 $chart2 .= '{ label: "'.$d['just_date'].'", y: '.intval($total).' }, ';
68 }
69 $chart = rtrim(trim($chart), ",");
70 $chart2 = rtrim(trim($chart2), ",");
b3712021
PM
71
72
73
74
75
fbdd1785
PM
76 ob_start(); ?>
77 var chart<?PHP echo $d['petition_id'];?> = new CanvasJS.Chart("chartContainer<?PHP echo $d['petition_id'];?>", {
78 theme:"light2",
79 animationEnabled: true,
80 exportEnabled: true,
81 title:{
82 text: "<?PHP echo $d['petition_name'];?> MD-Petition.com Signature Tracker"
83 },
84 axisY :{
85 includeZero: false,
86 title: "Number of Signatures",
87 suffix: "",
88 scaleBreaks: {
89 autoCalculate: true
90 }
91 },
92 toolTip: {
93 shared: "true"
94 },
95 legend:{
96 cursor:"pointer",
97 itemclick : toggleDataSeries
98 },
99 data: [{
100 type: "spline",
101 visible: true,
102 showInLegend: true,
103 yValueFormatString: "#####",
104 name: "Total Signatures",
105 dataPoints: [
106 <?PHP echo $chart2; ?>
107 ]
108 },{
2e96f88a 109 type: "column",
fbdd1785
PM
110 visible: true,
111 showInLegend: true,
112 yValueFormatString: "#####",
113 name: "New Signatures",
114 dataPoints: [
115 <?PHP echo $chart; ?>
116 ]
117 }]
118 }
119
120
121 );
122 chart<?PHP echo $d['petition_id'];?>.render();
123
124 <?PHP $javascript .= ob_get_clean();
125}
126?>
127
128
129
130
131
132
133
134
135
136
137
138
139
140
6865119a 141
79f261d4 142<form id='form3' name='form3' method='POST' action='printer.php'>
3f627365 143<?PHP
214e6829 144 if($_COOKIE['level'] == 'admin'){
feef9b7e 145 $q="SELECT * FROM petitions where admin_status = 'approved' ";
214e6829 146 }else{
feef9b7e 147 $q="SELECT * FROM petitions where group_id = '$group_id' and admin_status = 'approved'";
80b72550
PM
148 }
149$r = $petition->query($q);
150while($d = mysqli_fetch_array($r)){
6b1f3680 151 echo "<fieldset style='background-color:$d[web_color];'><legend style='background-color:white;'>$d[petition_name] - Unprinted</legend>
9a5ee71a
PM
152 <a onclick=\"javascript:checkAll('form3', true);\" href=\"javascript:void();\">Check All</a>
153 <a onclick=\"javascript:checkAll('form3', false);\" href=\"javascript:void();\">Uncheck All</a>
154 <input type='submit' value='PRINT'>";
80b72550
PM
155 echo "<table border='1' cellpadding='0' cellspacing='5'>";
156 unset($hide);
157 $hide = array();
158 $pID = $d['petition_id'];
0c13e2c5 159 $q2="SELECT * FROM signatures where petition_id = '$pID' and printed_status = '' and signature_status <> 'deleted' order by signature_status, id desc";
80b72550
PM
160 $r2 = $petition->query($q2);
161 while($d2 = mysqli_fetch_array($r2)){
6a911fb1 162 if ($d2['signature_status'] == 'verified'){
96e91f82 163 echo "<tr><td><input type='checkbox' name='print[".$d2[id]."]'></td><td>$d2[ip_address]</td><td>$d2[date_time_signed]</td><td>$d2[signed_name_as]</td><td>$d2[signed_name_as_circulator]</td><td>$d2[contact_phone]</td><td>$d2[signature_status]-<a href='?review=$d2[id]'>Flag for Review</a></td><td>$d2[printed_status]</td></tr>";
8452f380
PM
164 }else{
165 echo "<tr><td><a href='?override=$d2[id]'>Override</a> or <a href='?delete=$d2[id]'>Delete</a></td><td>$d2[ip_address]</td><td>$d2[date_time_signed]</td><td>$d2[signed_name_as]</td><td>$d2[signed_name_as_circulator]</td><td>$d2[contact_phone]</td><td>$d2[signature_status]</td><td>$d2[printed_status]</td></tr>";
166 }
80b72550 167 }
22e166b5 168 echo '</table></fieldset>';
fbdd1785 169
6865119a
PM
170
171
172}
173 ?>
174</form>
175
176<form id='form2' name='form2' method='POST' action='printer.php'>
177
178<?PHP
179 if($_COOKIE['level'] == 'admin'){
180 $q="SELECT * FROM petitions where admin_status = 'approved' ";
181 }else{
182 $q="SELECT * FROM petitions where group_id = '$group_id' and admin_status = 'approved' ";
183 }
184$r = $petition->query($q);
185while($d = mysqli_fetch_array($r)){
186 echo "<fieldset style='background-color:$d[web_color];'><legend style='background-color:white;'>$d[petition_name] - Printed</legend>
187 <a onclick=\"javascript:checkAll('form2', true);\" href=\"javascript:void();\">Check All</a>
188 <a onclick=\"javascript:checkAll('form2', false);\" href=\"javascript:void();\">Uncheck All</a>
189 <input type='submit' value='PRINT'>";
190 echo "<table border='1' cellpadding='0' cellspacing='5'>";
191 unset($hide);
192 $hide = array();
193 $pID = $d['petition_id'];
194 $q2="SELECT * FROM signatures where petition_id = '$pID' and printed_status <> '' and signature_status <> 'deleted' order by signature_status, id desc";
195 $r2 = $petition->query($q2);
196 while($d2 = mysqli_fetch_array($r2)){
197 if ($d2['signature_status'] == 'verified'){
198 echo "<tr><td><input type='checkbox' name='print[".$d2[id]."]'></td><td>$d2[ip_address]</td><td>$d2[date_time_signed]</td><td>$d2[signed_name_as]</td><td>$d2[signed_name_as_circulator]</td><td>$d2[contact_phone]</td><td>$d2[signature_status]-<a href='?review=$d2[id]'>Flag for Review</a></td><td>$d2[printed_status]</td></tr>";
199 }else{
200 echo "<tr><td><a href='?override=$d2[id]'>Override</a> or <a href='?delete=$d2[id]'>Delete</a></td><td>$d2[ip_address]</td><td>$d2[date_time_signed]</td><td>$d2[signed_name_as]</td><td>$d2[signed_name_as_circulator]</td><td>$d2[contact_phone]</td><td>$d2[signature_status]</td><td>$d2[printed_status]</td></tr>";
201 }
202 }
203 echo '</table></fieldset>';
204
205
206}
207?>
208</form>
209
210
211
212
213
214<script>
215window.onload = function () {
216
217<?PHP echo $javascript;?>
ddec0164
PM
218
219function toggleDataSeries(e) {
220 if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible ){
221 e.dataSeries.visible = false;
222 } else {
223 e.dataSeries.visible = true;
224 }
225 chart.render();
226}
227
228}
229</script>
230
231
232
6865119a 233<script src="../files/canvasjs.min.js"></script>
3f627365 234<?PHP
e3599ddc
PM
235include_once('footer.php');
236?>