Subversion-Projekte lars-tiefland.content-management

Revision

Revision 1 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    /**
4
     * @package   Content-management
5
     * @author    Webagentur Niewerth <tiefland@weban.de>
6
     * @copyright 2011 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
2 lars 8
     * @version   $Rev: 4249 $
1 lars 9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Webagentur Niewerth <tiefland@weban.de>
17
     * @copyright 2011 Webagentur Niewerth
18
     */
19
 
2 lars 20
    // SVN: $Id: lagerbestand.php 4249 2012-03-23 15:42:14Z tiefland $
1 lars 21
    require_once "../toolbox/common.php";
22
    require_once "includes/bestellungen/system/artikelDatabase.php";
23
    require_once "module/weban/weban_utils.class.php";
24
    $item = Weban_Utils::clean_global_input( "item", "post", "int" );
25
    $order_id = Weban_Utils::clean_global_input( "order_id", "post", "int" );
26
    $shop_id = Weban_Utils::clean_global_input( "shop_id", "post", "int" );
27
    $GLOBALS["db_name"] = shopDatabase( $shop_id );
2 lars 28
    $artikel = getArtikel( $item );
1 lars 29
    $lieferanten = getArtikelLieferanten( $item );
30
    foreach ( $lieferanten as $id => $lieferant )
31
    {
32
        $sql_l = "SELECT
33
                id,
34
                name,
35
                bestellbar,
36
                bestand,
37
                status,
38
                verf_codes,
39
                ek_preis,
2 lars 40
                vk_preis,
41
                import_date
1 lars 42
            FROM
43
                " . $GLOBALS["db_name"] . "lieferanten_lager ll
44
            JOIN
45
                " . $GLOBALS["db_name"] . "artikel_lagerbestand al
46
            ON
47
                al.artikel_id=$item
48
            AND
49
                al.lager_id=ll.id
50
            WHERE
51
                lieferanten_id=" . $lieferant["id"] . "
52
            ORDER BY
53
                rang,
54
                name
55
        ";
56
        $res_l = mysql_query( $sql_l );
57
        while ( $row_l = mysql_fetch_assoc( $res_l ) )
58
        {
59
            $verf_codes = unserialize( $row_l["verf_codes"] );
60
            unset( $row_l["verf_codes"] );
61
            foreach ( $verf_codes as $verf_code )
62
            {
63
                $row_l["verf_codes"][$verf_code["key"]]["name"] = $verf_code["value"];
64
                $row_l["verf_codes"][$verf_code["key"]]["image"] = $verf_code["image"];
65
            }
66
            $lieferanten[$id]["lager"][] = $row_l;
67
        }
68
        $id++;
69
    }
2 lars 70
    $GLOBALS["ui"]->assign( "artikel", $artikel );
1 lars 71
    $GLOBALS["ui"]->assign( "item_id", $item );
72
    $GLOBALS["ui"]->assign( "order_id", $order_id );
73
    $GLOBALS["ui"]->assign( "shop_id", $shop_id );
74
    $GLOBALS["ui"]->assign( "lieferanten", $lieferanten );
75
    $GLOBALS["ui"]->display( "lagerbestand.tpl" );
76
 
77
    function getArtikelLieferanten( $item )
78
    {
79
        $id = 0;
80
        $ret = array();
81
        $sql = "SELECT
82
                l.id,
83
                l.name
84
            FROM
85
                " . $GLOBALS["db_name"] . "artikel_to_lieferanten al,
86
                " . $GLOBALS["db_name"] . "lieferanten l
87
            WHERE
88
                al.lieferanten_id=l.id
89
            AND
90
                al.artikel_id=$item
91
            AND
92
                al.lieferanten_artnr !=''
93
            ORDER BY
94
                rang,
95
                name
96
        ";
97
        $res = mysql_query( $sql );
98
        while ( $row = mysql_fetch_assoc( $res ) )
99
        {
100
            $ret[$id++] = $row;
101
        }
102
        return $ret;
103
    }
2 lars 104
 
105
    function getArtikel( $item )
106
    {
107
        $sql = "SELECT
108
                a.kurzbezeichnung,
109
                al.lieferanten_artnr
110
            FROM
111
                " . $GLOBALS["db_name"] . "artikel a
112
            JOIN
113
                " . $GLOBALS["db_name"] . "artikel_to_lieferanten al
114
            ON
115
                al.artikel_id=a.id
116
            AND
117
                a.id=$item
118
        ";
119
        $res = mysql_query( $sql );
120
        $row = mysql_fetch_assoc( $res );
121
        //var_dump($row);
122
        return $row;
123
    }
1 lars 124
?>