101 lines
2.2 KiB
PHP
101 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Subclass for representing a row from the 'app_add_price' table.
|
|
*
|
|
*
|
|
*
|
|
* @package plugins.appAddPricePlugin.lib.model
|
|
*/
|
|
class AddPrice extends BaseAddPrice
|
|
{
|
|
protected static $clearCache = true;
|
|
|
|
public function getAdminGeneratorTitle()
|
|
{
|
|
return $this->getCurrency()->getShortcut();
|
|
}
|
|
|
|
public function disableClearCache()
|
|
{
|
|
self::$clearCache = false;
|
|
}
|
|
|
|
public function enableClearCache()
|
|
{
|
|
self::$clearCache = true;
|
|
}
|
|
|
|
public function setPrice($v)
|
|
{
|
|
$this->setPriceNetto($v);
|
|
}
|
|
|
|
public function setOldPrice($v)
|
|
{
|
|
$this->setOldPriceNetto($v);
|
|
}
|
|
|
|
public function getPrice()
|
|
{
|
|
return $this->getPriceNetto();
|
|
}
|
|
|
|
public function getOldPrice()
|
|
{
|
|
return $this->getOldPriceNetto();
|
|
}
|
|
|
|
public function save($con = null)
|
|
{
|
|
if ($this->isNew() && null === $this->getTaxId())
|
|
{
|
|
$this->setTax($this->getProduct()->getTax());
|
|
}
|
|
|
|
if (!$this->getPriceNetto() && $this->getPriceBrutto())
|
|
{
|
|
$this->setPriceNetto(stPrice::extract($this->getPriceBrutto(), $this->getVatValue()));
|
|
}
|
|
elseif ($this->getPriceNetto() && !$this->getPriceBrutto())
|
|
{
|
|
$this->setPriceBrutto(stPrice::calculate($this->getPriceNetto(), $this->getVatValue()));
|
|
}
|
|
|
|
if (!$this->getOldPriceNetto() && $this->getOldPriceBrutto())
|
|
{
|
|
$this->setOldPriceNetto(stPrice::extract($this->getOldPriceBrutto(), $this->getVatValue()));
|
|
}
|
|
elseif ($this->getOldPriceNetto() && !$this->getOldPriceBrutto())
|
|
{
|
|
$this->setOldPriceBrutto(stPrice::calculate($this->getOldPriceNetto(), $this->getVatValue()));
|
|
}
|
|
|
|
$isModified = $this->isModified();
|
|
|
|
$result = parent::save($con);
|
|
|
|
if (self::$clearCache && $isModified)
|
|
{
|
|
AddPricePeer::clearCache();
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function getVatValue()
|
|
{
|
|
return $this->getTax()->getVat();
|
|
}
|
|
|
|
public function setProductId($v)
|
|
{
|
|
$this->setId($v);
|
|
}
|
|
|
|
public function getProductId()
|
|
{
|
|
return $this->getId();
|
|
}
|
|
}
|