| die(); | die(); | ||||
| } | } | ||||
| if (!empty($_POST['voter']) && ((int) $_POST['voter']) == $_POST['voter']) { | |||||
| $voter = (int) $_POST['voter']; | |||||
| $result = $db->query("update members set checkedin=true where voting_id=$voter"); | |||||
| } | |||||
| $header = new Header("2021 Michigan Flyers Election : Poll Worker"); | $header = new Header("2021 Michigan Flyers Election : Poll Worker"); | ||||
| $header->addStyle("/styles/style.css"); | $header->addStyle("/styles/style.css"); | ||||
| $header->addStyle("/styles/admin.css"); | $header->addStyle("/styles/admin.css"); | ||||
| $header->addStyle("/styles/vote.css"); | |||||
| $header->addScript("/js/jquery-1.11.3.min.js"); | $header->addScript("/js/jquery-1.11.3.min.js"); | ||||
| $header->addScript("/js/admin-search.js"); | $header->addScript("/js/admin-search.js"); | ||||
| $header->setAttribute('title', 'Michigan Flyers'); | $header->setAttribute('title', 'Michigan Flyers'); | ||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||
| var voters = <?= json_encode($voters); ?>; | var voters = <?= json_encode($voters); ?>; | ||||
| </script> | </script> | ||||
| <form> | |||||
| <form action="checkin.php" method="POST"> | |||||
| <div class="form-row"> | <div class="form-row"> | ||||
| <div class="selector"> | <div class="selector"> | ||||
| <label class="radio"> | <label class="radio"> | ||||
| <input type="radio" name="button" value="pe" /> | <input type="radio" name="button" value="pe" /> | ||||
| <a class="radio-button-label" href="/admin/paper.php">Paper Entry</a> | <a class="radio-button-label" href="/admin/paper.php">Paper Entry</a> | ||||
| </label> | </label> | ||||
| <label class="radio"> | |||||
| <input type="radio" name="button" value="re" /> | |||||
| <a class="radio-button-label" href="/admin/results.php">Results</a> | |||||
| </label> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="form-row"> | <div class="form-row"> | ||||
| <span class="placeholder">No Selected Voter</span> | <span class="placeholder">No Selected Voter</span> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="form-row"> | |||||
| <input class="submit" type="submit" name="submit" value="Check In" /> | |||||
| </div> | |||||
| </form> | </form> | ||||
| <?php if (!empty($voter)): ?> | |||||
| <div id="vote-result"> | |||||
| <div id="status" class="<?= $result ? "success" : "failure"; ?>"></div> | |||||
| <div id="message" class="<?= $result ? "success" : "failure"; ?>"> | |||||
| <?= !empty($error) ? $error : ($result ? "The member has been checked in" : | |||||
| "The member could not be checked in") ?> | |||||
| </div> | |||||
| </div> | |||||
| <?php endif; ?> | |||||
| <?php | <?php | ||||
| $footer = new Footer(); | $footer = new Footer(); | ||||
| $footer->output(); | $footer->output(); |
| $candidate = $db->fetchRow('select skymanager_id, name, username, md5(coalesce(email, "")) as `gravatar_hash` from members where skymanager_id=' . $candidate_selected); | $candidate = $db->fetchRow('select skymanager_id, name, username, md5(coalesce(email, "")) as `gravatar_hash` from members where skymanager_id=' . $candidate_selected); | ||||
| if ($result) { | if ($result) { | ||||
| $proxy_votes = $db->fetchAssoc("SELECT member_id, submitter_id from votes where submitter_id={$user->voterId()} and position=\"$ballot\""); | |||||
| $proxy_votes = $db->fetchAssoc("SELECT member_id, submitter_id from votes where submitter_id=$voter_selected and position=\"$ballot\""); | |||||
| $num_affected_rows = count($proxy_votes); | $num_affected_rows = count($proxy_votes); | ||||
| if ($num_affected_rows > 1) { | if ($num_affected_rows > 1) { | ||||
| $proxy_str = ""; | $proxy_str = ""; | ||||
| <input type="radio" name="button" value="pe" checked /> | <input type="radio" name="button" value="pe" checked /> | ||||
| <a class="radio-button-label" href="#">Paper Entry</a> | <a class="radio-button-label" href="#">Paper Entry</a> | ||||
| </label> | </label> | ||||
| <label class="radio"> | |||||
| <input type="radio" name="button" value="re" /> | |||||
| <a class="radio-button-label" href="/admin/results.php">Results</a> | |||||
| </label> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="form-row"> | <div class="form-row"> | ||||
| </div> | </div> | ||||
| <div class="ballot-section"> | <div class="ballot-section"> | ||||
| <h4 class="section-heading">Voter ID</h4> | <h4 class="section-heading">Voter ID</h4> | ||||
| <h4 id="ballot-voter-id">#<?= $user->voterId(); ?></h4> | |||||
| <h4 id="ballot-voter-id">#<?= $voter_selected; ?></h4> | |||||
| </div> | </div> | ||||
| <?php if ($proxy_str): ?> | <?php if ($proxy_str): ?> | ||||
| <div class="ballot-section"> | <div class="ballot-section"> |
| <?php | |||||
| include('../inc/inc.php'); | |||||
| if (!$user->loggedin()) { | |||||
| header('Location: /login.php'); | |||||
| die(); | |||||
| } | |||||
| if ($user->getRole() !== "admin") { | |||||
| header('Location: /index.php'); | |||||
| die(); | |||||
| } | |||||
| if (!empty($_POST['voter']) && ((int) $_POST['voter']) == $_POST['voter']) { | |||||
| $voter = (int) $_POST['voter']; | |||||
| $result = $db->query("update members set checkedin=true where voting_id=$voter"); | |||||
| } | |||||
| $header = new Header("2021 Michigan Flyers Election : Poll Worker"); | |||||
| $header->addStyle("/styles/style.css"); | |||||
| $header->addStyle("/styles/admin.css"); | |||||
| $header->addStyle("/styles/vote.css"); | |||||
| $header->addScript("/js/jquery-1.11.3.min.js"); | |||||
| $header->addScript("/js/admin-search.js"); | |||||
| $header->setAttribute('title', 'Michigan Flyers'); | |||||
| $header->setAttribute('tagline', '2021 Election Administration'); | |||||
| $header->output(); | |||||
| $checkedin = $db->fetchAssoc('select name, username, voting_id, NULL as `proxy` from members where checkedin=true UNION select voter.name, voter.username, voter.voting_id, members.voting_id as `proxy` from members left join proxy on (proxy.delegate_id=members.voting_id) left join members as `voter` on (voter.voting_id=proxy.voting_id) where members.checkedin = true'); | |||||
| $members = $db->fetchRow('select count(*) as `count` from members where voting_id is not null'); | |||||
| $count = $members['count']; | |||||
| $results = $db->fetchAssoc('select votes.position, members.name, count(*) as `votes` from votes left join members on (votes.candidate_id=members.skymanager_id) group by candidate_id, position'); | |||||
| ?> | |||||
| <form> | |||||
| <div class="form-row"> | |||||
| <div class="selector"> | |||||
| <label class="radio"> | |||||
| <input type="radio" name="button" value="ci" /> | |||||
| <a class="radio-button-label" href="/admin/checkin.php">Check-In</a> | |||||
| </label> | |||||
| <label class="radio"> | |||||
| <input type="radio" name="button" value="pe" /> | |||||
| <a class="radio-button-label" href="/admin/paper.php">Paper Entry</a> | |||||
| </label> | |||||
| <label class="radio"> | |||||
| <input type="radio" name="button" value="re" checked /> | |||||
| <a class="radio-button-label" href="#">Results</a> | |||||
| </label> | |||||
| </div> | |||||
| </div> | |||||
| </form> | |||||
| <h2>Quorum</h2> | |||||
| <h4><?= count($checkedin) ?> / <?= ceil($count * 0.2) ?> required</h4> | |||||
| <table border=1> | |||||
| <thead><tr><th>Position</th><th>Candidate</th><th>Votes</th></tr></thead> | |||||
| <tbody> | |||||
| <?php foreach ($results as $line): ?> | |||||
| <tr> | |||||
| <td><?= $line['position'] ?></td> | |||||
| <td><?= $line['name'] ?></td> | |||||
| <td><?= $line['votes'] ?></td> | |||||
| </tr> | |||||
| <?php endforeach; ?> | |||||
| </tbody> | |||||
| </table> | |||||
| <?php | |||||
| $footer = new Footer(); | |||||
| $footer->output(); |
| div#selectedCandidate::before { | |||||
| content: 'Selected Voter'; | |||||
| } | |||||
| .profile.ineligible { | .profile.ineligible { | ||||
| color: #c00; | color: #c00; | ||||
| } | } |
| if ($result) { | if ($result) { | ||||
| $to = 'mf2021elec@gmail.com'; | $to = 'mf2021elec@gmail.com'; | ||||
| $from = 'noreply@tyzoid.com'; | $from = 'noreply@tyzoid.com'; | ||||
| $subject = "[TEST] Ballot Submitted ({$user->voterId()} -> {$candidate['skymanager_id']})"; | |||||
| $subject = "Ballot Submitted ({$user->voterId()} -> {$candidate['skymanager_id']})"; | |||||
| $headers = | $headers = | ||||
| "From: {$from}\r\n" . | "From: {$from}\r\n" . | ||||
| "Message-ID: 2021election-voter-{$user->voterId()}-{$ballot}-" . mt_rand() . "@tyzoid.com\r\n"; | "Message-ID: 2021election-voter-{$user->voterId()}-{$ballot}-" . mt_rand() . "@tyzoid.com\r\n"; |