Skip to content
Code-Schnipsel Gruppen Projekte
Commit 16be0777 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'next' into 'master'

Next

See merge request !2
Übergeordnete b5672d86 29a1646a
Branches 1.x next-1.x
Tags 1.2.0
2 Merge Requests!13Update 'next-3.x' with latest changes from 'main',!2Next
Pipeline #9398 mit Warnungen bestanden mit Phasen
in 53 Sekunden
include:
- project: 'quiqqer/stabilization/semantic-release'
file: '/ci-templates/.gitlab-ci.yml'
PCSG QEL-1.0
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_discount_ajax_list', 'package_quiqqer_discount_ajax_list',
function ($params) { function ($params) {
$Grid = new QUI\Utils\Grid(); $Grid = new QUI\Utils\Grid();
$Discounts = new QUI\ERP\Discount\Handler(); $Discounts = new QUI\ERP\Discount\Handler();
$result = []; $result = [];
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
// search // search
$params = $Grid->parseDBParams(\json_decode($params, true)); $params = $Grid->parseDBParams(\json_decode($params, true));
...@@ -31,15 +31,15 @@ function ($params) { ...@@ -31,15 +31,15 @@ function ($params) {
foreach ($data as $entry) { foreach ($data as $entry) {
$entry['title'] = [ $entry['title'] = [
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$entry['id'].'.title' 'discount.' . $entry['id'] . '.title'
]; ];
$entry['text'] = $Locale->get( $entry['text'] = $Locale->get(
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$entry['id'].'.title' 'discount.' . $entry['id'] . '.title'
); );
$type = (int)$entry['discount_type']; $type = (int)$entry['discount_type'];
$usageType = (int)$entry['usage_type']; $usageType = (int)$entry['usage_type'];
// attributes // attributes
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
'package_quiqqer_discount_ajax_search', 'package_quiqqer_discount_ajax_search',
function ($fields, $params) { function ($fields, $params) {
$Discounts = new QUI\ERP\Discount\Handler(); $Discounts = new QUI\ERP\Discount\Handler();
$result = []; $result = [];
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
$allowedFields = $Discounts->getChildAttributes(); $allowedFields = $Discounts->getChildAttributes();
$query = []; $query = [];
$params = json_decode($params, true); $params = json_decode($params, true);
$fields = json_decode($fields, true); $fields = json_decode($fields, true);
...@@ -44,7 +44,7 @@ function ($fields, $params) { ...@@ -44,7 +44,7 @@ function ($fields, $params) {
} }
$query['where_or'][$field] = [ $query['where_or'][$field] = [
'type' => '%LIKE%', 'type' => '%LIKE%',
'value' => $value 'value' => $value
]; ];
} }
...@@ -55,12 +55,12 @@ function ($fields, $params) { ...@@ -55,12 +55,12 @@ function ($fields, $params) {
foreach ($data as $entry) { foreach ($data as $entry) {
$entry['title'] = [ $entry['title'] = [
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$entry['id'].'.title' 'discount.' . $entry['id'] . '.title'
]; ];
$entry['text'] = $Locale->get( $entry['text'] = $Locale->get(
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$entry['id'].'.title' 'discount.' . $entry['id'] . '.title'
); );
$result[] = $entry; $result[] = $entry;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
use QUI\Users\User; use QUI\Users\User;
use QUI\Permissions\Permission; use QUI\Permissions\Permission;
use QUI\Utils\Security\Orthos; use QUI\Utils\Security\Orthos;
use QUI\ERP\Areas\Utils as AreaUtils; use QUI\ERP\Areas\Utils as AreaUtils;
/** /**
...@@ -65,7 +64,7 @@ public function __construct($id, Handler $Factory) ...@@ -65,7 +64,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup); $cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) { if (!empty($cleanup)) {
$cleanup = ','.$cleanup.','; $cleanup = ',' . $cleanup . ',';
} }
$this->setAttribute('user_groups', $cleanup); $this->setAttribute('user_groups', $cleanup);
...@@ -76,7 +75,7 @@ public function __construct($id, Handler $Factory) ...@@ -76,7 +75,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup); $cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) { if (!empty($cleanup)) {
$cleanup = ','.$cleanup.','; $cleanup = ',' . $cleanup . ',';
} }
$this->setAttribute('articles', $cleanup); $this->setAttribute('articles', $cleanup);
...@@ -87,7 +86,7 @@ public function __construct($id, Handler $Factory) ...@@ -87,7 +86,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup); $cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) { if (!empty($cleanup)) {
$cleanup = ','.$cleanup.','; $cleanup = ',' . $cleanup . ',';
} }
$this->setAttribute('user_groups', $cleanup); $this->setAttribute('user_groups', $cleanup);
...@@ -98,7 +97,7 @@ public function __construct($id, Handler $Factory) ...@@ -98,7 +97,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup); $cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) { if (!empty($cleanup)) {
$cleanup = ','.$cleanup.','; $cleanup = ',' . $cleanup . ',';
} }
$this->setAttribute('articles', $cleanup); $this->setAttribute('articles', $cleanup);
...@@ -112,14 +111,15 @@ public function __construct($id, Handler $Factory) ...@@ -112,14 +111,15 @@ public function __construct($id, Handler $Factory)
$this->Events->addEvent('onDeleteEnd', function () { $this->Events->addEvent('onDeleteEnd', function () {
QUI\Translator::delete( QUI\Translator::delete(
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$this->getId().'.title' 'discount.' . $this->getId() . '.title'
); );
}); });
$this->Events->addEvent('onSaveBegin', function () { $this->Events->addEvent('onSaveBegin', function () {
Permission::checkPermission('quiqqer.areas.area.edit'); Permission::checkPermission('quiqqer.areas.area.edit');
if ($this->getAttribute('date_from') if (
$this->getAttribute('date_from')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_from')) && !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_from'))
) { ) {
throw new QUI\ERP\Discount\Exception([ throw new QUI\ERP\Discount\Exception([
...@@ -128,7 +128,8 @@ public function __construct($id, Handler $Factory) ...@@ -128,7 +128,8 @@ public function __construct($id, Handler $Factory)
]); ]);
} }
if ($this->getAttribute('date_until') if (
$this->getAttribute('date_until')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_until')) && !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_until'))
) { ) {
throw new QUI\ERP\Discount\Exception([ throw new QUI\ERP\Discount\Exception([
...@@ -137,10 +138,10 @@ public function __construct($id, Handler $Factory) ...@@ -137,10 +138,10 @@ public function __construct($id, Handler $Factory)
]); ]);
} }
$purchaseQuantityFrom = $this->getAttribute('purchase_quantity_from'); $purchaseQuantityFrom = $this->getAttribute('purchase_quantity_from');
$purchaseQuantityUntil = $this->getAttribute('purchase_quantity_until'); $purchaseQuantityUntil = $this->getAttribute('purchase_quantity_until');
$purchaseValueFrom = $this->getAttribute('purchase_value_from'); $purchaseValueFrom = $this->getAttribute('purchase_value_from');
$purchaseValueUntil = $this->getAttribute('purchase_value_until'); $purchaseValueUntil = $this->getAttribute('purchase_value_until');
if ($purchaseQuantityFrom !== '' && ($purchaseQuantityFrom === false || $purchaseQuantityFrom < 0)) { if ($purchaseQuantityFrom !== '' && ($purchaseQuantityFrom === false || $purchaseQuantityFrom < 0)) {
throw new QUI\ERP\Discount\Exception([ throw new QUI\ERP\Discount\Exception([
...@@ -216,7 +217,8 @@ public function setAttribute($key, $value) ...@@ -216,7 +217,8 @@ public function setAttribute($key, $value)
$value = null; $value = null;
} }
if ($key === 'scope' || if (
$key === 'scope' ||
$key === 'discount_type' || $key === 'discount_type' ||
$key === 'usage_type' $key === 'usage_type'
) { ) {
...@@ -240,7 +242,7 @@ public function getTitle($Locale = null) ...@@ -240,7 +242,7 @@ public function getTitle($Locale = null)
return $Locale->get( return $Locale->get(
'quiqqer/discount', 'quiqqer/discount',
'discount.'.$this->getId().'.title' 'discount.' . $this->getId() . '.title'
); );
} }
...@@ -296,9 +298,9 @@ public function canUsedBy(QUI\Interfaces\Users\User $User) ...@@ -296,9 +298,9 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
} }
// usage definitions / limits // usage definitions / limits
$dateFrom = $this->getAttribute('date_from'); $dateFrom = $this->getAttribute('date_from');
$dateUntil = $this->getAttribute('date_until'); $dateUntil = $this->getAttribute('date_until');
$now = \time(); $now = \time();
if ($dateFrom && \strtotime($dateFrom) > $now) { if ($dateFrom && \strtotime($dateFrom) > $now) {
return false; return false;
...@@ -310,7 +312,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User) ...@@ -310,7 +312,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
// assignment // assignment
$userGroupValue = $this->getAttribute('user_groups'); $userGroupValue = $this->getAttribute('user_groups');
$areasValue = $this->getAttribute('areas'); $areasValue = $this->getAttribute('areas');
// if groups and areas are empty, everbody is allowed // if groups and areas are empty, everbody is allowed
if (empty($userGroupValue) && empty($areasValue)) { if (empty($userGroupValue) && empty($areasValue)) {
...@@ -326,7 +328,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User) ...@@ -326,7 +328,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
$this->getAttribute('user_groups') $this->getAttribute('user_groups')
); );
$discountUsers = $userGroups['users']; $discountUsers = $userGroups['users'];
$discountGroups = $userGroups['groups']; $discountGroups = $userGroups['groups'];
// user checking // user checking
...@@ -368,7 +370,7 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc ...@@ -368,7 +370,7 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
return false; return false;
} }
$articles = $this->getAttribute('articles'); $articles = $this->getAttribute('articles');
$categories = $this->getAttribute('categories'); $categories = $this->getAttribute('categories');
if (\is_string($articles)) { if (\is_string($articles)) {
...@@ -465,7 +467,7 @@ public function verifyCombinationWith(Discount $Discount) ...@@ -465,7 +467,7 @@ public function verifyCombinationWith(Discount $Discount)
'quiqqer/discount', 'quiqqer/discount',
'exception.discount.not.combinable', 'exception.discount.not.combinable',
[ [
'id' => $this->getId(), 'id' => $this->getId(),
'discountId' => $Discount->getId() 'discountId' => $Discount->getId()
] ]
]); ]);
...@@ -485,7 +487,7 @@ public function verifyUser(User $User) ...@@ -485,7 +487,7 @@ public function verifyUser(User $User)
'quiqqer/discount', 'quiqqer/discount',
'exception.discount.user.cant.use.discount', 'exception.discount.user.cant.use.discount',
[ [
'id' => $this->getId(), 'id' => $this->getId(),
'userId' => $User->getId() 'userId' => $User->getId()
] ]
]); ]);
...@@ -524,8 +526,8 @@ public function toPriceFactor($Locale = null, $Customer = null) ...@@ -524,8 +526,8 @@ public function toPriceFactor($Locale = null, $Customer = null)
// check calculation basis VAT // check calculation basis VAT
$useAuto = $this->getAttribute('consider_vat') === 'auto' $useAuto = $this->getAttribute('consider_vat') === 'auto'
&& $Customer && $Customer
&& QUI\ERP\Utils\User::isNettoUser($Customer) === false; && QUI\ERP\Utils\User::isNettoUser($Customer) === false;
if ($useAuto || $this->getAttribute('consider_vat') === 'brutto') { if ($useAuto || $this->getAttribute('consider_vat') === 'brutto') {
$basis = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_VAT_BRUTTO; $basis = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_VAT_BRUTTO;
...@@ -552,30 +554,30 @@ public function toPriceFactor($Locale = null, $Customer = null) ...@@ -552,30 +554,30 @@ public function toPriceFactor($Locale = null, $Customer = null)
} }
return new PriceFactor([ return new PriceFactor([
'identifier' => 'discount-'.$this->getId(), 'identifier' => 'discount-' . $this->getId(),
'title' => $this->getTitle($Locale), 'title' => $this->getTitle($Locale),
'valueText' => $valueText, 'valueText' => $valueText,
'description' => '', 'description' => '',
'priority' => (int)$this->getAttribute('priority'), 'priority' => (int)$this->getAttribute('priority'),
'calculation' => $calculation, 'calculation' => $calculation,
'basis' => $basis, 'basis' => $basis,
'value' => $this->getAttribute('discount') * -1, 'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true, 'visible' => $hideDiscounts ? false : true,
'vat' => $this->getAttribute('vat') 'vat' => $this->getAttribute('vat')
]); ]);
} }
// to product // to product
return new QUI\ERP\Products\Utils\PriceFactor([ return new QUI\ERP\Products\Utils\PriceFactor([
'identifier' => 'discount-'.$this->getId(), 'identifier' => 'discount-' . $this->getId(),
'title' => $this->getTitle($Locale), 'title' => $this->getTitle($Locale),
// 'valueText' => $this->getTitle($Locale), // 'valueText' => $this->getTitle($Locale),
'description' => '', 'description' => '',
'priority' => (int)$this->getAttribute('priority'), 'priority' => (int)$this->getAttribute('priority'),
'calculation' => $calculation, 'calculation' => $calculation,
'basis' => $basis, 'basis' => $basis,
'value' => $this->getAttribute('discount') * -1, 'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true 'visible' => $hideDiscounts ? false : true
]); ]);
} }
...@@ -589,7 +591,7 @@ public function update() ...@@ -589,7 +591,7 @@ public function update()
$this->Events->fireEvent('saveBegin'); $this->Events->fireEvent('saveBegin');
$this->Events->fireEvent('updateBegin'); $this->Events->fireEvent('updateBegin');
$needles = $this->Factory->getChildAttributes(); $needles = $this->Factory->getChildAttributes();
$savedData = []; $savedData = [];
foreach ($needles as $needle) { foreach ($needles as $needle) {
...@@ -602,7 +604,7 @@ public function update() ...@@ -602,7 +604,7 @@ public function update()
switch ($needle) { switch ($needle) {
case 'user_groups': case 'user_groups':
if (!empty($value)) { if (!empty($value)) {
$value = ','.$value.','; $value = ',' . $value . ',';
} }
break; break;
} }
......
...@@ -70,7 +70,7 @@ protected static function getUserDiscounts(QUI\Interfaces\Users\User $User): arr ...@@ -70,7 +70,7 @@ protected static function getUserDiscounts(QUI\Interfaces\Users\User $User): arr
*/ */
public static function isDiscountUsableWithQuantity(Discount $Discount, $quantity): bool public static function isDiscountUsableWithQuantity(Discount $Discount, $quantity): bool
{ {
$purchaseQuantityFrom = $Discount->getAttribute('purchase_quantity_from'); $purchaseQuantityFrom = $Discount->getAttribute('purchase_quantity_from');
$purchaseQuantityUntil = $Discount->getAttribute('purchase_quantity_until'); $purchaseQuantityUntil = $Discount->getAttribute('purchase_quantity_until');
if ($quantity === 0) { if ($quantity === 0) {
...@@ -102,13 +102,15 @@ public static function isDiscountUsableWithQuantity(Discount $Discount, $quantit ...@@ -102,13 +102,15 @@ public static function isDiscountUsableWithQuantity(Discount $Discount, $quantit
*/ */
public static function isDiscountUsableWithPurchaseValue(Discount $Discount, $value): bool public static function isDiscountUsableWithPurchaseValue(Discount $Discount, $value): bool
{ {
$purchaseValueFrom = $Discount->getAttribute('purchase_value_from'); $purchaseValueFrom = $Discount->getAttribute('purchase_value_from');
$purchaseValueUntil = $Discount->getAttribute('purchase_value_until'); $purchaseValueUntil = $Discount->getAttribute('purchase_value_until');
// wenn complement, z.B. 10€, muss geprüft werden // wenn complement, z.B. 10€, muss geprüft werden
// ob meine value grösser ist als der gegebene value // ob meine value grösser ist als der gegebene value
if ((int)$Discount->getAttribute('discount_type') === ErpCalc::CALCULATION_COMPLEMENT if (
&& $Discount->getAttribute('discount') > $value) { (int)$Discount->getAttribute('discount_type') === ErpCalc::CALCULATION_COMPLEMENT
&& $Discount->getAttribute('discount') > $value
) {
return false; return false;
} }
...@@ -168,7 +170,7 @@ public static function onQuiqqerProductsCalcListProduct( ...@@ -168,7 +170,7 @@ public static function onQuiqqerProductsCalcListProduct(
return; return;
} }
$PriceFactors = $Product->getPriceFactors(); $PriceFactors = $Product->getPriceFactors();
$productQuantity = $Product->getQuantity(); $productQuantity = $Product->getQuantity();
$productNettoSum = $attributes['calculated_nettoSum']; $productNettoSum = $attributes['calculated_nettoSum'];
...@@ -184,7 +186,7 @@ public static function onQuiqqerProductsCalcListProduct( ...@@ -184,7 +186,7 @@ public static function onQuiqqerProductsCalcListProduct(
// check if Pricefactor is already in // check if Pricefactor is already in
$factors = $PriceFactors->toArray(); $factors = $PriceFactors->toArray();
$Factor = $Discount->toPriceFactor( $Factor = $Discount->toPriceFactor(
$Calc->getUser()->getLocale(), $Calc->getUser()->getLocale(),
$Calc->getUser() $Calc->getUser()
); );
...@@ -237,7 +239,7 @@ public static function onQuiqqerProductsCalcList( ...@@ -237,7 +239,7 @@ public static function onQuiqqerProductsCalcList(
} }
$listQuantity = $List->getQuantity(); $listQuantity = $List->getQuantity();
$products = $List->getProducts(); $products = $List->getProducts();
$PriceFactors = $List->getPriceFactors(); $PriceFactors = $List->getPriceFactors();
/* @var $Discount Discount */ /* @var $Discount Discount */
...@@ -307,7 +309,7 @@ public static function onQuiqqerProductsCalcList( ...@@ -307,7 +309,7 @@ public static function onQuiqqerProductsCalcList(
// check if Pricefactor is already in // check if Pricefactor is already in
$factors = $PriceFactors->toArray(); $factors = $PriceFactors->toArray();
$Factor = $Discount->toPriceFactor( $Factor = $Discount->toPriceFactor(
$Calc->getUser()->getLocale(), $Calc->getUser()->getLocale(),
$Calc->getUser() $Calc->getUser()
); );
......
...@@ -22,7 +22,7 @@ class Handler extends QUI\CRUD\Factory ...@@ -22,7 +22,7 @@ class Handler extends QUI\CRUD\Factory
const DISCOUNT_TYPE_PERCENT = 1; const DISCOUNT_TYPE_PERCENT = 1;
/** /**
* discount type -> crrency * discount type -> currency
*/ */
const DISCOUNT_TYPE_CURRENCY = 2; const DISCOUNT_TYPE_CURRENCY = 2;
...@@ -130,7 +130,7 @@ public function __construct() ...@@ -130,7 +130,7 @@ public function __construct()
// create new translation var for the discount // create new translation var for the discount
$this->Events->addEvent('onCreateEnd', function ($New, $data) { $this->Events->addEvent('onCreateEnd', function ($New, $data) {
/* @var $New QUI\ERP\Discount\Discount */ /* @var $New QUI\ERP\Discount\Discount */
$newVar = 'discount.'.$New->getId().'.title'; $newVar = 'discount.' . $New->getId() . '.title';
$current = QUI::getLocale()->getCurrent(); $current = QUI::getLocale()->getCurrent();
$title = $New->getAttribute('title'); $title = $New->getAttribute('title');
...@@ -146,9 +146,9 @@ public function __construct() ...@@ -146,9 +146,9 @@ public function __construct()
try { try {
QUI\Translator::addUserVar('quiqqer/discount', $newVar, [ QUI\Translator::addUserVar('quiqqer/discount', $newVar, [
$current => $title, $current => $title,
'datatype' => 'php,js', 'datatype' => 'php,js',
'package' => 'quiqqer/discount' 'package' => 'quiqqer/discount'
]); ]);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
QUI::getMessagesHandler()->addAttention( QUI::getMessagesHandler()->addAttention(
......
...@@ -28,15 +28,15 @@ class Utils ...@@ -28,15 +28,15 @@ class Utils
public static function getUserDiscounts(UserInterface $User): array public static function getUserDiscounts(UserInterface $User): array
{ {
$guString = UserGroups::getUserGroupStringFromUser($User); $guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.\str_replace(',', ',|,', $guString).','; $guString = ',' . \str_replace(',', ',|,', $guString) . ',';
$result = []; $result = [];
$Discounts = new Handler(); $Discounts = new Handler();
$personalDiscounts = $Discounts->getChildren([ $personalDiscounts = $Discounts->getChildren([
'where' => [ 'where' => [
'user_groups' => [ 'user_groups' => [
'type' => 'REGEXP', 'type' => 'REGEXP',
'value' => $guString 'value' => $guString
] ]
] ]
...@@ -70,14 +70,14 @@ public static function getUserDiscounts(UserInterface $User): array ...@@ -70,14 +70,14 @@ public static function getUserDiscounts(UserInterface $User): array
*/ */
public static function getProductDiscounts(Product $Product): array public static function getProductDiscounts(Product $Product): array
{ {
$result = []; $result = [];
$Discounts = new Handler(); $Discounts = new Handler();
$productDiscounts = $Discounts->getChildren([ $productDiscounts = $Discounts->getChildren([
'where' => [ 'where' => [
'user_groups' => [ 'user_groups' => [
'type' => 'REGEXP', 'type' => 'REGEXP',
'value' => ','.$Product->getId().',' 'value' => ',' . $Product->getId() . ','
] ]
] ]
]); ]);
...@@ -111,16 +111,16 @@ public static function getProductDiscounts(Product $Product): array ...@@ -111,16 +111,16 @@ public static function getProductDiscounts(Product $Product): array
public static function getActiveUserDiscounts(UserInterface $User): array public static function getActiveUserDiscounts(UserInterface $User): array
{ {
$guString = UserGroups::getUserGroupStringFromUser($User); $guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.\str_replace(',', ',|,', $guString).','; $guString = ',' . \str_replace(',', ',|,', $guString) . ',';
$result = []; $result = [];
$Discounts = new Handler(); $Discounts = new Handler();
$personalDiscounts = $Discounts->getChildren([ $personalDiscounts = $Discounts->getChildren([
'where' => [ 'where' => [
'active' => 1, 'active' => 1,
'user_groups' => [ 'user_groups' => [
'type' => 'REGEXP', 'type' => 'REGEXP',
'value' => $guString 'value' => $guString
] ]
] ]
...@@ -128,14 +128,14 @@ public static function getActiveUserDiscounts(UserInterface $User): array ...@@ -128,14 +128,14 @@ public static function getActiveUserDiscounts(UserInterface $User): array
$discounts = $Discounts->getChildren([ $discounts = $Discounts->getChildren([
'where' => [ 'where' => [
'active' => 1, 'active' => 1,
'user_groups' => '' 'user_groups' => ''
] ]
]); ]);
$discountsNULL = $Discounts->getChildren([ $discountsNULL = $Discounts->getChildren([
'where' => [ 'where' => [
'active' => 1, 'active' => 1,
'user_groups' => null 'user_groups' => null
] ]
]); ]);
...@@ -180,7 +180,7 @@ public static function getActiveUserDiscounts(UserInterface $User): array ...@@ -180,7 +180,7 @@ public static function getActiveUserDiscounts(UserInterface $User): array
public static function getUsableUserDiscounts(UserInterface $User): array public static function getUsableUserDiscounts(UserInterface $User): array
{ {
$discounts = self::getActiveUserDiscounts($User); $discounts = self::getActiveUserDiscounts($User);
$result = []; $result = [];
/* @var $Discount Discount */ /* @var $Discount Discount */
foreach ($discounts as $Discount) { foreach ($discounts as $Discount) {
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren