/** * Calculates supplier product price based on product id and expression id * * @param int $product_id The Product id to get information * @param int $expression_id The expression to parse * @param int $quantity Min quantity * @param int $tva_tx VAT rate * @param array $extra_values Any aditional values for expression * @return int > 0 if OK, < 1 if KO */ public function parseProductSupplier($product_id, $expression_id, $quantity = null, $tva_tx = null, $extra_values = array()) { //Get the expression from db $price_expression = new PriceExpression($this->db); $res = $price_expression->fetch($expression_id); if ($res < 1) { $this->error = array(19, null); return -1; } //Parse the expression and return the price return $this->parseProductSupplierExpression($product_id, $price_expression->expression, $quantity, $tva_tx, $extra_values); }
$tab = GETPOST('tab', 'alpha'); $tab = !empty($tab) ? $tab : 'card'; $tab = strtolower($tab); // Security check $result = restrictedArea($user, 'produit|service&fournisseur', $id, 'product&product', '', '', 'rowid'); //Initialize objects $product = new Product($db); $product->fetch($id, ''); $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');
print "<td>" . dol_print_date($db->jdate($objp->dp), "dayhour") . "</td>"; // Price level if (!empty($conf->global->PRODUIT_MULTIPRICES)) { print '<td align="center">' . $objp->price_level . "</td>"; } // Price by quantity if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { $type = $objp->price_by_qty == 1 ? 'PriceByQuantity' : 'Standard'; print '<td align="center">' . $langs->trans($type) . "</td>"; } print '<td align="center">' . $langs->trans($objp->price_base_type) . "</td>"; print '<td align="right">' . vatrate($objp->tva_tx, true, $objp->recuperableonly) . "</td>"; //Price if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); $res = $price_expression->fetch($objp->fk_price_expression); $title = $price_expression->title; print '<td align="right"></td>'; print '<td align="right"></td>'; print '<td align="right">' . $title . "</td>"; } else { print '<td align="right">' . price($objp->price) . "</td>"; print '<td align="right">' . price($objp->price_ttc) . "</td>"; if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled print '<td align="right"></td>'; } } print '<td align="right">' . price($objp->price_min) . '</td>'; print '<td align="right">' . price($objp->price_min_ttc) . '</td>'; // User