Update analytics.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / analytics.php
index 1e7a871..78f1241 100644 (file)
@@ -12,6 +12,16 @@ if (isset($_GET['clear_php_session_id'])){
   $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$id' ");
   header('Location: analytics.php');
 }
+if (isset($_GET['clear_email'])){
+  $email = $_GET['clear_email'];
+  $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
+  header('Location: analytics.php');
+}
+if (isset($_GET['sign_email'])){
+  $email = $_GET['sign_email'];
+  $petition->query("update presign set presign_status = 'SIGNED' where email_for_follow_up = '$email' ");
+  header('Location: analytics.php');
+}
 if (isset($_GET['sign_php_session_id'])){
   $id = $_GET['sign_php_session_id'];
   $petition->query("update presign set presign_status = 'SIGNED' where php_session_id = '$id' ");
@@ -114,7 +124,7 @@ if (isset($_GET['ip_address'])){
       <td style='white-space:pre;'>$d[browser_string]</td>
     </tr>"; 
   }
-  echo "</table>";
+  echo "</table><a href='?clear_email=$email'>CLEAR EMAIL</a> - <a href='?sign_email=$email'>SIGNATURE FOUND</a>";
 }elseif(isset($_GET['php_session_id']) && empty($_GET['follow_up'])){ 
   $php_session_id = $_GET['php_session_id']; 
   echo "<h1>Review $php_session_id</h1><table width='100%' border='1' cellpadding='5' cellspacing='5'>";    
@@ -141,9 +151,9 @@ if (isset($_GET['ip_address'])){
       <td style='white-space:pre;'>$d[browser_string]</td>
     </tr>"; 
   }
-  echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR ALERT</a> - 
+  echo "</table><a href='?clear_php_session_id=$php_session_id'>CLEAR SESSION</a> - 
   <a href='?sign_php_session_id=$php_session_id'>SIGNATURE FOUND</a><br> 
-  - <a href='?php_session_id=$php_session_id&follow_up=0'>ADD TO FOLLOW UP LIST Maryland General</a><br>
+  - <a href='?php_session_id=$php_session_id&follow_up=X'>ADD TO FOLLOW UP LIST Maryland General</a><br>
   - <a href='?php_session_id=$php_session_id&follow_up=1'>ADD TO FOLLOW UP LIST MGP</a><br> 
   - <a href='?php_session_id=$php_session_id&follow_up=2'>ADD TO FOLLOW UP LIST MLP</a><br> 
   - <a href='?php_session_id=$php_session_id&follow_up=3'>ADD TO FOLLOW UP LIST BTEC</a><br> 
@@ -183,8 +193,9 @@ if ($d[email_for_follow_up] != ''){
       <td style='white-space:pre;'>$d[browser_string]</td>
     </tr>"; 
   }
-  $petition->query("insert into follow_up (name, email, php_session, petition_id) values ('$name','$email','$php_session_id','$_GET[follow_up]') ");  
+  $petition->query("insert into follow_up (name, email, php_session, petition_id, date_sent) values ('$name','$email','$php_session_id','$_GET[follow_up]','".date('Y-m-d')."') ");  
   $petition->query("update presign set presign_status = 'DONE' where php_session_id = '$php_session_id' ");
+  $petition->query("update presign set presign_status = 'DONE' where email_for_follow_up = '$email' ");
   echo "</table>";
 }elseif (isset($_GET['VTRID'])){ 
   $VTRID = $_GET['VTRID'];
@@ -225,7 +236,7 @@ if ($d[email_for_follow_up] != ''){
 <table>
   
   <tr>
-  <td valign="top">
+  <td valign="top" colspan='2'><?PHP /*
 <h2>IP Address</h2>
 <div>Watching for duplicates.</div><ol>
 <?PHP
@@ -237,7 +248,7 @@ while($d = mysqli_fetch_array($r)){
   }
 }
 ?></ol>
-  </td><td valign="top">
+  </td><td valign="top"> */ ?>
 <h2>VTRID</h2>
 <div>Watching for duplicates.</div><ol>
 <?PHP
@@ -253,22 +264,33 @@ while($d = mysqli_fetch_array($r)){
   
   
 <tr>
-<td valign="top">
+<td valign="top" colspan='2'>
 <h2>Pre-Sign</h2>
 <div>Follow up requested - never signed.</div>
-<form method='GET'><input name='email'><input type='submit' value='SEARCH E-MAIL'></form><ol>
+<form method='GET'><input name='email'><input type='submit' value='SEARCH E-MAIL'></form><table>
 <?PHP
-$q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id desc";
+$q="SELECT distinct php_session_id FROM presign where presign_status = 'NEW' and email_for_follow_up <> '' order by id";
 $r = $petition->query($q);
 while($d = mysqli_fetch_array($r)){ 
   $q2="SELECT * FROM presign where php_session_id = '$d[php_session_id]' order by id desc";
   $r2 = $petition->query($q2);
   $d2 = mysqli_fetch_array($r2);
-    echo "<li><a href='?php_session_id=$d2[php_session_id]'>$d2[name] $d2[email_for_follow_up] ".id2petition($d2['petition'])." $d2[invite]</a></li>"; 
+  $sig = '';
+  if ($d2['name'] != ''){
+    $q3 = "SELECT date_time_signed FROM signatures where signed_name_as = '$d2[name]'";
+    $r3 = $petition->query($q3);
+    $d3 = mysqli_fetch_array($r3); 
+    if ($d3['date_time_signed'] != ''){
+      $sig = "<br><b><a href='?sign_email=$d2[email_for_follow_up]'>SIGNATURE $d3[date_time_signed]</a></b>";
+    }
+  }
+  echo "<tr><td><a href='?php_session_id=$d2[php_session_id]'>$d2[action_on]</a></td><td>$d2[name] $sig</td><td><a href='?email=$d2[email_for_follow_up]'>$d2[email_for_follow_up]</a></td><td>".id2petition($d2['petition'])."</td><td>$d2[invite]</td></tr>"; 
 }
-?></ol>
+?></table>
   </td>
-<td valign="top">
+  </tr>
+  <tr>
+<td valign="top" colspan='2'>
 <h2>Signatures</h2>
 <div>Last 10</div><ol>
 <?PHP