예제 #1
0
$page->m_items['token']->setValue("test");
$countries = $page->getCountries();
// check whether there is a teamplay and there is still room for a person/
$page->addItem("DropDown", "nationality", "in_template");
$page->m_items['nationality']->changeOnSubmit();
$page->m_items['nationality']->setValues($countries);
if ($_POST['nationality'] != "") {
    $page->m_items['nationality']->setDefaultValue($_POST['nationality']);
} else {
    $page->m_items['nationality']->startEmpty("-------------");
}
$page->m_items['nationality']->addValidation("MinMaxFloat", "0", "240", "1");
$page->m_items['nationality']->m_validationrule->setErrorMessage("Please enter a nationality");
if ($_POST['nationality'] != "") {
    $page->m_smarty->assign("selectednationality", $_POST['nationality']);
    $teamdata = $page->getTeamData($_POST['nationality']);
    $page->m_smarty->assign("memberamount", $teamdata[0]['memberamount']);
    if (count($teamdata) > 0 && $teamdata[0]['memberamount'] <= 3) {
        // this player can join an existing team
        $page->addItem("CheckBox", "addteam", "in_template");
        $page->m_items['addteam']->setValues(array('1' => "Add this player to team"));
        $page->m_items['token']->setValue("1");
    } else {
        if (count($teamdata) > 0 && $teamdata[0]['memberamount'] >= 4) {
            // this player can not be added to a team, it's full
            $page->m_smarty->assign("individual", "The national team is already full, it is not possible to add this player to the team");
            $page->m_items['token']->setValue("1");
        } else {
            // team does not exists, do u want to create one?
            $page->addItem("CheckBox", "createteam", "in_template");
            $page->m_items['createteam']->setValues(array('1' => "Create team"));