<?php 
$db = $GLOBALS['db'];
global $app_list_strings;
$query2=$db->query("select ROUND(sum(op.quantity*op.price),2) as total,rw.document_no,rw.id from 
ecmstockdocinsideouts as rw
join ecmstockoperations as op on op.parent_id=rw.id
where rw.total='0.00' 
GROUP BY op.parent_id order by rw.date_entered desc");
while($r = $db->fetchByAssoc($query2)){
	$db->query("update ecmstockdocinsideouts set
			total='".$r['total']."'
							where id='".$r['id']."'");
}
;
?>