query("SELECT id, parent_name, document_no, date_entered FROM ecminvoiceoutolds where type='$type' and parent_name like 'Real%' and register_date>='2014-01-01' and document_no NOT IN (SELECT nr_faktury FROM nr_faktury) AND canceled='0' ORDER BY register_date");
//$res = $db->query("SELECT id, parent_name, document_no, date_entered FROM ecminvoiceoutolds where type='correct' and parent_name like 'Real%' and document_no in ('FVKOR 853/14')");
$i =0;
echo $res->num_rows.'
';
//die();
while ($row = $db->fetchByAssoc($res)) {
echo $row['parent_name'].' '.$row['document_no'].' '.$row['date_entered'].'
';
$i++;
$inv = new EcmInvoiceOutOld();
$inv->retrieve($row['id']);
if ($type == 'normal')
$xml=createInvoiceXml($inv->id);
if ($type == 'correct')
$xml=createCorrectInvoiceXml($inv->id);
//die();
//continue;
$file="/home/mz/edi/infinite-salesorders/invoice/".str_replace(" ","",str_replace("/","",$inv->document_no)).".xml";
fopen($file);
file_put_contents($file,$xml);
chmod($file,0777);
unset($inv);
}
echo '
'.$i.'
';
return;
?>