$price_expression = new PriceExpression($db); $price_globals = new PriceGlobalVariable($db); //Fetch expression data if (empty($eid)) { $eid = 0; } else { if ($action != 'delete') { $price_expression->fetch($eid); } } /* * Actions */ if ($action == 'add') { if ($eid == 0) { $result = $price_expression->find_title($title); if ($result == 0) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); $price_result = $priceparser->parseProductSupplierExpression($id, $expression, 0, 0); if ($price_result < 0) { //Expression is not valid setEventMessages($priceparser->translatedError(), null, 'errors'); } else { $price_expression->title = $title; $price_expression->expression = $expression; $result = $price_expression->create($user); if ($result > 0) { $eid = $price_expression->id; setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else {