init
This commit is contained in:
41
modules/EcmReports/javascript/helper.php
Normal file
41
modules/EcmReports/javascript/helper.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( '-1' );
|
||||
if (! $_POST ['job'] || $_POST ['job'] == '')
|
||||
die ( '-1' );
|
||||
switch ($_POST ['job']) {
|
||||
case 'getProductOrders' :
|
||||
getProductOrders ( $_POST ['id'], $_POST ['date'],$_POST ['wz'],$_POST ['type']);
|
||||
break;
|
||||
}
|
||||
|
||||
function getProductOrders($id,$date,$wz,$type){
|
||||
$docDate=DateTime::createFromFormat ( 'Y-m-d', $date);
|
||||
|
||||
if($wz=='true'){
|
||||
$qwz="and z.id not in (select ecmsale_id from ecmstockdocouts where ecmsale_id=z.id)";
|
||||
} else {
|
||||
$qwz="";
|
||||
}
|
||||
$query="select z.id,z.document_no,z.parent_name,sum(p.quantity) as quantity,z.status from ecmsaleitems p inner join ecmsales z on z.id=p.ecmsale_id where p.ecmproduct_id='$id' and z.".$type."='".$docDate->format("Y-m-d")."' ".$qwz." group by z.id";
|
||||
|
||||
|
||||
|
||||
global $app_list_strings;
|
||||
$db=$GLOBALS['db'];
|
||||
|
||||
$res= $db->query($query);
|
||||
$data=[];
|
||||
while($return=$db->fetchByAssoc($res)){
|
||||
$return['quantity']=number_format($return['quantity'],2);
|
||||
$return['status']=$app_list_strings['ecmsales_status_dom'][$return['status']];
|
||||
$data['items'][]=$return;
|
||||
}
|
||||
|
||||
$ecmStockOperations = new EcmStockOperation();
|
||||
|
||||
$data['stock']=number_format($ecmStockOperations->getRealStock($id),2);
|
||||
|
||||
echo json_encode($data);
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user