first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for representing a row from the 'st_group_price' table.
*
*
*
* @package plugins.stGroupPricePlugin.lib.model
*/
class GroupPrice extends BaseGroupPrice
{
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_group_price' table.
*
*
*
* @package plugins.stGroupPricePlugin.lib.model
*/
class GroupPricePeer extends BaseGroupPricePeer
{
}

View File

@@ -0,0 +1,106 @@
<?php
/**
* This class adds structure of 'st_group_price' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stGroupPricePlugin.lib.model.map
*/
class GroupPriceMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stGroupPricePlugin.lib.model.map.GroupPriceMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_group_price');
$tMap->setPhpName('GroupPrice');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addForeignKey('TAX_ID', 'TaxId', 'int', CreoleTypes::INTEGER, 'st_tax', 'ID', false, null);
$tMap->addColumn('OPT_VAT', 'OptVat', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addForeignKey('CURRENCY_ID', 'CurrencyId', 'int', CreoleTypes::INTEGER, 'st_currency', 'ID', false, null);
$tMap->addColumn('PRICE_TYPE', 'PriceType', 'string', CreoleTypes::VARCHAR, false, 24);
$tMap->addColumn('PRICE_MODIFIER', 'PriceModifier', 'string', CreoleTypes::VARCHAR, false, 10);
$tMap->addColumn('PRICE_NETTO', 'PriceNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('PRICE_BRUTTO', 'PriceBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('OLD_PRICE_NETTO', 'OldPriceNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('OLD_PRICE_BRUTTO', 'OldPriceBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_A_NETTO', 'WholesaleANetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_A_BRUTTO', 'WholesaleABrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_B_NETTO', 'WholesaleBNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_B_BRUTTO', 'WholesaleBBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_C_NETTO', 'WholesaleCNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WHOLESALE_C_BRUTTO', 'WholesaleCBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
} // doBuild()
} // GroupPriceMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,969 @@
<?php
class stChangePriceProgressBar {
public function init() {
}
public function close() {
$i18n = sfContext::getInstance()->getI18N();
$group_price = self::getParam('group_price');
sfLoader::loadHelpers(array('Helper', 'stAdminGenerator'));
$button = st_get_admin_button('stProduct', __('Pokaż produkty', null, 'stGroupPriceBackend'), '@stGroupPricePlugin?action=productList&group_price_id='.$group_price['id'].'&filters[assigned_product]=1', array(
'class' => 'bs-mt-3',
));
$this->setMessage($i18n->__('Operacja zmiany cen zakończona pomyślnie.', '', 'stGroupPriceBackend'). '<br>' . $button);
}
public function send($offset) {
$group_price = self::getParam('group_price');
$i18n = sfContext::getInstance() -> getI18N();
$c = new Criteria();
$c -> setOffset($offset);
$c -> setLimit(100);
$c -> add(ProductPeer::GROUP_PRICE_ID, $group_price['id']);
$products = ProductPeer::doSelect($c);
$counter = 0;
foreach ($products as $product) {
$counter++;
if ($group_price['set_one_price'] == "false") {
if ($group_price['currency_id'] == $product -> getCurrencyId() || $product -> getCurrencyId() == "") {
$product -> setTaxId($group_price['tax_id']);
$product -> setOptVat($group_price['opt_vat']);
$product -> setPrice($group_price['price_netto']);
$product -> setOptPriceBrutto($group_price['price_brutto']);
$product -> setOldPrice($group_price['old_price_netto']);
$product -> setOptOldPriceBrutto($group_price['old_price_brutto']);
$product -> setWholesaleANetto($group_price['wholesale_a_price_netto']);
$product -> setWholesaleABrutto($group_price['wholesale_a_price_brutto']);
$product -> setWholesaleBNetto($group_price['wholesale_b_price_netto']);
$product -> setWholesaleBBrutto($group_price['wholesale_b_price_brutto']);
$product -> setWholesaleCNetto($group_price['wholesale_c_price_netto']);
$product -> setWholesaleCBrutto($group_price['wholesale_c_price_brutto']);
$product -> save();
} else {
$c = new Criteria();
$c -> add(AddPricePeer::ID, $product -> getId());
$c -> add(AddPricePeer::CURRENCY_ID, $group_price['currency_id']);
$addPrice = AddPricePeer::doSelectOne($c);
if (!$addPrice) {
$addPrice = new AddPrice();
$addPrice -> setId($product -> getId());
$addPrice -> setCurrencyId($group_price['currency_id']);
}
$addPrice -> setTaxId($group_price['tax_id']);
$addPrice -> setOptVat($group_price['opt_vat']);
$addPrice -> setPriceNetto($group_price['price_netto']);
$addPrice -> setPriceBrutto($group_price['price_brutto']);
$addPrice -> setOldPriceNetto($group_price['old_price_netto']);
$addPrice -> setOldPriceBrutto($group_price['old_price_brutto']);
$addPrice -> setWholesaleANetto($group_price['wholesale_a_price_netto']);
$addPrice -> setWholesaleABrutto($group_price['wholesale_a_price_brutto']);
$addPrice -> setWholesaleBNetto($group_price['wholesale_b_price_netto']);
$addPrice -> setWholesaleBBrutto($group_price['wholesale_b_price_brutto']);
$addPrice -> setWholesaleCNetto($group_price['wholesale_c_price_netto']);
$addPrice -> setWholesaleCBrutto($group_price['wholesale_c_price_brutto']);
$addPrice -> save();
}
}
if ($group_price['set_one_price'] == "true") {
if ($group_price['currency_id'] == $product -> getCurrencyId() || $product -> getCurrencyId() == "") {
// zmiana ceny netto
if ($group_price['type'] == "netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $product -> getPrice() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $product -> getPrice() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $product -> getPrice() + ($product -> getPrice() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $product -> getPrice() - ($product -> getPrice() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$product -> setPrice($netto);
$product -> setOptPriceBrutto($brutto);
}
// zmiana ceny brutto
if ($group_price['type'] == "brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getOptPriceBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getOptPriceBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getOptPriceBrutto() + ($product -> getOptPriceBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getOptPriceBrutto() - ($product -> getOptPriceBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$product -> setPrice($netto);
$product -> setOptPriceBrutto($brutto);
}
// zmiana ceny old netto
if ($group_price['type'] == "old_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $product -> getOldPrice() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $product -> getOldPrice() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $product -> getOldPrice() + ($product -> getOldPrice() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $product -> getOldPrice() - ($product -> getOldPrice() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$product -> setOldPrice($netto);
$product -> setOptOldPriceBrutto($brutto);
}
// zmiana ceny old brutto
if ($group_price['type'] == "old_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getOptOldPriceBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getOptOldPriceBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getOptOldPriceBrutto() + ($product -> getOptOldPriceBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getOptOldPriceBrutto() - ($product -> getOptOldPriceBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$product -> setOldPrice($netto);
$product -> setOptOldPriceBrutto($brutto);
}
// zmiana ceny wholesale_a_netto
if ($group_price['type'] == "wholesale_a_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleANetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleANetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleANetto() + ($product -> getWholesaleANetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleANetto() - ($product -> getWholesaleANetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$product -> setWholesaleANetto($netto);
$product -> setWholesaleABrutto($brutto);
}
// zmiana ceny wholesale_a_brutto
if ($group_price['type'] == "wholesale_a_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleABrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleABrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleABrutto() + ($product -> getWholesaleABrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleABrutto() - ($product -> getWholesaleABrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$product -> setWholesaleANetto($netto);
$product -> setWholesaleABrutto($brutto);
}
// zmiana ceny wholesale_b_netto
if ($group_price['type'] == "wholesale_b_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleBNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleBNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleBNetto() + ($product -> getWholesaleBNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleBNetto() - ($product -> getWholesaleBNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$product -> setWholesaleBNetto($netto);
$product -> setWholesaleBBrutto($brutto);
}
// zmiana ceny wholesale_a_brutto
if ($group_price['type'] == "wholesale_b_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleBBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleBBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleBBrutto() + ($product -> getWholesaleBBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleBBrutto() - ($product -> getWholesaleBBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$product -> setWholesaleBNetto($netto);
$product -> setWholesaleBBrutto($brutto);
}
// zmiana ceny wholesale_c_netto
if ($group_price['type'] == "wholesale_c_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleCNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $product -> getWholesaleCNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleCNetto() + ($product -> getWholesaleCNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $product -> getWholesaleCNetto() - ($product -> getWholesaleCNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$product -> setWholesaleCNetto($netto);
$product -> setWholesaleCBrutto($brutto);
}
// zmiana ceny wholesale_c_brutto
if ($group_price['type'] == "wholesale_c_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleCBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $product -> getWholesaleCBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleCBrutto() + ($product -> getWholesaleCBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $product -> getWholesaleCBrutto() - ($product -> getWholesaleCBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$product -> setWholesaleCNetto($netto);
$product -> setWholesaleCBrutto($brutto);
}
$product -> save();
} else {
$c = new Criteria();
$c -> add(AddPricePeer::ID, $product -> getId());
$c -> add(AddPricePeer::CURRENCY_ID, $group_price['currency_id']);
$addPrice = AddPricePeer::doSelectOne($c);
if (!$addPrice && $group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$addPrice = new AddPrice();
$addPrice -> setId($product -> getId());
$addPrice -> setCurrencyId($group_price['currency_id']);
$addPrice -> setTaxId($group_price['tax_id']);
$addPrice -> setOptVat($product->getOptVat());
}
if($addPrice){
// zmiana ceny netto
if ($group_price['type'] == "netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getPriceNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getPriceNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getPriceNetto() + ($addPrice -> getPriceNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getPriceNetto() - ($addPrice -> getPriceNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$addPrice -> setPriceNetto($netto);
$addPrice -> setPriceBrutto(stPrice::calculate($netto, $product->getOptVat()));
}
// zmiana ceny brutto
if ($group_price['type'] == "brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getPriceBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getPriceBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getPriceBrutto() + ($addPrice -> getPriceBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getPriceBrutto() - ($addPrice -> getPriceBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$addPrice -> setPriceNetto(stPrice::extract($brutto, $product->getOptVat()));
$addPrice -> setPriceBrutto($brutto);
}
// zmiana ceny old netto
if ($group_price['type'] == "old_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getOldPriceNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getOldPriceNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getOldPriceNetto() + ($addPrice -> getOldPriceNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getOldPriceNetto() - ($addPrice -> getOldPriceNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$addPrice -> setOldPriceNetto($netto);
$addPrice -> setOldPriceBrutto(stPrice::calculate($netto, $product->getOptVat()));
}
// zmiana ceny old brutto
if ($group_price['type'] == "old_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getOldPriceBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getOldPriceBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getOldPriceBrutto() + ($addPrice -> getOldPriceBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getOldPriceBrutto() - ($addPrice -> getOldPriceBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$addPrice -> setOldPriceNetto(stPrice::extract($brutto, $product->getOptVat()));
$addPrice -> setOldPriceBrutto($brutto);
}
// zmiana ceny wholesale_a_netto
if ($group_price['type'] == "wholesale_a_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleANetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleANetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleANetto() + ($addPrice -> getWholesaleANetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleANetto() - ($addPrice -> getWholesaleANetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$addPrice -> setWholesaleANetto($netto);
$addPrice -> setWholesaleABrutto(stPrice::calculate($netto, $product->getOptVat()));
}
// zmiana ceny wholesale_a_brutto
if ($group_price['type'] == "wholesale_a_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleABrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleABrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleABrutto() + ($addPrice -> getWholesaleABrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleABrutto() - ($addPrice -> getWholesaleABrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$addPrice -> setWholesaleANetto(stPrice::extract($brutto, $product->getOptVat()));
$addPrice -> setWholesaleABrutto($brutto);
}
// zmiana ceny wholesale_b_netto
if ($group_price['type'] == "wholesale_b_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleBNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleBNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleBNetto() + ($addPrice -> getWholesaleBNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleBNetto() - ($addPrice -> getWholesaleBNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$addPrice -> setWholesaleBNetto(stPrice::calculate($netto, $product->getOptVat()));
$addPrice -> setWholesaleBBrutto($brutto);
}
// zmiana ceny wholesale_a_brutto
if ($group_price['type'] == "wholesale_b_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleBBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleBBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleBBrutto() + ($addPrice -> getWholesaleBBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleBBrutto() - ($addPrice -> getWholesaleBBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$addPrice -> setWholesaleBNetto(stPrice::extract($brutto, $product->getOptVat()));
$addPrice -> setWholesaleBBrutto($brutto);
}
// zmiana ceny wholesale_c_netto
if ($group_price['type'] == "wholesale_c_netto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleCNetto() + $group_price['value'];
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = $addPrice -> getWholesaleCNetto() - $group_price['value'];
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleCNetto() + ($addPrice -> getWholesaleCNetto() * ($group_price['value'] / 100));
$brutto = null;
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = $addPrice -> getWholesaleCNetto() - ($addPrice -> getWholesaleCNetto() * ($group_price['value'] / 100));
$brutto = null;
if ($netto < 0) {
$netto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = $group_price['value'];
$brutto = null;
}
$addPrice -> setWholesaleCNetto($netto);
$addPrice -> setWholesaleCBrutto(stPrice::calculate($netto, $product->getOptVat()));
}
// zmiana ceny wholesale_c_brutto
if ($group_price['type'] == "wholesale_c_brutto") {
if ($group_price['prefix'] == "+" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleCBrutto() + $group_price['value'];
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $addPrice -> getWholesaleCBrutto() - $group_price['value'];
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "+" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleCBrutto() + ($addPrice -> getWholesaleCBrutto() * ($group_price['value'] / 100));
} elseif ($group_price['prefix'] == "-" && $group_price['sufix'] == "true") {
$netto = null;
$brutto = $addPrice -> getWholesaleCBrutto() - ($addPrice -> getWholesaleCBrutto() * ($group_price['value'] / 100));
if ($brutto < 0) {
$brutto = 0;
}
} elseif ($group_price['prefix'] == "false" && $group_price['sufix'] == "false") {
$netto = null;
$brutto = $group_price['value'];
}
$addPrice -> setWholesaleCNetto(stPrice::extract($brutto, $product->getOptVat()));
$addPrice -> setWholesaleCBrutto($brutto);
}
$addPrice -> save();
}
}
}
}
self::setMessage($i18n -> __('Zmiana cen w toku %current%/%from%', array('%current%' => $offset, '%from%' => self::getAttribute('steps')), 'stNewsletterBackend'));
sleep(1);
return $offset + count($products);
}
public static function setParam($name, $value) {
sfContext::getInstance() -> getUser() -> setAttribute($name, $value, 'soteshop/stChangePriceProgressBar');
}
public static function getParam($name, $default = null) {
return sfContext::getInstance() -> getUser() -> getAttribute($name, $default, 'soteshop/stChangePriceProgressBar');
}
public static function getAttribute($name) {
$attributes = sfContext::getInstance() -> getUser() -> getAttribute('smChangePrice', array(), 'soteshop/stProgressBarPlugin');
return isset($attributes[$name]) ? $attributes[$name] : null;
}
public static function setMessage($message) {
sfContext::getInstance() -> getUser() -> setAttribute('stProgressBar-stChangePrice', $message, 'symfony/flash');
}
}

View File

@@ -0,0 +1,25 @@
<?php
class stGroupPriceExport {
static public function getProduct($object = null) {
return $object -> getGroupPrice();
}
static public function setProduct($object = null, $group_price = null) {
if ($group_price!=null) {
$c = new Criteria();
$c -> add(GroupPricePeer::NAME, $group_price);
$group = GroupPricePeer::doSelectOne($c);
if (!is_object($group)) {
$group = new GroupPrice();
$group -> setName($group_price);
$group -> save();
}
$object -> setGroupPriceId($group -> getId());
}
return true;
}
}

View File

@@ -0,0 +1,10 @@
<?php
class stGroupPricePluginListener {
public static function generateStProduct(sfEvent $event) {
$event -> getSubject() -> attachAdminGeneratorFile('stGroupPricePlugin', 'stProduct.yml');
}
}