a:1:{i:0;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:15:"fv2_beam_update";s:4:"nome";s:9:"onExecute";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:3486:"//****************************TOTAL UPDATES********************************
//posting greige pieces knit using yarn in top bar
$str="Posting top bar useage to sets.\n";
echo nl2br($str);
$update_use_grpcs= 
"
UPDATE sets c
INNER JOIN 
(SELECT tset, SUM(lbs_recd*tper) as t_total
  FROM grpcs
  GROUP BY tset)
x ON c.setno = x.tset
SET c.lbs_knit = x.t_total,c.inventory=c.set_lbs-c.lbs_knit-c.lbs_sold-c.waste
";
sc_exec_sql($update_use_grpcs);
$str="Posting Complete.\n";
echo nl2br($str);
//posting greige pieces knit using yarn in bottom bar
$str="Posting bottom bar useage to sets.\n";
echo nl2br($str);
$update_use_grpcs= 
"
UPDATE sets c
INNER JOIN 
(SELECT bset, SUM(lbs_recd*bper) as t_total
  FROM grpcs
  GROUP BY bset)
x ON c.setno = x.bset
SET c.lbs_knit = x.t_total,c.inventory=c.set_lbs-c.lbs_knit-c.lbs_sold-c.waste
";
sc_exec_sql($update_use_grpcs);
$str="Posting Complete.\n";
echo nl2br($str);
//posting L3 bar useage to sets."; 
$str="Posting L3 bar useage to sets.\n";
echo nl2br($str);
$update_use_grpcs= 
"
UPDATE sets c
INNER JOIN 
(SELECT l3set, SUM(lbs_recd*l3per) as t_total
  FROM grpcs
  GROUP BY l3set)
x ON c.setno = x.l3set
SET c.lbs_knit = x.t_total,c.inventory=c.set_lbs-c.lbs_knit-c.lbs_sold-c.waste
";
sc_exec_sql($update_use_grpcs);
$str="Posting Complete.\n";
echo nl2br($str);
//posting L4 bar useage to sets."; 
$str="Posting L4 bar useage to sets.\n";
echo nl2br($str);
$update_use_grpcs= 
"
UPDATE sets c
INNER JOIN 
(SELECT l4set, SUM(lbs_recd*l4per) as t_total
  FROM grpcs
  GROUP BY l4set)
x ON c.setno = x.l4set
SET c.lbs_knit = x.t_total,c.inventory=c.set_lbs-c.lbs_knit-c.lbs_sold-c.waste
";
sc_exec_sql($update_use_grpcs);
$str="Posting Complete.\n";
echo nl2br($str);
//posting sets received to beam yarn receivors (invoices)
$str="Posting sets received to warping/beam yarn invoices.\n";
echo nl2br($str);
$update_wstemp_sets= 
"
UPDATE wstemp c
INNER JOIN 
(SELECT invoice, sum(set_lbs) as slbs
  FROM sets
  GROUP BY invoice)
x ON c.invoice = x.invoice
SET c.lbs_recd=x.slbs
";
sc_exec_sql($update_wstemp_sets);
$str="Posting Complete.\n";
echo nl2br($str);
//posting warping/beam yarn invoices to warping/beam yarn po
$str="Posting warping/beam yarn invoices to warping/beam yarn po.\n";
echo nl2br($str);
$update_warppo_wstemp= 
"
UPDATE warppo c
INNER JOIN 
(SELECT p_o_number,sum(lbs_recd) as tlbs
  FROM wstemp
  GROUP BY p_o_number)
x ON c.p_o_number = x.p_o_number
SET c.lbs_recd=x.tlbs
";
sc_exec_sql($update_warppo_wstemp);
$str="Posting Complete.\n";
echo nl2br($str);
$str="Posting sets to warping/beam yarn po.\n";
echo nl2br($str);
$update_warppo_sets= 
"
UPDATE warppo c
INNER JOIN 
(SELECT p_o_number,sum(lbs_knit) as klbs,sum(waste) as wlbs, sum(lbs_sold) as slbs,count(*) as nsets
  FROM sets
  GROUP BY p_o_number)
x ON c.p_o_number = x.p_o_number
SET c.lbs_knit=x.klbs,c.waste=x.wlbs,c.lbs_sold=x.slbs,c.inventory=c.lbs_recd-c.waste-c.lbs_sold-c.lbs_knit,c.ns=x.nsets
";
sc_exec_sql($update_warppo_sets);
$str="Posting Complete.\n";
echo nl2br($str);
$str="Calculating inventory.\n";
echo nl2br($str);
$update_warppo_sets= 
"
UPDATE warppo c
SET c.inventory=c.lbs_recd-c.waste-c.lbs_sold-c.lbs_knit
";
sc_exec_sql($update_warppo_sets);
// creates another frame->sc_redir('fv2_beam_tab');
$str="Calculating complete.\n";
echo nl2br($str);
$str="Update complete.\n";
echo nl2br($str);



";}}