<?php
/**
* FFL Team overview and editing
*
* Used to:
* <ol>
* <li>Display teams in a league</li>
* <li>Display details of a single team</li>
* <li>Edit a team</li>
* <li>Add/delete a team (Admin only)</li>
* </ol>
*
* @author Stephen Rochelle <hide@address.com>
* @version OFFL v0.2
* @copyright Copyright (c) 2004 Stephen Rochelle. Some rights reserved.
* @package offl-ui
*/
require_once("offlconfig.php");
require_once($DOC_ROOT . "/lib/functions.php");
if(empty($_GET["action"]))
{ $_GET["action"] = NULL; }
if(empty($_REQUEST["mode"]))
{ $_REQUEST["mode"] = NULL; }
if(empty($_GET["year"]))
{ $_GET["year"] = getThisYear(); }
$pageTitle = $_GET["year"] . " Team Info";
require_once($DOC_ROOT . "/lib/header.php");
if(isset($_GET["fflteam_id"]))
{
$thisTeam = new OFFL_FFLTeam($_GET["fflteam_id"]);
if (isset($_GET["league_id"]));
{ $thisTeam->setLeagueID($_GET["league_id"]); }
$thisLeague = new OFFL_League($thisTeam->getLeagueID());
$thisUser = new OFFL_User($thisTeam->getUserID());
if(!empty($thisTeam->_emsg))
{
?><div class="alert"><?php echo $thisTeam->_emsg; ?></div><?php
}
}
elseif(isset($_SESSION["league_id"]))
{
if (isset($_SESSION["fflteam_id"]))
{
$thisTeam = new OFFL_FFLTeam($_SESSION["fflteam_id"]);
$thisUser = new OFFL_User($thisTeam->getUserID());
}
$thisLeague = new OFFL_League($_SESSION["league_id"]);
if(!empty($thisTeam->_emsg))
{
?><div class="alert"><?php echo $thisTeam->_emsg; ?></div><?php
}
}
// Stub team object
// $thisTeam = new OFFL_FFLTeam();
// user is saving info (edit or add)
if($_GET["action"] == "save")
{
if(($_REQUEST["mode"] == "add") && !$_SESSION["admin"])
{
echo "<p class=\"error\">Must have admin rights to add a team!</p>\n";
require("$DOC_ROOT/lib/footer.php");
die();
}
// If edit, get the existing record
if($_REQUEST["mode"] == "edit")
{
$thisTeam = new OFFL_FFLTeam($_GET["fflteam_id"]);
if ($_GET["division_id"] > 0)
{
$thisDivision = new OFFL_Division($_GET["division_id"]);
$_GET["league_id"] = $thisDivision->getLeagueID();
}
else
{
$_GET["league_id"] = 0;
}
}
elseif($_REQUEST["mode"] == "add") // this is a new team
{
$thisTeam = new OFFL_FFLTeam();
$thisTeam->setDivisionID($_GET["division_id"]);
$thisTeam->setLeagueID($_GET["league_id"]);
$thisTeam->setUserID($_GET["user_id"]);
$thisTeam->setWaiverPriority(); /* autoinserts */
}
// Populate fields with form data
$thisTeam->setFFLTeamCity($_GET["fflteam_city"]);
$thisTeam->setFFLTeamName($_GET["fflteam_name"]);
// functionality moved to uploadlogo.php
// if(!empty($_GET["fflteam_logo"]))
// { $thisTeam->setFFLTeamLogo($_GET["fflteam_logo"]); }
if(!empty($_SESSION["admin"])) {
// Don't want to set this unless it's set by admin
$thisTeam->setDivisionID($_GET["division_id"]);
$thisTeam->setLeagueID($_GET["league_id"]);
$thisTeam->setUserID($_GET["user_id"]);
}
if(!empty($_GET["stadium_name"]))
{ $thisTeam->setStadiumName($_GET["stadium_name"]); }
if(!empty($_GET["coach_head"]))
{ $thisTeam->setCoachHead($_GET["coach_head"]); }
if(!empty($_GET["coach_off"]))
{ $thisTeam->setCoachOff($_GET["coach_off"]); }
if(!empty($_GET["coach_def"]))
{ $thisTeam->setCoachDef($_GET["coach_def"]); }
if(!empty($_GET["coach_spec"]))
{ $thisTeam->setCoachSpec($_GET["coach_spec"]); }
$thisTeam->save();
if ($_REQUEST["mode"] == "add")
{
$thisUser = new OFFL_User($thisTeam->getUserID());
$thisUser->addLeagueID($thisTeam->getLeagueID());
$thisUser->addFFLTeamID($thisTeam->getFFLTeamID());
$thisUser->save();
}
?><div class="success">Team <?php echo $thisTeam->getFFLTeamCity() . " " . $thisTeam->getFFLTeamName(); ?> successfully saved.</div><p>
<META http-equiv="refresh" content="1; URL=<?php echo "$WEB_ROOT/teams.php"; if($_SESSION["admin"]) echo "?mode=admin"; ?>">
<?php
}
else
{
switch ($_REQUEST["mode"])
{
case "admin":
/************************************************
*
*
* ADMIN SECTION
*
* (GOTTA REHASH THIS MUG)
************************************************/
$showall = FALSE;
if (isset($_REQUEST["showallteams"]))
{ $showall = TRUE; }
$teams = $thisLeague->getAllFFLTeams($showall); // assume league-only for now
?>
<div id="edit-teams">
<h3>Edit Teams</h3>
<table>
<thead>
<tr><th>Team</th><th>Owner</th><th></th></tr>
</thead>
<tfoot><tr><td colspan="3"></td></tr></tfoot>
<tbody>
<?php
foreach ($teams as $team)
{
$user = new OFFL_User($team->getUserID());
echo " <tr>\n <td>" . $team->getFFLTeamFullName() . "</td>\n";
echo " <td>" . $user->getName() . "</td>\n";
echo " <td><a href=\"" . $WEB_ROOT . "/teams.php?mode=edit&fflteam_id=" . $team->getFFLTeamID() . "\">[EDIT]</a></td>\n </tr>\n";
}
?>
</tbody>
</table>
<p><a href="<?php echo $WEB_ROOT; ?>/teams.php?mode=admin&showallteams=on">Edit All Teams</a></p>
</div>
<div id="add-team">
<h3>Add Team</h3>
<form name="addteam" action="<?php echo $WEB_ROOT; ?>/teams.php" method="post">
<input type="hidden" name="mode" value="add" />
<table>
<thead>
<tr><th>Owner</th><th>League</th><th></th></tr>
</thead>
<tfoot><tr><td colspan="3"></td></tr></tfoot>
<tbody><tr>
<td><select name="user_id">
<option value="" selected>Select User Account</option>
<?php
if (!isset($myuser))
{ $myuser = new OFFL_User(); }
$users = $myuser->getAllUsers();
foreach ($users as $user)
{ echo " <option value=\"" . $user->getUserID() . "\">" . $user->getUsername() . " (" . $user->getName() . ")</option>\n"; }
?>
</select></td>
<td><select name="league_id">
<option value="" selected>Select League</option>
<?php
if (!isset($myleague))
{ $myleague = new OFFL_League(); }
$leagues = $myleague->getAllLeagues();
foreach ($leagues as $league)
{ echo " <option value=\"" . $league->getLeagueID() . "\">" . $league->getLeagueName() . "</option>\n"; }
?>
</select></td>
<td><input type="submit" value="Add Team" /></td>
</tr></tbody>
</table>
</form>
</div>
<?php
break;
case "edit":
/************************************************
*
*
* EDIT SINGLE TEAM SECTION
*
* I am not sure why it's else... if instead of elseif offhand.
************************************************/
if(empty($_GET["fflteam_id"]) || (!isset($_SESSION["admin"])))
{ $_GET["fflteam_id"]=$myteam->getFFLTeamID(); }
// $thisTeam variable contains what we need
?>
<form name="teaminfo" action="<?php echo $WEB_ROOT; ?>/teams.php">
<input type="hidden" name="fflteam_id" value="<?php echo $thisTeam->getFFLTeamID() ?>">
<!-- should these be selectable somehow? -->
<input type="hidden" name="user_id" value="<?php echo $thisTeam->getUserID() ?>">
<!-- end question -->
<input type="hidden" name="mode" value="edit">
<input type="hidden" name="type" value="<?php echo $_GET["type"] ?>">
<input type="hidden" name="action" value="save">
<table border="0">
<tr class="evenrow">
<th colspan="3">Team</th>
</tr>
<tr>
<th align="right">Team Name:</th>
<td><input type="text" name="fflteam_city" size="20" maxlength="40"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getFFLTeamCity() ?>"<?php } ?>></td>
<td><input type="text" name="fflteam_name" size="20" maxlength="40"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getFFLTeamName() ?>"<?php } ?>></td>
</tr>
<tr valign="top">
<th align="right"> </th>
<td class="small">City</td>
<td class="small">Nickname</td>
</tr>
<?php // I'd like some other check here; admins don't need to be able to accidentally change divisions.
if(isset($_SESSION["admin"])) { ?>
<tr>
<th align="right">Division:</th>
<td colspan="2">
<select name="division_id" size="1">
<option value="0"> -- Select One -- </option>
<option value="0"><<No Division>></option>
<?php
$divisions = $thisLeague->getAllDivisions(TRUE);
foreach($divisions as $tmp_division)
{
$this_tmp_league = new OFFL_League($tmp_division->getLeagueID());
?>
<option value="<?php echo $tmp_division->getDivisionID(); ?>"<?php
if(($_REQUEST["mode"] == "edit") && ($tmp_division->getDivisionID() == $thisTeam->getDivisionID())) { ?> selected<?php } ?>><?php echo $tmp_division->getDivisionDesc() . " (" . $this_tmp_league->getLeagueAbbv() . ")"; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<?php } else { ?>
<tr>
<th style="text-align:right;">Division:</th>
<td><?php echo $thisTeam->getDivisionDesc(); ?></td>
</tr>
<?php } ?>
<tr>
<th align="right">Team Logo:</th>
<td colspan="2">
<?php
if (!is_null($thisTeam->getFFLTeamLogo()) && strlen($thisTeam->getFFLTeamLogo()))
{
?><img src="<?php echo $thisTeam->getFFLTeamLogo(); ?>" alt="<?php echo $thisTeam->getFFLTeamFullName(); ?> logo" />
<?php }
?><p style="margin: 0;"><a href="<?php echo $WEB_ROOT; ?>/uploadlogo.php?fflteam_id=<?php echo $thisTeam->getFFLTeamID(); ?>">Change Logo</a></p>
</td>
</tr>
<tr class="evenrow">
<th colspan="3">Stadium</th>
</tr>
<tr>
<th align="right">Stadium Name:</th>
<td colspan="2"><input type="text" name="stadium_name" size="40" maxlength="60"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getStadiumName() ?>"<?php } ?>></td>
</tr>
<tr class="evenrow">
<th colspan="3">Coaching Staff</th>
</tr>
<tr>
<th align="right">Head Coach:</th>
<td colspan="2"><input type="text" name="coach_head" size="40" maxlength="60"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getCoachHead() ?>"<?php } ?>></td>
</tr>
<tr>
<th align="right">Offensive Coordinator:</th>
<td colspan="2"><input type="text" name="coach_off" size="40" maxlength="60"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getCoachOff() ?>"<?php } ?>></td>
</tr>
<tr>
<th align="right">Defensive Coordinator:</th>
<td colspan="2"><input type="text" name="coach_def" size="40" maxlength="60"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getCoachDef() ?>"<?php } ?>></td>
</tr>
<tr>
<th align="right">Special Teams Coach:</th>
<td colspan="2"><input type="text" name="coach_spec" size="40" maxlength="60"<?php if($_REQUEST["mode"] == "edit") { ?> value="<?php echo $thisTeam->getCoachSpec() ?>"<?php } ?>></td>
</tr>
<tr class="evenrow">
<tr>
<td></td>
<td colspan="2"><input type="submit" value="Save Team"></td>
</tr>
</table>
</form>
<?php
break;
case "add":
// Gotta figure this puppy out!
if (!$_SESSION["admin"])
{ break; }
if ($_POST["league_id"] == "")
{
echo "<p class=\"error\">League not set!</p>";
break;
}
if ($_POST["user_id"] == "")
{
echo "<p class=\"error\">User not set!</p>";
break;
}
?>
<form name="teaminfo" action="<?php echo $WEB_ROOT; ?>/teams.php">
<!-- <input type="hidden" name="fflteam_id" value="<?php // echo $thisTeam->getFFLTeamID() ?>"> -->
<input type="hidden" name="user_id" value="<?php echo $_POST["user_id"]; ?>">
<input type="hidden" name="league_id" value="<?php echo $_POST["league_id"]; ?>">
<input type="hidden" name="mode" value="add">
<input type="hidden" name="type" value="<?php echo $_GET["type"] ?>">
<input type="hidden" name="action" value="save">
<table border="0">
<tr class="evenrow">
<th colspan="3">Team</th>
</tr>
<tr>
<th align="right">Team Name:</th>
<td><input type="text" name="fflteam_city" size="20" maxlength="40"></td>
<td><input type="text" name="fflteam_name" size="20" maxlength="40"></td>
</tr>
<tr valign="top">
<th align="right"> </th>
<td class="small">City</td>
<td class="small">Nickname</td>
</tr>
<tr>
<th align="right">Division:</th>
<td colspan="2">
<select name="division_id" size="1">
<option value="0"> -- Select One -- </option>
<?php
$lg = new OFFL_League($_POST["league_id"]);
$divisions = $lg->getAllDivisions();
for($i=0; $i<sizeof($divisions); $i++)
{
?>
<option value="<?php echo $divisions[$i]->getDivisionID(); ?>"<?php
if(($_REQUEST["mode"] == "edit") && ($divisions[$i]->getDivisionID() == $thisTeam->getDivisionID())) { ?> selected<?php } ?>><?php echo $divisions[$i]->getDivisionDesc(); ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td colspan="2"><input type="submit" value="Save Team"></td>
</tr>
</table>
</form>
<?php
break;
default:
// Present display (read-only) information
if(empty($_GET["fflteam_id"]))
{
// No fflteam_id is selected, show list of teams and owners
$league = new OFFL_League($_SESSION["league_id"]);
$teams = $league->getAllFFLTeams();
?>
<table id="teamlist">
<tr>
<th align="left">Team</th>
<th align="left">Owner</th>
</tr>
<?php
foreach($teams as $i=>$team)
{
$user = new OFFL_User($team->getUserID());
?>
<tr class="<?php if ($i % 2) echo "evenrow"; else echo "oddrow"; if ($team->getFFLTeamID() == $_SESSION["fflteamid"]) echo " active"; ?>">
<td><a href="teams.php?fflteam_id=<?php echo $team->getFFLTeamID(); ?>"><?php echo $team->getFFLTeamFullName(); ?></a></td>
<td><?php echo $user->getName(); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
// Show information of given team
$thisTeam = new OFFL_FFLTeam($_GET["fflteam_id"]);
if (isset($_GET["league_id"]))
{ $thisTeam->setLeagueID($_GET["league_id"]); }
$thisUser = new OFFL_User($thisTeam->getUserID());
?>
<table border="0" width="75%">
<tr valign="top">
<td style="width:60%">
<div class="big"><?php echo $thisTeam->getFFLTeamFullName(); ?></div>
<div class="line"></div>
<table style="border-collapse: collapse;">
<tr>
<td>Owner:</td>
<td><span style="font-weight:bold;"><?php echo $thisUser->getName(); ?></span><?php if (strlen($thisUser->getEmail())) { ?>, <a href="mailto:<?php echo $thisUser->getEmail(); ?>"><?php echo $thisUser->getEmail(); ?></a><?php } ?></td>
</tr>
<tr>
<td>Division:</td>
<td><span style="font-weight:bold;"><?php echo $thisTeam->getDivisionDesc() ?></span></td>
</tr>
<tr>
<td>Stadium:</td>
<td><?php echo $thisTeam->getStadiumName(); ?></td>
</tr>
<tr>
<td>Capacity:</td>
<td><?php echo number_format(rand(40000,75000)); ?></td>
</tr>
</table>
<table style="border-collapse: collapse;">
<tr>
<th colspan="2">Coaching Staff</th>
</tr>
<tr>
<td align="right">Head Coach:</td><td><?php echo $thisTeam->getCoachHead(); ?></td>
</tr>
<tr>
<td align="right">Offensive Coordinator:</td><td><?php echo $thisTeam->getCoachOff(); ?></td>
</tr>
<tr>
<td align="right">Defensive Coordinator:</td><td><?php echo $thisTeam->getCoachDef(); ?></td>
</tr>
<tr>
<td align="right">Special Teams Coach:</td><td><?php echo $thisTeam->getCoachSpec(); ?></td>
</tr>
</table>
<table id="ffl-sched">
<thead><tr><th id="sched-title" colspan="5"><a href="<?php echo $WEB_ROOT; ?>/games.php?year=<?php echo $_GET["year"]; ?>"><?php echo $_GET["year"] ?> Schedule</a></th></tr>
<tr>
<th>Week</th>
<th style="width:70%">Opponent</th>
<th colspan="3">Result</th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="2"><a href="<?php echo $WEB_ROOT; ?>/standings.php?view=standard" title="View the League Standings"><?php echo $_GET["year"] ?> Record</a></th>
<th><abbr title="Wins">W</abbr></th><th><abbr title="Losses">L</abbr></th><th><abbr title="Ties">T</abbr></th>
</tr>
<tr>
<th class="record" colspan="2">Overall</th>
<td><?php echo $thisTeam->getOverallWins($_GET["year"]); ?></td>
<td><?php echo $thisTeam->getOverallLosses($_GET["year"]); ?></td>
<td><?php echo $thisTeam->getOverallTies($_GET["year"]); ?></td>
</tr>
<tr>
<th class="record" colspan="2">Division</th>
<td><?php echo $thisTeam->getDivisionWins($_GET["year"]); ?></td>
<td><?php echo $thisTeam->getDivisionLosses($_GET["year"]); ?></td>
<td><?php echo $thisTeam->getDivisionTies($_GET["year"]); ?></td>
</tr>
</tfoot>
<tbody>
<?php $games = $thisTeam->getSchedule($_GET["year"]);
if(sizeof($games) == 0) {
?><tr><td colspan="4"><i>None found</i></td></tr><?php
} else {
foreach($games as $i=>$game)
{ ?>
<tr class="<?php if($i % 2) echo "evenrow"; else echo "oddrow"; ?>">
<td><a href="<?php echo $WEB_ROOT . "/games.php?year=" . $game->getYear() . "&week=" . $game->getWeek(); ?>" title="Schedule for Week <?php echo $game->getWeek(); ?>"><?php echo $game->getWeek(); ?></a></td>
<?php if($game->getVFFLTeamID() == $thisTeam->getFFLTeamID())
{ /* Away game */
$hTeam = new OFFL_FFLTeam($game->getHFFLTeamID());
?>
<td class="awaygame<?php if ($game->getHFFLTeamID() == $_SESSION["fflteamid"]) echo " active"; ?>">@ <a href="<?php echo $WEB_ROOT; ?>/teams.php?fflteam_id=<?php echo $game->getHFFLTeamID();
if (isset($_GET["year"]))
{ echo "&year=$_GET[year]"; }
?>"><?php echo $hTeam->getFFLTeamFullName(); ?></a></td>
<td colspan="3"><a href="<?php echo $WEB_ROOT . "/matchups.php?game_id=" . $game->getGameID(); ?>"><?php
if($game->getVFFLTeamScore() > $game->getHFFLTeamScore())
{
echo $game->getVFFLTeamScore() . " - " . $game->getHFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Win\">W</abbr>"; }
}
elseif($game->getVFFLTeamScore() < $game->getHFFLTeamScore())
{
echo $game->getVFFLTeamScore() . " - " . $game->getHFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Loss\">L</abbr>"; }
}
elseif(($game->getVFFLTeamScore() != "")&&($game->getHFFLTeamScore() != ""))
{
echo $game->getVFFLTeamScore() . " - " . $game->getHFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Tie\">T</abbr>"; }
}
else
{ echo "<span style=\"font-size:smaller;\">[MATCHUP]</span>"; }
?></a></td>
<?php }
else
{ /* HOME GAME */
$vTeam = new OFFL_FFLTeam($game->getVFFLTeamID());
?>
<td class="homegame<?php if ($game->getVFFLTeamID() == $_SESSION["fflteamid"]) echo " active"; ?>"><a href="<?php echo $WEB_ROOT; ?>/teams.php?fflteam_id=<?php echo $game->getVFFLTeamID();
if (isset($_GET["year"]))
{
echo "&year=$_GET[year]";
}
?>"><?php echo $vTeam->getFFLTeamFullName(); ?></a></td>
<td colspan="3"><a href="<?php echo $WEB_ROOT . "/matchups.php?game_id=" . $game->getGameID(); ?>"><?php
if($game->getHFFLTeamScore() > $game->getVFFLTeamScore())
{
echo $game->getHFFLTeamScore() . " - " . $game->getVFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Win\">W</abbr>"; }
}
elseif($game->getHFFLTeamScore() < $game->getVFFLTeamScore())
{
echo $game->getHFFLTeamScore() . " - " . $game->getVFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Loss\">L</abbr>"; }
}
elseif(($game->getHFFLTeamScore() != "")&&($game->getVFFLTeamScore() != ""))
{
echo $game->getHFFLTeamScore() . " - " . $game->getVFFLTeamScore();
if ($game->getFinal())
{ echo " <abbr title=\"Tie\">T</abbr>"; }
}
else
{ echo "<span style=\"font-size:smaller;\">[MATCHUP]</span>"; }
?></a></td>
<?php } ?>
</tr>
<?php }
} ?>
</tbody>
</table>
</td>
<td style="width:40%">
<?php
if(strlen($thisTeam->getFFLTeamLogo()))
{ ?>
<img src="<?php echo $thisTeam->getFFLTeamLogo(); ?>" alt="<?php echo $thisTeam->getFFLTeamFullName(); ?> logo" style="float:right;" title="<?php echo $thisTeam->getFFLTeamFullName(); ?>" />
<?php }
$players = $thisTeam->getRoster();
usort($players, "cmp_players_starter");
$errors = $thisTeam->validateRosterFlex($players,$control);
for($i=0; $i<sizeof($errors); $i++)
{ echo "<div class=\"alert\">$errors[$i]</div>"; } ?>
<table id="ffl-roster">
<thead>
<tr><th colspan="2" id="roster-title"><a href="<?php echo $WEB_ROOT; ?>/rosters.php">Roster</a></th></tr>
<tr>
<th ><abbr title="Position">Pos</abbr></th>
<th style="width:90%">Name</th>
</tr>
</thead>
<tfoot style="display: none;"><tr><td></td></tr></tfoot>
<tbody>
<?php $starter=1;
if(sizeof($players) == 0)
{ ?>
<tr><td colspan="2"><i>None found</i></td></tr><?php
}
else
{
foreach($players as $i=>$player)
{
if ($starter && (!$player->getStarter()))
{
$starter = 0;
echo "<tr><th colspan=\"2\" id=\"benchline\" /></tr>\n";
} ?>
<tr class="<?php if($i % 2) echo "evenrow"; else echo "oddrow"; ?>">
<td><?php echo "<abbr title=\"" . $player->getPositionName() . "\">" . $player->getPositionAbbv() . "</abbr>"; ?></td>
<td><a href="players.php?player_id=<?php echo $player->getPlayerID(); ?>"><?php echo $player->getName(); ?></a></td>
</tr>
<?php }
} ?>
</tbody>
</table>
<?php
if ($thisTeam->getFFLTeamID() == $_SESSION["fflteam_id"])
{
$fflteam_id = $_SESSION["fflteam_id"];
$x = new OFFL_Trade();
$teamTrades = $x->getAllTeamTrades($fflteam_id);
if (sizeof($teamTrades))
{ echo "<div class=\"big\">Trades</div>"; }
foreach($teamTrades as $trade)
{
switch ($trade->getStatus())
{
case "rosterviolation":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{ $thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID()); }
else
{ $thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID()); }
echo "<p class=\"error\">Your trade with <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> cannot be completed until a roster inconsistency is resolved: ";
break;
case "proposed":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{
$thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID());
echo "<p>You have proposed a trade to <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a>:";
}
else
{
$thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID());
echo "<p><a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> has proposed a trade to you:";
}
break;
case "accepted":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{
$thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID());
echo "<p><a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> has accepted your trade, and it is pending:";
}
else
{
$thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID());
echo "<p>You have accepted a trade from <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a>, and it is pending:";
}
break;
case "vetoed":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{
$thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID());
echo "<p>Your trade with <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> has been vetoed by the commissioner:";
}
else
{
$thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID());
echo "<p><a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a>'s trade with you has been vetoed by the commissioner:";
}
break;
case "protested":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{
$thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID());
echo "<p>Your trade with <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> has been overturned by league protest:";
}
else
{
$thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID());
echo "<p><a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a>'s trade with you has been overturned by league protest:";
}
break;
case "declined":
if ($trade->getProposedFFLTeamID() == $fflteam_id)
{
$thatTeam = new OFFL_FFLTeam($trade->getTargetFFLTeamID());
echo "<p><a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a> has declined your trade offer:";
}
else
{
$thatTeam = new OFFL_FFLTeam($trade->getProposedFFLTeamID());
echo "<p>You have declined a trade offer from <a href=\"" . $WEB_ROOT . "/teams.php?fflteam_id=" . $thatTeam->getFFLTeamID() . "\">" . $thatTeam->getFFLTeamFullName() . "</a>:";
}
}
echo " <a href=\"$WEB_ROOT/trades.php?trade_id=" . $trade->getTradeID();
if ($isAdmin)
echo "&mode=admin";
echo "\">[details]</a></p>\n";
}
} /* end foreach trade */ ?>
</td>
</tr>
</table>
<?php
} // end if $_SESSION["fflteam_id"]
break;
} // end switch ($_REQUEST["mode"])
} // end else $_GET["action"]
require($DOC_ROOT . "/lib/footer.php"); ?>