Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 32 | Revision 35 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
16 lars 1
<?
2
	define("IN_ADMIN", true);
3
	require("include/common.php");
4
	$mode=isset($_POST["mode"])?$_POST["mode"]:"";
5
	$id=intval(isset($_POST["id"])?$_POST["id"]:0);
32 lars 6
	$g_m1=intval(isset($_POST["g_m1"])?$_POST["g_m1"]:-1);
7
	$g_m2=intval(isset($_POST["g_m2"])?$_POST["g_m2"]:-1);
8
	$g_g1=intval(isset($_POST["g_g1"])?$_POST["g_g1"]:-1);
9
	$g_g2=intval(isset($_POST["g_g2"])?$_POST["g_g2"]:-1);
10
	$g_location=intval(isset($_POST["g_location"])?$_POST["g_location"]:-1);
11
	$g_type=intval(isset($_POST["g_typ"])?$_POST["g_typ"]:-1);
12
	$g_name=addslashes(isset($_POST["g_name"])?$_POST["g_name"]:"");
13
	$month=intval(isset($_POST["Month"])?$_POST["Month"]:-1);
14
	$day=intval(isset($_POST["Day"])?$_POST["Day"]:-1);
15
	$hour=intval(isset($_POST["Hour"])?$_POST["Hour"]:-1);
33 lars 16
	$game=new Spiele($id);
32 lars 17
	if ($hour >=0 AND $day > 0 AND $month > 0)
18
	{
19
		$g_date=mktime($hour, 0, 0, $month, $day, 2006);
20
	}
31 lars 21
	function fill_form()
18 lars 22
	{
33 lars 23
		global $db, $smarty, $id, $new_mode, $g_date, $title, $game;
16 lars 24
		$t_namen[]="Bitte wählen!";
25
		$t_ids[]=-1;
18 lars 26
		$typ_namen[]="Bitte wählen!";
27
		$typ_ids[]=-1;
16 lars 28
		$l_namen[]="Bitte wählen!";
29
		$l_ids[]=-1;
30
		$g_l=Gruppe::listeGruppe(0,0);
31
		while($row_g=$g_l->fetchRow(DB_FETCHMODE_ASSOC))
32
		{
33
			$g_id=$row_g["g_id"];
34
			$g_name=$row_g["g_name"];
35
			$t_namen[]="---------- Gruppe $g_name ----------";
36
			$t_ids[]=-1;
37
			$sql_t="SELECT * FROM teams WHERE t_group=$g_id";
38
			$t_l=$db->query($sql_t);
39
			while ($row_t=$t_l->fetchRow(DB_FETCHMODE_ASSOC))
40
			{
41
				$t_name=$row_t["t_name"];
42
				$t_id=$row_t["t_id"];
43
				$t_namen[]=$t_name;
44
				$t_ids[]=$t_id;
19 lars 45
			}
16 lars 46
		}
18 lars 47
		$l_l=Ort::listeOrt(0,0);
16 lars 48
		while ($row_l=$l_l->fetchRow(DB_FETCHMODE_ASSOC))
49
		{
50
			$l_name=$row_l["l_name"];
51
			$l_id=$row_l["l_id"];
52
			$l_namen[]=$l_name;
53
			$l_ids[]=$l_id;
19 lars 54
		}
18 lars 55
		$typ_l=Typ::listeTyp(0,0);
56
		while ($row_typ=$typ_l->fetchRow(DB_FETCHMODE_ASSOC))
57
		{
58
			$typ_name=$row_typ["t_name"];
59
			$typ_id=$row_typ["t_id"];
60
			$typ_namen[]=$typ_name;
61
			$typ_ids[]=$typ_id;
62
		}
28 lars 63
		$smarty->assign("id", $id);
33 lars 64
		$smarty->assign("g_date", (!isset($g_date))?$game->g_date:$g_date);
65
		$smarty->assign("g_name", ($game->g_name));
18 lars 66
		$smarty->assign("akt_typ_id", $game->g_type);
67
		$smarty->assign("akt_m1_id", $game->g_m1);
68
		$smarty->assign("akt_m2_id", $game->g_m2);
69
		$smarty->assign("akt_l_id", $game->g_location);
19 lars 70
		$smarty->assign("g_g1", $game->g_g1);
71
		$smarty->assign("g_g2", $game->g_g2);
18 lars 72
		$smarty->assign("t_namen", $t_namen);
73
		$smarty->assign("t_ids", $t_ids);
74
		$smarty->assign("typ_namen", $typ_namen);
75
		$smarty->assign("typ_ids", $typ_ids);
76
		$smarty->assign("l_ids", $l_ids);
77
		$smarty->assign("l_namen", $l_namen);
78
		$smarty->assign("mode", $new_mode);
79
		$smarty->assign("title", $title);
16 lars 80
		$smarty->display("edit_games.tpl");
81
	}
