function ClearResults($connection, $tournamentKey, $result) { $emptyDate = TournamentDetails::EMPTYDATE; $td = GetTournamentDetails($connection, $tournamentKey); if (isset($td)) { // Clear the fields. $file = null; switch ($result) { case 'Scores': case 'MatchPlayResults': $file = $td->ScoresFile; UpdateTournamentDetails($connection, $tournamentKey, 'ScoresFile', ''); UpdateTournamentDetails($connection, $tournamentKey, 'ScoresPostedDate', $emptyDate); break; case 'Chits': $file = $td->ChitsFile; UpdateTournamentDetails($connection, $tournamentKey, 'ChitsFile', ''); UpdateTournamentDetails($connection, $tournamentKey, 'ChitsPostedDate', $emptyDate); break; case 'Pool': $file = $td->PoolFile; UpdateTournamentDetails($connection, $tournamentKey, 'PoolFile', ''); UpdateTournamentDetails($connection, $tournamentKey, 'PoolPostedDate', $emptyDate); break; default: die('Unknown result type: ' . $result); } } // Delete the data ClearTableWithTournamentKey($connection, $result, $tournamentKey); // And remove the results html file too if (isset($file) && !empty($file)) { $file = "results/" . $file; if (file_exists($file)) { unlink($file); } } }
break; default: $overrideTitle = "Results"; break; } get_header(); echo ' <div id="content-container" class="entry-content">'; echo ' <div id="content" role="main">' . PHP_EOL; $tournamentKey = $_GET['tournament']; if (!isset($result)) { die("The requested result (scores/chits/pool) was not included in the URL"); } if ($tournamentKey) { $t = GetTournament($connection, $tournamentKey); if (isset($t)) { $td = GetTournamentDetails($connection, $tournamentKey); switch ($result) { case 'scores': ShowResultsHeader($connection, $t, 'Scores', ''); if (isset($td->ScoresFile) && !empty($td->ScoresFile)) { ShowFile($web_site, $td->ScoresFile); } else { if ($t->MatchPlay) { ShowMatchResults($connection, $t->TournamentKey); } else { $scoresResults = GetScoresResults($connection, $tournamentKey, $t->Stableford); ShowScoresResults($scoresResults, $t->Stableford, $t->StartDate !== $t->EndDate); } } break; case 'chits':
function ShowTournamentResultsLinks($connection, $tournament, $style, $skipThisResult, $script_folder_href) { $details = GetTournamentDetails($connection, $tournament->TournamentKey); if ($skipThisResult != 'Scores') { if ($details->ScoresPostedDate != TournamentDetails::EMPTYDATE || $tournament->MatchPlay) { echo '<td ' . $style . '><a href="' . $script_folder_href . 'results.php?tournament=' . $tournament->TournamentKey . '&result=scores">Scores</a></td>'; } else { echo '<td ' . $style . '>Scores</td>'; } } if ($skipThisResult != 'Chits') { if ($details->ChitsPostedDate != TournamentDetails::EMPTYDATE) { echo '<td ' . $style . '><a href="' . $script_folder_href . 'results.php?tournament=' . $tournament->TournamentKey . '&result=chits">Chits</a></td>'; } else { echo '<td ' . $style . '>Chits</td>'; } } if ($skipThisResult != 'Pool') { if ($details->PoolPostedDate != TournamentDetails::EMPTYDATE) { echo '<td ' . $style . '><a href="' . $script_folder_href . 'results.php?tournament=' . $tournament->TournamentKey . '&result=pool">Pool</a></td>'; } else { echo '<td ' . $style . '>Pool</td>'; } } if ($skipThisResult != 'Closest-To-The-Pin') { if (IsDateSet($details->ClosestToThePinPostedDate)) { echo '<td ' . $style . '><a href="' . $script_folder_href . 'closest_to_the_pin.php?tournament=' . $tournament->TournamentKey . '">Closest to Pin</a></td>'; } else { echo '<td ' . $style . '>Closest to Pin</td>'; } } }
date_default_timezone_set('America/Los_Angeles'); get_header(); $connection = new mysqli('p:' . $db_hostname, $db_username, $db_password, $db_database); if ($connection->connect_error) { die($connection->connect_error); } echo ' <div id="content-container" class="entry-content">'; echo ' <div id="content" role="main">'; ShowDues($script_folder_href); $currentTournaments = GetCurrentTournaments($connection); if (isset($currentTournaments) && count($currentTournaments) > 0) { $now = new DateTime("now"); echo '<h2>Current and Upcoming Tournaments:</h2>'; echo '<table style="border:none;margin-left:30px;">' . PHP_EOL; for ($i = 0; $i < count($currentTournaments); ++$i) { $details = GetTournamentDetails($connection, $currentTournaments[$i]->TournamentKey); $startSignUp = new DateTime($currentTournaments[$i]->SignupStartDate); $endSignUp = new DateTime($currentTournaments[$i]->SignupEndDate); $endSignUp->add(new DateInterval('PT12H00M')); // noon $endSignUpFriendlyDate = date('M d', strtotime($currentTournaments[$i]->SignupEndDate)); //echo 'now ' . $now->format('M d G') . '<br>'; //echo 'end ' . $endSignUp->format('M d G') . '<br>'; echo '<tr style="font-size:large;">'; echo '<td style="border:none">' . GetFriendlyTournamentDates($currentTournaments[$i]) . '</td>'; if ($currentTournaments[$i]->AnnouncementOnly) { if ($now >= $startSignUp) { echo '<td style="border:none;text-align:center" colspan="4"> ------ ' . $currentTournaments[$i]->Name . ' ------ </td>'; } } else { echo '<td style="border:none">' . $currentTournaments[$i]->Name . '</td>';