Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	$self=basename($PHP_SELF);
3
	$tab="Termine";
4
	require_once "../Online-Shop/connect2.php";
5
 
6
	$subtabellen=array();
7
 
8
	if ($action=="update")
9
	{
10
		if (!$ID)
11
		{	// insert Dummy-Entry
12
			$query = "insert into $tab (erstellt_am,erstellt_von) VALUES (NOW(),'$PHP_AUTH_USER')";
13
			$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>".$query."<hr>");
14
			$ID=mysql_insert_id();
15
			// subtabellen versorgen
16
			foreach($subtabellen as $elem)
17
			{
18
				if ($elem[insert])
19
				{
20
					$query = "insert into $elem[Rufname] (Firmenverzeichnis,erstellt_am,erstellt_von) VALUES ($ID,NOW(),'$PHP_AUTH_USER')";
21
					$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>".$query."<hr>");
22
				}
23
			}
24
		}
25
 
26
		unset($HTTP_POST_VARS[action]);
27
		unset($HTTP_POST_VARS[ID]);
28
 
29
		foreach(array_keys($HTTP_POST_VARS) as $elem)
30
		{
31
			if ($elem[0] == "_")
32
			{
33
				unset($HTTP_POST_VARS[$elem]);
34
				$button=$$elem;
35
				$elem=substr($elem,1);
36
				$Pfad=$HTTP_POST_VARS[$elem."_Pfad"];
37
				unset($HTTP_POST_VARS[$elem."_Pfad"]);
38
				$image=$$elem;
39
				$image_name=$elem."_name";
40
				$image_name=urlencode($$image_name);
41
				switch ($button)
42
				{
43
					case 0:
44
						break;
45
					case 1:
46
						$HTTP_POST_VARS[$elem]='';
47
	   					break;
48
	   				case 2:
49
						$image_name=$ID."_".$image_name;
50
						//$image_name=$ID.strrchr($image_name,".");
51
						$HTTP_POST_VARS[$elem]=$image_name;
52
						copy($image,$Pfad.$image_name);
53
				        break;
54
				    default:
55
				        break;
56
			    }
57
			}
58
		}
59
		$HTTP_POST_VARS[Datum]=human2date($HTTP_POST_VARS[Datum]);
60
		$names=array();
61
		foreach(array_keys($HTTP_POST_VARS) as $elem)
62
		{
63
			array_push($names,"$elem='$HTTP_POST_VARS[$elem]'");
64
		}
65
		$query="update $tab set ".join($names,', ');
66
		$query=$query.", letzte_Aenderung_am=NOW(), letzte_Aenderung_von='$PHP_AUTH_USER' where ID = '$ID'";
67
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
68
		header("Location: ".$self);
69
	}
70
 
71
	if ($action=="delete")
72
	{
73
		if ($ID)
74
		{
75
			$condition=array();
76
			foreach ($ID as $elem)
77
			{
78
				array_push($condition," ID = '$elem'");
79
			}
80
			$cond=join(" or ",$condition);
81
			$query = "DELETE FROM $tab WHERE $cond";
82
			$result = mysql_query ("$query") or die (mysql_errno().": ".mysql_error());
83
			foreach($subtabellen as $elem)
84
			{
85
				if ($elem[delete])
86
				{
87
					$condition=array();
88
					foreach ($ID as $elem2) { array_push($condition," $elem[foreign_key] = '$elem2'"); }
89
					$cond=join(" or ",$condition);
90
 
91
					$query = "DELETE FROM $elem[rufname] WHERE $cond";
92
					$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>".$query."<hr>");
93
				}
94
			}
95
 
96
			header("Location: ".$self);
97
		}
98
	}
99
	if (!$action)
100
	{
101
		$action="select_edit";
102
	}
103
	if (!$sort) {$sort='Rufname';}
104
?>
105
 
