var values = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("Page", Page),
new KeyValuePair<string, string>("Sides[0]", side1),
new KeyValuePair<string, string>("Sides[1]", side2),
....
};
var values = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("Page", Page)
};
for(var i = 0; i < sides.Length;i++)
values.Add( new KeyValuePair<string, string>("Sides["+i+"]", sides[i]));
GROUP_CONCAT(A.ACTID)
SELECT
CASE WHEN P.PRODUCTID != '' THEN P.PRODUCTNAME WHEN L.LICENSEID != '' THEN L.NAME ELSE S.SERVICENAME END AS PRODUCTNAME
, CASE WHEN P.PRODUCTID != '' THEN 'product' WHEN L.LICENSEID != '' THEN 'license' ELSE 'service' END AS TYPE
, SUM(INV.QUANTITY) AS QUANTITY
, SUM(INV.QUANTITY*INV.LISTPRICE*(1-COALESCE(INV.DISCOUNT_PERCENT, 0)/100)-COALESCE(INV.DISCOUNT_AMOUNT, 0)) AS SUBTOTAL
, GROUP_CONCAT(A.ACTID)
FROM
VTIGER_SP_ACT A
INNER JOIN
VTIGER_CRMENTITY E
ON
E.CRMID = A.ACTID
INNER JOIN
VTIGER_INVENTORYPRODUCTREL INV
ON
INV.ID = A.ACTID
LEFT JOIN
VTIGER_PRODUCTS P
ON
P.PRODUCTID = INV.PRODUCTID
LEFT JOIN
VTIGER_SERVICE S
ON
S.SERVICEID = INV.PRODUCTID
LEFT JOIN
VTIGER_LICENSE L
ON
L.LICENSEID = INV.PRODUCTID
WHERE
E.DELETED = FALSE
AND ACTDATE BETWEEN '$from_date' AND '$to_date'
AND A.BRANCH_OR_AGENT IN ($branches)
GROUP BY
1
, 2