oxwrapping.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxWrapping extends oxI18n
00008 {
00014     protected $_sCoreTbl = 'oxwrapping';
00015 
00021     protected $_sClassName = 'oxwrapping';
00022 
00028     protected $_oPrice = null;
00029 
00035     protected $_dVat = 0;
00036 
00043     public function __construct()
00044     {
00045         $this->setWrappingVat( $this->getConfig()->getConfigParam( 'dDefaultVAT' ) );
00046         parent::__construct();
00047         $this->init( 'oxwrapping' );
00048     }
00049 
00057     public function __get($sName)
00058     {
00059         switch ( $sName ) {
00060             case 'fprice':
00061                 $sValue = $this->getFPrice();
00062                 break;
00063             default:
00064                 return $sValue = parent::__get( $sName );
00065                 break;
00066                 break;
00067                 break;
00068                 break;
00069                 break;
00070         }
00071 
00072         return $sValue;
00073     }
00074 
00082     public function setWrappingVat( $dVat )
00083     {
00084         $this->_dVat = $dVat;
00085     }
00086 
00094     public function assign( $dbRecord )
00095     {
00096         // loading object from database
00097         parent::assign( $dbRecord );
00098 
00099         // setting image path
00100         $myConfig = $this->getConfig();
00101         // this will be removed later
00102         $this->dimagedir       = $myConfig->getDynImageDir( $this->oxwrapping__oxshopid->value );
00103         $this->nossl_dimagedir = $myConfig->getDynImageDir( $this->oxwrapping__oxshopid->value, true );
00104     }
00105 
00113     public function getWrappingPrice( $dAmount = 1 )
00114     {
00115         if ( $this->_oPrice === null ) {
00116             $this->_oPrice = oxNew( 'oxprice' );
00117 
00118             $oCur = $this->getConfig()->getActShopCurrencyObject();
00119             $this->_oPrice->setPrice( $this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat );
00120             $this->_oPrice->multiply( $dAmount );
00121         }
00122 
00123         return $this->_oPrice;
00124     }
00125 
00133     public function getWrappingList( $sWrapType )
00134     {
00135         // load wrapping
00136         $oEntries = oxNew( 'oxlist' );
00137         $oEntries->init( 'oxwrapping' );
00138         $sWrappingViewName = getViewName( 'oxwrapping' );
00139         $sSelect =  "select * from $sWrappingViewName where $sWrappingViewName.".$this->getSqlFieldName( 'oxactive' )." = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote( $sWrapType );
00140         $oEntries->selectString( $sSelect );
00141 
00142         return $oEntries;
00143     }
00144 
00152     public function getWrappingCount( $sWrapType )
00153     {
00154         $sWrappingViewName = getViewName( 'oxwrapping' );
00155         $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.".$this->getSqlFieldName( 'oxactive' )." = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote( $sWrapType );
00156         return (int) oxDb::getDb()->getOne( $sQ );
00157     }
00158 
00164     public function getFPrice()
00165     {
00166         return oxLang::getInstance()->formatCurrency( $this->getWrappingPrice()->getBruttoPrice(), $this->getConfig()->getActShopCurrencyObject() );
00167     }
00168 
00174     public function getNoSslDynImageDir()
00175     {
00176         return $this->getConfig()->getDynImageDir( $this->oxwrapping__oxshopid->value, true );
00177     }
00178 
00184     public function getPictureUrl()
00185     {
00186         return $this->getConfig()->getDynImageDir( $this->oxwrapping__oxshopid->value );
00187     }
00188 
00189 }