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 assign( $dbRecord )
00085     {
00086         // loading object from database
00087         parent::assign( $dbRecord );
00088 
00089         // setting image path
00090         $myConfig = $this->getConfig();
00091     }
00092 
00100     public function getWrappingPrice( $dAmount = 1 )
00101     {
00102         if ( $this->_oPrice === null ) {
00103             $this->_oPrice = oxNew( 'oxprice' );
00104 
00105             if ( !$this->_blWrappingVatOnTop ) {
00106                 $this->_oPrice->setBruttoPriceMode();
00107             } else {
00108                 $this->_oPrice->setNettoPriceMode();
00109             }
00110 
00111             $oCur = $this->getConfig()->getActShopCurrencyObject();
00112             $this->_oPrice->setPrice( $this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat );
00113             $this->_oPrice->multiply( $dAmount );
00114         }
00115 
00116         return $this->_oPrice;
00117     }
00118 
00126     public function getWrappingList( $sWrapType )
00127     {
00128         // load wrapping
00129         $oEntries = oxNew( 'oxlist' );
00130         $oEntries->init( 'oxwrapping' );
00131         $sWrappingViewName = getViewName( 'oxwrapping' );
00132         $sSelect =  "select * from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote( $sWrapType );
00133         $oEntries->selectString( $sSelect );
00134 
00135         return $oEntries;
00136     }
00137 
00145     public function getWrappingCount( $sWrapType )
00146     {
00147         $sWrappingViewName = getViewName( 'oxwrapping' );
00148         $oDb = oxDb::getDb();
00149         $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . $oDb->quote( $sWrapType );
00150         return (int) $oDb->getOne( $sQ );
00151     }
00152 
00158     protected function _isPriceViewModeNetto()
00159     {
00160         $blResult = (bool) $this->getConfig()->getConfigParam('blShowNetPrice');
00161         $oUser = $this->getUser();
00162         if ( $oUser ) {
00163             $blResult = $oUser->isPriceViewModeNetto();
00164         }
00165 
00166         return $blResult;
00167     }
00168 
00174     public function getFPrice()
00175     {
00176         if ( $this->_isPriceViewModeNetto() ) {
00177             $dPrice = $this->getWrappingPrice()->getNettoPrice();
00178         } else {
00179             $dPrice = $this->getWrappingPrice()->getBruttoPrice();
00180         }
00181 
00182         return oxRegistry::getLang()->formatCurrency( $dPrice, $this->getConfig()->getActShopCurrencyObject() );
00183     }
00184 
00190     public function getNoSslDynImageDir()
00191     {
00192         return $this->getConfig()->getPictureUrl(null, false, false, null, $this->oxwrapping__oxshopid->value);
00193     }
00194 
00200     public function getPictureUrl()
00201     {
00202         if ( $this->oxwrapping__oxpic->value ) {
00203            return $this->getConfig()->getPictureUrl( "master/wrapping/".$this->oxwrapping__oxpic->value, false, $this->getConfig()->isSsl(), null, $this->oxwrapping__oxshopid->value );
00204         }
00205     }
00206 }