function showVoteInput($q) { $info = explode(".", $q); $district = $info[0]; $machine = $info[1]; echo "<center><h1 class='title'>Enter Election Results for District: <span class='big'>{$district}</span>, Machine: <span class='big'>{$machine}</span></h1></center>"; echo "<form action = './saveInputs.php' method ='post'>"; //get categories $categoriesResult = getCategories(); $count = 0; $categoryCount = 0; echo "<table><tr><td class='category'>"; while ($category = mysql_fetch_array($categoriesResult)) { //get candidates $id = $category['category_id']; //echo " ID = {$id} "; $candidates = getCandidates($id); echo "<h1> {$category['category_name']}</h1><table>"; while ($candidate = mysql_fetch_array($candidates)) { $info = "{$district},{$machine},{$candidate['candidate_id']},"; //echo $info; $hidden = "candidateID" . $count++; echo "<tr><td width = 25px></td><td>{$candidate['candidate_name']}</td><td>"; echo "<input type ='number' id='{$candidate['candidate_id']}' name='{$candidate['candidate_id']}' value = "; echo "'"; echo getElectionResults($district, $machine, $candidate['candidate_id']); echo "'"; //$functionStr = "ajaxGetInfo({$info}, this.value)"; // . $info . ")"; echo " oninput='ajaxGetInfo(this.value, this.name)' min=0></td></tr>"; echo "<input type=hidden name = {$hidden} METHOD='POST' value='{$candidate['candidate_id']}'>"; // echo "<input type=hidden name = 'candidateID' METHOD='POST' value='{$candidate['candidate_id']}'>"; } echo "</table>"; echo "<input type=hidden id = 'district' value='{$district}'>"; echo "<input type=hidden id = 'machine' value='{$machine}'>"; if ($categoryCount % 3 == 2) { echo "</td><td style='padding-left:45px'>"; } $categoryCount++; } echo "</td></tr></table>"; }
function createOverviewTableForCategory($category_id) { global $variables; $table = $variables['categoriesTableName']; $query = "SELECT * FROM {$table} WHERE {$variables['category_id_categories']} = {$category_id}"; $result = mysql_query($query) or die(" Find createOverviewTableForCategory query Failed!" . mysql_error()); $category = mysql_fetch_array($result); $text = "<table class='overviewOuter'>"; $text .= createDistrictMachineHeader($category['category_name']); //get each candidate $candidates = getCandidates($category_id); while ($candidate = mysql_fetch_array($candidates)) { $text .= "<tr><td class='overviewNoWrap'>{$candidate['candidate_name']}</td>"; //TODO get machines and districts //data entered $machineArray = getArrayOfMachines(); foreach ($machineArray as $machineInfo) { $district = $machineInfo[0]; $machine = $machineInfo[1]; $text .= "<td class='overview'>"; $text .= getElectionResults($district, $machine, $candidate['candidate_id']); $text .= "</td>"; } $text .= "</tr>"; } //get votes for each cell $text .= "</table>"; return $text; }
function createOverviewTableForCategory($category_id) { global $variables; global $conn; $table = $variables['categoriesTableName']; $query = "SELECT * FROM {$table} WHERE id = {$category_id}"; $result = runQuery($query); $category = $result->fetch_assoc(); //mysql_fetch_array($result); $text = "<table class='overviewOuter' id='table1'>"; $text .= createDistrictMachineHeader($category['question']); //election id $election_id = getCurrentElectionID(); //get each candidate $candidates = getCandidates($category_id); while ($candidate = $candidates->fetch_assoc()) { //mysql_fetch_array($candidates)){ $text .= "<tr><td class='overviewNoWrap'>{$candidate['response']}</td>"; // get machines and districts $machineArray = getArrayOfMachinesForElection($election_id); foreach ($machineArray as $machineInfo) { $district = $machineInfo[0]; //echo "District $district <br>"; $machine = $machineInfo[1]; $text .= "<td class='tally'>"; $text .= getElectionResults($district, $machine, $candidate['id']); $text .= "</td>"; } $text .= "<td class='tally'>" . getTotalTally($category_id, $candidate['response'], $election_id) . "</td>"; $text .= "</tr>"; } /* if(is_numeric(stripos($category['question'], "Machine"))){ $text .= createDistrictVotesRow($category_id); $text .= createRegisteredVotersRow($category_id); $text .= createPercentageRow($category_id); } */ $text .= createMachineSumRow($category_id); $text .= createDistrictVotesRow($category_id); $text .= createRegisteredVotersRow($category_id); $text .= createPercentageRow($category_id); $text .= "</table>"; return $text; }
function showVoteInput($q) { //Not editable if prior election $canEdit = $_SESSION['is_active']; //Can't edit if readonly user if (!(stripos($_SESSION['privilege'], 'read') === false)) { $canEdit = false; } $info = explode(".", $q); $district = $info[0]; $machine = $info[1]; //get name of district $query = "Select * from districts where id = {$district}"; //$result = mysql_query($query) or die("Query Failed!" . $query); $result = runQuery($query); $districtInfo = $result->fetch_assoc(); //mysql_fetch_array($result); $name = $districtInfo['name']; echo "<center><h1 class='title'>Enter Election Results for District: <span class='big'>{$name}</span>, Machine: <span class='big'>{$machine}</span></h1></center>"; echo "<form action = './saveInputs.php' method ='post'>"; //get categories $election_id = getCurrentElectionID(); $categoriesResult = getCategories($election_id); $count = 0; $categoryCount = 0; echo "<table><tr><td class='category'>"; while ($category = $categoriesResult->fetch_assoc()) { //get candidates $id = $category['id']; //echo " ID = {$id} "; $candidates = getCandidates($id); echo "<h1> {$category['question']}</h1><table>"; while ($candidate = $candidates->fetch_assoc()) { $hidden = "candidateID" . $count++; echo "<tr><td width = 25px></td><td>{$candidate['response']}</td><td>"; echo "<input type ='number' id='{$candidate['id']}' name='{$candidate['id']}' value = "; echo "'"; echo getElectionResults($district, $machine, $candidate['id']); echo "'"; if ($canEdit) { echo " oninput='ajaxGetInfo(this.value, this.name)' min=0>"; } else { //READONLY echo " READONLY>"; } echo "</td></tr>"; echo "<input type=hidden name = {$hidden} METHOD='POST' value='{$candidate['id']}'>"; // echo "<input type=hidden name = 'candidateID' METHOD='POST' value='{$candidate['candidate_id']}'>"; } echo "</table>"; echo "<input type=hidden id = 'district' value='{$district}'>"; echo "<input type=hidden id = 'machine' value='{$machine}'>"; if ($categoryCount % 3 == 2) { echo "</td><td style='padding-left:45px'>"; } $categoryCount++; } echo "</td></tr></table>"; echo "<input type=hidden name = 'maxCount' value='{$count}'>"; // echo "<input type=hidden name = 'maxCategoryCount' value='{$categoryCount}'>"; }