<?php


class Lib_Equation
{
	function calculate($field,$row,$rowE) 
	{	
		$arrayZ = array(
			'WYSP' => 'order_product_options_3', 
			'WYSL' => 'order_product_options_4', 
			'WYS' => 'order_product_height', 
			'SZER' => 'order_product_width', 
			'GLEB' => 'order_product_depth', 
			'PARA' => 'order_product_wysszerA', 
			'PARB' => 'order_product_wysszerB', 
			'PARC' => 'order_product_wysszerC', 
			'PARD' => 'order_product_wysszerD', 
			'PARE' => 'order_product_wysszerE', 
			'OPP' => 'order_product_options_1', 
			'OPL' => 'order_product_options_2'
		);
		
		$pol = $rowE[$field];
		foreach( $arrayZ as $keyZ => $valZ ){			
			$pol = str_replace( $keyZ, $row[$valZ], $pol );
		}
		
		$pol = str_replace( 'PIERWIASTEK', 'sqrt', $pol );
		
		eval('$wynik = '.$pol.';');
		
    	return $wynik;
	} 
}