106
<html>
107
<head>
108
<title>Vorlage: Redaktionssystem</title>
109
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
110
<link rel=stylesheet type="text/css" href="../buttons.css">
111
<!--
112
<style type="text/css" link="buttons.css"><? //require_once "buttons.css"; ?></style>
113
-->
114
<script language="JavaScript">
115
<!--
116
function MM_swapImgRestore() { //v3.0
117
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
118
}
119
 
120
function MM_preloadImages() { //v3.0
121
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
122
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
123
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
124
}
125
 
126
function MM_findObj(n, d) { //v4.01
127
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
128
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
129
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
130
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
131
  if(!x && d.getElementById) x=d.getElementById(n); return x;
132
}
133
 
134
function MM_swapImage() { //v3.0
135
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
136
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
137
}
138
//-->
139
</script>
140
<script language="JavaScript" src="checkDate.js"></script>
141
<meta name="description" content="Redaktionssystem">
142
<meta name="author" content="Webagentur Niewerth">
143
<meta name="robots" content="noindex">
144
</head>
145
<body bgcolor="#<? echo $webs[bgcolor_seite]; ?>" leftmargin="20" topmargin="10" marginwidth="20" marginheight="10" onLoad="MM_preloadImages('../images/navigation/bt_neu_f2.gif','../images/navigation/bt_delete_f2.gif','../images/navigation/bt_bearbeiten_f2.gif','../images/bt_neu_f2.gif','../images/bt_bearbeiten_f2.gif','../images/bt_delete_f2.gif')" text="#<? echo $webs[font_color_seite]; ?>">
146
<form method="post" action="<? echo $self ?>" name="formname" enctype="multipart/form-data">
147
  <table width="662" border="0" cellspacing="0" cellpadding="0">
148
    <tr>
149
      <td colspan="2" valign="top">
150
  <!--  Auswahl Löschen START  -->
151
  <?
152
	if ($action=="delete")
153
	{
154
		$query="SELECT * FROM $tab ";
155
		$query=$query."order by $sort";
156
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
157
		if (mysql_num_rows($result) == 0)
158
		{
159
?>
160
  <p class="error">Es sind keine Daten eingetragen !</p>
161
  <p></p>
162
  <?
163
		}
164
		else
165
		{
166
?>
167
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
168
          <tr>
169
            <td class="headline" colspan="2" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Termine
170
              (allgemeine Informationen) : L&ouml;schen</font></td>
171
          </tr>
172
          <?
173
	while ($zeile=mysql_fetch_array($result))
174
	{
175
?>
176
          <tr>
177
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
178
              <? echo $zeile[Rufname]?>
179
              , </a><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
180
              <? echo $zeile[Feiertag]?>
181
              ,
182
              <? echo date2human($zeile[Datum])?>
183
              </a> </td>
184
            <td width="5%" align="center" bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
185
              <input type="checkbox" name="ID[]" value="<?  echo $zeile[ID] ?>">
186
            </td>
187
          </tr>
188
          <?
189
	}
190
?>
191
          <tr>
192
            <td colspan="2" align="right" bgcolor="#<? echo $webs[bgcolor_links] ?>">
193
              <a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
194
              <? echo $zeile[Rufname] ?>
195
              </a>
196
              <input type="hidden" name="action" value='delete'>
197
              <input name="submit" type="submit" value="LÖSCHEN">
198
              <input type="reset" name="Button22" value="Zur&uuml;cksetzen">
199
            </td>
200
          </tr>
201
        </table>
202
        <?
203
		}
204
?>
205
        <?
206
 	}
207
?>
208
        <!--  Auswahl Löschen ENDE  -->
209
        <!--  Auswahl SELECT_EDIT START  -->
210
        <?
211
 
212
  if ($action=="select_edit")
