Files
grzanieplus.pl/plugins/appAddPricePlugin/lib/model/AddGroupPrice.php
2025-03-12 17:06:23 +01:00

119 lines
2.6 KiB
PHP

<?php
/**
* Subclass for representing a row from the 'app_add_group_price' table.
*
*
*
* @package plugins.appAddPricePlugin.lib.model
*/
class AddGroupPrice extends BaseAddGroupPrice
{
public function getTypeLabel()
{
$types = GroupPricePeer::getTypes(sfContext::getInstance()->getI18N());
return $types[null !== $this->price_type];
}
public function countProducts()
{
return $this->getGroupPrice()->countProducts();
}
public function getAdminGeneratorTitle()
{
return $this->getCurrency()->getShortcut();
}
public function setCurrencyOldPrice(array $v)
{
if (isset($v['netto']))
{
$this->setOldPriceNetto($v['netto']);
}
if (isset($v['brutto']))
{
$this->setOldPriceBrutto($v['brutto']);
}
}
public function setCurrencyPrice(array $v)
{
if (isset($v['netto']))
{
$this->setPriceNetto($v['netto']);
}
if (isset($v['brutto']))
{
$this->setPriceBrutto($v['brutto']);
}
}
public function setCurrencyWholesale(array $v)
{
foreach (array('a', 'b', 'c') as $group)
{
$group_netto = $group.'_netto';
$group_brutto = $group.'_brutto';
$methodPrefix = 'setWholesale'.ucfirst($group);
$methodNetto = $methodPrefix.'Netto';
$methodBrutto = $methodPrefix.'Brutto';
if (isset($v[$group_netto]))
{
$this->$methodNetto($v[$group_netto]);
}
if (isset($v[$group_brutto]))
{
$this->$methodBrutto($v[$group_brutto]);
}
}
}
public function setCurrencyPriceType($v)
{
$this->setPriceType($v);
}
public function setCurrencyTaxId($v)
{
$this->setTaxId($v);
}
public function getTaxId()
{
return null === $this->price_type ? $this->getGroupPrice()->getTaxId() : null;
}
public function getTax($con = null)
{
return null === $this->price_type ? parent::getTax($con) : null;
}
public function getOptVat()
{
if (null !== $this->price_type)
{
return null;
}
$vat = parent::getOptVat();
return null === $vat ? $this->getTax()->getDefaultTaxRate() : $vat;
}
public function save($con = null)
{
if ($this->isColumnModified(AddGroupPricePeer::TAX_ID))
{
$this->setOptVat($this->getTax()->getDefaultTaxRate());
}
return parent::save($con);
}
}