Location: PHPKode > projects > Online Fantasy Football League > offl-0.2.6/www/editstats.php
<?php
/**
 * Stats editor
 *
 * This file allows admins to correct stats processed by the automatic parser.  It will need to be edited as new stats
 * fields are added.
 *
 * @author Stephen Rochelle <hide@address.com>
 * @version OFFL v0.2
 * @copyright Copyright (c) 2004 Stephen Rochelle.  Some rights reserved.
 * @package offl-ui
 */

$pageTitle = "Edit Player Stats";
require_once("offlconfig.php");
require_once($DOC_ROOT . "/lib/header.php");

/* THIS FILE SHOULD ONLY BE ACCESSIBLE BY ADMINS */

if ($_SESSION["admin"] == 1)
{
	$stat_lookup = new OFFL_PlayerStat();
	if ($_POST["action"] == "save")
	{
		// this is where I save things
		unset ($_POST["action"]);

		$statrec = $stat_lookup->getStatsByPlayerIDYearWeek($_POST["PlayerID"], $_POST["Year"], $_POST["Week"]);
		if ($statrec === FALSE)
			$statrec = new OFFL_PlayerStat();

		foreach ($_POST as $name=>$var)
		{
			if ($var != "")
				$statrec->{"set" . $name}($var);
		}
		$statrec->save();
		
		?><meta http-equiv="refresh" content="0; URL=<?php echo "$WEB_ROOT/players.php?player_id=" . $_POST["PlayerID"] . "&year=" . $_POST["Year"] . "&week=" . $_POST["Week"] . "" ?>"><?php

	}
	elseif (isset($_GET["player_id"]) && isset($_GET["year"]) && isset($_GET["week"]))
	// don't bother proceeding if this info not present.
	{
		$player = new OFFL_Player($_GET["player_id"]);
		$statrec = $stat_lookup->getStatsByPlayerIDYearWeek($_GET["player_id"], $_GET["year"], $_GET["week"]);
		// I'll have to do this lookup on save side as well, see if I need to create a new one.
		if ($statrec === FALSE)
			$statrec = new OFFL_PlayerStat();
		echo "<h3>Stats for " . $player->getName() . ", " . $_GET["year"] . " week " . $_GET["week"] . "</h3>\n";
		echo "<form name=\"statform\" method=\"post\" action=\"$WEB_ROOT/editstats.php\">";
		echo "<input type=\"hidden\" name=\"PlayerID\" value=\"" . $_GET["player_id"] . "\" />\n";
		echo "<input type=\"hidden\" name=\"Year\" value=\"" . $_GET["year"] . "\" />\n";
		echo "<input type=\"hidden\" name=\"Week\" value=\"" . $_GET["week"] . "\" />\n";
		echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
		echo "<table id=\"stattable\">\n";

		echo "<tr><th>Pass Att</th><td><input type=\"text\" name=\"PassAtt\" size=\"20\" value=\"" . $statrec->getPassAtt() . "\" /></td></tr>\n";
		echo "<tr><th>Pass Cmp</th><td><input type=\"text\" name=\"PassCmp\" size=\"20\" value=\"" . $statrec->getPassCmp() . "\" /></td></tr>\n";
		echo "<tr><th>Pass Yd</th><td><input type=\"text\" name=\"PassYd\" size=\"20\" value=\"" . $statrec->getPassYd() . "\" /></td></tr>\n";
		echo "<tr><th>Pass TD</th><td><input type=\"text\" name=\"PassTD\" size=\"20\" value=\"" . $statrec->getPassTD() . "\" /></td></tr>\n";
		echo "<tr><th>Rush Att</th><td><input type=\"text\" name=\"RushAtt\" size=\"20\" value=\"" . $statrec->getRushAtt() . "\" /></td></tr>\n";
		echo "<tr><th>Rush Yd</th><td><input type=\"text\" name=\"RushYd\" size=\"20\" value=\"" . $statrec->getRushYd() . "\" /></td></tr>\n";
		echo "<tr><th>Rush TD</th><td><input type=\"text\" name=\"RushTD\" size=\"20\" value=\"" . $statrec->getRushTD() . "\" /></td></tr>\n";
		echo "<tr><th>Rec Att</th><td><input type=\"text\" name=\"RecAtt\" size=\"20\" value=\"" . $statrec->getRecAtt() . "\" /></td></tr>\n";
		echo "<tr><th>Rec Yd</th><td><input type=\"text\" name=\"RecYd\" size=\"20\" value=\"" . $statrec->getRecYd() . "\" /></td></tr>\n";
		echo "<tr><th>Rec TD</th><td><input type=\"text\" name=\"RecTD\" size=\"20\" value=\"" . $statrec->getRecTD() . "\" /></td></tr>\n";
		echo "<tr><th>Int</th><td><input type=\"text\" name=\"Int\" size=\"20\" value=\"" . $statrec->getInt() . "\" /></td></tr>\n";
		echo "<tr><th>Fmbl Lost</th><td><input type=\"text\" name=\"FmblLost\" size=\"20\" value=\"" . $statrec->getFmblLost() . "\" /></td></tr>\n";
		echo "<tr><th>2 Point</th><td><input type=\"text\" name=\"TwoPt\" size=\"20\" value=\"" . $statrec->getTwoPt() . "\" /></td></tr>\n";
		echo "<tr><th>Kick Ret Att</th><td><input type=\"text\" name=\"KRetAtt\" size=\"20\" value=\"" . $statrec->getKRetAtt() . "\" /></td></tr>\n";
		echo "<tr><th>Kick Ret Yd</th><td><input type=\"text\" name=\"KRetYd\" size=\"20\" value=\"" . $statrec->getKRetYd() . "\" /></td></tr>\n";
		echo "<tr><th>Kick Ret TD</th><td><input type=\"text\" name=\"KRetTD\" size=\"20\" value=\"" . $statrec->getKRetTD() . "\" /></td></tr>\n";
		echo "<tr><th>Punt Ret Att</th><td><input type=\"text\" name=\"PRetAtt\" size=\"20\" value=\"" . $statrec->getPRetAtt() . "\" /></td></tr>\n";
		echo "<tr><th>Punt Ret Yd</th><td><input type=\"text\" name=\"PRetYd\" size=\"20\" value=\"" . $statrec->getPRetYd() . "\" /></td></tr>\n";
		echo "<tr><th>Punt Ret TD</th><td><input type=\"text\" name=\"PRetTD\" size=\"20\" value=\"" . $statrec->getPRetTD() . "\" /></td></tr>\n";
		echo "<tr><th>FG 0-19 Yd</th><td><input type=\"text\" name=\"FG_0_19\" size=\"20\" value=\"" . $statrec->getFG_0_19() . "\" /></td></tr>\n";
		echo "<tr><th>FG 20-29 Yd</th><td><input type=\"text\" name=\"FG_20_29\" size=\"20\" value=\"" . $statrec->getFG_20_29() . "\" /></td></tr>\n";
		echo "<tr><th>FG 30-39 Yd</th><td><input type=\"text\" name=\"FG_30_39\" size=\"20\" value=\"" . $statrec->getFG_30_39() . "\" /></td></tr>\n";
		echo "<tr><th>FG 40-49 Yd</th><td><input type=\"text\" name=\"FG_40_49\" size=\"20\" value=\"" . $statrec->getFG_40_49() . "\" /></td></tr>\n";
		echo "<tr><th>FG 50+ Yd</th><td><input type=\"text\" name=\"FG_50p\" size=\"20\" value=\"" . $statrec->getFG_50p() . "\" /></td></tr>\n";
		echo "<tr><th>FG Att</th><td><input type=\"text\" name=\"FGA\" size=\"20\" value=\"" . $statrec->getFGA() . "\" /></td></tr>\n";
		echo "<tr><th>XP</th><td><input type=\"text\" name=\"XP\" size=\"20\" value=\"" . $statrec->getXP() . "\" /></td></tr>\n";
		echo "<tr><th>XP Att</th><td><input type=\"text\" name=\"XPA\" size=\"20\" value=\"" . $statrec->getXPA() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Pts Allowed</th><td><input type=\"text\" name=\"DEFPt\" size=\"20\" value=\"" . $statrec->getDEFPt() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Yds Allowed</th><td><input type=\"text\" name=\"DEFYd\" size=\"20\" value=\"" . $statrec->getDEFYd() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Pass Yds Allowed</th><td><input type=\"text\" name=\"DEFPYd\" size=\"20\" value=\"" . $statrec->getDEFPYd() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Rush Yds Allowed</th><td><input type=\"text\" name=\"DEFRYd\" size=\"20\" value=\"" . $statrec->getDEFRYd() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Sacks</th><td><input type=\"text\" name=\"DEFSack\" size=\"20\" value=\"" . $statrec->getDEFSack() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Fumbles Recovered</th><td><input type=\"text\" name=\"DEFFmblRec\" size=\"20\" value=\"" . $statrec->getDEFFmblRec() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Interceptions</th><td><input type=\"text\" name=\"DEFInt\" size=\"20\" value=\"" . $statrec->getDEFInt() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Fumble TDs</th><td><input type=\"text\" name=\"DEFFmblTD\" size=\"20\" value=\"" . $statrec->getDEFFmblTD() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Interception TDs</th><td><input type=\"text\" name=\"DEFIntTD\" size=\"20\" value=\"" . $statrec->getDEFIntTD() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Kick/Punt TDs</th><td><input type=\"text\" name=\"DEFRetTD\" size=\"20\" value=\"" . $statrec->getDEFRetTD() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Misc TDs</th><td><input type=\"text\" name=\"DEFMiscTD\" size=\"20\" value=\"" . $statrec->getDEFMiscTD() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Safetys</th><td><input type=\"text\" name=\"DEFSafety\" size=\"20\" value=\"" . $statrec->getDEFSafety() . "\" /></td></tr>\n";
		echo "<tr><th>Defense: Blocked Kicks</th><td><input type=\"text\" name=\"DEFBlkKick\" size=\"20\" value=\"" . $statrec->getDEFBlkKick() . "\" /></td></tr>\n";


		echo "</table>\n";

		echo "<input type=\"submit\" />\n";
		echo "</form>\n";

	} // end player/year/week set
} // end is Admin check

require($DOC_ROOT . "/lib/footer.php"); ?>
Return current item: Online Fantasy Football League