Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 8 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php
    /**
     * @package shop
     * @author Lars Tiefland <ltiefland@gmail.com>
     * @copyright 2012
     * @version $Id$
     */

    /**
     * @package shop
     * @author Lars Tiefland <ltiefland@gmail.com>
     * @copyright 2012
     * @version $Id$
     */

    namespace Weban;
    require_once "classes/preise.class.php";
    class artikel
    {
        public $id;
        public $name;
        public $beschreibung;
        public $link;
        public $hersteller;
        public $bilder;
        public $kennung;
        public $ean;
        public function __construct( $id )
        {
            $sql = "SELECT
                    id,
                    kurzbezeichnung AS name,
                    beschreibung,
                    father,
                    hersteller,
                    kennung,
                    ean
                FROM
                    artikel
                WHERE
                    id = $id
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
            ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            $this->id = $row["id"];
            $this->name = $row["name"];
            $this->beschreibung = $row["beschreibung"];
            $this->father = $row["father"];
            $this->kennung = $row["kennung"];
            $this->ean = $row["ean"];
            $this->link = "/index.php?item=" . $this->id;
            $fd = new directory( $this->father );
            $this->artikelstamm = $fd->artikelstamm;
            $this->hersteller = new hersteller( $row["hersteller"] );
            $this->bilder = artikel_bild::Liste( $this->id );
            $staffeln = preise::Liste( $this->id );
            foreach ( $staffeln as $p_index => $staffel )
            {
                $preis = $staffel["preis"][0];
                unset( $staffel["preis"][0] );
                unset( $staffel["menge"][0] );
                $this->preis[$p_index]["preis"] = $preis;
                $this->preis[$p_index]["staffel"] = $staffel;
            }
            $this->instantConfirm = "/index.php?basket=true&item=$this->id&menge=1";
        }

        public static function Liste( $father )
        {
            $items = array();
            $sql = "SELECT
                    id
                FROM
                    artikel
                WHERE
                    father = $father
                AND
                    status = 0
                AND
                    language='" . $GLOBALS["INI"]["language"] . "'
            ";
            $res = $GLOBALS["db"]->query( $sql );
            while ( $row = $res->fetchRow() )
            {
                $items[] = new artikel( $row["id"] );
            }
            return $items;
        }

    }
?>