Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 40 | Revision 45 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

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