Files
crm.twinpol.com/modules/EcmReceipts2/LoadEcmStockDocCorrects.php
2025-05-12 15:44:39 +00:00

48 lines
1.1 KiB
PHP
Executable File

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/EcmReceipts/EcmInvoiceOut.php');
$source = new EcmReceipt();
$source->retrieve($outId);
if(isset($source->id) && $source->id != '') {
$pos=$source->getPositionList(true);
$focus->name = $source->name;
/*echo '<pre>';
print_r($pos);
echo '</pre>';*/
foreach($pos as $pp){
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select quantity,price from ecmreceiptitems where id='".$pp['item_id']."'"));
if($pp['quantity']!=$r['quantity']){
$rprod=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select name from ecmproducts where id='".$pp['id']."'"));
$pname=$rprod['name'];
$pp['name']=$pname;
$pp['quantity']=$r['quantity']-$pp['quantity'];
$ppos[]=$pp;
}
}
/*echo '<pre>';
print_r($ppos);
echo '</pre>';*/
if(count($ppos) > 0) {
$json = getJSONobj();
$focus->position_list = str_replace('&quot;','\"',$json->encode($ppos));
}
$focus->template_id = $source->template_id;
$focus->template_name = $source->template_name;
}
?>