Files
crm.e5.pl/modules/EcmActions/dbpost.php
2024-04-27 09:23:34 +02:00

36 lines
898 B
PHP

<?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
die ( '-1' );
if (! $_POST ['job'] || $_POST ['job'] == '')
die ( '-1' );
switch ($_POST ['job']) {
case 'getProductList' :
getProductList ( $_POST ['id'] );
break;
}
function getProductList($id) {
$db = $GLOBALS ['db'];
$result = array();
$q = "SELECT b.id, b.code, b.name FROM ecmproductactions a, ecmproducts b WHERE a.ecmproduct_id = b.id AND a.ecmaction_id = '". $id ."' GROUP BY ecmproduct_id;";
$rs = $db->query($q);
if ($rs->num_rows > 0) {
while ($return = $db->fetchByAssoc($rs)) {
$row = array();
$row2 = array();
$row ['id'] = $return ['id'];
$row ['name'] = $return ['name'];
$row ['code'] = $return ['code'];
$row2['code'] =$row;
$row2['name'] = $row;
$result [] = $row2;
}
} else {
$result = null;
}
$json = json_encode($result);
print $json;
}