function getJoinQueryPrior() { //TODO //only include districts completed //get all districts $election_id = getPriorElectionID(); $result = getAllDistricts($election_id); $query = "SELECT responses.response, questions.question, district_id, machine_number, tally, election_districts.reg_voters"; $query .= " FROM questions,responses, results, election_districts WHERE results.response_id=responses.id AND responses.question_id=questions.id "; $query .= "AND election_districts.id = results.election_district_id AND election_districts.election_id = {$election_id}"; $query .= " ORDER BY questions.question, responses.response"; return $query; }
<input id="cb-select-all-2" type="checkbox"> </td> <th class="manage-column column-col_district_name" scope="col"><?php echo __('Name', 'idp-plugin'); ?> </th> <th class="manage-column column-col_district_ranking" scope="col"><?php echo __('Ranking', 'idp-plugin'); ?> </th> </tr> </tfoot> <tbody> <?php $districts = getAllDistricts(); $row_alternate = true; foreach ($districts as $district) { if ($row_alternate) { echo "<tr class=\"alternate\" valign=\"top\">"; } else { echo "<tr valign=\"top\">"; } echo "<th class=\"check-column\" scope=\"row\">"; echo "<label class=\"screen-reader-text\" for=\"cb-select-" . $district["district_id"] . "\">" . __('Select district', 'idp-plugin') . "</label>"; echo "<input id=\"cb-select-" . $district["district_id"] . "\" type=\"checkbox\" name=\"post[]\" value=\"" . $district["district_id"] . "\">"; echo "</th>"; echo "<td class=\"has-row-actions column-primary column-col_district_name\">"; echo $district["district_name"]; echo "<div class=\"row-actions\">"; echo "<span><a href=\"javascript:void(0)\" onclick=\"showDistrict(" . $district["district_id"] . ", '" . $district["district_bounds"] . "')\">" . __('Show bounds', 'idp-plugin') . "</a> |</span>";
function getSalesSummaryByDistrict($suppNo, $distNo = null) { //if distNo not set --> get all district and return an array // $districts[distNo] --> result include_once "District.php"; if (!isset($distNo)) { $result = getAllDistricts(); while ($row = $result->fetch_array()) { $districts[$row[distNo]] = getSalesSummaryByDistrict($suppNo, $row[distNo], "Sold", "DESC"); } return $districts; } $query = "SELECT District." . distNo . ", District." . distName . ", OrderLine." . prodNo . ", Product." . prodName . ", Product." . prodPhoto . ", Product." . catNo . ", Category." . catName . ", SUM(OrderLine." . qty . ") AS Sold " . "FROM OrderLine " . "JOIN CustOrder ON OrderLine." . ordNo . " = CustOrder." . ordNo . " " . "JOIN Product ON Product." . prodNo . " = OrderLine." . prodNo . " " . "JOIN Category ON Product." . catNo . " = Category." . catNo . " " . "JOIN District ON CustOrder." . distNo . " = District." . distNo . " " . "WHERE Product." . suppNo . " = '{$suppNo}' " . "AND District." . distNo . " = '{$distNo}' " . "AND " . isDeleted . " = 0 " . "GROUP BY Product." . prodNo . " " . DB::genOrderByStr(func_get_args(), func_num_args(), 2); return DB::query($query); }