<?php
ini_set('display_errors',1); 
$inv='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
$w=$GLOBALS['db']->query("select * from ecminvoiceouts WHERE type!='canceled'");
$i=0;
while($r=$GLOBALS['db']->fetchByAssoc($w)){
 		$GLOBALS ['db']->query ("INSERT INTO ecmtransactions(id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,value,parent_name,parent_id,payment_date,type,paid,register_date,record_id)VALUES('".create_guid()."','".$r['document_no']."','".$r['date_entered']."','".$r['date_modified']."','".$r['modified_user_id']."','".$r['created_by']."','".$r['description']."','".$r['canceled']."','".$r['assigned_user_id']."','".$r['total']."','".$r['parent_name']."','".$r['parent_id']."','".$r['payment_date']."','0','".$r['paid']."','".$r['register_date']."','".$r['id']."')");
		$i++;
	//s	if($r['name']=='') echo $r['id'].' name empty<br>';
	//	if($r['ecminvoiceout_name']=='') echo $r['id'].'inv empty<br>';
}
//echo '<br>'.create_guid();
$inv.='</table>';
echo $i;
?>