OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxwrapping.php
Go to the documentation of this file.
1 <?php
2 
8 class oxWrapping extends oxI18n
9 {
15  protected $_sClassName = 'oxwrapping';
16 
22  protected $_oPrice = null;
23 
29  protected $_dVat = 0;
30 
36  protected $_blWrappingVatOnTop = false;
37 
44  public function __construct()
45  {
46  $oConfig = $this->getConfig();
47  $this->setWrappingVat( $oConfig->getConfigParam( 'dDefaultVAT' ) );
48  $this->setWrappingVatOnTop( $oConfig->getConfigParam( 'blWrappingVatOnTop' ) );
50  $this->init( 'oxwrapping' );
51  }
52 
60  public function setWrappingVat( $dVat )
61  {
62  $this->_dVat = $dVat;
63  }
64 
72  public function setWrappingVatOnTop( $blOnTop )
73  {
74  $this->_blWrappingVatOnTop = $blOnTop;
75  }
76 
84  public function getWrappingPrice( $dAmount = 1 )
85  {
86  if ( $this->_oPrice === null ) {
87  $this->_oPrice = oxNew( 'oxprice' );
88 
89  if ( !$this->_blWrappingVatOnTop ) {
90  $this->_oPrice->setBruttoPriceMode();
91  } else {
92  $this->_oPrice->setNettoPriceMode();
93  }
94 
95  $oCur = $this->getConfig()->getActShopCurrencyObject();
96  $this->_oPrice->setPrice( $this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat );
97  $this->_oPrice->multiply( $dAmount );
98  }
99 
100  return $this->_oPrice;
101  }
102 
110  public function getWrappingList( $sWrapType )
111  {
112  // load wrapping
113  $oEntries = oxNew( 'oxlist' );
114  $oEntries->init( 'oxwrapping' );
115  $sWrappingViewName = getViewName( 'oxwrapping' );
116  $sSelect = "select * from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote( $sWrapType );
117  $oEntries->selectString( $sSelect );
118 
119  return $oEntries;
120  }
121 
129  public function getWrappingCount( $sWrapType )
130  {
131  $sWrappingViewName = getViewName( 'oxwrapping' );
132  $oDb = oxDb::getDb();
133  $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . $oDb->quote( $sWrapType );
134  return (int) $oDb->getOne( $sQ );
135  }
136 
142  protected function _isPriceViewModeNetto()
143  {
144  $blResult = (bool) $this->getConfig()->getConfigParam('blShowNetPrice');
145  $oUser = $this->getUser();
146  if ( $oUser ) {
147  $blResult = $oUser->isPriceViewModeNetto();
148  }
149 
150  return $blResult;
151  }
152 
160  public function getFPrice()
161  {
162  $dPrice = $this->getPrice();
163 
164  return oxRegistry::getLang()->formatCurrency( $dPrice, $this->getConfig()->getActShopCurrencyObject() );
165  }
166 
170  public function getPrice()
171  {
172  if ( $this->_isPriceViewModeNetto() ) {
173  $dPrice = $this->getWrappingPrice()->getNettoPrice();
174  } else {
175  $dPrice = $this->getWrappingPrice()->getBruttoPrice();
176  }
177 
178  return $dPrice;
179  }
180 
186  public function getNoSslDynImageDir()
187  {
188  return $this->getConfig()->getPictureUrl(null, false, false, null, $this->oxwrapping__oxshopid->value);
189  }
190 
196  public function getPictureUrl()
197  {
198  if ( $this->oxwrapping__oxpic->value ) {
199  return $this->getConfig()->getPictureUrl( "master/wrapping/".$this->oxwrapping__oxpic->value, false, $this->getConfig()->isSsl(), null, $this->oxwrapping__oxshopid->value );
200  }
201  }
202 }