can't use named parameters for prepared statements, prevent parameterlist with surplus entries for prepared statements
This commit is contained in:
parent
db2d8cb09a
commit
f990a05031
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
|
use oxRegistry;
|
||||||
|
|
||||||
require_once('genericAbstract.php');
|
require_once('genericAbstract.php');
|
||||||
|
|
||||||
abstract class articlePricesAbstract extends genericAbstract
|
abstract class articlePricesAbstract extends genericAbstract
|
||||||
@ -22,27 +24,27 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
public $baseQueriesDefaultTax = [
|
public $baseQueriesDefaultTax = [
|
||||||
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IS NULL);',
|
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IS NULL);',
|
||||||
// default prices
|
// default prices
|
||||||
'UPDATE oxarticles SET oxprice = (oxprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IS NULL)',
|
'UPDATE oxarticles SET oxprice = (oxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
|
||||||
// recommended retail price
|
// recommended retail price
|
||||||
'UPDATE oxarticles SET oxtprice = (oxtprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IS NULL)',
|
'UPDATE oxarticles SET oxtprice = (oxtprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
|
||||||
|
|
||||||
// varminprices
|
// varminprices
|
||||||
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IS NULL)',
|
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)',
|
||||||
// varmaxprices
|
// varmaxprices
|
||||||
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IS NULL)'
|
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IS NULL)'
|
||||||
];
|
];
|
||||||
|
|
||||||
public $baseQueriesCustomTax = [
|
public $baseQueriesCustomTax = [
|
||||||
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IN(16, 19));',
|
//'UPDATE oxarticles SET oxprice = (oxprice / 1.19 * 1.16) WHERE oxshopid = 'oxbaseshop' AND (oxvat IN(16, 19));',
|
||||||
// default prices
|
// default prices
|
||||||
'UPDATE oxarticles SET oxprice = (oxprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IN(:oldTaxRate, :newTaxRate))',
|
'UPDATE oxarticles SET oxprice = (oxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
|
||||||
// recommended retail price
|
// recommended retail price
|
||||||
'UPDATE oxarticles SET oxtprice = (oxtprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IN(:oldTaxRate, :newTaxRate))',
|
'UPDATE oxarticles SET oxtprice = (oxtprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
|
||||||
|
|
||||||
// varminprices
|
// varminprices
|
||||||
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IN(:oldTaxRate, :newTaxRate))',
|
'UPDATE oxarticles SET oxvarminprice = (oxvarminprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))',
|
||||||
// varmaxprices
|
// varmaxprices
|
||||||
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IN(:oldTaxRate, :newTaxRate))'
|
'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / ? * ?) WHERE oxshopid = ? AND (oxvat IN(?, ?))'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
@ -83,12 +85,11 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function changeSubshopArticlePricesDefaultTax($shopId)
|
public function changeSubshopArticlePricesDefaultTax($shopId)
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
$oCurrConfig = new \oxConfig();
|
$oCurrConfig = oxRegistry::getConfig();
|
||||||
|
|
||||||
$oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT');
|
$oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT');
|
||||||
$newTaxRate = $this->rateChanges[$oldTaxRate];
|
$newTaxRate = $this->rateChanges[$oldTaxRate];
|
||||||
@ -102,14 +103,18 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
foreach ($this->baseQueriesDefaultTax as $query) {
|
foreach ($this->baseQueriesDefaultTax as $query) {
|
||||||
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
||||||
|
|
||||||
$queryParameters = [
|
$paramLength = substr_count($query, '?');
|
||||||
'shopid' => $shopId,
|
|
||||||
'oldTaxRate'=> $oldTaxRate,
|
$allQueryParameters = [
|
||||||
'oldTaxPercent' => 1 + ($oldTaxRate / 100),
|
1 + ($oldTaxRate / 100),
|
||||||
'newTaxRate'=> $newTaxRate,
|
1 + ($newTaxRate / 100),
|
||||||
'newTaxPercent' => 1 + ($newTaxRate / 100),
|
$shopId,
|
||||||
|
$oldTaxRate,
|
||||||
|
$newTaxRate,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$queryParameters = array_slice($allQueryParameters, 0, $paramLength);
|
||||||
|
|
||||||
$count += $db->execute($query, $queryParameters);
|
$count += $db->execute($query, $queryParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,14 +128,18 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) {
|
foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) {
|
||||||
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
||||||
|
|
||||||
$queryParameters = [
|
$paramLength = substr_count($query, '?');
|
||||||
'shopid' => $shopId,
|
|
||||||
'oldTaxRate'=> $oldTaxRate,
|
$allQueryParameters = [
|
||||||
'oldTaxPercent' => 1 + ($oldTaxRate / 100),
|
1 + ($oldTaxRate / 100),
|
||||||
'newTaxRate'=> $newTaxRate,
|
1 + ($newTaxRate / 100),
|
||||||
'newTaxPercent' => 1 + ($newTaxRate / 100),
|
$shopId,
|
||||||
|
$oldTaxRate,
|
||||||
|
$newTaxRate,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$queryParameters = array_slice($allQueryParameters, 0, $paramLength);
|
||||||
|
|
||||||
$count += $db->execute($query, $queryParameters);
|
$count += $db->execute($query, $queryParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
|
use oxConfig;
|
||||||
|
use oxRegistry;
|
||||||
|
|
||||||
abstract class genericAbstract
|
abstract class genericAbstract
|
||||||
{
|
{
|
||||||
public $rateChanges = [
|
public $rateChanges = [
|
||||||
|
Reference in New Issue
Block a user