OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
oxwrapping.php
Go to the documentation of this file.
1 <?php
2 
8 class oxWrapping extends oxI18n
9 {
10 
16  protected $_sClassName = 'oxwrapping';
17 
23  protected $_oPrice = null;
24 
30  protected $_dVat = 0;
31 
37  protected $_blWrappingVatOnTop = false;
38 
45  public function __construct()
46  {
47  $oConfig = $this->getConfig();
48  $this->setWrappingVat($oConfig->getConfigParam('dDefaultVAT'));
49  $this->setWrappingVatOnTop($oConfig->getConfigParam('blWrappingVatOnTop'));
51  $this->init('oxwrapping');
52  }
53 
59  public function setWrappingVat($dVat)
60  {
61  $this->_dVat = $dVat;
62  }
63 
69  public function setWrappingVatOnTop($blOnTop)
70  {
71  $this->_blWrappingVatOnTop = $blOnTop;
72  }
73 
81  public function getWrappingPrice($dAmount = 1)
82  {
83  if ($this->_oPrice === null) {
84  $this->_oPrice = oxNew('oxprice');
85 
86  if (!$this->_blWrappingVatOnTop) {
87  $this->_oPrice->setBruttoPriceMode();
88  } else {
89  $this->_oPrice->setNettoPriceMode();
90  }
91 
92  $oCur = $this->getConfig()->getActShopCurrencyObject();
93  $this->_oPrice->setPrice($this->oxwrapping__oxprice->value * $oCur->rate, $this->_dVat);
94  $this->_oPrice->multiply($dAmount);
95  }
96 
97  return $this->_oPrice;
98  }
99 
107  public function getWrappingList($sWrapType)
108  {
109  // load wrapping
110  $oEntries = oxNew('oxlist');
111  $oEntries->init('oxwrapping');
112  $sWrappingViewName = getViewName('oxwrapping');
113  $sSelect = "select * from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . oxDb::getDb()->quote($sWrapType);
114  $oEntries->selectString($sSelect);
115 
116  return $oEntries;
117  }
118 
126  public function getWrappingCount($sWrapType)
127  {
128  $sWrappingViewName = getViewName('oxwrapping');
129  $oDb = oxDb::getDb();
130  $sQ = "select count(*) from $sWrappingViewName where $sWrappingViewName.oxactive = '1' and $sWrappingViewName.oxtype = " . $oDb->quote($sWrapType);
131 
132  return (int) $oDb->getOne($sQ);
133  }
134 
140  protected function _isPriceViewModeNetto()
141  {
142  $blResult = (bool) $this->getConfig()->getConfigParam('blShowNetPrice');
143  $oUser = $this->getUser();
144  if ($oUser) {
145  $blResult = $oUser->isPriceViewModeNetto();
146  }
147 
148  return $blResult;
149  }
150 
158  public function getFPrice()
159  {
160  $dPrice = $this->getPrice();
161 
162  return oxRegistry::getLang()->formatCurrency($dPrice, $this->getConfig()->getActShopCurrencyObject());
163  }
164 
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 }