213
	{
214
	$query="SELECT * FROM $tab ";
215
	$query=$query."order by $sort";
216
 
217
	$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
218
	$count = mysql_num_rows($result);
219
	if ($count == 0)
220
	{
221
	?>
222
        <p class="error">Es sind keine Daten eingetragen !</p>
223
        <p></p>
224
        <?
225
	}
226
	else
227
	{
228
	?>
229
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
230
          <tr>
231
            <td class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>" colspan="2">
232
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
233
                <tr>
234
                  <td class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Termine
235
                    (allgemeine Informationen) : Bearbeiten</font></td>
236
                  <td align="right" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">
237
                    <? echo $count ?>
238
                    Eintr&auml;ge</font></td>
239
                </tr>
240
              </table>
241
            </td>
242
          </tr>
243
          <tr>
244
            <td colspan="2" class="headline"><a href="<? echo $self ?>?action=select_edit&sort=Rufname">Rufname</a>,
245
              <a href="<? echo $self ?>?action=select_edit&sort=Feiertag">Feiertag</a>,
246
              <a href="<? echo $self ?>?action=select_edit&sort=Datum">Datum</a></td>
247
          </tr>
248
          <?
249
	while ($zeile=mysql_fetch_array($result))
250
	{
251
?>
252
          <tr>
253
            <td colspan="2" bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
254
              <? echo $zeile[Rufname] ?>
255
              ,
256
              <? echo $zeile[Feiertag] ?>
257
              , </a><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
258
              <? echo date2human($zeile[Datum])?>
259
              </a></td>
260
          </tr>
261
          <?
262
	}
263
?>
264
          <tr>
265
            <td colspan="2" bgcolor="#<? echo $webs[bgcolor_links] ?>">&nbsp;</td>
266
          </tr>
267
        </table>
268
        <?
269
	}
270
?>
271
        <?
272
 	}
273
?>
274
        <!--  Auswahl SELECT_EDIT ENDE  -->
275
        <?
276
	if ($action=="edit")
