<?php //Email notification script //Search the users in the db for anyone with at leat one game that is not picked //Count games in week //Count games user has picked //compare //If picked < games || score IS NULL) = send email // Load Databases and Common functions require "mysql.php"; include 'common.php'; include "functions.php"; //Site Functions //include('include/test_include.php'); //try to guess the current week, function in get_winners guessCurrentWeek(); $num_games = getNumberOfGames($this_season_year, $this_season_type, $this_week); $sql = "SELECT COUNT(pick_id) as num_picks, user_id FROM picks WHERE season_year='{$this_season_year}' AND season_type='{$this_season_type}' AND week='{$this_week}' GROUP BY user_id"; $result = mysqli_query($db, $sql) or die(mysqli_error($db)); while ($user = mysqli_fetch_array($result)) { if ($user['num_picks'] < $num_games) { echo 'User ' . getUserNameFromId($db, $user['user_id']) . ' has only picked ' . $user['num_picks'] . ' of ' . $num_games . ' send her an email at ' . getUserEmailFromId($db, $user['user_id']); notifyUser(getUserEmailFromId($db, $user['user_id']), getUserNameFromId($db, $user['user_id']), $num_games, $user['num_picks']); } }
function displayWeeklyStandings($db, $users, $season_year, $season_type, $week) { $num_games = getNumberOfGames($season_year, $season_type, $week); $percentages = array(); //$monday_night = getMondayNight($season_year,$season_type,$week); $monday_night_game_id = getMondayNightGame($season_year, $season_type, $week); $monday_kickoff_time = getMondayNightKickoffTime($monday_night_game_id); //echo 'Monday Night game '.$monday_night_game_id.' Kick Time '.$monday_kickoff_time; foreach ($users as $user) { $num_correct = getWeeklyPoints($db, $user['user_id'], $user['group_id'], $season_year, $season_type, $week); $score = getWeeklyScore($db, $user['user_id'], $user['group_id'], $monday_night_game_id); //returns array with score, gsis_id and winner // $score = getGameScore($monday_night_game_id); //$winner = getMondayNightWinner($monday_night_game_id); $percentage = $num_correct / $num_games * 100; //$percentages[$user['user_name']] = $percentage; $this_key = $user['user_name']; //$this_game_id = $score[0]; $totals[$this_key] = $num_correct; $scores[$this_key] = $score[1]; $winners[$this_key] = $score[2]; } /* arsort($percentages); $i=0; foreach($percentages as $u => $p) { echo "<div class=\"progress-label\">".$u."</div><div class=\"progress\">"; echo "<div class=\"progress-bar"; if($i==0 && $p > 0) { echo " progress-bar-success"; } echo "\" role=\"progressbar\" aria-valuenow=\"$p\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"min-width: 2em; width: $p%\"> $p% </div> </div>"; $i++; }*/ arsort($totals); $i = 0; $last_total = 0; echo ' <table class="progress-table"> <tr>'; if (strtotime($monday_kickoff_time) < time()) { echo '<th class="winner">Monday Night Winner</th><th class="score">Score</th>'; echo '<th class="user">User</th><th class="points">Points</th></tr>'; } foreach ($totals as $u => $n) { $length = $n / $num_games * 100; $length = round($length); $total_str = "{$n} ({$n}/{$num_games}, {$length}%)"; echo ' <tr>'; if (strtotime($monday_kickoff_time) < time()) { echo ' <td class="winner">' . $winners[$u] . '</td> <td class="score">' . $scores[$u] . '</td>'; } echo ' <td class="user"> <div class="progress-label">' . substr($u, 0, 12) . '</div> </td> <td class="points"> <div class="progress"> <div class="progress-bar'; if ($n > 0) { if ($i == 0 || $n == $last_total) { echo " progress-bar-success"; $last_total = $n; } } echo '" role="progressbar" aria-valuenow="' . $length . '" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: ' . $length . '%;">' . $total_str . '</div> </div> </td> </tr>'; $i++; } echo '</table>'; }