48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
|
||
|
|
|
||
|
|
$source = new EcmInvoiceOutOld();
|
||
|
|
$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 ecminvoiceoutolditems 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('"','\"',$json->encode($ppos));
|
||
|
|
}
|
||
|
|
$focus->template_id = $source->template_id;
|
||
|
|
$focus->template_name = $source->template_name;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
?>
|