136 lines
3.1 KiB
PHP
136 lines
3.1 KiB
PHP
|
|
<?php
|
||
|
|
$db = $GLOBALS['db'];
|
||
|
|
|
||
|
|
$invoices = $db -> query("SELECT * FROM ecminvoiceoutolds WHERE id ='66d9450c-0d62-6f19-9aa2-52721d0a433e' ORDER BY date_entered DESC");
|
||
|
|
|
||
|
|
while ($inv = $db->fetchByAssoc($invoices)) {
|
||
|
|
|
||
|
|
echo $inv['document_no'].'<br>';
|
||
|
|
//add invoice
|
||
|
|
$q = "
|
||
|
|
INSERT INTO ecminvoiceouts (
|
||
|
|
id,
|
||
|
|
date_entered,
|
||
|
|
date_modified,
|
||
|
|
modified_user_id,
|
||
|
|
assigned_user_id,
|
||
|
|
created_by,
|
||
|
|
deleted,
|
||
|
|
number,
|
||
|
|
document_no,
|
||
|
|
parent_name,
|
||
|
|
parent_id,
|
||
|
|
type,
|
||
|
|
register_date,
|
||
|
|
total_netto,
|
||
|
|
total_brutto,
|
||
|
|
canceled,
|
||
|
|
currency_id,
|
||
|
|
currency_value_nbp
|
||
|
|
) VALUES (
|
||
|
|
'".$inv['id']."',
|
||
|
|
'".$inv['date_entered']."',
|
||
|
|
'".$inv['date_modified']."',
|
||
|
|
'".$inv['modified_user_id']."',
|
||
|
|
'".$inv['assigned_user_id']."',
|
||
|
|
'".$inv['created_by']."',
|
||
|
|
'".$inv['deleted']."',
|
||
|
|
'".$inv['number']."',
|
||
|
|
'".$inv['document_no']."',
|
||
|
|
'".$inv['parent_name']."',
|
||
|
|
'".$inv['parent_id']."',
|
||
|
|
'".$inv['type']."',
|
||
|
|
'".$inv['register_date']."',
|
||
|
|
'".$inv['subtotal']."',
|
||
|
|
'".$inv['total']."',
|
||
|
|
'".$inv['canceled']."',
|
||
|
|
'".$inv['currency_id']."',
|
||
|
|
'".$inv['currency_value_nbp']."'
|
||
|
|
);
|
||
|
|
";
|
||
|
|
|
||
|
|
//items
|
||
|
|
$db->query($q);
|
||
|
|
|
||
|
|
$items = $db->query("SELECT * FROM ecminvoiceoutolditems WHERE ecminvoiceoutold_id = '".$inv['id']."'");
|
||
|
|
while ($i = $db->fetchByAssoc($items)) {
|
||
|
|
$qi = "
|
||
|
|
INSERT INTO ecminvoiceoutitems (
|
||
|
|
id,
|
||
|
|
date_entered,
|
||
|
|
date_modified,
|
||
|
|
modified_user_id,
|
||
|
|
assigned_user_id,
|
||
|
|
created_by,
|
||
|
|
ecminvoiceout_id,
|
||
|
|
ecmproduct_id,
|
||
|
|
position,
|
||
|
|
code,
|
||
|
|
name,
|
||
|
|
quantity,
|
||
|
|
price_start,
|
||
|
|
price_netto,
|
||
|
|
price_brutto,
|
||
|
|
discount,
|
||
|
|
total_netto,
|
||
|
|
total_brutto,
|
||
|
|
dd_unit_id,
|
||
|
|
dd_unit_name,
|
||
|
|
ecmvat_id,
|
||
|
|
ecmvat_name,
|
||
|
|
ecmvat_value,
|
||
|
|
ecmproductcategory_id,
|
||
|
|
recipient_code,
|
||
|
|
ecminvoiceoutitem_id,
|
||
|
|
old_ecminvoiceoutitem_id,
|
||
|
|
old_total_netto,
|
||
|
|
old_quantity,
|
||
|
|
old_total_brutto,
|
||
|
|
price_purchase,
|
||
|
|
total_netto_corrected,
|
||
|
|
quantity_corrected,
|
||
|
|
total_brutto_corrected
|
||
|
|
) VALUES (
|
||
|
|
'".$i['id']."',
|
||
|
|
'".$i['date_entered']."',
|
||
|
|
'".$i['date_modified']."',
|
||
|
|
'".$i['modified_user_id']."',
|
||
|
|
'".$i['assigned_user_id']."',
|
||
|
|
'".$i['created_by']."',
|
||
|
|
'".$i['ecminvoiceoutold_id']."',
|
||
|
|
'".$i['ecmproduct_id']."',
|
||
|
|
'".$i['position']."',
|
||
|
|
'".$i['code']."',
|
||
|
|
'".$i['name']."',
|
||
|
|
'".$i['quantity']."',
|
||
|
|
'".$i['startprice']."',
|
||
|
|
'".$i['subprice']."',
|
||
|
|
'".$i['price']."',
|
||
|
|
'".$i['discount']."',
|
||
|
|
'".$i['subtotal']."',
|
||
|
|
'".$i['total']."',
|
||
|
|
'".$i['dd_unit_id']."',
|
||
|
|
'".$i['dd_unit_name']."',
|
||
|
|
'".$i['ecmvat_id']."',
|
||
|
|
'".$i['ecmvat_name']."',
|
||
|
|
'".$i['ecmvat_value']."',
|
||
|
|
'".$i['ecmproductcategory_id']."',
|
||
|
|
'".$i['recipient_code']."',
|
||
|
|
'".$i['ecminvoiceoutolditem_id']."',
|
||
|
|
'".$i['old_ecminvoiceoutolditem_id']."',
|
||
|
|
'".$i['old_subtotal']."',
|
||
|
|
'".$i['old_quantity']."',
|
||
|
|
'".$i['old_total']."',
|
||
|
|
'".$i['purchase_price']."',
|
||
|
|
'".$i['subtotal_corrected']."',
|
||
|
|
'".$i['quantity_corrected']."',
|
||
|
|
'".$i['total_corrected']."'
|
||
|
|
);
|
||
|
|
";
|
||
|
|
|
||
|
|
//echo $qi.'<br><br>';
|
||
|
|
$db -> query($qi);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
?>
|