$skipTurn .= '<input type = "hidden" name = "userID" id = "pickingUser" value = "' . $nextToDraft["userID"] . '">'; $skipTurn .= '<button class="btn btn-primary validate" type="button" id = "skip_pick_button" onclick="javascript:submitForm(\'skip_pick\',\'skip_pick_button\');">Skip Pick For ' . $nextToDraft["gmName"] . ' >></button> </form>'; echo $skipTurn; } else { $openDraftButton .= '<form method = "post" name = "open_draft_form" enctype="multipart/form-data" >'; $openDraftButton .= '<input type = "hidden" name = "action" value = "openDraft" >'; $openDraftButton .= '<input type = "hidden" name = "leagueID" value = "' . $leagueID . '">'; $openDraftButton .= '<button class="btn btn-primary validate" type="button" id = "open_draft_button" onclick="javascript:submitForm(\'open_draft_form\',\'open_draft_button\');">Open Draft >></button> </form>'; echo $openDraftButton; } ?> </td></tr></table> <?php } $positionLimits = getAllPositionLimits($leagueID); $limit_f = $positionLimits["f_a"] + $positionLimits["f_b"]; $limit_d = $positionLimits["d_a"] + $positionLimits["d_b"]; $limit_g = $positionLimits["g_a"] + $positionLimits["g_b"]; $roster_f = selectCount("fch_draft", " Where leagueID = {$leagueID} and userID = {$userID} and position = \"F\" "); $roster_d = selectCount("fch_draft", " Where leagueID = {$leagueID} and userID = {$userID} and position = \"D\" "); $roster_g = selectCount("fch_draft", " Where leagueID = {$leagueID} and userID = {$userID} and position = \"G\" "); $allowF = 0; $allowD = 0; $allowG = 0; if ($limit_f > $roster_f) { $allowF = 1; } if ($limit_d > $roster_d) { $allowD = 1; }
function closeDraft($leagueID) { debug("Entering CloseDraft."); $season = getSeason(); executeGenericSQL("DELETE FROM fch_rosters WHERE leagueID = {$leagueID} and season = \"{$season}\""); $positionLimits = getAllPositionLimits($leagueID); $sql = "SELECT userID, playerID, position FROM fch_draft WHERE leagueID = {$leagueID} and status <> \"W\" and status <> \"C\" and status <> \"P\" ORDER BY overallPick DESC "; debug("CloseDraft: {$sql}"); // acquirePlayer($userID,$leagueID,$playerID,$activeOrBench, $position,$transactionID) $con = initializeDB(); $result = $con->query($sql); if ($result->num_rows > 0) { // output data of each row while ($row = $result->fetch_assoc()) { $userID = $row["userID"]; $x = selectCount("fch_rosters", " WHERE userID = {$userID} and leagueID = {$leagueID} and season = \"{$season}\" and position = \"" . $row["position"] . "\""); debug("<B>x=" . $x . " Limit " . $positionLimits["f_a"] . "</b>"); if ($row["position"] == "F") { if ($x < $positionLimits["f_a"]) { $dest = "act"; } else { $dest = "ben"; } debug($row["playerID"] . " F, Dest = {$dest} "); } if ($row["position"] == "D") { if ($x < $positionLimits["d_a"]) { $dest = "act"; } else { $dest = "ben"; } debug($row["playerID"] . " D, Dest = {$dest} "); } if ($row["position"] == "G") { if ($x < $positionLimits["g_a"]) { $dest = "act"; } else { $dest = "ben"; } debug($row["playerID"] . " G, Dest = {$dest} "); } debug("CloseDraft: acquire: " . $row["userID"] . $leagueID . " " . $row["playerID"] . " " . $dest . " " . $row["position"]); acquirePlayer($row["userID"], $leagueID, $row["playerID"], $dest, $row["position"], getNextTransactionID($userID, $leagueID)); } } closeDB($con); }