</ul>
</div>
<div  class = "fch">
	<h3>&nbsp;</h3>
		<ul class = "right" id="l6">

	<?php 
?>

	</ul>
</div>
<div id="newline"><br/>&nbsp;</div>
	<fieldset>
		<input name = "action" value = "doRelease" type = "hidden">
		<input name = "transactionID" value = "<?php 
echo getNextTransactionID($userID, $leagueID);
?>
" type = "hidden">

		<div class="form-actions">	
			<button id = "submitQuery" class="btn btn-primary validate" type="button" onClick= "javaScript:submitForm('processRoster','submitQuery');">Go &gt;&gt;</button>	
		</div>
		</fieldset>
		<?php 
echo $hiddenFields;
?>

</form>

	<p/>
            $userHasButton = true;
        }
        if ($roster_d_a < $limit_d_a && $allow == 1 && $row['position'] == "D") {
            $acquire .= "<form method = \"post\" name = \"submit_" . $row['playerID'] . "_a\" enctype=\"multipart/form-data\"><input name = \"transactionID\" value = \"" . getNextTransactionID($userID, $leagueID) . "\" type = \"hidden\"><input value = \"" . $row['position'] . "\" type = \"hidden\" name = \"position\"><input value = \"doAcquire\" type = \"hidden\" name = \"action\"><input type = \"hidden\" name =\"destination\" value = \"act\"><input type = \"hidden\" name = \"playerID\" value = \"" . $row['playerID'] . "\"><button class=\"btn btn-primary validate\" type=\"button\" id = \"button_submit_" . $row['playerID'] . "_a\" onclick=\"javascript:submitForm('submit_" . $row['playerID'] . "_a','button_submit_" . $row['playerID'] . "_a');\">Acquire to Active &gt;&gt;</button> </form>&nbsp;\n";
            $userHasButton = true;
        }
        if ($roster_d_b < $limit_d_b && $allow == 1 && $row['position'] == "D") {
            $acquire .= "<form method = \"post\" name = \"submit_" . $row['playerID'] . "_b\" enctype=\"multipart/form-data\"><input name = \"transactionID\" value = \"" . getNextTransactionID($userID, $leagueID) . "\" type = \"hidden\"><input value = \"" . $row['position'] . "\" type = \"hidden\" name = \"position\"><input value = \"doAcquire\" type = \"hidden\" name = \"action\"><input type = \"hidden\" name =\"destination\" value = \"ben\"><input type = \"hidden\" name = \"playerID\" value = \"" . $row['playerID'] . "\"><button class=\"btn btn-primary validate\" type=\"button\" id = \"button_submit_" . $row['playerID'] . "_b\" onclick=\"javascript:submitForm('submit_" . $row['playerID'] . "_b','button_submit_" . $row['playerID'] . "_b');\">Acquire to Reserve &gt;&gt;</button> </form>&nbsp;\n";
            $userHasButton = true;
        }
        if ($roster_g_a < $limit_g_a && $allow == 1 && $row['position'] == "G") {
            $acquire .= "<form method = \"post\" name = \"submit_" . $row['playerID'] . "_a\" enctype=\"multipart/form-data\"><input name = \"transactionID\" value = \"" . getNextTransactionID($userID, $leagueID) . "\" type = \"hidden\"><input value = \"" . $row['position'] . "\" type = \"hidden\" name = \"position\"><input value = \"doAcquire\" type = \"hidden\" name = \"action\"><input type = \"hidden\" name =\"destination\" value = \"act\"><input type = \"hidden\" name = \"playerID\" value = \"" . $row['playerID'] . "\"><button class=\"btn btn-primary validate\" type=\"button\" id = \"button_submit_" . $row['playerID'] . "_a\" onclick=\"javascript:submitForm('submit_" . $row['playerID'] . "_a','button_submit_" . $row['playerID'] . "_a');\">Acquire to Active &gt;&gt;</button> </form>&nbsp;\n";
            $userHasButton = true;
        }
        if ($roster_g_b < $limit_g_b && $allow == 1 && $row['position'] == "G") {
            $acquire .= "<form method = \"post\" name = \"submit_" . $row['playerID'] . "_b\" enctype=\"multipart/form-data\"><input name = \"transactionID\" value = \"" . getNextTransactionID($userID, $leagueID) . "\" type = \"hidden\"><input value = \"" . $row['position'] . "\" type = \"hidden\" name = \"position\"><input value = \"doAcquire\" type = \"hidden\" name = \"action\"><input type = \"hidden\" name =\"destination\" value = \"ben\"><input type = \"hidden\" name = \"playerID\" value = \"" . $row['playerID'] . "\"><button class=\"btn btn-primary validate\" type=\"button\" id = \"button_submit_" . $row['playerID'] . "_b\" onclick=\"javascript:submitForm('submit_" . $row['playerID'] . "_b','button_submit_" . $row['playerID'] . "_b');\">Acquire to Reserve &gt;&gt;</button> </form>&nbsp;\n";
            $userHasButton = true;
        }
        if (!$userHasButton) {
            $acquire .= "--No Available Slots--";
        }
        $out .= "<tr><td class = \"rowHead\">" . $row['playerDisplayName'] . "</td><td>" . $row['position'] . "</td><td>" . $status . "</td><td>{$acquire}</td></tr>\n";
    }
    $out .= "</table>";
} else {
    echo "<h3>No Results Found</h3>Please try again.";
}
echo $out;
?>

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);
}