query("select id,wz_id,document_no,type,ecminvoiceoutold_id from ecminvoiceoutolds where register_date>='".$_REQUEST['date_from']."%' and register_date<='".$_REQUEST['date_to']."' and deleted='0'"); while($r=$GLOBALS[db]->fetchByAssoc($w)){ //echo $r['document_no'].'
'; $ww=$GLOBALS[db]->query("select id,ecmproduct_id from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['id']."'"); while($rr=$GLOBALS[db]->fetchByAssoc($ww)){ if($r['type']!="normal"){ $rcor=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select wz_id from ecminvoiceoutolds where id='".$r['ecminvoiceoutold_id']."'")); $r['wz_id']=$rcor['wz_id']; } $rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price from ecmstockoperations where parent_id='".$r['wz_id']."' and product_id='".$rr['ecmproduct_id']."'")); $purchase_price=$rrr['price']; echo $rr['code']."
"; //if($purchase_price<=0){ $GLOBALS[db]->query("update ecminvoiceoutolditems set purchase_price='".$purchase_price."' where ecminvoiceoutold_id='".$r['id']."' and ecmproduct_id='".$rr['ecmproduct_id']."';"); //echo $purchase_price."
"; } } ?>