Subversion-Projekte lars-tiefland.ci

Revision

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

<?php

/**
 * @author Lars Tiefland
 * @copyright 2016
 */

/**
 * Shop
 * 
 * erstellt die Startseite für den Shop
 * 
 * @package WebanOS CI
 * @author Lars Tiefland
 * @copyright 2016
 * @version $Id: Shop.php 753 2016-10-07 22:30:38Z lars $
 * @access public
 */
class Shop extends CI_Controller
{

        /**
         * Shop::__construct()
         * 
         * @return
         */
        public function __construct()
        {
                parent::__construct();
                $this->load->model('Aktion_model', 'aktion');
                $this->load->model('artikel_model', 'artikel');
                if (ENVIRONMENT == "production")
                {
                        $this->output->cache(120);
                }
        }
        /**
         * Shop::index()
         * 
         * @return
         */
        public function index()
        {
                $aktion = $this->aktion->get_cur_aktion();
                $this->smarty->assign('title', $GLOBALS['INI']['title']['standard'].' - '.$GLOBALS['INI']['titel_only']);
                $this->smarty->assign('aktion', $aktion);
                $this->smarty->view('start.tpl');
        }

        public function update_session()
        {
                $landID = 47;
                if (isset($_SESSION['SHOP']['buy']["Persdata"]["liefer_land"]))
                {
                        if (isset($GLOBALS["steuern"][$_SESSION['SHOP']['buy']["Persdata"]["liefer_land"]]))
                        {
                                $landID = $_SESSION['SHOP']['buy']["Persdata"]["liefer_land"];
                        }
                        elseif (isset($GLOBALS["INI"]["steuern"]["default_countryID"]))
                        {
                                $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
                        }
                }
                elseif (isset($GLOBALS["INI"]["steuern"]["default_countryID"]))
                {
                        $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
                }
                $versandOptionen = get_versandkosten();
                if ($_POST["thirdPartyPaymentMethod"])
                {
                        $method = $_POST["thirdPartyPaymentMethod"];
                        foreach ($versandOptionen as $opt)
                        {
                                if (substr($opt["kurz"], 0, 25) == $method)
                                {
                                        $VersandItem = array(
                                                "Menge" => 1,
                                                "ID" => $opt["ID"],
                                                "Versand" => true,
                                                'kurzbezeichnung' => $opt['kurz'],
                                                "rufname" => $vItem["short_line_1"],
                                                "preis" => $opt["preis"],
                                                );
                                        $_SESSION['SHOP']["VERSAND"] = $VersandItem;
                                        $_SESSION["SHOP"]["SUMMEINCVERSAND"] = $_SESSION["SHOP"]["SUMME"] + $opt["preis"];
                                        $_SESSION["SHOP"]["buy"]["Versand"] = true;
                                        break;
                                }
                        }
                }
                else
                {
                        $method = "PayPalPlus";
                        foreach ($versandOptionen as $opt)
                        {
                                if ($opt["rufname"] == $method)
                                {
                                        $VersandItem = array(
                                                "Menge" => 1,
                                                "ID" => $opt["ID"],
                                                'kurzbezeichnung' => $opt['kurz'],
                                                "Versand" => true,
                                                "rufname" => $vItem["short_line_1"],
                                                "preis" => $opt["preis"],
                                                );
                                        $_SESSION['SHOP']["VERSAND"] = $VersandItem;
                                        $_SESSION["SHOP"]["SUMMEINCVERSAND"] = $_SESSION["SHOP"]["SUMME"] + $opt["preis"];
                                        $_SESSION["SHOP"]["buy"]["Versand"] = true;
                                        break;
                                }
                        }
                }
                $item = $this->artikel->get_artikel($VersandItem['ID'], true);
                $itemTax = (isset($item["tax1"]) && $item["tax1"] != "") ? $item["tax1"] : 0;
                $mwst = $GLOBALS["steuern"][$landID][$itemTax];
                //admin_debug($_SESSION['SHOP'], true);
                //$_SESSION["netto_preis"] ist gesetzt wenn ein Kunde sich einlogt und dieser zu einer Kundengruppe die in der
                // Ini gesetzt ist angeh�rt und dort das Flag netto_preis aktiviert ist.
                if ((isset($GLOBALS["INI"]["netto_preise"]) && $GLOBALS["INI"]["netto_preise"] ==
                        1) || (isset($_SESSION["netto_preis"]) && $_SESSION["netto_preis"] == true))
                {
                        $mwst = $VersandItem['Menge'] * $VersandItem['preis'] * $mwst / 100;
                }
                else
                {
                        $mwst = $VersandItem['Menge'] * $VersandItem['preis'] / (100 + $mwst) * $mwst;
                }
                if (!isset($_SESSION['SHOP']["MWST"][$GLOBALS["steuern"][$landID][$itemTax]]))
                {
                        $_SESSION['SHOP']["MWST"][$GLOBALS["steuern"][$landID][$itemTax]] = 0;
                }
                $_SESSION['SHOP']["MWST"][$GLOBALS["steuern"][$landID][$itemTax]] += $mwst;
                $_SESSION['SHOP']['MWSTVONSUMME'] = array_sum($_SESSION['SHOP']['MWST']);

                if ($_POST["ts"])
                {
                        $rufname = $vItem["short_line_1"];
                        $tsID = $_POST["ts"];
                        $max = $GLOBALS["tsItems"][$tsID]["max"];
                        $preis = $GLOBALS["tsItems"][$tsID]["preis"] * 1.19;
                        $preis = sprintf("%.02f", $preis);
                        //admin_debug($preis,true);
                        $buf = array(
                                "ID" => 999999,
                                "kurzbezeichnung" => utf8_encode("Käuferschutz bis ".$max." EUR (".$preis.
                                        " EUR inkl. MwSt)"),
                                "Menge" => 1,
                                "preis" => $preis,
                                "product" => $tsID,
                                "basketItemSumme" => $preis,
                                "method" => $GLOBALS["tsMethods"][$rufname],
                                "ts" => true,
                                );
                        $_SESSION["SHOP"]["BASKET"][] = $buf;

                }
        }
}

?>