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 }
00067
00068 return $sValue;
00069 }
00070
00078 public function setWrappingVat( $dVat )
00079 {
00080 $this->_dVat = $dVat;
00081 }
00082
00090 public function assign( $dbRecord )
00091 {
00092
00093 parent::assign( $dbRecord );
00094
00095
00096 $myConfig = $this->getConfig();
00097
00098 $this->dimagedir = $myConfig->getDynImageDir( $this->oxwrapping__oxshopid->value );
00099 $this->nossl_dimagedir = $myConfig->getDynImageDir( $this->oxwrapping__oxshopid->value, true );
00100 }
00101
00109 public function getWrappingPrice( $dAmount = 1 )
00110 {
00111 if ( $this->_oPrice === null ) {
00112 $this->_oPrice = oxNew( 'oxprice' );
00113
00114 $oCur = $this->getConfig()->getActShopCurrencyObject();
00115 $this->_oPrice->setPrice( $this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat );
00116 $this->_oPrice->multiply( $dAmount );
00117 }
00118
00119 return $this->_oPrice;
00120 }
00121
00129 public function getWrappingList( $sWrapType )
00130 {
00131
00132 $oEntries = oxNew( 'oxlist' );
00133 $oEntries->init( 'oxwrapping' );
00134 $sWrappingViewName = getViewName( 'oxwrapping' );
00135 $sSelect = "select * from $sWrappingViewName where $sWrappingViewName.".$this->getSqlFieldName( 'oxactive' )." = '1' and $sWrappingViewName.oxtype = '$sWrapType' ";
00136 $oEntries->selectString( $sSelect );
00137
00138 return $oEntries;
00139 }
00140
00148 public function getWrappingCount( $sWrapType )
00149 {
00150 $sWrappingViewName = getViewName( 'oxwrapping' );
00151 $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.".$this->getSqlFieldName( 'oxactive' )." = '1' and $sWrappingViewName.oxtype = '$sWrapType' ";
00152 return (int) oxDb::getDb()->getOne( $sQ );
00153 }
00154
00160 public function getFPrice()
00161 {
00162 return oxLang::getInstance()->formatCurrency( $this->getWrappingPrice()->getBruttoPrice(), $this->getConfig()->getActShopCurrencyObject() );
00163 }
00164
00170 public function getNoSslDynImageDir()
00171 {
00172 return $this->getConfig()->getDynImageDir( $this->oxwrapping__oxshopid->value, true );
00173 }
00174
00180 public function getPictureUrl()
00181 {
00182 return $this->getConfig()->getDynImageDir( $this->oxwrapping__oxshopid->value );
00183 }
00184
00185 }