a:7:{i:0;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:15:"AMOUNT_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:14:"priceupdate();";}i:1;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:17:"LBS_RECD_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:15:"priceupdate(); ";}i:2;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:13:"onAfterDelete";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:12:"updMaster();";}i:3;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:13:"onAfterInsert";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:12:"updMaster();";}i:4;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:13:"onAfterUpdate";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:12:"updMaster();";}i:5;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:11:"priceupdate";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:33:"{price_lb} = {amount}/{lbs_recd};";}i:6;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:21:"beam_wstemp_edit_grid";s:4:"nome";s:9:"updMaster";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:2400:"sc_lookup(dataset,"SELECT SUM(lbs_recd), SUM(amount)
                  FROM wstemp 
                   WHERE p_o_number = {p_o_number}");
$master_lbsrecd = {dataset[0][0]};
$master_amount = {dataset[0][1]};
sc_lookup(dataset,"SELECT lbs_orderd, inventory, lbs_sold, lbs_knit, waste, lbs_allocd, cost_lb_y, tv FROM warppo WHERE p_o_number = {p_o_number}");
$master_ordered = {dataset[0][0]};
$master_lbssold = {dataset[0][2]};
$master_lbsknit = {dataset[0][3]};	
$master_waste = {dataset[0][4]};
$master_lbsallocd = {dataset[0][5]};
$master_costlby = {dataset[0][6]};
$master_lbsavail = round($master_lbsrecd - $master_lbsallocd,0);
$master_lbsopen = round($master_ordered - $master_lbsrecd,1);
$master_costlbw = round($master_amount / $master_lbsrecd,3);
$master_costlbt = round($master_costlby + $master_costlbw,3);
$master_inventory = round($master_lbsrecd - $master_lbsknit - $master_lbssold - $master_waste,1);
$master_tv = round($master_inventory * $master_costlbt,2);
sc_master_value('lbs_recd', $master_lbsrecd);
sc_master_value('lbs_open', $master_lbsopen);
sc_master_value('inventory', $master_inventory);
sc_master_value('lbs_avail', $master_lbsavail);
sc_master_value('cost_lb_w', $master_costlbw);
sc_master_value('cost_lb_t', $master_costlbt);
sc_master_value('tv',$master_tv); 
sc_exec_sql("UPDATE warppo
             SET lbs_recd = $master_lbsrecd,
                 lbs_open = $master_lbsopen,
				 inventory = $master_inventory,
                 lbs_avail = $master_lbsavail,
                 cost_lb_w = $master_costlbw,
            	 cost_lb_t = $master_costlbt, 
	 		     tv = $master_tv	
WHERE P_O_NUMBER = {P_O_NUMBER}");
sc_lookup(dataset,"SELECT warp_perc FROM pyalloc WHERE p_o_number = {p_o_number}");
//this needs more work.  You might have more than one pyalloc for a warping order
//also it doesn't change what is displayed but it does change the record.
//below will only update the first record it finds.
if (empty({dataset})==FALSE)
{	
	$master_warpperc = {dataset[0][0]};
	//this can't work. not a "master" and there may be more than one.
	//sc_master_value('pyalloc.twarp',$master_lbsrecd);
	//sc_master_value('pyalloc.lbs_warped',$master_lbswarped);
	sc_exec_sql("UPDATE pyalloc
         		SET twarp = $master_lbsrecd,
	                lbs_warped = warp_perc * twarp
	         WHERE p_o_number = {p_o_number}");
}

	";}}