Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
        function delete_bestellung($BestellID, $deleteLogin = false, $deleteStatistik = false, $noMail = false)
        {
                // LoginID festsstellen
                $query="select Bestellung.Login from Bestellung where ID = $BestellID";
                $result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
                $zeile=mysql_fetch_array($result);
                $LoginID=$zeile[Login];

                /*
                        ####################################################################################################
                */
                global $web_rechte;
                global $PHP_AUTH_USER;
                global $site;
                
                if (deleteLogin == false)
                {
                        $mail = $web_rechte[Warenwirtschaft][bestellung][loeschen];
                }
                else
                {
                        $mail = $web_rechte[Warenwirtschaft][bestellung][loeschen2];
                }

                $queries=array
                (
                        "Bestellung"                            =>      "select *, date_format(erstellt_am, '%d.%m.%Y') as datum from Bestellung where ID = $BestellID",
                        "Kundendaten"                           =>      "select * from Logins where ID = $LoginID",
                        "Artikel der Bestellung"        =>      "select * from artikel_to_Bestellung where Bestellung = $BestellID"
                );

                $text=array();
                foreach(array_keys($queries) as $elem)
                {
                        $query=$queries[$elem];
                        $result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
                        while($buffer=mysql_fetch_assoc($result))
                        {
                                $text[$elem][] = $buffer;
                        }
                        if (count($text[$elem]) == 1)
                        {
                                $text[$elem] = $text[$elem][0];
                        }
                }               

                $datum = array_pop($text[Bestellung]);

                $text = implode
                                (
                                        "\n",
                                        array_slice
                                        (
                                                explode("\n", print_r($text, true)),
                                                2,
                                                -3
                                        )
                                );
                
                if 
                (
                        ($noMail != true)
                        &&
                        (
                                preg_match
                                (
                                        "/^[A-Za-z0-9-_.]+\@[A-Za-z0-9-_]+\.[A-Za-z]+$/",
                                        $mail
                                )
                        )
                )
                {
                        mail
                        (
                                $mail,
                                "Bestellung vom $datum wurde von $PHP_AUTH_USER gelöscht",
                                print_r($text, true),
                                "from: Warenwirtschaftssystem@".$site
                        );
                }

                /*
                        ####################################################################################################
                */

                $queries=array
                (
                        "delete from Bestellung where ID = $BestellID",
                        "delete from artikel_to_Bestellung where Bestellung = $BestellID",
                );
                
                if ($deleteLogin == true)
                {
                        $queries[] = "delete from Logins where ID = $LoginID";
                }

                if ($deleteStatistik == true)
                {
                        $queries[] = "delete from shop_log where eintrag3 = '".$BestellID."'";
                }

                foreach($queries as $query)
                {
                        $result = mysql_query ($query);
                }               
        }
?>