oxwrapping.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxWrapping extends oxI18n
00009 {
00010 
00016     protected $_sClassName = 'oxwrapping';
00017 
00023     protected $_oPrice = null;
00024 
00030     protected $_dVat = 0;
00031 
00037     protected $_blWrappingVatOnTop = false;
00038 
00045     public function __construct()
00046     {
00047         $oConfig = $this->getConfig();
00048         $this->setWrappingVat($oConfig->getConfigParam('dDefaultVAT'));
00049         $this->setWrappingVatOnTop($oConfig->getConfigParam('blWrappingVatOnTop'));
00050         parent::__construct();
00051         $this->init('oxwrapping');
00052     }
00053 
00059     public function setWrappingVat($dVat)
00060     {
00061         $this->_dVat = $dVat;
00062     }
00063 
00069     public function setWrappingVatOnTop($blOnTop)
00070     {
00071         $this->_blWrappingVatOnTop = $blOnTop;
00072     }
00073 
00081     public function getWrappingPrice($dAmount = 1)
00082     {
00083         if ($this->_oPrice === null) {
00084             $this->_oPrice = oxNew('oxprice');
00085 
00086             if (!$this->_blWrappingVatOnTop) {
00087                 $this->_oPrice->setBruttoPriceMode();
00088             } else {
00089                 $this->_oPrice->setNettoPriceMode();
00090             }
00091 
00092             $oCur = $this->getConfig()->getActShopCurrencyObject();
00093             $this->_oPrice->setPrice($this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat);
00094             $this->_oPrice->multiply($dAmount);
00095         }
00096 
00097         return $this->_oPrice;
00098     }
00099 
00107     public function getWrappingList($sWrapType)
00108     {
00109         // load wrapping
00110         $oEntries = oxNew('oxlist');
00111         $oEntries->init('oxwrapping');
00112         $sWrappingViewName = getViewName('oxwrapping');
00113         $sSelect = "select * from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote($sWrapType);
00114         $oEntries->selectString($sSelect);
00115 
00116         return $oEntries;
00117     }
00118 
00126     public function getWrappingCount($sWrapType)
00127     {
00128         $sWrappingViewName = getViewName('oxwrapping');
00129         $oDb = oxDb::getDb();
00130         $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . $oDb->quote($sWrapType);
00131 
00132         return (int) $oDb->getOne($sQ);
00133     }
00134 
00140     protected function _isPriceViewModeNetto()
00141     {
00142         $blResult = (bool) $this->getConfig()->getConfigParam('blShowNetPrice');
00143         $oUser = $this->getUser();
00144         if ($oUser) {
00145             $blResult = $oUser->isPriceViewModeNetto();
00146         }
00147 
00148         return $blResult;
00149     }
00150 
00158     public function getFPrice()
00159     {
00160         $dPrice = $this->getPrice();
00161 
00162         return oxRegistry::getLang()->formatCurrency($dPrice, $this->getConfig()->getActShopCurrencyObject());
00163     }
00164 
00170     public function getPrice()
00171     {
00172         if ($this->_isPriceViewModeNetto()) {
00173             $dPrice = $this->getWrappingPrice()->getNettoPrice();
00174         } else {
00175             $dPrice = $this->getWrappingPrice()->getBruttoPrice();
00176         }
00177 
00178         return $dPrice;
00179     }
00180 
00186     public function getNoSslDynImageDir()
00187     {
00188         return $this->getConfig()->getPictureUrl(null, false, false, null, $this->oxwrapping__oxshopid->value);
00189     }
00190 
00196     public function getPictureUrl()
00197     {
00198         if ($this->oxwrapping__oxpic->value) {
00199             return $this->getConfig()->getPictureUrl("master/wrapping/" . $this->oxwrapping__oxpic->value, false, $this->getConfig()->isSsl(), null, $this->oxwrapping__oxshopid->value);
00200         }
00201     }
00202 }