Subversion-Projekte lars-tiefland.em_wm

Revision

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