Subversion-Projekte lars-tiefland.php_share

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php
    /* $Id: Weban_Shop.class.php 21 2007-12-07 09:04:37Z markus $ */

    /**
     * Shop module class. This builds the Base class for
     * the shop module and is created for further updates.
     *
     * This class handles the traffic between a client and the 
     * server. My clou is to put any used Function in a Method
     * formate and replace them with the original.
     *
     * PHP versions 4 and 5
     *
     * LICENSE: This source file is subject to version 3.0 of the PHP license
     * that is available through the world-wide-web at the following URI:
     * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
     * the PHP License and are unable to obtain it through the web, please
     * send a note to license@php.net so we can mail you a copy immediately.
     *
     * @category   Shop
     * @package    Weban_Shop
     * @author     Markus Niewerth <markus@weban.de>
     * @copyright  1997-2005 The PHP Group
     * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
     * @since      File available since Release 1.0.1
     */


    // {{{ constants
    define( '__BASELANGUAGE__', 'DE' );
    define( '__SHOP_ID__', 1 );
    define( '__TEMPLATE_EXTENSION__', '.htm' );
    define( '__IMAGE_POPUP_TAG__', file_get_contents("templates/Weban_Shop/image.htm", true) );
    define( '__IMAGE_EMAIL_INPUT__', $_SESSION['INI']['emailInputImage'] );
    define( '__EMAIL_IMAGE_CONTENT_TYPE__', $_SESSION['INI']['emailImageOutput'] );
    define( '__GD_TTF_FONT__', $_SESSION['INI']['gdTTFFont'] );

    // }}}
    // {{{ GLOBALS

    // -------------------
    // IF any put in here!
    // -------------------

    // }}}
    // {{{ Weban_Shop

    /**
     * Dies bildet die Basis Klasse f�r das Shop Modul.
     *
     * Diese Klasse bildet die Schnittstelle zwischen dem Client
     * und dem Server und wird die Funktionssyntax abl�sen.
     * Neue Funktionen werden nur noch in Form von Methoden 
     * implementiert. Alle �lteren Funktionen sollten wenn m�glich 
     * hier als Methoden implementiert werden.
     *
     * Funktionen k�nnen aber auch in einer Sammlung gekapselt
     * werden. So, dass sie zum Beispiel eine eigene Klasse bilden
     * (sinnvoll bei Datenbank Funktionen)
     *
     * @category   CMS
     * @package    Weban_Shop
     * @author     Markus Niewerth      <markus@weban.de>
     * @author     Lars Tiefland        <tiefland@weban.de>
     * @copyright  1997-2007 Webagentur Niewerth
     * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
     * @link       http://server2/intranet/3_0.txt
     * @see        Functions
     * @since      Class available since Release 1.1
     */

    class Weban_Shop
    {

        // {{{ properties

        /**
         * The Shops ID number.
         * 
         * Its a very important ID, cause the 
         * ID is saved in any userdefined data-
         * base entry like articles a.s.o.
         *
         * @var int     
         */
        var $shopsId;

        /**
         * The Shop language.
         *
         * The Base language is DE. Note that this
         * value could be mixed! But stadard is DE
         *
         * @var         array    
         */
        var $language;

        /**
         * The Functions Object
         *
         * A refference to the Functions Object 
         * constructed with this Base Class.
         * ote that you have to call to the 
         * object with the -> operator, like:
         * $Weban_Shop->Functions->Method()
         *
         * @var object
         * @var object           
         */
        var $Functions;

        var $Rapid_Templates;

        var $Basket;

        var $Error;

        // }}}
        // {{{ Weban_Shop()

        /**
         * Base Constructor
         *
         * @param       object
         * @param       object  
         * @return      Weban_Shop       
         */
        function Weban_Shop( $shopsId = 1, $language = __BASELANGUAGE__ )
        {

            $this->shopsId = $shopsId;
            $this->language = $language;

            // Construct the Functions Object
            $this->Functions = &new Functions( $this->shopsId, $this->language );
            $this->Rapid_Templates = &new Rapid_Templates( $this->shopsId,
                __TEMPLATE_EXTENSION__, '' );
            $this->Basket = &new Basket( $this->shopsId, __TEMPLATE_EXTENSION__ );
            $this->Error = &new Error( $this->shopsId, $this->language );
        }
        // }}}

        function showBasket( $templateRoot )
        {
            $template = loadTemplates( $templateRoot );
            $buffer = array();
            $content = array();

            $basketItems = getBasketItems();

            if ( $basketItems == array() )
            {
                echo templateContent( array(), $template["basketEmpty"] );
                echo $this->Rapid_Templates->rapidEngine();
            }
            else
            {
                foreach ( $basketItems as $elem )
                {
                    if ( $elem["Father"] != -3 )
                    {
                        $addonItems = array();

                        foreach ( getAddOnItems($elem["ID"]) as $addonItem )
                        {
                            templateContent( $addOnItem, $template["addOnItemImage"] );
                        }
                        $elem[MengeAdd] = $elem[Menge] + 1;
                        $elem[MengeSub] = $elem[Menge] - 1;

                        $buffer[] = templateContent( $elem, $template["basketItem"] );
                    }
                }

                $content["basketItems"] = implode( "", $buffer );

                // Gesamtsumme ausgeben
                $content["basketSumme"] = templateContent( array("title" =>
                    "Gesamtsumme (inkl. 19 % MwSt.: " . numberFormat(getBasketSummeMWST()) .
                    "&nbsp;&euro;)", "summe" => numberFormat(getBasketSumme()) . "&nbsp;&euro;"),
                    $template["msg"] );

                unset( $msg );

                // Versandoptionen lesen und ausgeben
                $versandarten = array();

                foreach ( getVersandItems() as $vItem )
                {
                    $vItem_Beschreibung = $vItem[beschr];
                    $vItem[preis] = numberFormat( $vItem[preis] ) . "&euro;";
                    $versandarten[] = templateContent( $vItem, $template[versandItem] );
                }

                if ( $_SESSION[SHOP][Lieferadresse] == "true" )
                {
                    $Land = $_SESSION[SHOP][buy][Persdata][liefer_Land];
                }
                else
                {
                    $Land = $_SESSION[SHOP][buy][Persdata][Land];
                }

                $msg[title] = "M&ouml;gliche Versandarten f&uuml;r " . getCountryByID( $Land ) .
                    " (inkl. 19% MwSt.):<br>";
                $msg[Versand] = "<ul>" . implode( "", $versandarten ) . "</ul>";
                if ( count($versandarten) == 1 )
                {
                    $msg[Versand] .= "<p>" . $vItem_Beschreibung . "</p>";
                }
                $content["basketVersand"] = templateContent( $msg, $template["msg"] );
                unset( $msg );

                echo templateContent( $content, $template["basketContainer"] );

            }
        }

        function getNavTree( $root = "root", $rootInfo = false )
        {
            static $getNavTreeBuffer = array();

            if ( $getNavTreeBuffer != array() )
            {
                $buffer = $getNavTreeBuffer;
            }
            else
            {
                $query = "
                                select
                                        directory.*,
                                        if (directory.Father = -1, 'root', directory.Father) as Father,
                                        Herstellerkatalog.Logo1 as Logo
                                from
                                        directory
                                left join
                                        Herstellerkatalog
                                on
                                        Herstellerkatalog.Bezeichnung = directory.Name
                                where
                                        directory.status=0
                                and
                                        directory.Artikelstamm=0
                                and
                                        directory.Language= '" . $_SESSION['INI']['language'] . "'
                                order by
                                        directory.Kennung               
                        ";

                $buffer = array();
                $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
                    "<hr>$query<hr>" );
                while ( $zeile = mysql_fetch_assoc($result) )
                {
                    $buffer[$zeile['ID']] = $zeile;
                }

                foreach ( array_keys($buffer) as $id )
                {
                    if ( !$buffer[$id]['childNodes'] )
                    {
                        $buffer[$id]['childNodes'] = array();
                    }
                    $buffer[$buffer[$id]['Father']]['childNodes'][] = &$buffer[$id];
                }
            }

            $getNavTreeBuffer = $buffer;

            if ( $rootInfo == true )
            {
                return $buffer[$root];
            }
            else
            {
                return $buffer[$root]['childNodes'];
            }
        }

        function getPath( $root )
        {
            static $level = 0;
            $level++;

            if ( $root > 0 )
            {
                $query = "
                                select
                                        *
                                from
                                        directory
                                where
                                        ID = $root
                                and
                                        language= '" . $_SESSION['INI']['language'] . "'
                                ";
                $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
                    "<hr>" . $query );
                $zeile = mysql_fetch_assoc( $result );

                // Bilder um Pfad und Tag erweitern
                foreach ( array("", "2") as $i )
                {
                    if ( $zeile["bild_url" . $i] )
                    {
                        $_tmp = $zeile["bild_url" . $i];
                        $zeile["image_tag" . $i] = sprintf( __IMAGE_POPUP_TAG__, $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
                            $i] . $zeile["bild_url" . $i], $zeile["bild_url" . $i], $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
                            $i] . "kl/" . $_tmp );
                        $zeile["bild_url" . $i] = "<img src=" . $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
                            $i] . $_tmp . " >";
                    }
                    else
                    {
                        $zeile["bild_url" . $i] = "";
                    }
                }


                $path = $this->getPath( $zeile['Father'] );

                $path[] = $zeile;

                $level--;

                if ( $level == 0 )
                {
                    foreach ( $path as $p )
                    {
                        if ( $p['status'] == 1 )
                        {
                            $path = array();
                        }
                    }
                }

                return $path;
            }
            else
            {
                $level--;
                return array();
            }
        }

        function _navigation( $root = "root" )
        {
            $treebuffer = $this->getNavTree( $root );
            if ( $treebuffer == array() )
            {
                return;
            }

            $treebufferCount = count( $treebuffer ) - 1;

            foreach ( $treebuffer as $counter => $zeile )
            {
                /* ######################################################################## */
                /* Link entsprechend der Alias-Definition generieren.                                           */
                /* ######################################################################## */
                if ( $_SESSION['INI']['alias'] == 0 )
                {
                    // dirLink
                    $zeile['dirLink'] = "?navigation=" . $zeile['ID'];
                }
                else
                {
                    // Pfad ermitteln
                    $buffer = array();
                    foreach ( $this->getPath($zeile['ID']) as $elem )
                    {
                        $buffer[] = preg_replace( "/[\W]+/", "", $elem['ID'] . "_" . $elem['Name'] );
                    }

                    // dirLink
                    $zeile['dirLink'] = "/" . implode( "/", $buffer ) . "/";
                }

                /* ######################################################################## */
                /* Ausgabe der Unterverzeichnisse                                                                                       */
                /* ######################################################################## */

                $classes = array();
                $classes[] = "normal";
                if ( $_SESSION['navigation']['status'][$zeile['ID']] == true )
                {
                    $classes[] = "active";
                }


                echo "<div class=\"" . implode( " ", $classes ) . "\">";

                echo "<a href=\"" . $zeile['dirLink'] . "\">";
                echo $zeile['Name'];
                echo "</a>";

                if ( ($_SESSION['navigation']['status'][$zeile['ID']] == true) && ($zeile['Father'] ==
                    "root") )
                {
                    $this->navigation( $zeile['ID'] );
                }

                echo "</div>\n";
            }
        }

        function navigation( $root )
        {
            ob_start();
            {
                echo "<div class=nav>";

                if ( $_REQUEST['staticNav'] == "true" )
                {
                    include ( $_SESSION['INI']['staticNav'] );
                }
                else
                {
                    $this->_navigation( $root );
                }

                echo "</div>";
            }
            $_ret = ob_get_contents();
            ob_end_clean();
            return $_ret;
        }


        function shopPosition( $item = "" )
        {
            $return = null;
            $buffer = array();

            foreach ( getPath($_SESSION['navigation']['position']) as $dir )
            {
                if ( $dir['Father'] > 0 )
                {
                    //echo " / ";
                    $return = $return . $_SESSION['INI']['shopPosition']['imageTrennerSrc'];
                }

                $buffer[] = preg_replace( "/[\W]+/", "", $dir['ID'] . "_" . $dir['Name'] );

                if ( $_SESSION['INI']['alias'] == 0 )
                {
                    $link = "?navigation=" . $dir['ID'];
                }
                else
                {
                    $link = "/" . implode( "/", $buffer ) . "/";
                }

                if ( $dir['Artikelstamm'] == 0 )
                {
                    $return = $return . "<a href=\"$link\">" . $dir['Name'] . "</a>";
                }
                else
                {
                    $return = $return . "<a href=\"$link\">" . $dir['Name'] . "</a>";
                }
            }
            if ( is_array($item) )
            {
                //echo " / ";
                $return = $return . "<a href=\"" . $item['itemLink'] . "\">" . $item['kurzbezeichnung'] .
                    "</a>";
            }
            return $return;
        }
        function showError( $msg = "!" )
        {
            echo "<span class=\"error\">" . nl2br( $msg ) . "</span>";
        }

        function getVersandItems()
        {
            if ( $_SESSION['SHOP']['Lieferadresse'] == "true" )
            {
                $Land = $_SESSION['SHOP']['buy']['Persdata']['liefer_Land'];
            }
            else
            {
                $Land = $_SESSION['SHOP']['buy']['Persdata']['Land'];
            }

            if ( !$Land )
            {
                $_SESSION['SHOP']['buy']['Persdata']['Land'] = 1;
                $Land = $_SESSION['SHOP']['buy']['Persdata']['Land'];
            }

            $query = "
                        SELECT
                                ID,
                                kurzbezeichnung as kurz,
                                langbezeichnung as lang,
                                beschreibung as beschr,
                                preis1 as preis,
                                1 as Versand
                        FROM
                                artikel
                        WHERE
                                Father = -3
                        AND 
                                Language = 'DE'
                        AND
                                Lieferstatus & " . $Land . " = " . $Land . "
                        AND
                                status = " . $_SESSION['INI']['shops_ID'] . "
                ";


            if ( $_SESSION['INI']['versandByWeight'] )
            {
                $query .= "
                        AND
                        (
                                (" . $this->Basket->getBasketGewicht() .
                    " between preis_neu1 and preis_neu2)
                                OR
                                ( preis_neu1=preis_neu2)
                        )
                        ";
            }
            else
            {
                $query .= "
                        AND
                        (
                                (" . $this->Basket->getBasketSumme( true ) .
                    " between preis_neu3 and preis_neu4)
                                OR
                                ( preis_neu3 = preis_neu4)
                        )
                        ";
            }
            $query .= " order by Rang asc";

            $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
                pre($query, true) );
            $buffer = array();
            while ( $zeile = mysql_fetch_assoc($result) )
            {
                $buffer[] = $zeile;
            }
            return $buffer;
        }

        function getVersandItem( $gewicht, $preis )
        {
            $query = "
                SELECT
                        ID,
                        kurzbezeichnung as kurz,
                        langbezeichnung as lang,
                        beschreibung as beschr,
                        preis1 as preis,
                        1 as Versand
                FROM
                        artikel
                WHERE
                        Father = -3
                AND 
                        Language = 'DE'
                AND
                        Lieferstatus & 1 = 1
                AND
                        status = " . $_SESSION['INI']['shops_ID'] . "
                AND
                        '" . $gewicht . "' between preis_neu1 and preis_neu2
                AND
                        (
                                ('" . $preis . "' between preis_neu3 and preis_neu4)
                                or
                                (preis_neu3 = preis_neu4)
                        )
                AND
                        kurzbezeichnung like '%Nachnahme%'
                ORDER BY
                        preis1 ASC
                LIMIT 1
                ";


            $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
                pre($query, true) );
            if ( $zeile = mysql_fetch_assoc($result) )
            {
                return $zeile;
            }
            else
            {
                return false;
            }
        }

        function getSelectedVersandItem()
        {
            foreach ( $_SESSION['SHOP']['BASKET'] as $id => $item )
            {
                if ( $item[$opt['ID']]['Versand'] )
                {
                    return $id;
                }
            }
            return false;
        }
        // Formatiert nicht gesetzte argumente mit
        // einem Standard auffüller. Und setzt für
        // alles Umbrüche.
        function formate( $mixed, $fomate = 'getSubDirs' )
        {
            switch ( $formate )
            {
                case 'getSubDirs':
                default:
                    foreach ( array_keys($mixed) as $key )
                    {
                        if ( $key == "Beschreibung" )
                        {
                            $mixed[$key] = empty( $mixed[$key] ) ? $_SESSION['INI']['formateFiller'] :
                                nl2br( $mixed[$key] );
                        }
                    }
                    break;
            }
        }

        function subdir( $dirId )
        {
            $this->counter( $dirId, 'directory', $_SESSION['INI']['shops_ID'] ); // Marked for replace
            $template = loadTemplates( $_SESSION['INI']['TEMPLATE']['subDir'] ); // Marked for replace

            // Unterverzeichnisse + Templates auslesen & ausgeben
            $data = array();

            if ( $_SESSION['INI']['getSubDirs'] )
            {

                $counter = 0;
                $subdirs = getSubDirs( $dirId );
                $subdirlast = sizeof( $subdirs ) - 1;

                // Shop Position ausgeben
                /**
                 * echo "<div id=shopPosition>";
                 * echo $this->shopPosition($dirId, true);
                 * echo "</div>";
                 */

                // Subdirs durchlaufen
                foreach ( $subdirs as $subDir ) // Marked for replace

                {
                    $this->formate( $subDir, 'getSubDirs' );

                    if ( $_SESSION['INI']['alias'] == 0 )
                    {
                        // dirLink
                        $subDir['dirLink'] = "?navigation=" . $subDir['ID'];
                    }
                    else
                    {
                        // Pfad ermitteln
                        $buffer = array();
                        foreach ( getPath($subDir['ID']) as $elem ) // Marked for replace

                        {
                            $buffer[] = preg_replace( "/[\W]+/", "", $elem['ID'] . "_" . $elem['Name'] );
                        }

                        // dirLink
                        $subDir['dirLink'] = "/" . implode( "/", $buffer ) . "/";
                    }

                    $subDir['imageSrcClosed'] = "<img src=" . $_SESSION['INI']['navigation']['imageSrcClosed'] .
                        ">";

                    $data['subDirs'] .= templateContent( $subDir, $template['subDir'] );

                    if ( $counter != $subdirlast )
                    {
                        $data['subDirs'] .= $_SESSION['INI']['subdir']['seperator'];
                    }

                    $counter++;
                }
                $prepare = array( "shopPosition" => $data['subDirs'] );


                $data['subDirs'] = templateContent( $prepare, $template['subDirNavContainer'] );
            }
            // $data['subDirs'].=$this->Rapid_Templates->rapidEngine('templates/subdir_new/subdir', $subDir, true);

            if ( count($data) > 0 && strtolower($_SESSION['INI']['shopPosition']['position']) ==
                'top' )
            {
                echo templateContent( $data, $template['subDirContainer'] ); // Marked for replace
            }

            // Verzeichnistemplate auslesen & ausgeben
            $dirInfo = array_pop( $this->getPath($dirId) );
            $dirInfo['PATH'] = $this->shopPosition( $dirId, true );
            $dirInfo['TopText'] = "Ordner";

            echo templateContent( $dirInfo, $template['subDirHead'] ); // Marked for replace

            if ( $_GET["hersteller"] )
            {
                $cond = "kurzbezeichnung like '" . $_GET["hersteller"] . "%' ";
            }
            else
            {
                $cond = 1;
            }

            switch ( $_REQUEST['sort'] )
            {
                case "asc":
                    $items = getItems( $dirId, "artikel.preis" . $_SESSION['INI']['indexPreis'] .
                        " asc", $cond ); // Marked for replace
                    break;
                case "desc":
                    $items = getItems( $dirId, "artikel.preis" . $_SESSION['INI']['indexPreis'] .
                        " desc", $cond ); // Marked for replace
                    break;
                default:
                    $items = getItems( $dirId, "artikel.kurzbezeichnung", $cond ); // Marked for replace
                    break;
            }
            if ( count($data) > 0 && strtolower($_SESSION['INI']['shopPosition']['position']) ==
                'bottom' )
            {
                echo templateContent( $data, $template['subDirContainer'] ); // Marked for replace
            }
            $sort = array();

            // Herstellerauswahl erstellen
            // Wenn mehr als 1 Hersteller ... Auswahlliste ausgeben
            $hersteller = getItemsHersteller( $dirId ); // Marked for replace
            if ( count($hersteller) > 1 )
            {
                $herstellerBuffer = "";
                foreach ( $hersteller as $elem )
                {
                    if ( $elem["Bezeichnung"] == $_GET["hersteller"] )
                    {
                        $elem["selected"] = " selected";
                    }
                    $herstellerBuffer .= templateContent( $elem, $template["herstellerOption"] ); // Marked for replace
                }

                $sort["herstellerSelect"] = templateContent( array_merge($_GET, array("herstellerListe" =>
                    $herstellerBuffer)), $template["herstellerSelect"] );
            }

            // Sort-Buttons ausgeben falls gen�gend Items vorhanden
            if ( count($items) > $_SESSION['INI']['subDirSortMin'] )
            {
                switch ( $_GET["sort"] )
                {
                    case "asc":
                        $data = array( "asc" => " selected" );
                        break;
                    case "desc":
                        $data = array( "desc" => " selected" );
                        break;
                    default:
                        break;
                }

                if ( $_SESSION['INI']['preisSort'] )
                {
                    $sort["preisSort"] = templateContent( $data, $template["preisSort"] );
                }
                else
                {
                    $sort["preisSort"] = null;
                }
            } // Marked for replace


            if ( $_SESSION['INI']['subDirSort'] )
            {
                echo templateContent( $sort, $template['subDirSort'] ); // Marked for replace
            }

            echo "<div style=\"clear:both\"></div>";

            // Artikel und Artikelst�mme auslesen und vereinigen
            // getItemContainers: Artikelst�mme als Artikel maskieren
            // $items beinhaltet zu diesem Zeitpunkt die Artikel des Unterverzeichnisses
            $items = array_merge( getItemContainers($dirId), // Marked for replace
                $items );

            // Artikel ausgeben
            foreach ( $items as $item )
            {
                $item['Lieferstatus'] = templateContent( $item, $template["lieferstatus" . $item['LieferstatusValue']] );

                if ( $item['billigerGesehen'] )
                {
                    $item['billigerGesehen'] = templateContent( $item, $template['billigerGesehen'] );
                }

                if ( $item['Artikelstamm'] == 0 )
                {
                    echo templateContent( $item, $template['item'] );
                }
                else
                {
                    echo templateContent( $item, $template['itemContainer'] );
                }
            }
        }

        function counter( $ID, $typ, $shops_ID )
        {
            $query = array( "update" => "update
                                                                counter
                                                        set
                                                                impressionCounter = impressionCounter + 1
                                                        where
                                                                ID = $ID
                                                        and
                                                                typ = '$typ'
                                                        and
                                                                shops_ID = $shops_ID
                                                        and 
                                                                date = date_format(NOW(),'%Y-%m-%d')", "insert" => "insert into
                                                                counter
                                                        values
                                                        (
                                                                $ID,
                                                                $shops_ID,
                                                                '$typ',
                                                                date_format(NOW(),'%Y-%m-%d'),
                                                                0,
                                                                0,
                                                                0
                                                        )
                                                        " );

            mysql_query( $query['insert'] );
            mysql_query( $query['update'] );
        }

    function createMailOrderText()
    {
        //$ret = getAbschlag();
        $text = "\nMenge   Art-Nr. Artikelname                      Einzelpreis    Gesamtpreis\n___________________________________________________________________________\n";

        /*
        $query = "
        select
        *
        from
        artikel
        where
        (
        ID = " . implode( " or ID = ", array_keys($_SESSION['SHOP']['BASKET']) ) .
        "
        )
        and
        Language='" . $_SESSION['INI']['language'] . "'
        order by
        Father desc,Kennung
        ";
        $result = mysql_query( $query ) or mail( "niewerth@weban.de",
        "Fehler in createMailOrderText.php", mysql_errno() . ": " .
        mysql_error() . "<hr>$query<hr>", "from: hausshop-24.de" );
        */

        foreach ( $_SESSION['SHOP']['BASKET'] as $basketItemID => $elem )
                {

            //while ( $zeile = @mysql_fetch_array($result) )
            //{
            //$zeile = itemKorrektur( $elem );

            $zeile = getItem( $elem['ID'] );

            if ( stristr( $zeile['kurzbezeichnung'], 'Nachnahme' ) )
            {
                $nachnamegebuehr = "\n\r + Nachnahmegebühr, welche vom Auslieferer erhoben wird.\n\r";
            }

            if ( $elem['Versand'] )
            {
                $text = $text . "\n1     x Versand: " . str_pad( $zeile['kurzbezeichnung'],
                    37 ) . str_pad( number_format( $zeile['preis'], 2, ',',
                    '.' ), 14, " ", STR_PAD_LEFT ) . " EUR";
                if ( is_numeric( $zeile["preis2"] ) && $zeile["preis2"] > 0 )
                {
                    $text = $text . "\n" . str_pad( "1", 5 ) . " x " .
                        str_pad( "Zahlungssystemaufschlag", 31 ) . " " .
                        str_pad( numberFormat( getAufschlag() ), 6, " ",
                        STR_PAD_LEFT ) . " Euro" . str_pad( numberFormat( getAufschlag
                        () ), 10, " ", STR_PAD_LEFT ) . " Euro\n";
                }
            }
            else
            {
                /* START Artikeloptionen zusammenstellen */
                if ( is_array( $elem['option'] ) )
                {
                    $query_Feature_options =
                        "select * from Feature_options where ID = " .
                        implode( " or ID = ", $elem['option'] );
                    $result_Feature_options = mysql_query( $query_Feature_options ) or
                        mail( "niewerth@weban.de",
                        "Fehler2 in createMailOrderText.php", mysql_errno() .
                        ": " . mysql_error() . "<hr>$query<hr>",
                        "from: it-styles.de" );


                    while ( $zeile_Feature_options = mysql_fetch_array( $result_Feature_options ) )
                    {
                        $Feature_options[] = $zeile_Feature_options['Value'];
                    }
                    $optionen = " (" . implode( ", ", $Feature_options ) .
                        ")";
                    unset( $Feature_options );
                }
                else
                {
                    $optionen = "";
                }

                $artikeltext = $zeile['kennung'] . " " . $zeile['kurzbezeichnung'] .
                    " " . $optionen;


                // ME: bei Stempeln die Detailinfos anzeigen
                if ( $elem['ct_zeilen'] )
                {
                    foreach ( $elem as $k => $v )
                    {
                        if ( stristr( $k, "ct_" ) )
                        {
                            $opt[$k] = mysql_real_escape_string( $v );
                        }
                    }
                    $artikeltext .= buildCustomTextEmail( $opt );
                }



                /* STOP Artikeloptionen zusammenstellen */
                $text .= "\n" . str_pad( $elem['Menge'], 5 ) . " x " .
                    str_pad( $artikeltext, 40 ) . " " . str_pad( number_format
                    ( $zeile['preis'], 2, ",", "." ), 6, " ", STR_PAD_LEFT ) .
                    " EUR" . str_pad( number_format( $elem['Menge'] * $zeile['preis'],
                    2, ",", "." ), 10, " ", STR_PAD_LEFT ) . " EUR";
            }
        }
        $rabatt = getBasketSumme( true ) * -1 * $ret["abschlag"] / 100;
        /*$text .= "
                    \n1     x " . str_pad( $ret["abschlag"] .
            "% Skonto auf Warenwert ", 37 ) . str_pad( number_format( $rabatt,
            2, ',', '.' ), 14, " ", STR_PAD_LEFT ) . " EUR
                ";
        */
        $text = $text . "\n---------------------------------------------------------------------------\nGesamtpreis: " .
            str_pad( number_Format( getBasketSumme(), 2, ',', '.' ), 58, " ",
            STR_PAD_LEFT ) . " EUR " . $nachnamegebuehr . " \nDieser Betrag enthält 19 % MwSt.:" .
            str_pad( number_Format( getBasketSummeMWST(), 2, ',', '.' ), 61,
            " ", STR_PAD_LEFT ) . " EUR";


        return $text;

    }

        // Ist ausgelagert worden in ein eigenes Modul
        /**
         * Erstellt ein Bild anhand eines Codes, der auf
         * eine Email refferenziert.
         *  
         * @deprecated  Please use the Module Email_Safe
         * @since               26.06.2007
         */
        function createEmailImage()
        {
            $code = $_SESSION['emailAddr'][$_GET['mx']]; //  Weban_Shop::translate_email_code($_SESSION['emailRegister'],$_GET['mx']);
            header( "Content-type: " . __EMAIL_IMAGE_CONTENT_TYPE__ );

            $cp_im = imagecreatefromjpeg( __IMAGE_EMAIL_INPUT__ );
            $white = ImageColorAllocate( $cp_im, 255, 255, 255 );
            $black = ImageColorAllocate( $cp_im, 0, 0, 0 );
            imagettftext( $cp_im, 8, 0, 21, 28, $black, __GD_TTF_FONT__, "<" . $code .
                ">" );

            imagepng( $cp_im );
            imagedestroy( $cp_im );

        }

        /**
         * Erzeugt ein Email Register
         * "Codes, Variablen und Emails"
         *  
         * @deprecated  Please use the Module Email_Safe
         * @since               26.06.2007
         */
        function create_email_register( $emails )
        {
            foreach ( $emails as $email )
            {
                $_SESSION['emailAddr'][md5( $email )] = $email;
                $_SESSION['emailRegister'][$email] = md5( $email );
            }
        }
        /**
         * Übersetzt einen MD5 Code in eine Email Adresse
         *  
         * @deprecated  Please use the Module Email_Safe
         * @since               26.06.2007
         */
        function translate_email_code( $email, $emArr )
        {
            return $emArr[$email];
        }
    }
    // }}}

    /*
    * Local variables:
    * tab-width: 4
    * c-basic-offset: 4
    * c-hanging-comment-ender-p: nil
    * End:
    */
?>