Update printable_qr_code.php
[clinton/MarylandElectronicPetitionSignature.git] / eligible.php
index 80647b7..70dd7c2 100644 (file)
@@ -2,6 +2,7 @@
 ob_start();
 include_once('header.php'); 
 $head = ob_get_clean();
+$VoterList_table   = $_COOKIE['VoterList_table'];
 $web_first_name   = $_COOKIE['web_first_name'];
 $web_last_name    = $_COOKIE['web_last_name'];
 $web_house_number = $_COOKIE['web_house_number'];
@@ -18,7 +19,7 @@ if ($web_first_name != '' && $web_last_name != '' && $web_house_number != '' &&
   // we should NEVER hit this page anymore
   header('Location: warning_incomplete.php');
 }
-$q = "select * from VoterList where LASTNAME = '$web_last_name' and FIRSTNAME = '$web_first_name' and HOUSE_NUMBER = '$web_house_number' and RESIDENTIALZIP5 = '$web_zip_code'";
+$q = "select * from $VoterList_table where LASTNAME = '$web_last_name' and FIRSTNAME = '$web_first_name' and HOUSE_NUMBER = '$web_house_number' and RESIDENTIALZIP5 = '$web_zip_code'";
 $r = $petition->query($q);
 $d = mysqli_fetch_array($r);
 if ($d['VTRID'] != ''){
@@ -48,28 +49,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 */
+$my_test = $d[$field];
   
-  if($d[$field] == $pass){
+  if($my_test == $pass){
+    // good to go
    $checked = ''; 
    if($_COOKIE['invite'] != '' && strtoupper($_COOKIE['invite']) == strtoupper($d2['web_short_name'])){
      $checked = 'checked';
@@ -77,15 +67,16 @@ if ($d4['id'] > 0){
      $checked = '';
    }
   $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 class='col-sm-3' style='color: $d2[web_color_text]; background-color:$d2[web_color];'>&#8594;<input onclick='document.getElementById(\"form\").submit();' type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked >&#8592;</div>
+  <div class='col-sm-6' style='color: $d2[web_color_text]; background-color:$d2[web_color];'><h3>$d2[petition_name] <br> $field == $pass</h3></div>
+  <div class='col-sm-1' style='color: $d2[web_color_text]; background-color:$d2[web_color];'><h3>$d2[eligibleVoterListEnforce]</h3></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';
@@ -93,12 +84,17 @@ if ($d4['id'] > 0){
      $checked = '';
    }
   $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 class='col-sm-3' style='color: $d2[web_color_text]; background-color:$d2[web_color];'>"; if ($d2['eligibleVoterListEnforce'] == 'NO'){ $available .="&#8594;<input onclick='document.getElementById(\"form\").submit();' type='radio' id='petition' name='petition' value='$d2[petition_id]' $checked >&#8592;"; }else{ $available .= "<h3>Constituents Only</h3>"; } $available .= "</div>
+  <div class='col-sm-6' style='color: $d2[web_color_text]; background-color:$d2[web_color];'><h3>$d2[petition_name] <br> $field != $pass ($my_test)</h3></div>
+  <div class='col-sm-1' style='color: $d2[web_color_text]; background-color:$d2[web_color];'><h3>$d2[eligibleVoterListEnforce]</h3></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
+     $error = "$field is not $pass it is $my_test";
+     setcookie("invite_error", $error); // record error
+     $available .= '<script>alert("'.$d2[eligibleVoterListWarning].'"); location.reload();</script>';
    }
  }
 }
@@ -117,7 +113,7 @@ if ($d4['id'] > 0){
   </style>
   
   <div class='row'>
-    <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 class='col-sm-10' style='height:100px; text-align:center;'><h1><?PHP echo $d['text_title'];?></h1><h3><?PHP echo $d['text_block'];?></h3></div>
   </div>
 
   <div class='row'>
@@ -129,10 +125,11 @@ if ($d4['id'] > 0){
   <?PHP echo $available;?>
 
   <div class='row'>
-    <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>     
-     
+    <div class='col-sm-10'><button type="submit" class="btn btn-success btn-lg btn-block"><img class='click_me' src="files/click_here.gif">Next</button></div>
+   </div>     
+  <div class='row'>
+    <div class='col-sm-10'><button type="button" class="btn btn-danger btn-lg btn-block" onclick="window.location.href='reset.php'">Reset / Restart</button></div>
+  </div>    
       
 </form>