diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 771a79cd95b..eec9318f9ba 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1749,7 +1749,7 @@ class Form } // Price by quantity - if (!empty($objp->quantity) && $objp->quantity >= 1 && $conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) + if (!empty($objp->quantity) && $objp->quantity >= 1 && ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { $found = 1; $outqty=$objp->quantity; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b38bcd150a9..1a6c5a35511 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -198,7 +198,7 @@ HelpAddThisServiceCard=This option allows you to create or clone a service if it CurrentProductPrice=Current price AlwaysUseNewPrice=Always use current price of product/service AlwaysUseFixedPrice=Use the fixed price -PriceByQuantity=Price by quantity +PriceByQuantity=Different prices by quantity PriceByQuantityRange=Quantity range ProductsDashboard=Products/Services summary UpdateOriginalProductLabel=Modify original label @@ -234,9 +234,9 @@ DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar c BarCodeDataForProduct=Barcode information of product %s : BarCodeDataForThirdparty=Barcode information of thirdparty %s : ResetBarcodeForAllRecords=Define barcode value for all records (this will also reset barcode value already defined with new values) -PriceByCustomer=Price by customer +PriceByCustomer=Different price for each customer PriceCatalogue=Unique price per product/service -PricingRule=Pricing Rules +PricingRule=Rules for customer prices AddCustomerPrice=Add price by customers ForceUpdateChildPriceSoc=Set same price on customer subsidiaries PriceByCustomerLog=Price by customer log diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 7ecc390516d..2d0c1cca468 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -44,13 +44,13 @@ $value = GETPOST('value','alpha'); // Pricing Rules $select_pricing_rules=array( -'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price -'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level -'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer') // Different price for each customer +'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price +'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level +'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer ); -if ($conf->global->MAIN_FEATURES_LEVEL==2) +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity'); + $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity'); // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES'] = $langs->trans('MultiPricesAbility') . '+' . $langs->trans('PriceByQuantity'); } diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 61a1c3bff73..7dda37b6f2c 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -58,32 +58,32 @@ $price_by_qty_rowid = GETPOST('pbq', 'int'); dol_syslog(join(',', $_GET)); // print_r($_GET); -if (! empty($action) && $action == 'fetch' && ! empty($id)) { +if (! empty($action) && $action == 'fetch' && ! empty($id)) +{ require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - + $outjson = array(); - + $object = new Product($db); $ret = $object->fetch($id); - if ($ret > 0) { + if ($ret > 0) + { $outref = $object->ref; $outlabel = $object->label; $outdesc = $object->description; $outtype = $object->type; $outqty = 1; $outdiscount = 0; - + $found = false; - + // Price by qty - if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a - // particular price related - // to qty + if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty { $sql = "SELECT price, unitprice, quantity, remise_percent"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; $sql .= " WHERE rowid=" . $price_by_qty_rowid . ""; - + $result = $db->query($sql); if ($result) { $objp = $db->fetch_object($result); @@ -98,7 +98,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) { } } } - + // Multiprice if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price // level (from 1 to 6) @@ -110,7 +110,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) { $sql .= " AND price_level=" . $price_level; $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1"; - + $result = $db->query($sql); if ($result) { $objp = $db->fetch_object($result); @@ -123,16 +123,16 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) { } } } - + // Price by customer if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) { - + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - + $prodcustprice = new Productcustomerprice($db); - + $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid); - + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { if (count($prodcustprice->lines) > 0) { @@ -144,48 +144,48 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) { } } } - + if (! $found) { $outprice_ht = price($object->price); $outprice_ttc = price($object->price_ttc); $outpricebasetype = $object->price_base_type; $outtva_tx = $object->tva_tx; } - + $outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount); } - + echo json_encode($outjson); } else { require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; - + $langs->load("products"); $langs->load("main"); - + top_httphead(); - + if (empty($htmlname)) return; - + $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); sort($match); $idprod = (! empty($match [0]) ? $match [0] : ''); - + if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; - + // When used from jQuery, the search term is added as GET param "term". $searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : '')); - + $form = new Form($db); if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid); } elseif ($mode == 2) { $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); } - + $db->close(); - + if ($outjson) print json_encode($arrayresult); } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index ce2ed5f11d8..98cfd675fac 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -430,12 +430,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; // Price by quantity - if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) { + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { print '' . $langs->trans("PriceByQuantity") . ' ' . $i; print ''; if ($object->prices_by_qty [$i] == 1) { - print ''; + print '
'; print ''; print ''; @@ -445,30 +446,30 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; foreach ($object->prices_by_qty_list [$i] as $ii => $prices) { - if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; // print ''; - print ''; + print ''; print ''; print ''; print ''; } else { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -524,7 +525,8 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; // Price by quantity - if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) { + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { print '
' . $langs->trans("PriceByQuantityRange") . ' ' . $i . ' 
 ' . $object->price_base_type . ' ' . $object->price_base_type . '  % %
' . $prices ['quantity'] . '' . price($prices ['price']) . '' . price($prices ['unitprice']) . '' . price($prices ['remise_percent']) . ' %' . price($prices['price']) . '' . price($prices['unitprice']) . '' . price($prices['remise_percent']) . ' %'; if (($user->rights->produit->creer || $user->rights->service->creer)) { - print ''; + print ''; print img_edit() . ''; - print ''; + print ''; print img_delete() . ''; } else { print ' '; @@ -480,7 +481,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if ($action != 'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) { print '
'; print ''; - print ''; + print ''; print ''; print '
' . $langs->trans("PriceByQuantity"); if ($object->prices_by_qty [0] == 0) { print ' ' . $langs->trans("Activate"); @@ -532,7 +534,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; if ($object->prices_by_qty [0] == 1) { - print ''; + print '
'; print ''; print ''; print ''; @@ -540,31 +542,33 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; - foreach ($object->prices_by_qty_list [0] as $ii => $prices) { - if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { + foreach ($object->prices_by_qty_list [0] as $ii => $prices) + { + if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) + { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; // print ''; - print ''; + print ''; print ''; print ''; print ''; } else { print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print '"; } // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; print '"; }
' . $langs->trans("PriceByQuantityRange") . '' . $langs->trans("HT") . '' . $langs->trans("Discount") . ' 
 ' . $object->price_base_type . ' ' . $object->price_base_type . '  % %
' . $prices ['quantity'] . '' . price($prices ['price']) . '' . price($prices ['unitprice']) . '' . price($prices ['remise_percent']) . ' %' . $prices['quantity'] . '' . price($prices['price']) . '' . price($prices['unitprice']) . '' . price($prices['remise_percent']) . ' %'; if (($user->rights->produit->creer || $user->rights->service->creer)) { - print ''; + print ''; print img_edit() . ''; - print ''; + print ''; print img_delete() . ''; } else { print ' '; @@ -803,7 +807,8 @@ if ($result) { print '' . $objp->price_level . "' . $langs->trans($type) . "