Update mgp.php
[clinton/MarylandElectronicPetitionSignature.git] / eligible.php
index 74deee9..f2bf53a 100644 (file)
@@ -48,28 +48,17 @@ echo $head;
 
 
 $available='';
-$q2 = "SELECT * FROM petitions";
+$q2 = "SELECT * FROM petitions where admin_status = 'approved'";
 $r2 = $petition->query($q2);
 while($d2 = mysqli_fetch_array($r2)){
  $checked = '';
  $field = $d2['eligibleVoterListField'];
  $pass = $d2['eligibleVoterListEquals'];
- $q4 = "select * from signatures where VTRID = '$VTRID' and petition_id = '$d2[petition_id]' and signature_status <> 'removed' ";
- $r4 = $petition->query($q4);
- $d4 = mysqli_fetch_array($r4);
-  if ($d4['id'] > 0){
-    slack_general($VTRID.' Already Signed '.$d2[petition_id].' ('.$_COOKIE['invite'].')','md-petition');
-  }
-  /*
-if ($d4['id'] > 0){
-  $available .= "<div class='row' style='background-color:lightyellow;'>
-  <div class='col-sm-3'>Already Signed, <a target='_Blank' href='soft_copy.php?id=$d4[id]'>View</a> or <a href='?remove=$d4[id]'>Remove</a></div>
-  <div class='col-sm-6'>$d2[petition_name]</div>
-  <div class='col-sm-3'>$field == $pass</div>
-    </div>"; 
- }else */
+
   
   if($d[$field] == $pass){
+    // good to go
    $checked = ''; 
    if($_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name'])){
      $checked = 'checked';
@@ -86,6 +75,7 @@ if ($d4['id'] > 0){
      $available .= '<script>document.getElementById("form").submit();</script>';
    }
  }else{
+    // not a eligable voter
    $checked = '';
    if($_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name'])){
      $checked = 'checked';
@@ -97,8 +87,11 @@ if ($d4['id'] > 0){
   <div class='col-sm-6' style='background-color:$d2[web_color];'><h2>$d2[petition_name] <br> $field != $pass</h2></div>
   <div class='col-sm-1' style='background-color:$d2[web_color];'><h2>$d2[eligibleVoterListEnforce]</h2></div>
     </div>"; 
-   if($_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name'])){
+   if($d2['eligibleVoterListEnforce'] == 'NO' && $_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name']) ){
      $available .= '<script>document.getElementById("form").submit();</script>';
+   }elseif($d2['eligibleVoterListEnforce'] == 'YES' && $_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name']) ){
+     setcookie("invite", ""); // clear invite
+     $available .= '<script>alert("'.$d2[eligibleVoterListWarning].'");</script>';
    }
  }
 }
@@ -129,11 +122,9 @@ if ($d4['id'] > 0){
   <?PHP echo $available;?>
 
   <div class='row'>
-    <div class='col-sm-10' style='height:100px; text-align:center;'><button type="submit" class="btn btn-success btn-lg btn-block">Next</button><div>
-  </div>
-<div class='row'>
- <div class='col-sm-10' style='text-align:center;'><button type="button" class="btn btn-danger btn-lg btn-block" onclick="window.location.href='reset.php'">Reset / Restart</button></div>
-</div>     
+    <div class='col-sm-5'><button type="submit" class="btn btn-success btn-lg btn-block">Next</button></div>
+    <div class='col-sm-5'><button type="button" class="btn btn-danger btn-lg btn-block" onclick="window.location.href='reset.php'">Reset / Restart</button></div>
+  </div>     
      
       
 </form>