diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index cb5201f59da..69eb63717b2 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -155,7 +155,8 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) + { $head[$h] = array( 0 => DOL_URL_ROOT."/product/admin/price_rules.php", 1 => $langs->trans('MultipriceRules'), diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a4b7423ebe8..d5243b02bb2 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1708,3 +1708,4 @@ TitleExampleForMajorRelease=Example of message you can use to announce this majo TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites) ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. +MultiPriceRuleDesc=When option "Several level of prices per product/service" is on, you can define different prices (one per price level) for each product. To save you time, you can enter here rule to have price for each level autocalculated according to price of first level, so you will have to enter only price for first level on each product. This page is here to save you time and can be usefull only if your prices for each leve are relative to first level. You can ignore this page in most cases. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 46cea209d3a..ddda0152245 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -69,6 +69,7 @@ ProductStatusNotOnBuyShort=Not for purchase UpdatePrice=Update price UpdateVAT=Update vat UpdateDefaultPrice=Update default price +UpdateLevelPrices=Update prices for each level AppliedPricesFrom=Applied prices from SellingPrice=Selling price SellingPriceHT=Selling price (net of tax) @@ -236,7 +237,7 @@ ProductsDashboard=Products/Services summary UpdateOriginalProductLabel=Modify original label HelpUpdateOriginalProductLabel=Allows to edit the name of the product MultipriceRules=Price level rules -UseMultipriceRules=Use price level rules +UseMultipriceRules=Use price level rules (defined into product module setup) to autocalculate prices of all other level according to first level PercentVariationOver=%% variation over %s PercentDiscountOver=%% discount over %s ### composition fabrication diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index 76b907e14d4..83d90485b3d 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -1,6 +1,5 @@ . + * + * Page to set how to autocalculate price for each level when option + * PRODUCT_MULTIPRICE is on. */ require '../../main.inc.php'; @@ -125,10 +127,16 @@ llxHeader('', $langs->trans('MultipriceRules')); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title,$linkback,'title_setup'); + + +print '
'; + $head = product_admin_prepare_head(); dol_fiche_head($head, 'generator', $tab, 0, 'product'); -print load_fiche_titre($langs->trans('MultipriceRules')); +print $langs->trans("MultiPriceRuleDesc").'

'; + +print load_fiche_titre($langs->trans('MultipriceRules'), '', ''); //Array that contains the number of prices available $price_options = array(); @@ -150,8 +158,6 @@ $genPriceOptions = function($level) use ($price_options) { ?> - - @@ -184,13 +190,16 @@ $genPriceOptions = function($level) use ($price_options) {
trans('PriceLevel') ?>
-
+ - - -
+dol_fiche_end(); - + + '; + +print ''; -llxFooter(); \ No newline at end of file +llxFooter(); + +$db->close(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8ac288e71bf..dcf8661466c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1344,10 +1344,10 @@ class Product extends CommonObject * @param int $level 0=standard, >0 = level if multilevel prices * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT * @param int $newpsq 1 if it has price by quantity - * @param int $ignore_autogen Used to avoid infinite loops + * @param int $ignore_autogen Used to avoid infinite loops * @return int <0 if KO, >0 if OK */ - function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen = 0) + function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen=0) { global $conf,$langs; @@ -1362,9 +1362,10 @@ class Product extends CommonObject // Check parameters if ($newvat == '') $newvat=$this->tva_tx; - //If multiprices are enabled, then we check if the current product is subject to price autogeneration - //Price will be modified ONLY when the first one is the one that is being modified - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { + // If multiprices are enabled, then we check if the current product is subject to price autogeneration + // Price will be modified ONLY when the first one is the one that is being modified + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1)) + { return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq); } @@ -4024,6 +4025,7 @@ class Product extends CommonObject { global $conf, $db; + // FIXME USing * into select is forbidden $sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules"; $query = $db->query($sql); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 4dfea1ca1ab..8822fd9f7f4 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -716,28 +716,30 @@ if (! $action || $action == 'delete' || $action == 'showlog_customer_price' || $ { print "\n" . '
' . "\n"; - if (empty($conf->global->PRODUIT_MULTIPRICES)) + if (empty($conf->global->PRODUIT_MULTIPRICES)) // For everyone, except multiprices { if ($user->rights->produit->creer || $user->rights->service->creer) { print '
' . $langs->trans("UpdateDefaultPrice") . '
'; } } - else + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + if ($user->rights->produit->creer || $user->rights->service->creer) { + print '
id . '">' . $langs->trans("AddCustomerPrice") . '
'; + } + } + + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print '
' . $langs->trans("UpdateVAT") . '
'; } if ($user->rights->produit->creer || $user->rights->service->creer) { - print '
' . $langs->trans("UpdateDefaultPrice") . '
'; + print '
' . $langs->trans("UpdateLevelPrices") . '
'; } } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print '
id . '">' . $langs->trans("AddCustomerPrice") . '
'; - } - } print "\n
\n"; } @@ -912,11 +914,16 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) + { + print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; + } + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - if ($i > 1) print '
'; print '
'; + if ($i > 1) print '
'; print ''; print ''; print ''; @@ -928,9 +935,8 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; // VAT - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense { - print ''; print '';
' . $langs->trans('UseMultipriceRules'). 'price_autogen ? 'checked' : '').'>
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id); print '