Skip to content

Commit

Permalink
Address Issue #1580
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffhumphrey committed Oct 16, 2024
1 parent b0fee14 commit 6844dcc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
27 changes: 22 additions & 5 deletions output/export.output.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
if ((($go == "judging_scores_bos") || ($go == "judging_scores")) && (($view == "html") || ($view == "pdf"))) $authorized = TRUE;
}

if ($section == "export-personal-results") $authorized = TRUE;

if (!$authorized) {
$redirect = "../../403.php";
$redirect_go_to = sprintf("Location: %s", $redirect);
Expand Down Expand Up @@ -65,6 +67,10 @@
* info from BJCP XML output.
*/

// Run the integrity function.
// This will make sure that user ids line up with brewer uids, etc.
if ($authorized) data_integrity_check();

// Queries for current data
if ($filter == "default") {
$winner_method = $_SESSION['prefsWinnerMethod'];
Expand Down Expand Up @@ -3308,7 +3314,7 @@ function mysqli_field_name($result, $field_offset) {

if ((isset($_SESSION['loginUsername'])) && ($section == "export-personal-results") && ($id != "default")) {

$query_brewer = sprintf("SELECT DISTINCT a.brewCategory, a.brewSubCategory, a.id AS eid, a.brewStyle, a.brewInfo, a.brewInfoOptional, a.brewComments, b.scoreEntry, b.scorePlace, c.brewerFirstName, c.brewerLastName, c.brewerClubs, c.brewerEmail, c.brewerMHP FROM %s a, %s b, %s c WHERE a.brewBrewerID = '%s' AND b.bid = '%s' AND c.uid = '%s' AND a.id = b.eid", $prefix."brewing", $prefix."judging_scores", $prefix."brewer", $id, $id, $id);
$query_brewer = sprintf("SELECT DISTINCT a.brewCategory, a.brewSubCategory, a.id AS eid, a.brewStyle, a.brewInfo, a.brewInfoOptional, a.brewComments, b.scoreEntry, b.scorePlace, c.brewerFirstName, c.brewerLastName, c.brewerClubs, c.brewerEmail, c.brewerMHP, c.brewerBreweryName FROM %s a, %s b, %s c WHERE a.brewBrewerID = '%s' AND b.bid = '%s' AND c.uid = '%s' AND a.id = b.eid", $prefix."brewing", $prefix."judging_scores", $prefix."brewer", $id, $id, $id);
$brewer = mysqli_query($connection,$query_brewer);
$row_brewer = mysqli_fetch_assoc($brewer);
$totalRows_brewer = mysqli_num_rows($brewer);
Expand All @@ -3327,7 +3333,7 @@ function mysqli_field_name($result, $field_offset) {
// Results data headers
$results[] = array("Category", "Category Name", "Required Info", "Official Score", "Highest Score", "Place");

if ($row_brewer) {
if (($row_brewer) && ($totalRows_brewer > 0)) {

do {

Expand Down Expand Up @@ -3396,6 +3402,7 @@ function mysqli_field_name($result, $field_offset) {
if ($results_count == $totalRows_brewer) {
$first_name = convert_to_entities($row_brewer['brewerFirstName']);
$last_name = convert_to_entities($row_brewer['brewerLastName']);
$org_name = convert_to_entities($row_brewer['brewerBreweryName']);
$club = convert_to_entities($row_brewer['brewerClubs']);
$email = convert_to_entities($row_brewer['brewerEmail']);
if ($filter == "MHP") $mhp = convert_to_entities($row_brewer['brewerMHP']);
Expand All @@ -3418,8 +3425,17 @@ function mysqli_field_name($result, $field_offset) {
}

else {
$personal[] = array("Last Name", "First Name", "Club", "Email");
$personal[] = array($last_name,$first_name,$club,$email);

if ($_SESSION['prefsProEdition'] == 1) {
$personal[] = array("Organization Name", "Contact Email");
$personal[] = array($org_name,$email);
}

else {
$personal[] = array("Last Name", "First Name", "Club", "Email");
$personal[] = array($last_name,$first_name,$club,$email);
}

}

// Spacer
Expand All @@ -3437,7 +3453,8 @@ function mysqli_field_name($result, $field_offset) {
$separator = ",";
$extension = ".csv";
$date = date("m-d-Y");
$filename = $first_name."_".$last_name."_Personal_Results_".$_SESSION['contestName']."_";
if ($_SESSION['prefsProEdition'] == 1) $filename = $org_name."_Organization_Results_".$_SESSION['contestName']."_";
else $filename = $first_name."_".$last_name."_Personal_Results_".$_SESSION['contestName']."_";
if ($filter == "MHP") $filename .= "MHP_";
$filename .= $date.$extension;
$filename = filename($filename);
Expand Down
5 changes: 4 additions & 1 deletion sections/brewer_entries.sec.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@

if (($totalRows_log > 0) && ($show_scores)) {

if ($_SESSION['prefsProEdition'] == 1) $pay_button_label = $label_results_export;
else $pay_button_label = $label_results_export_personal;

$link_results_export = $base_url."includes/output.inc.php?section=export-personal-results&id=".$_SESSION['brewerID'];
$pay_button .= sprintf("<a href=\"%s\" class=\"btn btn-success hide-loader\" target=\"_blank\"><i class=\"fa fa-lg fa-file-csv\" style=\"margin-right: 8px;\"></i>%s</a>",$link_results_export, $label_results_export_personal);
$pay_button .= sprintf("<a href=\"%s\" class=\"btn btn-success hide-loader\" target=\"_blank\"><i class=\"fa fa-lg fa-file-csv\" style=\"margin-right: 8px;\"></i>%s</a>",$link_results_export, $pay_button_label);

}

Expand Down

0 comments on commit 6844dcc

Please sign in to comment.