Exemple #1
0
<?php

// Season Selector
$my_points = getWeeklyPoints($db, $this_user_id, $this_group_id, $this_season_year, $this_season_type, $this_week);
// functions.php
$current_time = date("l h:iA T", time());
?>

<nav class="navbar navbar-inverse navbar-fixed-top weekSelector">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar2" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
      </button>
    </div><!--/.navbar-header -->
    <p class="weekSelector-text">Your Picks for <?php 
echo "{$this_season_year} {$this_season_type} Week {$this_week}";
?>
</p>
    <div id="navbar2" class="navbar-collapse collapse weekSelector">
     <ul class="nav navbar-nav weekSelector">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php 
echo getGroupName($db, $this_group_id);
?>
 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li class="dropdown-header">Groups</li>
            <?php 
$groups = getGroups($db, $this_user_id);
Exemple #2
0
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>';
}
Exemple #3
0
function updatePoints($db, $user_id, $group_id, $season_year, $season_type, $week, $verbose)
{
    // check picks table for games that match season/week and sum them
    //$sql = "SELECT SUM(points) AS points_sum FROM picks WHERE user_id='$user_id' AND season_year='$season_year' AND season_type='$season_type' AND week='$week'";
    //$result = mysqli_query($db,$sql);
    //$row = mysqli_fetch_assoc($result);
    //$sum = $row['points_sum'];
    //echo $sum;
    $sum = getWeeklyPoints($db, $user_id, $group_id, $season_year, $season_type, $week);
    $sql = "SELECT * FROM points WHERE user_id='{$user_id}' AND group_id='{$group_id}' AND season_year='{$season_year}' AND season_type='{$season_type}' AND week='{$week}'";
    $result = mysqli_query($db, $sql);
    if (mysqli_num_rows($result) > 0) {
        // user has points for week in db so update
        // update points total in points table for user
        $sql = "UPDATE points SET points='{$sum}' WHERE user_id='{$user_id}' AND group_id='{$group_id}' AND season_year='{$season_year}' AND season_type='{$season_type}' AND week='{$week}'";
        //$result = mysqli_query($db,$sql);
        if (mysqli_query($db, $sql)) {
            if ($verbose) {
                echo "Point total for user_id {$user_id} in group_id {$group_id} for {$season_year} {$season_type} Week {$week} updated to {$sum}.<br>\n";
            }
            return mysqli_insert_id($db);
        } else {
            echo mysqli_error($db);
        }
    } else {
        //no point total has been added so insert
        $sql = "INSERT INTO points (points_id, user_id, group_id, season_year, season_type, week, points,winner) VALUES (NULL,'{$user_id}','{$group_id}','{$season_year}','{$season_type}','{$week}',{$sum},NULL)";
        if (mysqli_query($db, $sql)) {
            if ($verbose) {
                echo "Point total for user_id {$user_id} in group_id {$group_id} for {$season_year} {$season_type} Week {$week} inserted as {$sum}.<br>\n";
            }
            return mysqli_insert_id($db);
        } else {
            echo mysqli_error($db);
        }
    }
}