277
	{
278
		if ($ID)
279
		{
280
			$result = mysql_query ("SELECT * FROM $tab where ID = '$ID'") or die (mysql_errno().": ".mysql_error());
281
			$zeile=mysql_fetch_array($result);
282
		}
283
	?>
284
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
285
          <tr>
286
            <td colspan="2" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Termine (allgemeine Informationen)
287
              :
288
              <?
289
					if ($ID)
290
					{
291
					 ?>
292
              Bearbeiten
293
              <?
294
					}
295
					else
296
					{
297
					 ?>
298
              Neueintrag
299
              <?
300
					}
301
				?></font>
302
            </td>
303
          </tr>
304
          <tr>
305
            <td class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Rufname:
306
              <?
307
					if ($ID)
308
					{
309
					$query="SELECT Rufname, Feiertag, Vortag FROM Termine where ID = $zeile[ID]";
310
					$result_Mitarbeiter = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
311
					$zeile_Mitarbeiter=mysql_fetch_array($result_Mitarbeiter);
312
					 ?>
313
              <?
314
					}
315
					else
316
					{
317
					 ?>
318
              <?
319
					}
320
				?></font>
321
            </td>
322
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
323
              <input name="Rufname" type="text" id="Rufname" value="<? echo $zeile[Rufname] ?>" size="30">
324
            </td>
325
          </tr>
326
          <tr>
327
            <td height="30" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Feiertag:</font></td>
328
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
329
              <input name="Feiertag" type="text" id="Feiertag" onFocus="current_value=this.value;if (this.value=='') {this.value=today()};this.select();" onChange="this.value=check_Date(this.value)" value="<? echo $zeile[Feiertag] ?>" size="30">
330
            </td>
331
          </tr>
332
          <tr>
333
            <td height="30" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Datum:</font></td>
334
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
335
              <input name="Datum" type="text" id="Datum" value="<? echo date2human($zeile[Datum]) ?>" size="30">
336
            </td>
337
          </tr>
338
          <tr>
339
            <td height="30" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Vortag:</font></td>
340
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
341
              <input name="Vortag" type="text" id="Vortag" value="<? echo $zeile[Vortag] ?>" size="30">
342
            </td>
343
          </tr>
344
          <tr>
345
            <td height="30" class="headline" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">Startseite:</font></td>
346
            <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
347
			<input type="hidden" name="Startseite" value="0">
348
              <input name="Startseite" type="checkbox" id="Startseite" value="1" <? if ($zeile[Startseite]==1){echo checked;}?>>
349
              Termine auf Startseite anzeigen?</td>
350
          </tr>
351
          <?
352
	if ($ID)
353
	{
354
?>
355
          <tr>
356
            <td class="headline" colspan="2" align="center" nowrap bgcolor="#<? echo $webs[bgcolor_links] ?>">&nbsp;</td>
357
          </tr>
358
          <tr>
359
            <td class="headline" width="20%" bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">erstellt am:</font></td>
360
            <? $erstellt_am=datetime2human($zeile[erstellt_am]); ?>
361
            <td class="headline" bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><font color="#<? echo $webs[font_color_rechts] ?>">am:
362
              <? echo $erstellt_am[Datum] ?>
363
              um:
364
              <? echo $erstellt_am[Zeit] ?>
365
              von:
366
              <? echo $zeile[erstellt_von] ?></font>
367
            </td>
368
          </tr>
369
          <tr>
370
            <td class="headline" width="20%" nowrap bgcolor="#<? echo $webs[bgcolor_links] ?>"><font color="#<? echo $webs[font_color_links] ?>">letzte &Auml;nderung:</font></td>
371
            <? $letzte_Aenderung_am=datetime2human($zeile[letzte_Aenderung_am]); ?>
372
            <td class="headline" bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><font color="#<? echo $webs[font_color_rechts] ?>">am:
373
              <? echo $letzte_Aenderung_am[Datum] ?>
374
              um:
375
              <? echo $letzte_Aenderung_am[Zeit] ?>
376
              von:
377
              <? echo $zeile[letzte_Aenderung_von] ?></font>
378
            </td>
379
          </tr>
380
          <?
381
}
382
?>
383
          <tr>
384
            <td align="right" colspan="2" bgcolor="#<? echo $webs[bgcolor_links] ?>">
385
              <input type="hidden" name="ID" value="<? echo $ID ?>">
386
              <input type="hidden" name="action" value="update">
387
              <input type="submit" value="   OK   ">
388
              <input type="reset" name="Button" value="Abbrechen">
389
            </td>
390
          </tr>
391
        </table>
392
        <?
393
	}
394
?>
395
      </td>
396
      <td width="77" align="right" valign="top">
397
        <table width="67" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#999999">
398
          <tr>
399
            <td><a href="<? echo $self ?>?action=edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('new','','../images/navigation/bt_neu_f2.gif',1)"><img name="new" border="0" src="../images/navigation/bt_neu.gif" width="67" height="40" alt="Neueintrag"></a></td>
400
          </tr>
401
          <tr>
402
            <td><a href="<? echo $self ?>?action=select_edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('edit','','../images/navigation/bt_bearbeiten_f2.gif',1)"><img name="edit" border="0" src="../images/navigation/bt_bearbeiten.gif" width="67" height="40" alt="Eintrag bearbeiten"></a></td>
403
          </tr>
404
          <tr>
405
            <td><a href="<? echo $self ?>?action=delete<? if (($action=="edit") && ($ID > 0)) { ?>&ID[]=<?=$ID?>" onClick="return confirm('Diesen Eintrag wirklich löschen ?');"<? } else { ?>"<? } ?> onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('delete','','../images/navigation/bt_delete_f2.gif',1)"><img name="delete" border="0" src="../images/navigation/bt_delete.gif" width="67" height="40" alt="Eintrag l&ouml;schen"></a></td>
406
		</tr>
407
        </table>
408
      </td>
409
    </tr>
410
  </table>
411
</form>
412
</body>