Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php/* $Id: Basket.class.php 7 2007-04-11 07:43:23Z markus $ *//*** Basket handling class, for Shop modules.** This class handles the loading of any function needed by* a module e.g. Shop or any else. You easy could instance* this in the main Class of the module.* @see Shop()** PHP versions 4 and 5** LICENSE: This source file is subject to version 3.0 of the PHP license* that is available through the world-wide-web at the following URI:* http://www.php.net/license/3_0.txt. If you did not receive a copy of* the PHP License and are unable to obtain it through the web, please* send a note to license@php.net so we can mail you a copy immediately.** @category CMS* @package Basket* @author Markus Niewerth <markus@weban.de>* @copyright 1997-2005 The PHP Group* @license http://www.php.net/license/3_0.txt PHP License 3.0* @since File available since Release 1.0.1*/// {{{ constants// -------------------// IF any put in here!// -------------------// }}}// {{{ GLOBALS// -------------------// IF any put in here!// -------------------// }}}// {{{ Functions/*** Funktions Verwaltungs Modul** This class handles the loading of any function needed by* a module e.g. Shop or any else. You easy could instance* this in the main Class of the module.* @see Shop()** Diese Klasse behandelt das laden von Funktionen, die mit hilfe* von listFiles aufgelistet werden, oder durch �bergabe von* parametern, geladen werden k�nnen.** @category CMS* @package Weban_Shop* @author Markus Niewerth <markus@weban.de>* @author Lars Tiefland <tiefland@weban.de>* @copyright 1997-2007 Webagentur Niewerth* @license http://www.php.net/license/3_0.txt PHP License 3.0* @link http://server2/intranet/3_0.txt* @see Functions* @since Class available since Release 1.1*/class Basket {// {{{ properties/*** Holds all file/function names.** @var array*/var $basketItems;/*** Extensions to load.** This parameter is needed in the file loader/includer.** @var string* @access private*/var $_basketItems;// }}}// {{{ Functions()function Basket (){// Init needed Parameters.$this->basketItems = array();$this->_basketItems = &$this->basketItems;}// }}}// {{{ factory()function &factory ($_option='new'){if( strlen($_option) < 3 ) {return false;} elseif($_option == 'new') {return new Basket();}elseif ($_option=="add"){return $this->_add($_GET["ID"], NULL);}elseif($_option=="update"){return $this->_update($_GET["ID"], NULL);} else {return false;}}// }}}// {{{ _engine()function _engine ($_type, $_file){switch ($_type) {case 'add':return add($itemID, $option);break;case "update":break;case 'remove':return remove($item);break;}return true;}// }}}// {{{ _load()function _load ($_function){return true;}// }}}// {{{ _remove()function _remove ($itemID){//return 0;if(in_array($itemID, $_SESSION["SHOP"]["BASKET"])){unset($this->basketItems[$itemID]);return true;}else{return false;}}// }}}// {{{ _add()/*** adds an article to the basket* @param int $itemID* @param mixed $option* @return object*/function _add ($itemID, $option=NULL){$item = array("ID" => $itemID,"Menge" => 1);if ($option){$item["option"] = $option;}$this->basketItems[$itemID]=$item;$_SESSION["SHOP"]["BASKET"]=$this->basketItems;return $this;//return 1;}// }}}/*** updates an article in the basket* @param int $itemID* @return object*/function _update($itemID){var_dump($_GET["Menge"]);if (is_array($_GET["Menge"])){foreach(array_keys($_GET["Menge"]) as $elem){// if ($_SESSION["SHOP"]["BASKET"][$elem]){$_SESSION["SHOP"]["BASKET"][$elem]["Menge"] = $_GET[Menge][$elem] * 1;$this->basketItems=$_SESSION["SHOP"]["BASKET"];if ($_SESSION["SHOP"]["BASKET"][$elem]["Menge"] == 0){unset($_SESSION["SHOP"]["BASKET"][$elem]);}}}}return $this;}/*** get the basket content* @return array*/function getContent(){// Itemtemplate auslesen$template = file_get_contents($basketContentTepmlatePath."2/2.htm");foreach($_SESSION['SHOP']['BASKET'] as $basketItem){if ($basketItem['Versand']) { continue; }$basketItem['optionen'] = $this->basketItemOptions($basketItem);// Artikelinformationen holen$item=getItem($basketItem['ID']);$AddOnItems = getAddOnItems($basketItem['ID']);/* ************************************************************************ */// AddOnItemstemplate auslesen$template1 = file_get_contents($basketContentTepmlatePath."5/5.htm");$buffer=array();foreach($AddOnItems as $AddOnItem){$buffer[] = templateContent($AddOnItem, $template1);}$buffer['AddOnItems'] = implode("",$buffer);// AddOnItemContainertemplate auslesen$template2 = file_get_contents($basketContentTepmlatePath."6/6.htm");$item['AddOnItems'] = templateContent($buffer, $template2);/* ************************************************************************ */$item=array_merge($item,$basketItem);$item['gesPreis'] = getBasketItemSumme($item);$item['preis'] = numberFormat($item['preis'])." €";// Artikel ausgebenreturn $item;}}/*** adds an article to the basket* @param int $itemID* @return array*/function basketItemOptions($basketItem){if (is_array($basketItem['option'])){$buffer=array();$itemOption=getOptions($basketItem['ID']); // Marked for replaceforeach(array_keys($basketItem['option']) as $id){$buffer[]=$itemOption[$id]['options'][$basketItem['option'][$id]]['optionName'];}$buffer="(".implode(", ",$buffer).")";return $buffer;}}function getBasketSumme($noVersand=false){$buffer=0;foreach($_SESSION['SHOP']['BASKET'] as $basketItem){if (($noVersand == true) and ($basketItem['Versand'])){return $buffer;}else{$item=getItem($basketItem['ID'], true); // Marked for replace$buffer = $buffer+$basketItem['Menge']*$item['preis'];}}return $buffer;}function getBasketSummeMWST($mwst=19, $netOpt=true){if ($netOpt) // Von Hundert{return $this->getBasketSumme() / (100) * $mwst;} else { // Auf Hundertreturn $this->getBasketSumme() / (100 + $mwst) * $mwst;}}function getBasketSummeBrutto($mwst=19){return $this->getBasketSumme() + $this->getBasketSummeMWST($mwst,true);}function getBasketSummeNetto($mwst=19){return $this->getBasketSumme() - $this->getBasketSummeMWST($mwst,false);}function getBasketItemSumme($item){return number_format($item["preis"] * $item['Menge'],2,',','.'). ' €';}function getBasketItemsCount(){$buffer=0;foreach($_SESSION['SHOP']['BASKET'] as $basketItem){if ($basketItem['Versand']){}else{ $buffer++; }}return $buffer;}function getBasketItemPartsCount(){$buffer=0;foreach($_SESSION['SHOP']['BASKET'] as $basketItem){if ($basketItem['Versand']){}else{ $buffer+=$basketItem['Menge']; }}return $buffer;}function getBasketItems(){$buffer=array();foreach($_SESSION['SHOP']['BASKET'] as $basketItemID => $basketData){$buf = array_merge(getItem($basketItemID), // Marked for replace$basketData);$buf["kurzbezeichnung"].=" ".$this->basketItemOptions($basketData);$buf["basketItemSumme"] = $this->getBasketItemSumme($buf);$buffer[] = $buf;}return $buffer;}function getBasketItemGewicht($item){return $item['gewicht'] * $item['Menge'];}function getBasketGewicht(){$query="SELECTID,gewicht as gewichtFROMartikelWHERELanguage = 'DE'ANDID = ".implode(" or ID=",array_keys($_SESSION['SHOP']['BASKET']));$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());$temp=0;while($zeile=mysql_fetch_array($result)){$temp+= $_SESSION['SHOP']['BASKET'][$zeile['ID']]['Menge'] * $zeile['gewicht'];}if ($temp==0){return 10;}else{return $temp;}}}/** Local variables:* tab-width: 4* c-basic-offset: 4* c-hanging-comment-ender-p: nil* End:*/?>