Esempio n. 1
0
                //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc);    // Do not use list here as it may be any vat rates for any country
                if (!empty($rowid)) {
                    $tmpproductsupplier = new ProductFournisseur($db);
                    $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
                    $default_vat = $tmpproductsupplier->fourn_tva_tx;
                } else {
                    if (empty($default_vat)) {
                        $default_vat = $object->tva_tx;
                    }
                }
                print '<input type="text" class="flat" size="5" name="tva_tx" value="' . (GETPOST("tva_tx") ? vatrate(GETPOST("tva_tx")) : ($default_vat != '' ? vatrate($default_vat) : '')) . '">';
                print '</td></tr>';
                if (!empty($conf->dynamicprices->enabled)) {
                    // Price mode selector
                    print '<tr><td class="fieldrequired">' . $langs->trans("PriceMode") . '</td><td>';
                    $price_expression = new PriceExpression($db);
                    $price_expression_list = array(0 => $langs->trans("PriceNumeric"));
                    //Put the numeric mode as first option
                    foreach ($price_expression->list_price_expression() as $entry) {
                        $price_expression_list[$entry->id] = $entry->title;
                    }
                    $price_expression_preselection = GETPOST('eid') ? GETPOST('eid') : ($object->fk_supplier_price_expression ? $object->fk_supplier_price_expression : '0');
                    print $form->selectarray('eid', $price_expression_list, $price_expression_preselection);
                    print '&nbsp; <div id="expression_editor" class="button">' . $langs->trans("PriceExpressionEditor") . '</div>';
                    print '</td></tr>';
                    // This code hides the numeric price input if is not selected, loads the editor page if editor button is pressed
                    print '<script type="text/javascript">
						jQuery(document).ready(run);
						function run() {
							jQuery("#expression_editor").click(on_click);
							jQuery("#eid").change(on_change);
Esempio n. 2
0
 /**
  *	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);
 }
Esempio n. 3
0
$langs->load("accountancy");
//"Back" translation is on this file
$id = GETPOST('id', 'int');
$eid = GETPOST('eid', 'int');
$action = GETPOST('action', 'alpha');
$title = GETPOST('expression_title', 'alpha');
$expression = GETPOST('expression');
$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);
Esempio n. 4
0
 // Date
 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>';