Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	function delete_bestellung($BestellID, $deleteLogin = false, $deleteStatistik = false, $noMail = false)
3
	{
4
		// LoginID festsstellen
5
		$query="select Bestellung.Login from Bestellung where ID = $BestellID";
6
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
7
		$zeile=mysql_fetch_array($result);
8
		$LoginID=$zeile[Login];
9
 
10
		/*
11
			####################################################################################################
12
		*/
13
		global $web_rechte;
14
		global $PHP_AUTH_USER;
15
		global $site;
16
 
17
		if (deleteLogin == false)
18
		{
19
			$mail = $web_rechte[Warenwirtschaft][bestellung][loeschen];
20
		}
21
		else
22
		{
23
			$mail = $web_rechte[Warenwirtschaft][bestellung][loeschen2];
24
		}
25
 
26
		$queries=array
27
		(
28
			"Bestellung"				=>	"select *, date_format(erstellt_am, '%d.%m.%Y') as datum from Bestellung where ID = $BestellID",
29
			"Kundendaten"				=>	"select * from Logins where ID = $LoginID",
30
			"Artikel der Bestellung"	=>	"select * from artikel_to_Bestellung where Bestellung = $BestellID"
31
		);
32
 
33
		$text=array();
34
		foreach(array_keys($queries) as $elem)
35
		{
36
			$query=$queries[$elem];
37
			$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
38
			while($buffer=mysql_fetch_assoc($result))
39
			{
40
				$text[$elem][] = $buffer;
41
			}
42
			if (count($text[$elem]) == 1)
43
			{
44
				$text[$elem] = $text[$elem][0];
45
			}
46
		}
47
 
48
		$datum = array_pop($text[Bestellung]);
49
 
50
		$text = implode
51
				(
52
					"\n",
53
					array_slice
54
					(
55
						explode("\n", print_r($text, true)),
56
						2,
57
						-3
58
					)
59
				);
60
 
61
		if
62
		(
63
			($noMail != true)
64
			&&
65
			(
66
				preg_match
67
				(
68
					"/^[A-Za-z0-9-_.]+\@[A-Za-z0-9-_]+\.[A-Za-z]+$/",
69
					$mail
70
				)
71
			)
72
		)
73
		{
74
			mail
75
			(
76
				$mail,
77
				"Bestellung vom $datum wurde von $PHP_AUTH_USER gelöscht",
78
				print_r($text, true),
79
				"from: Warenwirtschaftssystem@".$site
80
			);
81
		}
82
 
83
		/*
84
			####################################################################################################
85
		*/
86
 
87
		$queries=array
88
		(
89
			"delete from Bestellung where ID = $BestellID",
90
			"delete from artikel_to_Bestellung where Bestellung = $BestellID",
91
		);
92
 
93
		if ($deleteLogin == true)
94
		{
95
			$queries[] = "delete from Logins where ID = $LoginID";
96
		}
97
 
98
		if ($deleteStatistik == true)
99
		{
100
			$queries[] = "delete from shop_log where eintrag3 = '".$BestellID."'";
101
		}
102
 
103
		foreach($queries as $query)
104
		{
105
			$result = mysql_query ($query);
106
		}
107
	}
108
?>