Created
April 1, 2020 08:25
-
-
Save xxxrazorxxx/46199f9201df2449c9fb1fdd97e7ad8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/rma/func.php b/app/addons/rma/func.php | |
index f0ee3cb824e..54af66ff019 100644 | |
--- a/app/addons/rma/func.php | |
+++ b/app/addons/rma/func.php | |
@@ -1074,15 +1074,15 @@ function fn_rma_get_returns($params, $items_per_page = 0, $lang_code = CART_LANG | |
$params = LastView::instance()->update('rma', $params); | |
// Set default values to input params | |
- $default_params = array ( | |
+ $default_params = [ | |
'page' => 1, | |
'items_per_page' => $items_per_page | |
- ); | |
+ ]; | |
$params = array_merge($default_params, $params); | |
// Define fields that should be retrieved | |
- $fields = array ( | |
+ $fields = [ | |
'DISTINCT ?:rma_returns.return_id', | |
'?:rma_returns.order_id', | |
'?:rma_returns.timestamp', | |
@@ -1091,18 +1091,18 @@ function fn_rma_get_returns($params, $items_per_page = 0, $lang_code = CART_LANG | |
'?:rma_property_descriptions.property AS action', | |
'?:users.firstname', | |
'?:users.lastname' | |
- ); | |
+ ]; | |
// Define sort fields | |
- $sortings = array ( | |
- 'return_id' => "?:rma_returns.return_id", | |
- 'timestamp' => "?:rma_returns.timestamp", | |
- 'order_id' => "?:rma_returns.order_id", | |
- 'status' => "?:rma_returns.status", | |
- 'amount' => "?:rma_returns.total_amount", | |
- 'action' => "?:rma_returns.action", | |
- 'customer' => "?:users.lastname" | |
- ); | |
+ $sortings = [ | |
+ 'return_id' => '?:rma_returns.return_id', | |
+ 'timestamp' => '?:rma_returns.timestamp', | |
+ 'order_id' => '?:rma_returns.order_id', | |
+ 'status' => '?:rma_returns.status', | |
+ 'amount' => '?:rma_returns.total_amount', | |
+ 'action' => '?:rma_returns.action', | |
+ 'customer' => '?:users.lastname' | |
+ ]; | |
$sorting = db_sort($params, $sortings, 'timestamp', 'desc'); | |
@@ -1116,66 +1116,77 @@ function fn_rma_get_returns($params, $items_per_page = 0, $lang_code = CART_LANG | |
} | |
} | |
if (sizeof($arr) == 2) { | |
- $condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%".array_shift($arr)."%", "%".array_shift($arr)."%"); | |
+ $condition .= db_quote( | |
+ ' AND ((?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l)' | |
+ . ' OR (?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l))', | |
+ '%' . $arr[0] . '%', | |
+ '%' . $arr[1] . '%', | |
+ '%' . $arr[1] . '%', | |
+ '%' . $arr[0] . '%' | |
+ ); | |
} else { | |
- $condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%".trim($params['cname'])."%", "%".trim($params['cname'])."%"); | |
+ $condition .= db_quote( | |
+ ' AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)', | |
+ '%' . trim($params['cname']) . '%', | |
+ '%' . trim($params['cname']) . '%' | |
+ ); | |
} | |
} | |
if (isset($params['email']) && fn_string_not_empty($params['email'])) { | |
- $condition .= db_quote(" AND ?:users.email LIKE ?l", "%".trim($params['email'])."%"); | |
+ $condition .= db_quote(' AND ?:users.email LIKE ?l', '%' . trim($params['email']) . '%'); | |
} | |
if (isset($params['rma_amount_from']) && fn_is_numeric($params['rma_amount_from'])) { | |
- $condition .= db_quote("AND ?:rma_returns.total_amount >= ?d", $params['rma_amount_from']); | |
+ $condition .= db_quote(' AND ?:rma_returns.total_amount >= ?d', $params['rma_amount_from']); | |
} | |
if (isset($params['rma_amount_to']) && fn_is_numeric($params['rma_amount_to'])) { | |
- $condition .= db_quote("AND ?:rma_returns.total_amount <= ?d", $params['rma_amount_to']); | |
+ $condition .= db_quote(' AND ?:rma_returns.total_amount <= ?d', $params['rma_amount_to']); | |
} | |
if (!empty($params['action'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.action = ?s", $params['action']); | |
+ $condition .= db_quote(' AND ?:rma_returns.action = ?s', $params['action']); | |
} | |
if (!empty($params['return_id'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.return_id = ?i", $params['return_id']); | |
+ $condition .= db_quote(' AND ?:rma_returns.return_id = ?i', $params['return_id']); | |
} | |
if (!empty($params['request_status'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.status IN (?a)", $params['request_status']); | |
+ $condition .= db_quote(' AND ?:rma_returns.status IN (?a)', $params['request_status']); | |
} | |
if (!empty($params['period']) && $params['period'] != 'A') { | |
list($params['time_from'], $params['time_to']) = fn_create_periods($params); | |
- $condition .= db_quote(" AND (?:rma_returns.timestamp >= ?i AND ?:rma_returns.timestamp <= ?i)", $params['time_from'], $params['time_to']); | |
+ $condition .= db_quote(' AND (?:rma_returns.timestamp >= ?i AND ?:rma_returns.timestamp <= ?i)', $params['time_from'], $params['time_to']); | |
} | |
if (!empty($params['order_id'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.order_id = ?i", $params['order_id']); | |
+ $condition .= db_quote(' AND ?:rma_returns.order_id = ?i', $params['order_id']); | |
} elseif (!empty($params['order_ids'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.order_id IN (?a)", $params['order_ids']); | |
+ $condition .= db_quote(' AND ?:rma_returns.order_id IN (?a)', $params['order_ids']); | |
} | |
if (isset($params['user_id'])) { | |
- $condition .= db_quote(" AND ?:rma_returns.user_id = ?i", $params['user_id']); | |
+ $condition .= db_quote(' AND ?:rma_returns.user_id = ?i', $params['user_id']); | |
} | |
if (!empty($params['order_status'])) { | |
- $condition .= db_quote(" AND ?:orders.status IN (?a)", $params['order_status']); | |
+ $condition .= db_quote(' AND ?:orders.status IN (?a)', $params['order_status']); | |
} | |
if (!empty($params['p_ids']) || !empty($params['product_view_id'])) { | |
$arr = (strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids'])) ? explode(',', $params['p_ids']) : $params['p_ids']; | |
if (empty($params['product_view_id'])) { | |
- $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", $arr); | |
+ $condition .= db_quote(' AND ?:order_details.product_id IN (?n)', $arr); | |
} else { | |
- $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true)))); | |
+ $condition .= db_quote(' AND ?:order_details.product_id IN (?n)', db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true)))); | |
} | |
- $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id"; | |
- $group .= db_quote(" GROUP BY ?:rma_returns.return_id HAVING COUNT(?:orders.order_id) >= ?i", count($arr)); | |
+ $join .= ' LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id'; | |
+ $group .= db_quote(' GROUP BY ?:rma_returns.return_id HAVING COUNT(?:orders.order_id) >= ?i', count($arr)); | |
} | |
if (!empty($params['company_id'])) { | |
diff --git a/app/functions/fn.cart.php b/app/functions/fn.cart.php | |
index bc436b5a759..b2338fcb4c1 100644 | |
--- a/app/functions/fn.cart.php | |
+++ b/app/functions/fn.cart.php | |
@@ -9807,13 +9807,18 @@ function fn_get_carts($params, $items_per_page = 0) | |
} | |
if (sizeof($arr) == 2) { | |
$condition .= db_quote( | |
- " AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", | |
- "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%" | |
+ ' AND ((?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l)' | |
+ . ' OR (?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l))', | |
+ '%' . $arr[0] . '%', | |
+ '%' . $arr[1] . '%', | |
+ '%' . $arr[1] . '%', | |
+ '%' . $arr[0] . '%' | |
); | |
} else { | |
$condition .= db_quote( | |
- " AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", | |
- "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%" | |
+ ' AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)', | |
+ '%' . trim($params['cname']) . '%', | |
+ '%' . trim($params['cname']) . '%' | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment