| @@ -11,9 +11,15 @@ if ($user->getRole() !== "admin") { | |||
| 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'); | |||
| @@ -25,7 +31,7 @@ $voters = $db->fetchAssoc('select ANY_VALUE(skymanager_id) as `skymanager_id`, A | |||
| <script type="text/javascript"> | |||
| var voters = <?= json_encode($voters); ?>; | |||
| </script> | |||
| <form> | |||
| <form action="checkin.php" method="POST"> | |||
| <div class="form-row"> | |||
| <div class="selector"> | |||
| <label class="radio"> | |||
| @@ -36,6 +42,10 @@ var voters = <?= json_encode($voters); ?>; | |||
| <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" /> | |||
| <a class="radio-button-label" href="/admin/results.php">Results</a> | |||
| </label> | |||
| </div> | |||
| </div> | |||
| <div class="form-row"> | |||
| @@ -46,7 +56,19 @@ var voters = <?= json_encode($voters); ?>; | |||
| <span class="placeholder">No Selected Voter</span> | |||
| </div> | |||
| </div> | |||
| <div class="form-row"> | |||
| <input class="submit" type="submit" name="submit" value="Check In" /> | |||
| </div> | |||
| </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 | |||
| $footer = new Footer(); | |||
| $footer->output(); | |||
| @@ -25,7 +25,7 @@ if (!empty($_POST['ballot']) && !empty($_POST['candidate'])) { | |||
| $candidate = $db->fetchRow('select skymanager_id, name, username, md5(coalesce(email, "")) as `gravatar_hash` from members where skymanager_id=' . $candidate_selected); | |||
| 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); | |||
| if ($num_affected_rows > 1) { | |||
| $proxy_str = ""; | |||
| @@ -69,6 +69,10 @@ var candidates = <?= json_encode($candidates); ?>; | |||
| <input type="radio" name="button" value="pe" checked /> | |||
| <a class="radio-button-label" href="#">Paper Entry</a> | |||
| </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 class="form-row"> | |||
| @@ -132,7 +136,7 @@ var candidates = <?= json_encode($candidates); ?>; | |||
| </div> | |||
| <div class="ballot-section"> | |||
| <h4 class="section-heading">Voter ID</h4> | |||
| <h4 id="ballot-voter-id">#<?= $user->voterId(); ?></h4> | |||
| <h4 id="ballot-voter-id">#<?= $voter_selected; ?></h4> | |||
| </div> | |||
| <?php if ($proxy_str): ?> | |||
| <div class="ballot-section"> | |||
| @@ -0,0 +1,69 @@ | |||
| <?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(); | |||
| @@ -1,7 +1,3 @@ | |||
| div#selectedCandidate::before { | |||
| content: 'Selected Voter'; | |||
| } | |||
| .profile.ineligible { | |||
| color: #c00; | |||
| } | |||
| @@ -24,7 +24,7 @@ if (!$error) { | |||
| if ($result) { | |||
| $to = 'mf2021elec@gmail.com'; | |||
| $from = 'noreply@tyzoid.com'; | |||
| $subject = "[TEST] Ballot Submitted ({$user->voterId()} -> {$candidate['skymanager_id']})"; | |||
| $subject = "Ballot Submitted ({$user->voterId()} -> {$candidate['skymanager_id']})"; | |||
| $headers = | |||
| "From: {$from}\r\n" . | |||
| "Message-ID: 2021election-voter-{$user->voterId()}-{$ballot}-" . mt_rand() . "@tyzoid.com\r\n"; | |||