Skip to content

Commit

Permalink
Remaining region.php updates for #471
Browse files Browse the repository at this point in the history
  • Loading branch information
jteresco committed Jun 29, 2024
1 parent 60c2ece commit 2d0d99d
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions user/region.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ function redirect($link) {
JOIN listEntries le ON co.traveler = le.traveler
WHERE co.region = '$region' AND co.activeMileage > 0
GROUP BY co.traveler, le.includeInRanks
ORDER BY activeClinched DESC;
ORDER BY activeClinched DESC, le.includeInRanks DESC;
SQL;
$activeClinchedRes = tmdb_query($sql_command);
$row = tm_fetch_user_row_with_rank($activeClinchedRes, 'activeClinched');
// $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')";
$activeClinchedMileage = $row['activeClinched'];
if ($row['traveler'] != "" && $row['includeInRanks'] == "1") {
$activeMileageRank = $row['rank'];
$activeMileageRank = "Rank: ".$row['rank'];
} else {
$activeMileageRank = "N/A";
$activeMileageRank = "";
}

// build arrays that will form the contents of the travelers
Expand All @@ -196,6 +196,7 @@ function redirect($link) {
$activeClinchedRes->data_seek(0);
while ($row = $activeClinchedRes->fetch_assoc()) {
$activeTravelerInfo[$row['traveler']]['activeClinched'] = $row['activeClinched'];
$activeTravelerInfo[$row['traveler']]['includeInRanks'] = $row['includeInRanks'];
}

// and active+preview
Expand All @@ -208,16 +209,16 @@ function redirect($link) {
JOIN listEntries le ON co.traveler = le.traveler
WHERE co.region = '$region' AND co.activePreviewMileage > 0
GROUP BY co.traveler, le.includeInRanks
ORDER BY activePreviewClinched DESC;
ORDER BY activePreviewClinched DESC, le.includeInRanks DESC;
SQL;
$activePreviewClinchedRes = tmdb_query($sql_command);
$row = tm_fetch_user_row_with_rank($activePreviewClinchedRes, 'activePreviewClinched');
// $link = "redirect('/user/mapview.php?u=" . $tmuser . "&rg=" . $region . "')";
$activePreviewClinchedMileage = $row['activePreviewClinched'];
if ($row['traveler'] != "" && $row['includeInRanks'] == "1") {
$activePreviewMileageRank = $row['rank'];
$activePreviewMileageRank = "Rank: ".$row['rank'];
} else {
$activePreviewMileageRank = "N/A";
$activePreviewMileageRank = "";
}

// build arrays that will form the contents of the travelers
Expand All @@ -226,17 +227,18 @@ function redirect($link) {
$activePreviewClinchedRes->data_seek(0);
while ($row = $activePreviewClinchedRes->fetch_assoc()) {
$activePreviewTravelerInfo[$row['traveler']]['activePreviewClinched'] = $row['activePreviewClinched'];
$activePreviewTravelerInfo[$row['traveler']]['includeInRanks'] = $row['includeInRanks'];
}

echo "<tr class='notclickable'><td>Distance Traveled</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($activeClinchedMileage,$activeTotalMileage).';"';
echo "<td ".$style.">" . tm_convert_distance($activeClinchedMileage);
echo " of " . tm_convert_distance($activeTotalMileage) . " " . $tmunits . " (" . tm_percent($activeClinchedMileage, $activeTotalMileage) . "%) ";
echo "Rank: " . $activeMileageRank . "</td>";
echo $activeMileageRank . "</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($activePreviewClinchedMileage,$activePreviewTotalMileage).';"';
echo "<td ".$style.">" . tm_convert_distance($activePreviewClinchedMileage);
echo " of " . tm_convert_distance($activePreviewTotalMileage) . " " .$tmunits . " (" . tm_percent($activePreviewClinchedMileage, $activePreviewTotalMileage) . "%) ";
echo "Rank: " . $activePreviewMileageRank . "</td>";
echo $activePreviewMileageRank . "</td>";
echo "</tr>";

// Second, fetch routes clinched/driven
Expand Down Expand Up @@ -309,10 +311,10 @@ function redirect($link) {
$row = tm_fetch_user_row_with_rank($activeClinchedRes, 'clinched');
if ($row['traveler'] != "" && $row['includeInRanks'] == "1") {
$clinchedActiveRoutes = $row['clinched'];
$clinchedActiveRoutesRank = $row['rank'];
$clinchedActiveRoutesRank = "Rank: ".$row['rank'];
} else {
$clinchedActiveRoutes = 0;
$clinchedActiveRoutesRank = "N/A";
$clinchedActiveRoutesRank = "";
}

// Active only, driven
Expand Down Expand Up @@ -378,10 +380,10 @@ function redirect($link) {
$row = tm_fetch_user_row_with_rank($activeDrivenRes, 'driven');
if ($row['traveler'] != "" && $row['includeInRanks'] == "1") {
$drivenActiveRoutes = $row['driven'];
$drivenActiveRoutesRank = $row['rank'];
$drivenActiveRoutesRank = "Rank: ".$row['rank'];
} else {
$drivenActiveRoutes = 0;
$drivenActiveRoutesRank = "N/A";
$drivenActiveRoutesRank = "";
}

// add to the table of travelers by region stats
Expand Down Expand Up @@ -457,10 +459,10 @@ function redirect($link) {
$row = tm_fetch_user_row_with_rank($activePreviewClinchedRes, 'clinched');
if ($row['traveler'] != "" && $row['includeInRanks'] == "1") {
$clinchedActivePreviewRoutes = $row['clinched'];
$clinchedActivePreviewRoutesRank = $row['rank'];
$clinchedActivePreviewRoutesRank = "Rank: ".$row['rank'];
} else {
$clinchedActivePreviewRoutes = 0;
$clinchedActivePreviewRoutesRank = "N/A";
$clinchedActivePreviewRoutesRank = "";
}

// Active+Preview, driven
Expand Down Expand Up @@ -526,10 +528,10 @@ function redirect($link) {
$row = tm_fetch_user_row_with_rank($activePreviewDrivenRes, 'driven');
if ($row['traveler'] != "") {
$drivenActivePreviewRoutes = $row['driven'];
$drivenActivePreviewRoutesRank = $row['rank'];
$drivenActivePreviewRoutesRank = "Rank: ".$row['rank'];
} else {
$drivenActivePreviewRoutes = 0;
$drivenActivePreviewRoutesRank = "N/A";
$drivenActivePreviewRoutesRank = "";
}

// add to the table of travelers by region stats
Expand All @@ -544,17 +546,17 @@ function redirect($link) {
echo "<tr onClick=\"window.open('/shields/clinched.php?u={$tmuser}')\">";
echo "<td>Routes Traveled</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($drivenActiveRoutes,$totalActiveRoutes).';"';
echo "<td ".$style.">".$drivenActiveRoutes." of " . $totalActiveRoutes . " (". tm_percent($drivenActiveRoutes, $totalActiveRoutes) . "%) Rank: ".$drivenActiveRoutesRank."</td>";
echo "<td ".$style.">".$drivenActiveRoutes." of " . $totalActiveRoutes . " (". tm_percent($drivenActiveRoutes, $totalActiveRoutes) . "%) ".$drivenActiveRoutesRank."</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($drivenActivePreviewRoutes,$totalActivePreviewRoutes).';"';
echo "<td ".$style.">".$drivenActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . tm_percent($drivenActivePreviewRoutes, $totalActivePreviewRoutes, 2) . "%) Rank: ".$drivenActivePreviewRoutesRank."</td>";
echo "<td ".$style.">".$drivenActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . tm_percent($drivenActivePreviewRoutes, $totalActivePreviewRoutes, 2) . "%) ".$drivenActivePreviewRoutesRank."</td>";
echo "</tr>";

echo "<tr onClick=\"window.open('/shields/clinched.php?u={$tmuser}')\">";
echo "<td>Routes Clinched</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($clinchedActiveRoutes,$totalActiveRoutes).';"';
echo "<td ".$style.">".$clinchedActiveRoutes." of " . $totalActiveRoutes . " (" . tm_percent($clinchedActiveRoutes, $totalActiveRoutes) . "%) Rank: ". $clinchedActiveRoutesRank."</td>";
echo "<td ".$style.">".$clinchedActiveRoutes." of " . $totalActiveRoutes . " (" . tm_percent($clinchedActiveRoutes, $totalActiveRoutes) . "%) ". $clinchedActiveRoutesRank."</td>";
$style = 'style="background-color: '.tm_color_for_amount_traveled($clinchedActivePreviewRoutes,$totalActivePreviewRoutes).';"';
echo "<td ".$style.">".$clinchedActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . tm_percent($clinchedActivePreviewRoutes, $totalActivePreviewRoutes) . "%) Rank: ". $clinchedActivePreviewRoutesRank."</td>";
echo "<td ".$style.">".$clinchedActivePreviewRoutes." of " . $totalActivePreviewRoutes . " (" . tm_percent($clinchedActivePreviewRoutes, $totalActivePreviewRoutes) . "%) ". $clinchedActivePreviewRoutesRank."</td>";
echo "</tr>";

?>
Expand Down Expand Up @@ -669,6 +671,7 @@ function redirect($link) {
</thead>
<tbody>
<?php
$skipped = 0;
$prev_mileage = 0;
$pre_rank = 1;
$tie_rank = 1;
Expand All @@ -682,11 +685,18 @@ function redirect($link) {
$highlight = '';
}
$tie_rank = ($prev_mileage == $stats['activeClinched']) ? $tie_rank : $pre_rank;
if ($stats['includeInRanks'] == "1") {
$show_rank = $tie_rank - $skipped;
}
else {
$show_rank = "";
$skipped++;
}
$mileageStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['activeClinched'],$activeTotalMileage).';"';
$drivenStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['driven'],$totalActiveRoutes).';"';
$clinchedStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['clinched'],$totalActiveRoutes).';"';
echo "<tr class=\"".$highlight."\" onClick=\"window.document.location='?u=".$traveler."&rg=$region'\">";
echo "<td>".$tie_rank."</td>";
echo "<td>".$show_rank."</td>";
echo "<td>".$traveler."</td>";
echo "<td ".$mileageStyle.">".tm_convert_distance($stats['activeClinched'])."</td>";
$pct = round($stats['activeClinched'] / $activeTotalMileage * 100, 2);
Expand All @@ -707,6 +717,7 @@ function redirect($link) {
</thead>
<tbody>
<?php
$skipped = 0;
$prev_mileage = 0;
$pre_rank = 1;
$tie_rank = 1;
Expand All @@ -720,11 +731,18 @@ function redirect($link) {
$highlight = '';
}
$tie_rank = ($prev_mileage == $stats['activePreviewClinched']) ? $tie_rank : $pre_rank;
if ($stats['includeInRanks'] == "1") {
$show_rank = $tie_rank - $skipped;
}
else {
$show_rank = "";
$skipped++;
}
$mileageStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['activePreviewClinched'],$activePreviewTotalMileage).';"';
$drivenStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['driven'],$totalActivePreviewRoutes).';"';
$clinchedStyle = 'style="background-color: '.tm_color_for_amount_traveled($stats['clinched'],$totalActivePreviewRoutes).';"';
echo "<tr class=\"".$highlight."\" onClick=\"window.document.location='?u=".$traveler."&rg=$region'\">";
echo "<td>".$tie_rank."</td>";
echo "<td>".$show_rank."</td>";
echo "<td>".$traveler."</td>";
echo "<td ".$mileageStyle.">".tm_convert_distance($stats['activePreviewClinched'])."</td>";
$pct = round($stats['activePreviewClinched'] / $activePreviewTotalMileage * 100, 2);
Expand Down

1 comment on commit 2d0d99d

@jteresco
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit should reference #741, not #471

Please sign in to comment.