Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php

    /**
     * @package   teile-freak
     * @author    Lars Tiefland <tiefland@weban.de>
     * @copyright 2010 Webagentur Niewerth
     * @license   propietary http://www.weban.de
     * @version   $Rev: 913 $
     * @filesource
     * 
     */

    /**
     * 
     * @package   teile-freak
     * @author    Lars Tiefland <tiefland@weban.de>
     * @copyright 2010 Webagentur Niewerth
     */

    // SVN: $Id: getOrderDetails.php 913 2012-01-25 12:47:30Z tiefland $

    // deutsche Umgebung
    setlocale( LC_ALL, "de_DE" );
    // Connect-Datei einbinden
    define( "modul_name", "Warenwirtschaft" );
    define( "tool_name", "bestellung" );
    require_once "../Online-Shop/connect2.php";
    $GLOBALS["web_rechte"] = $web_rechte;
    require_once "Weban_Smarty.class.php";
    require_once "includes/bestellungen/system/artikelDatabase.php";

    $GLOBALS["ui"] = new Weban_Smarty();

    if ( isset( $_GET["id"] ) )
    {
        $data = view_order( $_GET["id"] );
        $GLOBALS["ui"]->assign( "order", $data );
        $GLOBALS["ui"]->display( "view_order.tpl" );
    }

    function view_order( $id )
    {
        $sql = "SELECT
                shops_id
            FROM
                Bestellung
            WHERE
                id = $id
        ";
        $res = mysql_query($sql);
        $row = mysql_fetch_assoc($res);
        $shop = $row["shops_id"];
        $db = shopDatabase( $shop );
        $ab_table = "artikel_to_Bestellung ab";
        $b_table = "Bestellung b";
        $a_table = $db . "artikel a";
        $sql = "SELECT
                b.ID,
                b.shops_ID,
                b.erstellt_am,
                b.letzte_aenderung_am,
        ";
        if ( isset( $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
        {
            $sql .= "
                    c.locale,
                ";
        }
        $sql .= "
                b.letzte_aenderung_von
            FROM
                $b_table,
        ";
        if ( isset( $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
        {
            $sql .= "
                        currencies c,
                ";
        }
        $sql .= "
                $ab_table
            JOIN
                $a_table
            ON
                a.ID=ab.artikel
            WHERE
                b.ID = $id
            AND
                ab.Bestellung=b.ID
        ";
        if ( isset( $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
        {
            $sql .= "
            AND
                c.id=b.currency
        ";
        }
        $res = mysql_query( $sql );
        $row = mysql_fetch_assoc( $res );
        $sql = "SELECT
                ab.*,
                a.kennung,
                a.kurzbezeichnung,
                a.Father,
                Menge * Preis_pro_Stueck AS gesamtpreis
            FROM
                $ab_table
            LEFT JOIN
                $a_table
            ON
                a.ID=ab.artikel
            WHERE
                ab.Bestellung=$id
        ";
        $res = mysql_query( $sql );
        while ( $ab_row = mysql_fetch_assoc( $res ) )
        {
            /*if ( $ab_row["Father"] == -3 )
            {
            $item = getItem( $ab_row["artikel"], false, true );
            }
            else
            {
            $item = getItem( $ab_row["artikel"] );
            }*/
            $ab_row["Bezeichnung"] = trim( $ab_row["Bezeichnung"] );
            $ab_row["itemLink"] = $item["itemLink"];
            $ab_row["father"] = $item["Father"];
            $row["items"][] = $ab_row;
        }
        return $row;
    }
?>