Revision 111 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?define( "IN_ADMIN", true );require ( "include/common.php" );$mode = ( $_POST["mode"] ) ? $_POST["mode"] : "new";$id = intval( isset($_POST["id"]) ? $_POST["id"] : 0 );$g_m1 = intval( isset($_POST["g_m1"]) ? $_POST["g_m1"] : 0 );$g_m2 = intval( isset($_POST["g_m2"]) ? $_POST["g_m2"] : 0 );$g_g1 = intval( isset($_POST["g_g1"]) ? $_POST["g_g1"] : 0 );$g_g2 = intval( isset($_POST["g_g2"]) ? $_POST["g_g2"] : 0 );$g_location = intval( isset($_POST["g_location"]) ? $_POST["g_location"] :0 );$g_type = intval( isset($_POST["g_typ"]) ? $_POST["g_typ"] : -1 );$g_name = addslashes( isset($_POST["g_name"]) ? $_POST["g_name"] : "" );$month = intval( isset($_POST["Month"]) ? $_POST["Month"] : -1 );$day = intval( isset($_POST["Day"]) ? $_POST["Day"] : -1 );$hour = intval( isset($_POST["Hour"]) ? $_POST["Hour"] : -1 );$min = intval( isset($_POST["Minute"]) ? $_POST["Minute"] : -1 );$g = Spiele::listSpiele( 0, 0 );$g_anz = $g->numRows();$g_max = 2 * $config->groups * $config->teams_per_group;if ( $hour >= 0 and $day > 0 and $month > 0 && $min > -1 ){$g_date = mktime( $hour, $min, 0, $month, $day, $config->year );}if ( $g_anz >= $g_max && $mode == "new" ){$smarty->assign( "meld", "Ein Fehler ist aufgetreten!" );$smarty->assign( "db_meld", "In dieser $config->type sind nur $g_max Spiele zulässig!" );$smarty->assign( "error", true );$smarty->display( "meld.tpl" );exit;}$smarty->assign( "mode", $mode );$smarty->assign( "id", $id );if ( $a->getAuth() ){if ( $u->u_type != 1 && $mode != "edit" ){$meld = "Ein Fehler ist aufgetreten!";$db_meld ="Nur Administratoren haben Zugriff auf diese Funktion!";$smarty->assign( "meld", $meld );$smarty->assign( "db_meld", $db_meld );$smarty->assign( "error", true );$smarty->display( "meld.tpl" );exit;}$game = new Spiele( $id );$t = new Typ( $g_type );$sql_t = "SELECT count(*) AS anzahl FROM games WHERE g_type=$g_type";$res_t = $db->query( $sql_t );$row_t = $res_t->fetchRow();$anz = $row_t["anzahl"];if ( $mode == "save" || $mode == "update" ){$game->update( $g_name, $g_m1, $g_m2, $g_g1, $g_g2, $g_location,$g_date, $g_type );}function fill_form(){global $db, $smarty, $id, $new_mode, $g_date, $title, $game;$teams[-1] = "Bitte wählen!";$typ_namen[] = "Bitte wählen!";$typ_ids[] = -1;$l_namen[] = "Bitte wählen!";$l_ids[] = -1;$g_l = Gruppe::listeGruppe( 0, 0 );while ( $row_g = $g_l->fetchRow() ){$g_id = $row_g["g_id"];$g_name = $row_g["g_name"];// $t_namen[]="---------- Gruppe $g_name ----------";// $t_ids[]=-1;$sql_t = "SELECT * FROM teams WHERE t_group=$g_id";$t_l = $db->query( $sql_t );while ( $row_t = $t_l->fetchRow() ){$t_name = $row_t["t_name"];$t_aus = $row_t["t_aus"];$t_id = $row_t["t_id"];// $t_namen[]=$t_name;// $t_ids[]=$t_id;$teams["Gruppe $g_name"][$t_id] = $t_name;}}$l_l = Ort::listeOrt( 0, 0 );while ( $row_l = $l_l->fetchRow() ){$l_name = $row_l["l_name"];$l_name2 = $row_l["l_name2"];$l_id = $row_l["l_id"];$l_namen[] = "$l_name - $l_name2";$l_ids[] = $l_id;}$typ_l = Typ::listeTyp( 0, 0 );while ( $row_typ = $typ_l->fetchRow() ){$typ_name = $row_typ["t_name"];$typ_id = $row_typ["t_id"];$typ_namen[] = $typ_name;$typ_ids[] = $typ_id;}$smarty->assign( "id", $id );$smarty->assign( "g_date", (!($g_date)) ? $game->g_date : $g_date );$smarty->assign( "g_name", ($game->g_name) );$smarty->assign( "akt_typ_id", $game->g_type );$smarty->assign( "akt_m1_id", $game->g_m1 );$smarty->assign( "akt_m2_id", $game->g_m2 );$smarty->assign( "akt_l_id", $game->g_location );$smarty->assign( "g_g1", $game->g_g1 );$smarty->assign( "g_g2", $game->g_g2 );// $smarty->assign("t_namen", $t_namen);$smarty->assign( "teams", $teams );// $smarty->assign("t_ids", $t_ids);$smarty->assign( "typ_namen", $typ_namen );$smarty->assign( "typ_ids", $typ_ids );$smarty->assign( "l_ids", $l_ids );$smarty->assign( "l_namen", $l_namen );$smarty->assign( "mode", $new_mode );$smarty->assign( "title", $title );$smarty->assign( "extra", ($new_mode == "save") ? "disabled=\"disabled\"" :"" );$smarty->display( "edit_games.tpl" );}switch ( $mode ){case "edit":$title = "Spiel $id ändern";$new_mode = "update";break;case "new":$title = "neues Spiel eingeben";$new_mode = "save";break;case "delete":case "ask":$title = "Spiel $id löschen";$new_mode = "delete";break;case "save":$title = "neues Spiel speichern";$new_mode = "save";$smarty->assign( "save", true );$smarty->assign( "weiter", "ein weiteres Spiel eingeben" );break;case "update":$title = "Spiel $id speichern";$new_mode = "update";break;}if ( $mode == "edit" or $mode == "new" ){fill_form();}else{switch ( $mode ){case "save":case "delete":case "update":if ( !checkdate($month, $day, $config->year) ){$meld = "Ein Fehler ist aufgetreten!";$db_meld = "$day.$month.$config->year ist kein gültiges Datum!";$error = true;$smarty->assign( "db_meld", $db_meld );$smarty->assign( "error", $error );$smarty->assign( "meld", $meld );fill_form();}else{if ( ($mode == "save" && $anz >= $t->t_max) || ($mode =="update" && $anz > $t->t_max) ){$meld = "Ein Fehler ist aufgetreten!";$db_meld = "Es kann nur $t->t_max Spiele vom Typ \"$t->t_name\" geben! Bitte den Typ oder ein vorhandenes Spiel ändern!";$error = true;$smarty->assign( "db_meld", $db_meld );$smarty->assign( "error", $error );$smarty->assign( "meld", $meld );fill_form();}else{$res = $game->save( $mode );if ( true == DB::isError($res) ){$smarty->assign( "meld","Ein Fehler ist aufgetreten!" );$smarty->assign( "db_meld", $res->getUserInfo() );$smarty->assign( "error", true );}else{if ( $mode == "save" ){$akt = "hinzugefügt";} elseif ( $mode == "update" ){$akt = "geändert";}else{$akt = "gelöscht";}$smarty->assign( "title", $title );$smarty->assign( "meld","Datensatz erfolgreich $akt!" );$smarty->assign( "db_meld", "" );$logger->info( "Spiel $game->g_name erfolgreich $akt!" );$smarty->assign( "error", false );if ( $mode == "update" ){if ( $game->g_type != 4 ){if ( $game->g_type < 4 ){if ( $game->g_g1 < $game->g_g2 ){$m_id = $game->g_m1;}else{$m_id = $game->g_m2;}}else{$m_id = "$game->g_m1 OR t_id=$game->g_m2";}$sql = "UPDATE teams SET t_aus='$game->g_type' WHERE t_id=$m_id";$res = $db->query( $sql );if ( DB::isError($res) ){$smarty->assign( "meld","Ein Fehler ist aufgetreten!" );$smarty->assign( "db_meld", $db->getUserInfo );$smarty->assign( "error", true );}}}}$smarty->display( "meld.tpl" );}}break;case "ask":$smarty->assign( "title", $title );$smarty->assign( "art", "Spiel" );$smarty->assign( "id", $id );$smarty->assign( "name", $game->g_name );$smarty->display( "del.tpl" );break;default:$smarty->assign( "title", $title );$smarty->assign( "meld", "Ein Fehler ist aufgetreten!" );$smarty->assign( "db_meld", "Ungültiger Modsu!" );$smarty->assign( "error", true );$smarty->display( "meld.tpl" );}}}?>