Subversion-Projekte lars-tiefland.em_wm

Revision

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