Update follow_up_emails.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / index.php
1 <?PHP
2 include_once('../slack.php');
3 include_once('security.php');
4 if ($_COOKIE['level'] == 'user'){
5 slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
6 header('Location: user_home.php');
7 }
8 if ($_COOKIE['level'] == 'manager'){
9 slack_general('ADMIN: Redirect Manager Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
10 header('Location: manager_home.php');
11 }
12
13 include_once('header.php');
14 if(isset($_GET['approve'])){
15 $id = $_GET['approve'];
16 $petition->query("update petitions set admin_status = 'approved' where petition_id = '$id' ");
17 }
18 slack_general('ADMIN: Home Page Loaded ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition');
19 ?>
20
21 <h1>Admin Home</h1>
22 <div id="chartContainer1" style="height: 400px; width: 100%; margin: 0px auto;"></div>
23 <h1>Users</h1>
24 <?PHP
25 $q="SELECT * FROM users";
26 $r = $petition->query($q);
27 while($d = mysqli_fetch_array($r)){
28 $alert='';
29 if ($d[pass] == ''){
30 $alert='NEEDS PASSWORD RESET';
31 }
32 echo "<li>$d[id] $d[email] $d[name] $d[group_id] $d[sec_level] $alert</li>";
33 }
34 ?>
35
36 <h1>New Petitions</h1>
37 <?PHP
38 $q="SELECT * FROM petitions where admin_status='new'";
39 $r = $petition->query($q);
40 while($d = mysqli_fetch_array($r)){
41 echo "<li><a href='?approve=$d[petition_id]'>$d[petition_id] $d[web_short_name] $d[web_color] $d[group_id] $d[petition_name] $d[eligibleVoterListField] $d[eligibleVoterListEquals] $d[eligibleVoterListEnforce]</a></li>";
42 }
43 ?>
44
45
46 <h1>Approved Petitions</h1>
47 <?PHP
48 $q="SELECT * FROM petitions where admin_status = 'approved'";
49 $r = $petition->query($q);
50 while($d = mysqli_fetch_array($r)){
51 echo "<li>$d[petition_id] $d[web_short_name] $d[web_color] $d[group_id] $d[petition_name] $d[eligibleVoterListField] $d[eligibleVoterListEquals] $d[eligibleVoterListEnforce]</li>";
52 }
53 ?>
54
55
56 <h1>Groups</h1>
57 <?PHP
58 $q="SELECT * FROM groups";
59 $r = $petition->query($q);
60 while($d = mysqli_fetch_array($r)){
61 echo "<li>$d[id] $d[name]</li>";
62 }
63 ?>
64
65
66
67
68 <h1>Website</h1>
69 <?PHP
70 $q="SELECT * FROM website_text";
71 $r = $petition->query($q);
72 while($d = mysqli_fetch_array($r)){
73 echo "<li>$d[id] $d[text_title]</li>";
74 }
75 ?>
76
77 <?PHP
78 $pID = 1;
79 //echo "<div id=\"chartContainer$pID\" style=\"height: 400px; width: 100%; margin: 0px auto;\"></div>";
80 $chart='';
81 $chart2='';
82 $chart3='';
83 $q3 = "SELECT just_date FROM signatures where just_date <> '0000-00-00' group by just_date";
84 //echo "<li>$q3</li>";
85 $r3 = $petition->query($q3);
86 $total=0;
87 $goal = $d['signature_goal'];
88 if ($goal == 0){
89 $goal = 10000;
90 }
91 while ($d3 = mysqli_fetch_array($r3)){
92 $just_date = $d3['just_date'];
93 $q2 = "SELECT * FROM signatures where just_date = '$just_date' and signature_status = 'verified' ";
94 //echo "<li>$q2</li>";
95 $r2 = $petition->query($q2);
96 $count = mysqli_num_rows($r2);
97 $chart .= '{ label: "'.$just_date.'", y: '.intval($count).' }, ';
98 $total = $total + intval($count);
99 $chart2 .= '{ label: "'.$just_date.'", y: '.intval($total).' }, ';
100 $goal = $goal - intval($count);
101 $chart3 .= '{ label: "'.$just_date.'", y: '.intval($goal).' }, ';
102 }
103 $chart = rtrim(trim($chart), ",");
104 $chart2 = rtrim(trim($chart2), ",");
105 $chart3 = rtrim(trim($chart3), ",");
106
107 ob_start(); ?>
108
109 var chart<?PHP echo $pID;?> = new CanvasJS.Chart("chartContainer<?PHP echo $pID;?>", {
110 theme:"light2",
111 animationEnabled: true,
112 exportEnabled: true,
113 title:{
114 text: "MD-Petition.com Signature Tracker"
115 },
116 axisY :{
117 includeZero: false,
118 title: "Number of Signatures",
119 suffix: "",
120 scaleBreaks: {
121 autoCalculate: true
122 }
123 },
124 toolTip: {
125 shared: "true"
126 },
127 legend:{
128 cursor:"pointer",
129 itemclick : toggleDataSeries
130 },
131 data: [{
132 type: "line",
133 visible: true,
134 showInLegend: true,
135 yValueFormatString: "#####",
136 name: "Total Signatures Count",
137 dataPoints: [
138 <?PHP echo $chart2; ?>
139 ]
140 },{
141 type: "column",
142 visible: true,
143 showInLegend: true,
144 yValueFormatString: "#####",
145 name: "New Daily Signatures",
146 dataPoints: [
147 <?PHP echo $chart; ?>
148 ]
149 }]
150 }
151
152
153 );
154 chart<?PHP echo $pID;?>.render();
155
156 <?PHP $javascript .= ob_get_clean(); ?>
157
158
159
160 <script>
161 window.onload = function () {
162
163 <?PHP echo $javascript;?>
164
165 function toggleDataSeries(e) {
166 if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible ){
167 e.dataSeries.visible = false;
168 } else {
169 e.dataSeries.visible = true;
170 }
171 chart.render();
172 }
173
174 }
175 </script>
176 <script src="../files/canvasjs.min.js"></script>
177 <?PHP
178
179
180 include_once('footer.php');
181 ?>