Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php

    /**
     * @package   Content-management
     * @author    Webagentur Niewerth <tiefland@weban.de>
     * @copyright 2011 Webagentur Niewerth
     * @license   propietary http://www.weban.de
     * @version   $Rev: 768 $
     * @filesource
     * 
     */

    /**
     * 
     * @package   Content-management
     * @author    Webagentur Niewerth <tiefland@weban.de>
     * @copyright 2011 Webagentur Niewerth
     */

    // SVN: $Id: preise.php 768 2011-10-28 06:34:37Z tiefland $

    require_once "../toolbox/common.php";
    $sql = "SELECT
            id,
            name,
            `database`
        FROM
            shops
        WHERE
            `database` != ''
    ";
    $res = mysql_query( $sql );
    $shops[0] = "--- Bitte wählen! ---";
    while ( $row = mysql_fetch_assoc( $res ) )
    {
        $shops[$row["id"]] = $row["name"];
        $shop_infos[$row["id"]] = $row;
    }
    if ( $_GET["login"] )
    {
        $login_id = Weban_Utils::clean_global_input( "login", "get", "int" );
        $sql = "SELECT
                pl.id,
                login_id,
                artikel_id,
                shop_id,
                name,
                preis,
                `database`
            FROM
                preise_to_login pl,
                shops s
            WHERE
                login_id=" . $login_id . "
            AND
                s.id=pl.shop_id
        ";
        $res = mysql_query( $sql );
        while ( $row = mysql_fetch_assoc( $res ) )
        {
            $sql_a = "SELECT
                    a.kurzbezeichnung,
                    preis1
                FROM
                    " . $row["database"] . ".artikel a
                WHERE
                    a.id=" . $row["artikel_id"] . "
            ";
            $res_a = mysql_query( $sql_a );
            $row_a = mysql_fetch_assoc( $res_a );
            if ( !is_array( $row_a ) )
            {
                $row_a["kurzbezeichnung"] = "";
            }
            $row["preis"] = unserialize( $row["preis"] );

            $daten["artikel"][] = array_merge( $row, $row_a );
        }
        $sql_l = "SELECT
                CONCAT(Vorname, ' ', Name1) AS login_name
            FROM
                Logins
            WHERE
                id=$login_id
        ";
        $res_l = mysql_query( $sql_l );
        $row_l = mysql_fetch_assoc( $res_l );
        $daten["login_name"] = $row_l["login_name"];
        $GLOBALS["ui"]->assign( "login_id", $login_id );
        $tpl_file = "preise.tpl";
    }
    else
    {
        $a_id = Weban_Utils::clean_get_input( "a_id", "int" );
        $s_id = Weban_Utils::clean_get_input( "s_id", "int" );
        $db = $webs["datenbank"];
        if ( $s_id )
        {
            $db = $shop_infos[$s_id]["database"];
        }
        $sql_a = "SELECT
                a.kurzbezeichnung,
                preis1
            FROM
                " . $db . ".artikel a
            WHERE
                a.id=" . $a_id . "
        ";
        $res_a = mysql_query( $sql_a );
        $row_a = mysql_fetch_assoc( $res_a );
        if ( !is_array( $row_a ) )
        {
            $row_a["kurzbezeichnung"] = "";
        }
        $sql = "SELECT
                pl.id,
                login_id,
                CONCAT(Vorname, ' ', Name1) AS login_name,
                shop_id,
                name,
                preis
            FROM
                preise_to_login pl,
                shops s,
                Logins l
            WHERE
                artikel_id=" . $a_id . "
            AND
                s.id=pl.shop_id
            AND
                l.id=pl.login_id
        ";
        $res = mysql_query( $sql );
        while ( $row = mysql_fetch_assoc( $res ) )
        {
            $row["preis"] = unserialize( $row["preis"] );

            $daten["logins"][] = array_merge( $row, $row_a );
        }
        $daten["artikel"] = $row_a;
        $GLOBALS["ui"]->assign( "a_id", $a_id );
        $GLOBALS["ui"]->assign( "s_id", $s_id );
        $tpl_file = "artikel.tpl";
    }
    $GLOBALS["ui"]->assign( "daten", $daten );
    $GLOBALS["ui"]->assign( "shops", $shops );
    $GLOBALS["ui"]->display( $tpl_file );
?>