From 4ff81c49c0d06724be40586707e28b397e2ee15a Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 23 Nov 2023 19:03:13 +0100 Subject: [PATCH 1/4] takt over from 7.0 Branch --- CHANGELOG.md | 3 +- metadata.php | 3 +- src/Controller/Admin/OrderList.php | 135 +++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 src/Controller/Admin/OrderList.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 804f8e0c..8d47cf6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007553](https://bugs.oxid-esales.com/view.php?id=7553) revert this task because, it is possible to have different billing and delivery addresses for invoice purchases (Paylater) - Discounts with time restrictions may not be invalidated directly in the checkout... -- +- provided additional Order-Number is searchable + ## [1.1.3] - 2023-11-14 - [0007526](https://bugs.oxid-esales.com/view.php?id=7526) Order would be saved only, if everything is correct. In all other cases redirect to checkout diff --git a/metadata.php b/metadata.php index eba1367d..a68122b8 100644 --- a/metadata.php +++ b/metadata.php @@ -9,6 +9,7 @@ * Metadata version */ +use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderList; use OxidSolutionCatalysts\Unzer\Model\DiscountList; use OxidSolutionCatalysts\Unzer\Controller\Admin\AdminOrderController; use OxidSolutionCatalysts\Unzer\Controller\Admin\ModuleConfiguration; @@ -21,7 +22,6 @@ use OxidSolutionCatalysts\Unzer\Core\Config; use OxidSolutionCatalysts\Unzer\Core\ShopControl; use OxidSolutionCatalysts\Unzer\Core\ViewConfig; -use OxidSolutionCatalysts\Unzer\Model\PaymentGateway; use OxidSolutionCatalysts\Unzer\Model\Article; use OxidSolutionCatalysts\Unzer\Model\Order; use OxidSolutionCatalysts\Unzer\Model\Payment; @@ -67,6 +67,7 @@ \OxidEsales\Eshop\Core\ShopControl::class => ShopControl::class, \OxidEsales\Eshop\Application\Controller\Admin\ModuleConfiguration::class => ModuleConfiguration::class, \OxidEsales\Eshop\Application\Controller\Admin\OrderMain::class => OrderMain::class, + \OxidEsales\Eshop\Application\Controller\Admin\OrderList::class => OrderList::class, \OxidEsales\Eshop\Application\Model\Article::class => Article::class, ], 'controllers' => [ diff --git a/src/Controller/Admin/OrderList.php b/src/Controller/Admin/OrderList.php new file mode 100644 index 00000000..ac94214d --- /dev/null +++ b/src/Controller/Admin/OrderList.php @@ -0,0 +1,135 @@ +getConfigParam('aOrderfolder'); + $folder = Registry::getRequest()->getRequestEscapedParameter('folder'); + + $query = $this->prepareOrderListQuery($queries, $queryForAppending); + if ($folder && $folder !== '-1') { + $query .= " and ( oxorder.oxfolder = " . $database->quote($folder) . " )"; + } elseif (!$folder && is_array($folders)) { + $folderNames = array_keys($folders); + $query .= " and ( oxorder.oxfolder = " . $database->quote($folderNames[0]) . " )"; + } + + $query .= " and oxorder.oxshopid = '" . $config->getShopId() . "'"; + + return $query; + } + + /** + * @param array $whereQuery + * @param string $filterQuery + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.StaticAccess) + * + * @return string + * @throws DatabaseConnectionException + */ + protected function prepareOrderListQuery(array $whereQuery, string $filterQuery): string + { + if (count($whereQuery)) { + $myUtilsString = Registry::getUtilsString(); + foreach ($whereQuery as $identifierName => $fieldValue) { + //passing oxunzerordernr because it will be combined with oxordernr + if ("oxorder.oxunzerordernr" === $identifierName) { + continue; + } + $fieldValue = trim($fieldValue); + //check if this is search string (contains % sign at beginning and end of string) + $isSearchValue = $this->isSearchValue($fieldValue); + //removing % symbols + $fieldValue = $this->processFilter($fieldValue); + if ($fieldValue !== '') { + $database = DatabaseProvider::getDb(); + $values = explode(' ', $fieldValue); + //for each search field using AND action + $queryBoolAction = ' and ('; + + //oxordernr is combined with oxunzerordernr + if ("oxorder.oxordernr" === $identifierName) { + $oxOrderNr = $database->quoteIdentifier("oxorder.oxordernr"); + $oxUnzerOrderNr = $database->quoteIdentifier("oxorder.oxunzerordernr"); + $orderNrQuery = []; + foreach ($values as $value) { + $orderNrQuery[] = "({$oxOrderNr} like '{$value}'" + . " or {$oxUnzerOrderNr} like '{$value}')"; + } + $filterQuery .= "and (" . implode(" or ", $orderNrQuery) . ")"; + + continue; + } + + foreach ($values as $value) { + // trying to search spec chars in search value + // if found, add cleaned search value to search sql + $uml = $myUtilsString->prepareStrForSearch($value); + if ($uml) { + $queryBoolAction .= '('; + } + $quotedIdentifierName = $database->quoteIdentifier($identifierName); + $filterQuery .= " {$queryBoolAction} {$quotedIdentifierName} "; + //for search in same field for different values using AND + $queryBoolAction = ' and '; + $filterQuery .= $this->buildFilter($value, $isSearchValue); + if ($uml) { + $filterQuery .= " or {$quotedIdentifierName} "; + + $filterQuery .= $this->buildFilter($uml, $isSearchValue); + $filterQuery .= ')'; // end of OR section + } + } + // end for AND action + $filterQuery .= ' ) '; + } + } + } + + return $filterQuery; + } + + /** + * Returns list filter array + * + * @SuppressWarnings(PHPMD.StaticAccess) + * + * @return array + */ + public function getListFilter() + { + if ($this->_aListFilter === null) { + $request = Registry::getRequest(); + $filter = (array)$request->getRequestParameter("where"); + $request->checkParamSpecialChars($filter); + + if (!empty($filter['oxorder']['oxordernr'])) { + $filter['oxorder']['oxunzerordernr'] = $filter['oxorder']['oxordernr']; + } + + $this->_aListFilter = $filter; + } + + return $this->_aListFilter; + } +} From d6b576fefeb3c49f6ed6dca4f6881fc9cb038f29 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 23 Nov 2023 19:47:13 +0100 Subject: [PATCH 2/4] CodeStyle --- Tests/PhpStan/phpstan-bootstrap.php | 9 ++- Tests/PhpStan/phpstan.neon | 1 + src/Controller/Admin/AdminOrderController.php | 8 +- src/Controller/Admin/OrderList.php | 12 +-- src/Model/DiscountList.php | 79 +++++++++++++------ 5 files changed, 72 insertions(+), 37 deletions(-) diff --git a/Tests/PhpStan/phpstan-bootstrap.php b/Tests/PhpStan/phpstan-bootstrap.php index 7408ce7e..344b0f30 100644 --- a/Tests/PhpStan/phpstan-bootstrap.php +++ b/Tests/PhpStan/phpstan-bootstrap.php @@ -12,6 +12,11 @@ class_alias( \OxidSolutionCatalysts\Unzer\Controller\Admin\OrderMain_parent::class ); +class_alias( + \OxidEsales\Eshop\Application\Controller\Admin\OrderList::class, + \OxidSolutionCatalysts\Unzer\Controller\Admin\OrderList_parent::class +); + class_alias( \OxidEsales\Eshop\Application\Controller\OrderController::class, \OxidSolutionCatalysts\Unzer\Controller\OrderController_parent::class @@ -57,6 +62,6 @@ class_alias( ); class_alias( - \OxidEsales\Eshop\Application\Model\PaymentGateway::class, - \OxidSolutionCatalysts\Unzer\Model\PaymentGateway_parent::class + \OxidEsales\Eshop\Application\Model\DiscountList::class, + \OxidSolutionCatalysts\Unzer\Model\DiscountList_parent::class ); diff --git a/Tests/PhpStan/phpstan.neon b/Tests/PhpStan/phpstan.neon index 13257600..42e0bdd8 100644 --- a/Tests/PhpStan/phpstan.neon +++ b/Tests/PhpStan/phpstan.neon @@ -1,5 +1,6 @@ parameters: checkMissingIterableValueType: false + treatPhpDocTypesAsCertain: false bootstrapFiles: - phpstan-bootstrap.php level: max diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 53773e8d..88c97390 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -229,10 +229,10 @@ protected function addAuthorizationViewData(Authorization $authorization): void $this->_aViewData["AuthId"] = $authorization->getId(); $this->_aViewData["AuthAmount"] = $authorization->getAmount(); $holderData = []; - $holderData['bic'] = $authorization->getBic(); - $holderData['iban'] = $authorization->getIban(); - $holderData['descriptor'] = $authorization->getDescriptor(); - $holderData['holder'] = $authorization->getHolder(); + $holderData['bic'] = $authorization->getBic(); + $holderData['iban'] = $authorization->getIban(); + $holderData['descriptor'] = $authorization->getDescriptor(); + $holderData['holder'] = $authorization->getHolder(); $this->_aViewData["holderData"] = $holderData; } diff --git a/src/Controller/Admin/OrderList.php b/src/Controller/Admin/OrderList.php index ac94214d..88c96a30 100644 --- a/src/Controller/Admin/OrderList.php +++ b/src/Controller/Admin/OrderList.php @@ -9,8 +9,8 @@ class OrderList extends OrderList_parent { /** - * @param $queries - * @param $queryForAppending + * @param array $queries + * @param string $queryForAppending * * @SuppressWarnings(PHPMD.StaticAccess) * @@ -58,9 +58,9 @@ protected function prepareOrderListQuery(array $whereQuery, string $filterQuery) } $fieldValue = trim($fieldValue); //check if this is search string (contains % sign at beginning and end of string) - $isSearchValue = $this->isSearchValue($fieldValue); + $isSearchValue = $this->_isSearchValue($fieldValue); //removing % symbols - $fieldValue = $this->processFilter($fieldValue); + $fieldValue = $this->_processFilter($fieldValue); if ($fieldValue !== '') { $database = DatabaseProvider::getDb(); $values = explode(' ', $fieldValue); @@ -92,11 +92,11 @@ protected function prepareOrderListQuery(array $whereQuery, string $filterQuery) $filterQuery .= " {$queryBoolAction} {$quotedIdentifierName} "; //for search in same field for different values using AND $queryBoolAction = ' and '; - $filterQuery .= $this->buildFilter($value, $isSearchValue); + $filterQuery .= $this->_buildFilter($value, $isSearchValue); if ($uml) { $filterQuery .= " or {$quotedIdentifierName} "; - $filterQuery .= $this->buildFilter($uml, $isSearchValue); + $filterQuery .= $this->_buildFilter($uml, $isSearchValue); $filterQuery .= ')'; // end of OR section } } diff --git a/src/Model/DiscountList.php b/src/Model/DiscountList.php index 3609834a..e23e35bf 100644 --- a/src/Model/DiscountList.php +++ b/src/Model/DiscountList.php @@ -7,17 +7,21 @@ namespace OxidSolutionCatalysts\Unzer\Model; +use OxidEsales\Eshop\Application\Model\Article; +use OxidEsales\Eshop\Application\Model\Groups; +use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Core\DatabaseProvider; +use OxidEsales\Eshop\Core\Model\ListModel; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Application\Model\DiscountList as CoreDisCountList; class DiscountList extends DiscountList_parent { - - /** * Returns array of discounts that can be globally (transparently) applied * - * @param \OxidEsales\Eshop\Application\Model\Article $oArticle article object - * @param \OxidEsales\Eshop\Application\Model\User $oUser oxuser object (optional) + * @param Article $oArticle article object + * @param User $oUser oxuser object (optional) * * @return array */ @@ -25,7 +29,9 @@ public function getArticleDiscounts($oArticle, $oUser = null) { $aList = []; $this->forceReload(); - $aDiscList = $this->_getList($oUser)->getArray(); + /** @var CoreDisCountList $oDiscList */ + $oDiscList = $this->_getList($oUser); + $aDiscList = $oDiscList->getArray(); foreach ($aDiscList as $oDiscount) { if ($oDiscount->isForArticle($oArticle)) { $aList[$oDiscount->getId()] = $oDiscount; @@ -39,33 +45,35 @@ public function getArticleDiscounts($oArticle, $oUser = null) /** * Creates discount list filter SQL to load current state discount list * - * @param \OxidEsales\Eshop\Application\Model\User $oUser user object + * @SuppressWarnings(PHPMD.StaticAccess) * - * @return string - * @deprecated underscore prefix violates PSR12, will be renamed to "getFilterSelect" in next major + * @inheritdoc */ protected function _getFilterSelect($oUser) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { $oBaseObject = $this->getBaseObject(); - $bDisableSqlActiveSnippet = Registry::getSession()->getVariable('disableSqlActiveSnippet'); + $bDisableSqlActive = Registry::getSession()->getVariable('disableSqlActiveSnippet'); $sTable = $oBaseObject->getViewName(); - $sQ = "select " . $oBaseObject->getSelectFields() . " from $sTable "; - $sQ .= true === $bDisableSqlActiveSnippet ? "where 1=1 " : "where " . $oBaseObject->getSqlActiveSnippet() . ' '; - + $sSql = "select " . $oBaseObject->getSelectFields() . " from $sTable where 1 "; + $sSql .= false === $bDisableSqlActive ? $oBaseObject->getSqlActiveSnippet() . ' ' : ''; // defining initial filter parameters $sUserId = null; $sGroupIds = null; $sCountryId = $this->getCountryId($oUser); - $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(); + $oDb = DatabaseProvider::getDb(); - // checking for current session user which gives additional restrictions for user itself, users group and country + // checking for current session user which gives additional restrictions for user itself, + // users group and country if ($oUser) { // user ID $sUserId = $oUser->getId(); // user group ids - foreach ($oUser->getUserGroups() as $oGroup) { + /** @var ListModel $userGroups */ + $userGroups = $oUser->getUserGroups(); + /** @var Groups $oGroup */ + foreach ($userGroups as $oGroup) { if ($sGroupIds) { $sGroupIds .= ', '; } @@ -77,24 +85,45 @@ protected function _getFilterSelect($oUser) // phpcs:ignore PSR2.Methods.MethodD $sGroupTable = getViewName('oxgroups'); $sCountryTable = getViewName('oxcountry'); - $sCountrySql = $sCountryId ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' and oxobject2discount.OXOBJECTID=" . $oDb->quote($sCountryId) . ")" : '0'; - $sUserSql = $sUserId ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' and oxobject2discount.OXOBJECTID=" . $oDb->quote($sUserId) . ")" : '0'; - $sGroupSql = $sGroupIds ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' and oxobject2discount.OXOBJECTID in ($sGroupIds) )" : '0'; - - $sQ .= "and ( - if(EXISTS(select 1 from oxobject2discount, $sCountryTable where $sCountryTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' LIMIT 1), + $sCountrySql = $sCountryId ? + "EXISTS(select oxobject2discount.oxid from oxobject2discount where + oxobject2discount.OXDISCOUNTID = $sTable.OXID and oxobject2discount.oxtype = 'oxcountry' and + oxobject2discount.OXOBJECTID = " . $oDb->quote($sCountryId) . ")" : + '0'; + $sUserSql = $sUserId ? + "EXISTS(select oxo bject2discount.oxid from oxobject2discount where + oxobject2discount.OXDISCOUNTID = $sTable.OXID and oxobject2discount.oxtype = 'oxuser' and + oxobject2discount.OXOBJECTID = " . $oDb->quote($sUserId) . ")" : + '0'; + $sGroupSql = $sGroupIds ? + "EXISTS(select oxobject2discount.oxid from oxobject2discount where + oxobject2discount.OXDISCOUNTID = $sTable.OXID and oxobject2discount.oxtype = 'oxgroups' and + oxobject2discount.OXOBJECTID in ($sGroupIds) )" : + '0'; + + $sSql .= "and ( + if(EXISTS(select 1 from oxobject2discount, $sCountryTable where + $sCountryTable.oxid = oxobject2discount.oxobjectid and + oxobject2discount.OXDISCOUNTID = $sTable.OXID and + oxobject2discount.oxtype = 'oxcountry' LIMIT 1), $sCountrySql, 1) && - if(EXISTS(select 1 from oxobject2discount, $sUserTable where $sUserTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' LIMIT 1), + if(EXISTS(select 1 from oxobject2discount, $sUserTable where + $sUserTable.oxid = oxobject2discount.oxobjectid and + oxobject2discount.OXDISCOUNTID = $sTable.OXID and + oxobject2discount.oxtype = 'oxuser' LIMIT 1), $sUserSql, 1) && - if(EXISTS(select 1 from oxobject2discount, $sGroupTable where $sGroupTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' LIMIT 1), + if(EXISTS(select 1 from oxobject2discount, $sGroupTable where + $sGroupTable.oxid = oxobject2discount.oxobjectid and + oxobject2discount.OXDISCOUNTID = $sTable.OXID and + oxobject2discount.oxtype = 'oxgroups' LIMIT 1), $sGroupSql, 1) )"; - $sQ .= " order by $sTable.oxsort "; + $sSql .= " order by $sTable.oxsort "; - return $sQ; + return $sSql; } } From a97134798ba9613cd9851b598bb67a9d1a85aaaa Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 23 Nov 2023 20:45:31 +0100 Subject: [PATCH 3/4] refactor _prepareWhereQuery --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index a68122b8..11d0cc19 100644 --- a/metadata.php +++ b/metadata.php @@ -9,11 +9,11 @@ * Metadata version */ -use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderList; use OxidSolutionCatalysts\Unzer\Model\DiscountList; use OxidSolutionCatalysts\Unzer\Controller\Admin\AdminOrderController; use OxidSolutionCatalysts\Unzer\Controller\Admin\ModuleConfiguration; use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderMain; +use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderList; use OxidSolutionCatalysts\Unzer\Controller\ApplePayCallbackController; use OxidSolutionCatalysts\Unzer\Controller\DispatcherController; use OxidSolutionCatalysts\Unzer\Controller\InstallmentController; From 2098f6e53f87930d39b70831b56837ab4c190c83 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 23 Nov 2023 20:45:44 +0100 Subject: [PATCH 4/4] refactor _prepareWhereQuery --- src/Controller/Admin/OrderList.php | 128 ++++++----------------------- src/Model/DiscountList.php | 2 +- 2 files changed, 24 insertions(+), 106 deletions(-) diff --git a/src/Controller/Admin/OrderList.php b/src/Controller/Admin/OrderList.php index 88c96a30..f2c3ba98 100644 --- a/src/Controller/Admin/OrderList.php +++ b/src/Controller/Admin/OrderList.php @@ -9,22 +9,30 @@ class OrderList extends OrderList_parent { /** - * @param array $queries - * @param string $queryForAppending + * Adding folder check + * bi * + * @param array $whereQuery SQL condition array + * @param string $fullQuery SQL query string * * @SuppressWarnings(PHPMD.StaticAccess) * * @return string - * @throws DatabaseConnectionException */ - protected function prepareWhereQuery($queries, $queryForAppending) + protected function _prepareWhereQuery($whereQuery, $fullQuery) { + // seperate oxordernr + $orderNrSearch = ''; + if (isset($whereQuery['oxorder.oxordernr'])) { + $orderNrSearch = $whereQuery['oxorder.oxordernr']; + unset($whereQuery['oxorder.oxordernr']); + } + $database = DatabaseProvider::getDb(); - $config = Registry::getConfig(); + $query = parent::_prepareWhereQuery($whereQuery, $fullQuery); + $config = $this->getConfig(); $folders = $config->getConfigParam('aOrderfolder'); - $folder = Registry::getRequest()->getRequestEscapedParameter('folder'); - - $query = $this->prepareOrderListQuery($queries, $queryForAppending); + $folder = Registry::getConfig()->getRequestParameter('folder'); + // Searching for empty oxfolder fields if ($folder && $folder !== '-1') { $query .= " and ( oxorder.oxfolder = " . $database->quote($folder) . " )"; } elseif (!$folder && is_array($folders)) { @@ -32,104 +40,14 @@ protected function prepareWhereQuery($queries, $queryForAppending) $query .= " and ( oxorder.oxfolder = " . $database->quote($folderNames[0]) . " )"; } - $query .= " and oxorder.oxshopid = '" . $config->getShopId() . "'"; - - return $query; - } - - /** - * @param array $whereQuery - * @param string $filterQuery - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.StaticAccess) - * - * @return string - * @throws DatabaseConnectionException - */ - protected function prepareOrderListQuery(array $whereQuery, string $filterQuery): string - { - if (count($whereQuery)) { - $myUtilsString = Registry::getUtilsString(); - foreach ($whereQuery as $identifierName => $fieldValue) { - //passing oxunzerordernr because it will be combined with oxordernr - if ("oxorder.oxunzerordernr" === $identifierName) { - continue; - } - $fieldValue = trim($fieldValue); - //check if this is search string (contains % sign at beginning and end of string) - $isSearchValue = $this->_isSearchValue($fieldValue); - //removing % symbols - $fieldValue = $this->_processFilter($fieldValue); - if ($fieldValue !== '') { - $database = DatabaseProvider::getDb(); - $values = explode(' ', $fieldValue); - //for each search field using AND action - $queryBoolAction = ' and ('; - - //oxordernr is combined with oxunzerordernr - if ("oxorder.oxordernr" === $identifierName) { - $oxOrderNr = $database->quoteIdentifier("oxorder.oxordernr"); - $oxUnzerOrderNr = $database->quoteIdentifier("oxorder.oxunzerordernr"); - $orderNrQuery = []; - foreach ($values as $value) { - $orderNrQuery[] = "({$oxOrderNr} like '{$value}'" - . " or {$oxUnzerOrderNr} like '{$value}')"; - } - $filterQuery .= "and (" . implode(" or ", $orderNrQuery) . ")"; - - continue; - } - - foreach ($values as $value) { - // trying to search spec chars in search value - // if found, add cleaned search value to search sql - $uml = $myUtilsString->prepareStrForSearch($value); - if ($uml) { - $queryBoolAction .= '('; - } - $quotedIdentifierName = $database->quoteIdentifier($identifierName); - $filterQuery .= " {$queryBoolAction} {$quotedIdentifierName} "; - //for search in same field for different values using AND - $queryBoolAction = ' and '; - $filterQuery .= $this->_buildFilter($value, $isSearchValue); - if ($uml) { - $filterQuery .= " or {$quotedIdentifierName} "; - - $filterQuery .= $this->_buildFilter($uml, $isSearchValue); - $filterQuery .= ')'; // end of OR section - } - } - // end for AND action - $filterQuery .= ' ) '; - } - } + // glue oxordernr + if ($orderNrSearch) { + $oxOrderNr = $database->quoteIdentifier("oxorder.oxordernr"); + $oxUnzerOrderNr = $database->quoteIdentifier("oxorder.oxunzerordernr"); + $orderNrValue = $database->quote($orderNrSearch); + $query .= " and ({$oxOrderNr} like {$orderNrValue} or {$oxUnzerOrderNr} like {$orderNrValue}) "; } - return $filterQuery; - } - - /** - * Returns list filter array - * - * @SuppressWarnings(PHPMD.StaticAccess) - * - * @return array - */ - public function getListFilter() - { - if ($this->_aListFilter === null) { - $request = Registry::getRequest(); - $filter = (array)$request->getRequestParameter("where"); - $request->checkParamSpecialChars($filter); - - if (!empty($filter['oxorder']['oxordernr'])) { - $filter['oxorder']['oxunzerordernr'] = $filter['oxorder']['oxordernr']; - } - - $this->_aListFilter = $filter; - } - - return $this->_aListFilter; + return $query; } } diff --git a/src/Model/DiscountList.php b/src/Model/DiscountList.php index e23e35bf..4891ae98 100644 --- a/src/Model/DiscountList.php +++ b/src/Model/DiscountList.php @@ -49,7 +49,7 @@ public function getArticleDiscounts($oArticle, $oUser = null) * * @inheritdoc */ - protected function _getFilterSelect($oUser) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore + protected function _getFilterSelect($oUser) { $oBaseObject = $this->getBaseObject(); $bDisableSqlActive = Registry::getSession()->getVariable('disableSqlActiveSnippet');