diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js
index 10bf9a52..e1c9eaf8 100644
--- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js
+++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js
@@ -211,7 +211,7 @@ function drawComponents(data) {
tr.append("
" + el.orderType + " | ");
tr.append("" + el.orderStatus + " | ");
tr.append("" + el.mainProductCode + " | ");
- tr.append("" + el.orderParent + " | ");
+ tr.append("" + el.orderParent + " | ");
tr.append("" + el.productShape + " | ");
tr.append("" + el.productBrand + " | ");
tr.append("" + el.orderSendDate + " | ");
diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php
index 7846464f..657ac5b1 100644
--- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php
+++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.php
@@ -381,14 +381,13 @@ function getComponents2($ids) {
$db = $GLOBALS['db'];
global $app_list_strings;
$idsString = join("','", $ids);
- $mainProduct = $db->fetchByAssoc($db->query(sprintf("SELECT name FROM ecmproducts WHERE id IN ('%s')", $idsString)));;
- $productsQuery = "SELECT si.ecmproduct_id, SUM(si.quantity) as quantity, s.document_no, s.parent_id, s.parent_name,
- s.id, s.type, s.status, s.send_date
+ $productsQuery = "SELECT si.ecmproduct_id, si.quantity as quantity, s.document_no,
+ s.id, s.type, s.status, s.send_date, s.shipping_address_name
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s
ON s.id = si.ecmsale_id
- WHERE si.id IN ('" . $idsString . "')
- GROUP BY si.ecmproduct_id";
+ WHERE si.id IN ('" . $idsString . "')";
+
$rows = $db->query($productsQuery);
$componentsData = array();
@@ -418,8 +417,7 @@ function getComponents2($ids) {
$row['orderId'] = $r['id'];
$row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
$row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']];
- $row['orderParent'] = $r['parent_name'];
- $row['orderParentId'] = $r['parent_id'];
+ $row['orderParent'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
$row['orderSendDate'] = $r['send_date'];
$componentsData[] = $row;
}