a:17:{i:0;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:16:"FIN_LBS_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:13:"yieldcalc2();";}i:1;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:19:"GR_LBS_REC_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:13:"yieldcalc2();";}i:2;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:15:"GYARDS_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:13:"yieldcalc2();";}i:3;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:19:"TOTAL_COST_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:13:"yieldcalc2();";}i:4;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:14:"WASTE_onChange";s:4:"tipo";s:1:"A";s:5:"parms";s:0:"";s:6:"codigo";s:13:"yieldcalc2();";}i:5;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:11:"deletecases";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:104:"$deletecases="
DELETE FROM veratex2.n3case WHERE dye_lot='[var_dyelot]'
";
sc_exec_sql($deletecases);";}i:6;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:9:"deletefgi";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:94:"$deletefgi="
DELETE FROM fgstock WHERE dye_lot='[var_dyelot]'
";
sc_exec_sql($deletefgi);
";}i:7;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:7:"makefgi";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:520:"$insert_sql="
INSERT INTO fgstock(
	INVOICE,
 		P_O_NUMBER,
		DYE_LOT,
		LOCATION,
		STYLE,
		COLOR,
		COLOR_NO,
		WIDTH,
		DESCRIPTIO,
		YARDS_RECD,
		COST,
		TRANS,
		FINISH,
		FIN_NO,
		PUTUP,
		C1YARDS,
		OPEN
)
	SELECT
 		INVOICE,
 		P_O_NUMBER,
		DYE_LOT,
		LOCATION,
		STYLE,
		COLOR,
		COLOR_NO,
		WIDTH,
		DESCRIPTIO,
		YARDS_RECD,
		COST,
		TRANS,
		FINISH,
		FIN_NO,
		PUTUP,
		C1YARDS,
		YARDS_RECD
	FROM dorec
	WHERE dye_lot='[var_dyelot]'";
sc_exec_sql($insert_sql);";}i:8;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:13:"onAfterDelete";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:15:"postrectodo2();";}i:9;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:13:"onAfterInsert";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:27:"makefgi();
postrectodo2();";}i:10;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:13:"onAfterUpdate";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:29:"postrectodo2();
updatefgi();";}i:11;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:14:"onBeforeDelete";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:28:"deletefgi();
deletecases();";}i:12;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:9:"onLoadAll";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:166:"[var_do]={p_o_number};
[var_style]={style};
[var_color]={color};
[var_colorno]={color_no};
[var_width]={width};
[var_dyelot]={dye_lot};
[var_olddl]={dye_lot};
";}i:13;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:10:"onValidate";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:38:"yieldcalc2();
[var_dyelot]={dye_lot};";}i:14;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:12:"postrectodo2";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:1231:"//getting undefined offset 0 when this runs on insert or update
sc_lookup(dataset2, "SELECT gr_lbs_o, cost_lb_g FROM dyeorder WHERE p_o_number='[var_do]'");
$grlbo={dataset2[0][0]};
$costlbg={dataset2[0][1]};	
sc_lookup(dataset1, "SELECT sum(total_cost),sum(yards_recd),sum(gr_lbs_rec),sum(fin_lbs) FROM dorec WHERE p_o_number = '[var_do]'");
$totalcost={dataset1[0][0]};
$ydsrecd={dataset1[0][1]};
$grlbsrec={dataset1[0][2]};
$finlbs={dataset1[0][3]};	
$grlbsop = $grlbo-$grlbsrec;
$grvalue=$costlbg*$grlbsop;		 
if($grlbsrec>0)
{	
	$workloss = ($grlbsrec-$finlbs)/$grlbsrec;
	$costlbd=$totalcost/$grlbsrec;
	$gryld=$ydsrecd/$grlbsrec;
}
else
{
	$workloss=0;
	$costlbd=0;
	$gryld=0;
}
$costlbt=$costlbg+$costlbd;
if($gryld>0)
{
$costydt=$costlbt/$gryld;
}
else
{
$costydt=0;	
}
sc_exec_sql("UPDATE	dyeorder
             SET  gr_lbs_d = $grlbsrec,
				  gr_lbs_op = $grlbsop,
				  gr_value = $grvalue,
				  work_loss = $workloss,
                  cost_lb_d = $costlbd,
			      cost_lb_t = $costlbt,
				  cost_yd_t = $costydt,
				  dye_cost = $totalcost,
				  fin_lbs = $finlbs,
 			      yards_recd = $ydsrecd,
				  gr_yield = $gryld
           WHERE p_o_number = '[var_do]'");
";}i:15;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:9:"updatefgi";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:794:"//this takes care of dye lot changea and updates case records too
$updatesql="
UPDATE  fgstock  
SET     dye_lot='{dye_lot}',
		invoice='{invoice}',
		location='{location}',
		style='{style}',
		color='{color}',
		color_no='{color_no}',
		width='{width}',
		descriptio='{descriptio}',
		yards_recd='{yards_recd}',
		cost='{cost}',
		trans='{trans}',
		finish='{finish}',
		fin_no='{fin_no}',
		putup='{putup}',
		c1yards='{c1yards}',
		open=yards_recd-shipped
WHERE   
	dye_lot = '[var_olddl]' 
";
sc_exec_sql($updatesql);
$updatesql="
UPDATE   veratex2.n3case
SET     dye_lot='{dye_lot}',
		style='{style}',
		color='{color}',
		color_no='{color_no}',
		width='{width}'
WHERE   
	dye_lot = '[var_olddl]' 
";
sc_exec_sql($updatesql);
[var_olddl]={dye_lot};

";}i:16;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:26:"fv2_dye_dorec_form_restore";s:4:"nome";s:10:"yieldcalc2";s:4:"tipo";s:1:"M";s:5:"parms";s:0:"";s:6:"codigo";s:310:"{yards_recd}={gyards}-{waste};
{cost}={total_cost}/{gyards};
	if({gr_lbs_rec}>0)
{
{cost_lb_d}={total_cost}/{gr_lbs_rec};
{gr_yield} = {yards_recd} / {gr_lbs_rec};
	if({fin_lbs}>0)
{
	{work_loss}=({gr_lbs_rec}-{fin_lbs})/{gr_lbs_rec};
}
else
{
	{work_loss}=0;
}

}
else
{
{gr_yield} = 0;
}
";}}