query($query); global $sugar_config; $defaultCurrency = $sugar_config['default_currency_symbol']; $currencies = array ( -99 => $defaultCurrency ); $arr = array(); if($result) while($row = $GLOBALS['db']->fetchByAssoc($result)) { $row['guid']=create_guid(); $row['price'] = $row['ems_price']; $row['quantity']=(int)$row['moq']; $w=$GLOBALS['db']->query("select c.ecmproduct_id as product_id,c.ecmcomponent_id as id,c.name,c.code,c.quantity, p.product_category_id as cat, p.purchase_price as price from ecmproductcomponents as c INNER JOIN ecmproducts as p ON p.id=c.ecmcomponent_id where c.ecmproduct_id='".$row['id']."' and c.deleted='0'"); while($r=$GLOBALS['db']->fetchByAssoc($w)){ $r['component']=1; $r['guid']=$row['guid']; $r['component_quantity']=$r['quantity']; $r['category_id']=$r['cat']; $row['components'][]=$r; } if(array_key_exists($row['currency_id'],$currencies)) $row['currency_symbol'] = $currencies[$row['currency_id']]; $arr[] = $row; } if(count($arr) > 0) { $json = getJSONobj(); echo str_replace(""", '\"', $json->encode($arr)); } } ?>