31 lars 82
 
83
	switch ($mode)
84
	{
85
		case "edit":
86
			$title="Spiel $id ändern";
87
			$new_mode="update";
88
			break;
89
		case "new":
90
			$title="neues Spiel eingeben";
91
			$new_mode="save";
92
			break;
93
		case "del":
94
		case "ask":
95
			$title="Spiel $id löschen";
96
			$new_mode="update";
97
			break;
98
		case "save":
99
			$title="neues Spiel speichern";
100
			$new_mode="update";
101
			break;
102
		case "update":
103
			$title="Spiel $id speichern";
104
			$new_mode="update";
105
			break;
106
	}
107
	if ($mode=="edit" OR $mode=="new")
108
	{
109
		fill_form();
110
	}
18 lars 111
	else
112
	{
113
		switch ($mode)
114
		{
115
			case "save":
28 lars 116
			case "del":
19 lars 117
			case "update":
31 lars 118
				if (!checkdate($month, $day, $config->year))
28 lars 119
				{
31 lars 120
					$meld="Ein Fehler ist aufgetreten!";
121
					$db_meld="$day.$month.$config->year ist kein gültiges Datum!";
122
						$error=true;
123
					$smarty->assign("db_meld", $db_meld);
124
					$smarty->assign("error", $error);
125
					$smarty->assign("meld", $meld);
126
					fill_form();
28 lars 127
				}
30 lars 128
				else
129
				{
31 lars 130
					$g=new Spiele($id);
131
					$g->update($g_name, $g_m1, $g_m2, $g_g1, $g_g2, $g_location, $g_date, $g_type);
132
					$res=$g->save($mode);
133
					if (true == DB::isError($res))
30 lars 134
					{
31 lars 135
						$smarty->assign("meld", "Ein Fehler ist aufgetreten!");
136
						$smarty->assign("db_meld", $res->getUserInfo());
137
						$smarty->assign("error", true);
30 lars 138
					}
139
					else
140
					{
31 lars 141
						if ($mode=="save")
142
						{
143
							$akt="hinzugefügt";
144
						}
145
						elseif ($mode=="update")
146
						{
147
							$akt="geändert";
148
						}
149
						else
150
						{
151
							$akt="gelöscht";
152
						}
153
						$smarty->assign("meld", "Datensatz erfolgreich $akt!");
154
						$smarty->assign("db_meld", "");
155
						$smarty->assign("error", false);
30 lars 156
					}
31 lars 157
					$smarty->display("meld.tpl");
30 lars 158
				}
19 lars 159
				break;
30 lars 160
			case "ask":
33 lars 161
				$smarty->assign("title", $title);
162
				$smarty->assign("art", "Spiel");
163
				$smarty->assign("id", $id);
164
				$smarty->assign("name",$game->g_name);
165
				$smarty->display("del.tpl");
30 lars 166
				break;
167
			default:
168
				$smarty->assign("meld","Ein Fehler ist aufgetreten!");
169
				$smarty->assign("db_meld", "Ungültiger Modsu!");
170
				$smarty->assign("error", true);
31 lars 171
				$smarty->display("meld.tpl");
18 lars 172
		}
173
	}
16 lars 174
?>