Update mgp.php
[clinton/MarylandElectronicPetitionSignature.git] / eligible.php
index eef2027..f2bf53a 100644 (file)
@@ -48,57 +48,50 @@ 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';
    }else{
      $checked = '';
    }
-  $available .= "<div class='row' style='background-color:lightgreen;'>
-  <div class='col-sm-3'><input type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked > </div>
-  <div class='col-sm-6'>$d2[petition_name]</div>
-  <div class='col-sm-3'>$field == $pass</div>
+  $available .= "<div class='row'>
+  <div class='col-sm-3' style='background-color:$d2[web_color];'><input type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked > </div>
+  <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'])){
      $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';
    }else{
      $checked = '';
    }
-  $available .= "<div class='row' style='background-color:#ffcccb;'>
-  <div class='col-sm-3'>"; if ($d2['eligibleVoterListEnforce'] == 'NO'){ $available .="<input type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked >"; }else{ $available .= "Constituents Only"; } $available .= "</div>
-  <div class='col-sm-6'>$d2[petition_name]</div>
-  <div class='col-sm-3'>$field != $pass</div>
+  $available .= "<div class='row'>
+  <div class='col-sm-3' style='background-color:$d2[web_color];'>"; if ($d2['eligibleVoterListEnforce'] == 'NO'){ $available .="<input type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked >"; }else{ $available .= "<h2>Constituents Only</h2>"; } $available .= "</div>
+  <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>';
    }
  }
 }
@@ -110,22 +103,28 @@ if ($d4['id'] > 0){
  $r = $petition->query($q);
  $d = mysqli_fetch_array($r);
  ?>
+  <style>
+  input[type=radio]{
+    transform:scale(2);
+  }
+  </style>
+  
   <div class='row'>
-    <div class='col-sm-1' style='height:100px; text-align:center;'><h1><?PHP echo $d['text_title'];?></h1><h2><?PHP echo $d['text_block'];?></h2></div>
+    <div class='col-sm-10' style='height:100px; text-align:center;'><h1><?PHP echo $d['text_title'];?></h1><h2><?PHP echo $d['text_block'];?></h2></div>
   </div>
 
   <div class='row'>
-    <div class='col-sm-2'><h3>Pick One</h3></div>
-    <div class='col-sm-6'><h3>Petition Name</h3></div>
-    <div class='col-sm-2'><h3>Requirements</h3></div>
+    <div class='col-sm-3'><h3>Pick One</h3></div>
+    <div class='col-sm-6'><h3>Petition Name <br> Eligible</h3></div>
+    <div class='col-sm-1'><h3>Locked</h3></div>
   </div>
 
   <?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='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>