a:2:{i:0;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"MainVeratex-StoppedWorking";s:4:"nome";s:0:"";s:4:"tipo";s:0:"";s:5:"parms";s:0:"";s:6:"codigo";s:819:"$update_sql = "
UPDATE doit
SET invoice='{invoice}', it='{item}',status='$'
WHERE smit='$smit'";
sc_exec_sql($update_sql);

$update_sql = "
UPDATE n3case
SET invoice='[var_invoice]', it='[var_item]'
WHERE smit='$smit'";
sc_exec_sql($update_sql);

$filename='/var/www/veratex.vrtxinc.com/myfile_'.date('m-d-Y_hisa');
	$output_sql = "
select 'Invoice','Dye Order','Dye Lot','Style','Color','Width','-----Case----',' ','-Yds' 
union 
select invoice,p_o_number,dye_lot,style,color,width,`case`,suffix,yds 
INTO OUTFILE '$filename' 
FROM n3case where n3case.invoice='[var_invoice]'
";
sc_exec_sql($output_sql);
$save_outfile="	
UPDATE item
SET memo = LOAD_FILE('$filename')
WHERE invoice = '[var_invoice]'
";
sc_exec_sql($save_outfile);	
sc_redir(fv2_billing_item_single_form,invoice='09904');

";}i:1;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"MainVeratex-StoppedWorking";s:4:"nome";s:9:"onExecute";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:2212:"$trunkit="Truncate doit";
sc_exec_sql($trunkit);
sc_exec_sql("
INSERT INTO doit 
(INVOICE) 
SELECT 
(INVOICE)
FROM item
");
sc_exec_sql("
DELETE a
FROM doit as a, doit as b
WHERE
          (a.invoice = b.invoice)
      AND a.ID2 < b.ID2
");
sc_exec_sql("
UPDATE doit
	SET
	SM= ID2+10000, SMIT=concat(SM,' 1')
");
$trunkit="Truncate doship";
sc_exec_sql($trunkit);
sc_exec_sql("
INSERT INTO doship 
(SM) 
SELECT 
(SM)
FROM doit
");

$update="
UPDATE doship
INNER JOIN doit on doship.sm=doit.sm
SET doship.invoice=doit.invoice";
sc_exec_sql($update);

$update="
UPDATE item
INNER JOIN doit ON item.invoice = doit.invoice
SET item.smit = doit.smit";
sc_exec_sql($update);

$update="
UPDATE doit
INNER JOIN item ON doit.smit = item.smit
SET doit.our_order = item.our_order,
    doit.sdate=item.date,
    doit.p_o_number=item.dye_order,
    doit.dye_lot=item.dye_lot,
    doit.price=item.price,
    doit.unit=item.unit,
    doit.lyards=item.lin,
    doit.syards=item.sq,
    doit.style=item.style,
    doit.color=item.color,
    doit.color_no=item.color_no,
    doit.width=item.width,
    doit.unit=item.unit,
    doit.custno=item.cust_order,
    doit.it=item.item,
    doit.desc=item.descrip,
    doit.status='$'
    ";
sc_exec_sql($update);

$update="
UPDATE doit
INNER JOIN invoice ON doit.invoice = invoice.invoice
SET doit.terms=invoice.terms,
    doit.terms2=invoice.terms2,
    doit.salesman=invoice.salesman,
    doit.factor=invoice.factored
    ";
sc_exec_sql($update);

$update="
UPDATE doship
INNER JOIN invoice on doship.invoice=invoice.invoice
SET doship.date = invoice.date,
    doship.s1=invoice.scode,
    doship.b1=invoice.bcode,
    doship.via1=invoice.shippedvia,
    doship.status='$',
	doship.cases=invoice.cases,
	doship.add_ons=invoice.add_ons,
    doship.add_charge=invoice.add_charge
   ";
sc_exec_sql($update);

$update="
UPDATE n3case
INNER JOIN doit on n3case.invoice=doit.invoice
SET n3case.smit=doit.smit
";
sc_exec_sql($update);

$update="
UPDATE `order`
INNER JOIN doit on order.order=doit.our_order
SET order.terms2=doit.terms2";
sc_exec_sql($update);

echo "Initialized.";



";}}