oxwrapping.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxWrapping extends oxI18n
00009 {
00015     protected $_sClassName = 'oxwrapping';
00016 
00022     protected $_oPrice = null;
00023 
00029     protected $_dVat = 0;
00030 
00036     protected $_blWrappingVatOnTop = false;
00037 
00044     public function __construct()
00045     {
00046         $oConfig = $this->getConfig();
00047         $this->setWrappingVat( $oConfig->getConfigParam( 'dDefaultVAT' ) );
00048         $this->setWrappingVatOnTop( $oConfig->getConfigParam( 'blWrappingVatOnTop' ) );
00049         parent::__construct();
00050         $this->init( 'oxwrapping' );
00051     }
00052 
00060     public function setWrappingVat( $dVat )
00061     {
00062         $this->_dVat = $dVat;
00063     }
00064 
00072     public function setWrappingVatOnTop( $blOnTop )
00073     {
00074         $this->_blWrappingVatOnTop = $blOnTop;
00075     }
00076 
00084     public function getWrappingPrice( $dAmount = 1 )
00085     {
00086         if ( $this->_oPrice === null ) {
00087             $this->_oPrice = oxNew( 'oxprice' );
00088 
00089             if ( !$this->_blWrappingVatOnTop ) {
00090                 $this->_oPrice->setBruttoPriceMode();
00091             } else {
00092                 $this->_oPrice->setNettoPriceMode();
00093             }
00094 
00095             $oCur = $this->getConfig()->getActShopCurrencyObject();
00096             $this->_oPrice->setPrice( $this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat );
00097             $this->_oPrice->multiply( $dAmount );
00098         }
00099 
00100         return $this->_oPrice;
00101     }
00102 
00110     public function getWrappingList( $sWrapType )
00111     {
00112         // load wrapping
00113         $oEntries = oxNew( 'oxlist' );
00114         $oEntries->init( 'oxwrapping' );
00115         $sWrappingViewName = getViewName( 'oxwrapping' );
00116         $sSelect =  "select * from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote( $sWrapType );
00117         $oEntries->selectString( $sSelect );
00118 
00119         return $oEntries;
00120     }
00121 
00129     public function getWrappingCount( $sWrapType )
00130     {
00131         $sWrappingViewName = getViewName( 'oxwrapping' );
00132         $oDb = oxDb::getDb();
00133         $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . $oDb->quote( $sWrapType );
00134         return (int) $oDb->getOne( $sQ );
00135     }
00136 
00142     protected function _isPriceViewModeNetto()
00143     {
00144         $blResult = (bool) $this->getConfig()->getConfigParam('blShowNetPrice');
00145         $oUser = $this->getUser();
00146         if ( $oUser ) {
00147             $blResult = $oUser->isPriceViewModeNetto();
00148         }
00149 
00150         return $blResult;
00151     }
00152 
00160     public function getFPrice()
00161     {
00162         $dPrice = $this->getPrice();
00163 
00164         return oxRegistry::getLang()->formatCurrency( $dPrice, $this->getConfig()->getActShopCurrencyObject() );
00165     }
00166 
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 }