From e7e152c122873c46143d06dc64bf4ff21802b534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 19 Oct 2015 15:13:19 +0200 Subject: [PATCH 01/35] NEW Level multiprice generator based on per cent variations over base price --- htdocs/core/lib/product.lib.php | 10 + .../install/mysql/migration/3.8.0-3.9.0.sql | 9 + htdocs/install/mysql/tables/llx_product.sql | 5 +- .../tables/llx_product_pricerules.key.sql | 19 ++ .../mysql/tables/llx_product_pricerules.sql | 26 +++ htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/en_US/products.lang | 4 + htdocs/product/admin/price_rules.php | 196 ++++++++++++++++++ htdocs/product/class/product.class.php | 79 ++++++- htdocs/product/price.php | 108 ++++++---- 10 files changed, 411 insertions(+), 46 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_product_pricerules.key.sql create mode 100644 htdocs/install/mysql/tables/llx_product_pricerules.sql create mode 100644 htdocs/product/admin/price_rules.php diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index ff2e9c14dbe..8357f7a65ac 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2009-2010 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -166,6 +167,15 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $head[$h] = array( + 0 => DOL_URL_ROOT."/product/admin/price_rules.php", + 1 => $langs->trans('MultipriceRules'), + 2 => 'generator' + ); + $h++; + } + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index a06736d3ce4..d9361cef4b6 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -67,6 +67,14 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); +CREATE TABLE llx_product_pricerules +( + rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + level INT NOT NULL, -- Which price level is this rule for? + fk_level INT NOT NULL, -- Price variations are made over price of X + var_percent FLOAT NOT NULL, -- Price variation over based price + var_min_percent FLOAT NOT NULL -- Min price discount over general price +); ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(10000); @@ -94,3 +102,4 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; +ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 42832a6b227..b5df0ade60c 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -46,7 +46,7 @@ create table llx_product price_base_type varchar(3) DEFAULT 'HT', tva_tx double(6,3), -- Default VAT rate of product recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT - localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1 + localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1 localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2 fk_user_author integer DEFAULT NULL, -- user making creation fk_user_modif integer, -- user making last change @@ -81,5 +81,6 @@ create table llx_product import_key varchar(14), -- Import key fk_price_expression integer, -- Link to the rule for dynamic price calculation desiredstock integer DEFAULT 0, - fk_unit integer DEFAULT NULL + fk_unit integer DEFAULT NULL, + price_autogen TINYINT DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_pricerules.key.sql b/htdocs/install/mysql/tables/llx_product_pricerules.key.sql new file mode 100644 index 00000000000..42b9289d26a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_pricerules.key.sql @@ -0,0 +1,19 @@ +-- ============================================================================ +-- Copyright (C) 2015 Marcos García +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =========================================================================== + +ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product_pricerules.sql b/htdocs/install/mysql/tables/llx_product_pricerules.sql new file mode 100644 index 00000000000..3e3dfc02ed1 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_pricerules.sql @@ -0,0 +1,26 @@ +-- ============================================================================ +-- Copyright (C) 2015 Marcos García +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =========================================================================== + +CREATE TABLE llx_product_pricerules +( + rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + level INT NOT NULL, -- Which price level is this rule for? + fk_level INT NOT NULL, -- Price variations are made over price of X + var_percent FLOAT NOT NULL, -- Price variation over based price + var_min_percent FLOAT NOT NULL -- Min price discount over general price +); \ No newline at end of file diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 6bf95ebe75b..858e76af447 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -173,6 +173,7 @@ ErrorFieldMustBeAnInteger=Field %s must be an integer ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided ErrorOppStatusRequiredIfAmount=You set an estimated amount for this opportunity/lead. So you must also enter its status ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In Module Descriptor (bad value for key fk_menu) +ErrorSavingChanges=An error has ocurred when saving the changes # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 6dcf4ce60f9..957fe0640ad 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -232,6 +232,10 @@ PriceByQuantityRange=Quantity range 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 +PercentVariationOver=%% variation over %s +PercentDiscountOver=%% discount over %s ### composition fabrication Building=Production and items dispatchment Build=Produce diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php new file mode 100644 index 00000000000..d6d494cd61d --- /dev/null +++ b/htdocs/product/admin/price_rules.php @@ -0,0 +1,196 @@ +. + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + +$langs->load("admin"); +$langs->load("products"); + +// Security check +if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) + accessforbidden(); + +/** + * Actions + */ + +if ($_POST) { + + $var_percent = GETPOST('var_percent', 'array'); + $var_min_percent = GETPOST('var_min_percent', 'array'); + $fk_level = GETPOST('fk_level', 'array'); + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + + $check = isset($var_min_percent[$i]); + + if ($i != 1) { + $check = $check && isset($var_percent[$i]) && isset($fk_level[$i]); + } + + if (!$check) { + continue; + } + + if ($i != 1) { + $i_var_percent = (float) price2num($var_percent[$i]); + } else { + $i_var_percent = 0; + } + + $i_var_min_percent = (float) price2num($var_min_percent[$i]); + $i_fk_level = (int) $fk_level[$i]; + + if ($i == 1) { + $check1 = true; + $check2 = $i_var_min_percent; + } else { + $check1 = $i_fk_level >= 1 && $i_fk_level <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; + $check2 = $i_var_percent && $i_var_min_percent; + } + + if (!$check1 || !$check2) { + + //If the level is between range but percent fields are empty, then we ensure it does not exist in DB + if ($check1 && !$check2) { + $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int)$i); + } + + continue; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_pricerules + SET level = ".(int) $i.", fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent; + + if (!$db->query($sql)) { + + //If we could not create, then we try updating + $sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules + SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i; + + if (!$db->query($sql)) { + setEventMessage($langs->trans('ErrorSavingChanges'), 'errors'); + } + } + + } + + setEventMessage($langs->trans("RecordSaved")); +} + +/* + * View + */ + +$sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules"; +$query = $db->query($sql); + +$rules = array(); + +while ($result = $db->fetch_object($query)) { + $rules[$result->level] = $result; +} + +$title = $langs->trans('ProductServiceSetup'); +$tab = $langs->trans("ProductsAndServices"); + +if (empty($conf->produit->enabled)) { + $title = $langs->trans('ServiceSetup'); + $tab = $langs->trans('Services'); +} elseif (empty($conf->service->enabled)) { + $title = $langs->trans('ProductSetup'); + $tab = $langs->trans('Products'); +} + +llxHeader('', $langs->trans('MultipriceRules')); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($title,$linkback,'title_setup'); + +$head = product_admin_prepare_head(); +dol_fiche_head($head, 'generator', $tab, 0, 'product'); + +print load_fiche_titre($langs->trans('MultipriceRules')); + +//Array that contains the number of prices available +$price_options = array(); + +for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + $price_options[$i] = $langs->trans('SellingPrice').' '.$i; +} + +$genPriceOptions = function($level) use ($price_options) { + + $return = array(); + + for ($i = 1; $i < $level; $i++) { + $return[$i] = $price_options[$i]; + } + + return $return; +}; + +?> + +
+ + + + + + + + + + + + global->PRODUIT_MULTIPRICES_LIMIT; $i++): ?> + + + + + + +
trans('PriceLevel') ?>trans('Price') ?>trans('MinPrice') ?>
trans('SellingPrice') ?> 1 trans('PercentDiscountOver', $langs->trans('SellingPrice').' 1') ?>
trans('SellingPrice').' '.$i; + // Label of price + if (! empty($conf->global->{"PRODUIT_MULTIPRICES_LABEL$i"})) { + print ' - '.$langs->trans($conf->global->$keyforlabel); + } + ?> + + + trans('PercentVariationOver', Form::selectarray("fk_level[$i]", $genPriceOptions($i), (isset($rules[$i]) ? $rules[$i]->fk_level : null))) ?> + + + trans('PercentDiscountOver', $langs->trans('SellingPrice').' '.$i) ?> +
+ +
+ +
+ +
+
+ +db->escape($this->accountancy_code_sell)."'"; $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -1337,9 +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 * @return int <0 if KO, >0 if OK */ - function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0) + function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen = 0) { global $conf,$langs; @@ -1353,6 +1361,12 @@ 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 + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen) { + return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq); + } + if (! empty($newminprice) && ($newminprice > $newprice)) { $this->error='ErrorPriceCantBeLowerThanMinPrice'; @@ -1531,7 +1545,7 @@ class Product extends CommonObject $sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,"; $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit"; - $sql.= " , fk_price_expression"; + $sql.= " , fk_price_expression, price_autogen"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id); else @@ -1608,6 +1622,7 @@ class Product extends CommonObject $this->ref_ext = $obj->ref_ext; $this->fk_price_expression = $obj->fk_price_expression; $this->fk_unit = $obj->fk_unit; + $this->price_autogen = $obj->price_autogen; $this->db->free($resql); @@ -3992,4 +4007,64 @@ class Product extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Generates prices for a product based on product multiprice generation rules + * + * @param User $user User that updates the prices + * @param float $baseprice Base price + * @param string $price_type Base price type + * @param float $price_vat VAT % tax + * @param int $npr NPR + * @param string $psq ¿? + * @return int -1 KO, 1 OK + */ + public function generateMultiprices(User $user, $baseprice, $price_type, $price_vat, $npr, $psq) + { + global $conf, $db; + + $sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules"; + $query = $db->query($sql); + + $rules = array(); + + while ($result = $db->fetch_object($query)) { + $rules[$result->level] = $result; + } + + //Because prices can be based on other level's prices, we temporarily store them + $prices = array( + 1 => $baseprice + ); + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + + $price = $baseprice; + $price_min = 0; + + if ($i > 1) { + //We have to make sure it does exist and it is > 0 + if (isset($rules[$i]->var_percent) && $rules[$i]->var_percent) { + $price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent/100)); + } + } + + $prices[$i] = $price; + + //We have to make sure it does exist and it is > 0 + if (isset($rules[$i]->var_min_percent) && $rules[$i]->var_min_percent) { + $price_min = $price * (1 - ($rules[$i]->var_min_percent/100)); + } + + if ($price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i])) { + continue; + } + + if ($this->updatePrice($price, $price_type, $user, $price_vat, $price_min, $i, $npr, $psq, true) < 0) { + return -1; + } + } + + return 1; + } } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 9c7defc4643..27d00db18f2 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -82,39 +82,37 @@ $parameters=array('id'=>$id, 'ref'=>$ref); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ - if ($action == 'update_price' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) - { +if (empty($reshook)) { + if ($action == 'update_price' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { + $newprice = ''; + $newprice_min = ''; + $newpricebase = ''; + $newvat = ''; + $maxpricesupplier = $object->min_recommended_price(); $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression // MultiPrix - if (! empty($conf->global->PRODUIT_MULTIPRICES)) - { - $newprice = ''; - $newprice_min = ''; - $newpricebase = ''; - $newvat = ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) - { - if (isset($_POST ["price_" . $i])) - { + //Shall we generate prices using price rules? + $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; + $object->update($object->id, $user); + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { + if (isset($_POST ["price_".$i])) { $level = $i; - $newprice = price2num($_POST ["price_" . $i], 'MU'); - $newprice_min = price2num($_POST ["price_min_" . $i], 'MU'); - $newpricebase = $_POST ["multiprices_base_type_" . $i]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx_" . $i]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx_" . $i]); + $newprice = price2num($_POST ["price_".$i], 'MU'); + $newprice_min = price2num($_POST ["price_min_".$i], 'MU'); + $newpricebase = $_POST ["multiprices_base_type_".$i]; + $newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0); + $newvat = str_replace('*', '', $_POST ["tva_tx_".$i]); $newpsq = GETPOST('psqflag'); $newpsq = empty($newpsq) ? 0 : $newpsq; break; // We found submited price } } - } - else - { + } else { $level = 0; $newprice = price2num($_POST ["price"], 'MU'); $newprice_min = price2num($_POST ["price_min"], 'MU'); @@ -125,42 +123,39 @@ if (empty($reshook)) $newpsq = empty($newpsq) ? 0 : $newpsq; } - if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) - { - setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors'); - $error++; - $action='edit_price'; + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { + setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); + $error ++; + $action = 'edit_price'; } - if ($newprice < $newprice_min && ! empty($object->fk_price_expression)) - { + if ($newprice < $newprice_min && !empty($object->fk_price_expression)) { $newprice = $newprice_min; //Set price same as min, the user will not see the } - if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) - { + $res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); + + if ($res) { + if ($object->fk_price_expression != 0) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); $price_result = $priceparser->parseProduct($object); if ($price_result < 0) { //Expression is not valid - $error++; - $action='edit_price'; + $error ++; + $action = 'edit_price'; setEventMessage($priceparser->translatedError(), 'errors'); } } - if (empty($error) && ! empty($conf->dynamicprices->enabled)) - { - $ret=$object->setPriceExpression($object->fk_price_expression); - if ($ret < 0) - { - $error++; - $action='edit_price'; + if (empty($error) && !empty($conf->dynamicprices->enabled)) { + $ret = $object->setPriceExpression($object->fk_price_expression); + if ($ret < 0) { + $error ++; + $action = 'edit_price'; setEventMessage($object->error, 'errors'); } } - if (empty($error)) - { + if (empty($error)) { $action = ''; setEventMessage($langs->trans("RecordSaved")); } @@ -170,6 +165,7 @@ if (empty($reshook)) } } + if ($action == 'delete' && $user->rights->produit->supprimer) { $result = $object->log_price_delete($user, $_GET ["lineid"]); @@ -785,6 +781,33 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> } else { + + ?> + + global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { print '
'; @@ -798,6 +821,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> // VAT if ($i == 1) { + print '' . $langs->trans('UseMultipriceRules'). 'price_autogen ? 'checked' : '').'>'; print '' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx ["$i"], $mysoc, '', $object->id); print ''; From 6db09a0d649a0bbc6fc3b072fc747a3873700976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 20 Oct 2015 11:35:49 +0200 Subject: [PATCH 02/35] Little correction --- htdocs/product/class/product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9b959517ce5..f5e95ff0e93 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1363,7 +1363,8 @@ class Product extends CommonObject if ($newvat == '') $newvat=$this->tva_tx; //If multiprices are enabled, then we check if the current product is subject to price autogeneration - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen) { + //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); } From 1b10612c4bee864b25b94991c0a631c172d23957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 20 Oct 2015 11:41:33 +0200 Subject: [PATCH 03/35] Fixed PHPCS check --- htdocs/product/admin/price_rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index d6d494cd61d..76b907e14d4 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -71,7 +71,7 @@ if ($_POST) { //If the level is between range but percent fields are empty, then we ensure it does not exist in DB if ($check1 && !$check2) { - $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int)$i); + $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int) $i); } continue; From c6baeacd3d6560e6d3c6f38bff6621839bba022d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 20 Oct 2015 11:42:56 +0200 Subject: [PATCH 04/35] Removed JS debugging --- htdocs/product/price.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 27d00db18f2..7eb9ee0b7e8 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -789,8 +789,6 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> var otherPrices = $('div.fiche form:not(:first)'); var minPrice1 = $('div.fiche form:first tr:eq(3)'); - console.log('e'); - if (jQuery('input#usePriceRules').prop('checked')) { otherPrices.hide(); minPrice1.hide(); From ca8c1adf55dc1f3ded447626064e9815d8856306 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Wed, 21 Oct 2015 10:07:53 +0200 Subject: [PATCH 05/35] Add trigger "SUPPLIER_PRODUCT_BUYPRICE_DELETE" for frounisseur.product remove_product_fournisseur_price() --- .../fourn/class/fournisseur.product.class.php | 19 ++++++++++++++++--- htdocs/product/fournisseurs.php | 9 +++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 490b5cf1ea3..346f69a4cef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -121,7 +121,7 @@ class ProductFournisseur extends Product */ function remove_product_fournisseur_price($rowid) { - global $conf; + global $conf, $user; $this->db->begin(); @@ -132,8 +132,21 @@ class ProductFournisseur extends Product $resql = $this->db->query($sql); if ($resql) { - $this->db->commit(); - return 1; + // Call trigger + $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + + if (empty($error)) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } else { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 72f8ed2b0b2..526b67b123c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -95,9 +95,14 @@ if (empty($reshook)) { if ($rowid) { - $result=$object->remove_product_fournisseur_price($rowid); $action = ''; - setEventMessage($langs->trans("PriceRemoved")); + $result=$product->remove_product_fournisseur_price($rowid); + if($result > 0){ + setEventMessage($langs->trans("PriceRemoved")); + }else{ + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + } } } From ceae04b76e243dff282cba2fdd4b68990e933454 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Thu, 22 Oct 2015 12:03:01 +0200 Subject: [PATCH 06/35] move trigger before query --- .../fourn/class/fournisseur.product.class.php | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 346f69a4cef..c143e2e98be 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -123,35 +123,34 @@ class ProductFournisseur extends Product { global $conf, $user; - $this->db->begin(); + // Call trigger + $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) + if (empty($error)) { - // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); - if ($result < 0) $error++; - // End call triggers + $this->db->begin(); - if (empty($error)) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql.= " WHERE rowid = ".$rowid; + + dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { $this->db->commit(); return 1; } else { + $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; } } else { - $this->error=$this->db->lasterror(); - $this->db->rollback(); return -1; } } From 00c2b1a32a6231eb7dc371bd198ad2563bbe0baa Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Thu, 22 Oct 2015 14:30:11 +0200 Subject: [PATCH 07/35] move db->begin() before trigger --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c143e2e98be..acbeba8a720 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -123,6 +123,8 @@ class ProductFournisseur extends Product { global $conf, $user; + $this->db->begin(); + // Call trigger $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); if ($result < 0) $error++; @@ -130,7 +132,6 @@ class ProductFournisseur extends Product if (empty($error)) { - $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE rowid = ".$rowid; From 990fbf3ef45a06577264f7ce6630964acdc9269c Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Mon, 26 Oct 2015 14:00:43 +0100 Subject: [PATCH 08/35] hooks correctly implemented , printObjectLine, printObjectSubLine In hook can change correctly label and ref (for my module need if is posible) --- htdocs/core/class/commonobject.class.php | 12 ++++++++---- htdocs/core/class/hookmanager.class.php | 4 +++- htdocs/core/lib/pdf.lib.php | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d5dac206e15..1439915ebdb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3108,20 +3108,21 @@ abstract class CommonObject $var=!$var; - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + if (is_object($hookmanager)) // Old code is commented on preceding line. { if (empty($line->fk_parent_line)) { $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); - $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); - $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } - else + if (empty($reshook)) { $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline); } @@ -3171,6 +3172,9 @@ abstract class CommonObject { $product_static = new Product($this->db); $product_static->fetch($line->fk_product); + + $product_static->ref = $line->ref; //can change ref in hook + $product_static->label = $line->label; //can change label in hook $text=$product_static->getNomUrl(1); // Define output language and label diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 249a6665a3f..a23977acebe 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -163,7 +163,9 @@ class HookManager 'printAddress', 'printSearchForm', 'formatEvent', - 'addCalendarChoice' + 'addCalendarChoice', + 'printObjectLine', + 'printObjectSubLine' ) )) $hooktype='addreplace'; // Deprecated hook types ('returnvalue') diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0d7f18e1c75..0bd13869ce8 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1088,6 +1088,12 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if ($idprod) { $prodser->fetch($idprod); + + //can change ref in hook + if(isset($object->lines[$i]->ref)){ + $prodser->ref = $object->lines[$i]->ref; + } + // If a predefined product and multilang and on other lang, we renamed label with label translated if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { From 4d839eea60310811254b0dcf708a7259d55b2822 Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 26 Oct 2015 20:33:42 +0100 Subject: [PATCH 09/35] Fix #2591 Margin is incorrect used with POS if buy price not defined, define buyprice as configured in margin admin. If 'Force buying price if null' is off, marge will be equal to suggested default.(min supplier price or pmp) Updated all classes reading 'Force buying price if null' setting. --- .../class/askpricesupplier.class.php | 32 +++++++--- htdocs/comm/propal/class/propal.class.php | 55 ++++++++-------- htdocs/commande/class/commande.class.php | 52 +++++++--------- htdocs/compta/facture/class/facture.class.php | 49 +++++++-------- htdocs/contrat/class/contrat.class.php | 47 ++++++++++---- htdocs/core/class/commonobject.class.php | 62 +++++++++++++++++++ htdocs/langs/en_US/margins.lang | 2 +- 7 files changed, 193 insertions(+), 106 deletions(-) diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index 26d412e87ea..2f563a17b1b 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -2649,11 +2649,18 @@ class AskPriceSupplierLine extends CommonObject if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } // Check parameters if ($this->product_type < 0) return -1; @@ -2817,10 +2824,17 @@ class AskPriceSupplierLine extends CommonObject if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } $this->db->begin(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 4d632a84c54..8d4c91f097d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -496,17 +496,7 @@ class Propal extends CommonObject $this->line->date_start=$date_start; $this->line->date_end=$date_end; - - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // Mise en option de la ligne @@ -660,16 +650,7 @@ class Propal extends CommonObject $this->line->skip_update_total = $skip_update_total; $this->line->fk_unit = $fk_unit; - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; $this->line->date_start=$date_start; @@ -3124,11 +3105,18 @@ class PropaleLigne extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } // Check parameters if ($this->product_type < 0) return -1; @@ -3296,10 +3284,17 @@ class PropaleLigne extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } $this->db->begin(); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d43314a8816..e3926603f86 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1281,16 +1281,7 @@ class Commande extends CommonOrder $this->line->date_start=$date_start; $this->line->date_end=$date_end; - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // TODO Ne plus utiliser @@ -2509,16 +2500,7 @@ class Commande extends CommonOrder $this->line->skip_update_total=$skip_update_total; $this->line->fk_unit=$fk_unit; - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - //by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // TODO deprecated @@ -3550,10 +3532,17 @@ class OrderLine extends CommonOrderLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } // Check parameters @@ -3677,10 +3666,17 @@ class OrderLine extends CommonOrderLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } $this->db->begin(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index bd3e2dac6f0..bc286cd2a59 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2361,16 +2361,7 @@ class Facture extends CommonInvoice $this->line->situation_percent = $situation_percent; $this->line->fk_unit = $fk_unit; - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // POS or external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; if (is_array($array_options) && count($array_options)>0) { @@ -3883,10 +3874,17 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } // Check parameters @@ -3906,14 +3904,6 @@ class FactureLigne extends CommonInvoiceLine } } - // POS or by external module, take lowest buying price - if (!empty($this->fk_product) && empty($this->fk_fournprice) && empty($this->pa_ht)) { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($this->fk_product); - $this->fk_fournprice = $productFournisseur->product_fourn_price_id; - } - $this->db->begin(); // Insertion dans base de la ligne @@ -4081,10 +4071,17 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } $this->db->begin(); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1d2bd9f4181..e38bb254f79 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1283,10 +1283,18 @@ class Contrat extends CommonObject if (empty($pa_ht)) $pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($pa_ht == 0) { - if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $pa_ht = $pu_ht * (1 - $remise_percent / 100); + + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) + { + return $result; + } + else + { + $pa_ht = $result; + } } // Insertion dans la base @@ -1456,10 +1464,17 @@ class Contrat extends CommonObject if (empty($pa_ht)) $pa_ht=0; - // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente - if ($pa_ht == 0) { - if ($pu > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $pa_ht = $pu * (1 - $remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($pu_ht, $remise_percent)) < 0) + { + return $result; + } + else + { + $pa_ht = $result; + } } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; @@ -2481,12 +2496,20 @@ class ContratLigne extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente - if ($this->pa_ht == 0) { - if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) - $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } } + $this->db->begin(); // Update request diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d5dac206e15..2aacad9a7ff 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4176,4 +4176,66 @@ abstract class CommonObject return true; } + + /** + * define buy price if not defined + * set buy price = sell price if ForceBuyingPriceIfNull configured, + * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice + * else set min buy price as buy price + * + * @param float $unitPrice product unit price + * @param float $discountPercent line discount percent + * @param int $fk_product product id + * + * @return float <0 if ko, buyprice if ok + */ + public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) + { + global $conf; + + $buyPrice = 0; + + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + { + $buyPrice = $unitPrice * (1 - $discountPercent / 100); + } + else + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + // Get PMP + if (! empty($fk_product)) + { + if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') + { + $product = new Product($this->db); + $result = $product->fetch($fk_product); + if ($result <= 0) + { + $this->error='ErrorProductIdDoesNotExists'; + return -1; + } + if (($product->pmp > 0)) + { + $buyPrice = $product->pmp; + } + // TODO add option to set PMP of product + } + else if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') + { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) + { + $buyPrice = $productFournisseur->fourn_price; + } + else + { + $this->error = $productFournisseur->error; + return -1; + } + } + } + } + return $buyPrice; + } } diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index eb77ca9fe4c..9aeaf8d60e6 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -24,7 +24,7 @@ StartDate=Start date EndDate=End date Launch=Start ForceBuyingPriceIfNull=Force buying price if null -ForceBuyingPriceIfNullDetails=if "ON", margin will be zero on line (buying price = selling price), otherwise ("OFF"), marge will be equal to selling price (buying price = 0) +ForceBuyingPriceIfNullDetails=if "ON", margin will be zero on line (buying price = selling price), otherwise ("OFF"), marge will be equal to suggested default. MARGIN_METHODE_FOR_DISCOUNT=Margin method for global discounts UseDiscountAsProduct=As a product UseDiscountAsService=As a service From b1bc000bae790cdb6814147671f17dc3d0082f88 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Tue, 27 Oct 2015 09:19:39 +0100 Subject: [PATCH 10/35] standardize --- htdocs/core/lib/pdf.lib.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0bd13869ce8..0d7f18e1c75 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1088,12 +1088,6 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if ($idprod) { $prodser->fetch($idprod); - - //can change ref in hook - if(isset($object->lines[$i]->ref)){ - $prodser->ref = $object->lines[$i]->ref; - } - // If a predefined product and multilang and on other lang, we renamed label with label translated if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { From 8992cfaeb437cd26178906e07af2674c0d2297ca Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 27 Oct 2015 15:50:55 +0100 Subject: [PATCH 11/35] move require_once --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2aacad9a7ff..dbc9686002a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4201,12 +4201,12 @@ abstract class CommonObject } else { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Get PMP if (! empty($fk_product)) { if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $product = new Product($this->db); $result = $product->fetch($fk_product); if ($result <= 0) @@ -4222,7 +4222,7 @@ abstract class CommonObject } else if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($this->db); if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) { From 7940b249f5f60b1e9edfa2dda1345c23635a6a5a Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 29 Oct 2015 09:58:43 +0100 Subject: [PATCH 12/35] Update Readme.md Add badges to show build status and downloads per day. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 576e3153ef9..f6f4b8be34f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DOLIBARR ERP & CRM +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dd/dolibarr.svg) + Dolibarr ERP & CRM is a modern software to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...). It's an Open Source software (wrote in PHP language) designed for small and medium companies, foundation and freelances. From e5063010b2d1b813cd69b686cdd12c3cf0c53ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:07:00 +0100 Subject: [PATCH 13/35] Update actions_printing.inc.php --- htdocs/core/actions_printing.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 431ac89a94e..6dfd1122eac 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -46,7 +46,12 @@ if ($action == 'print_file' and $user->rights->printing->read) if (! empty($conf->global->{$printer->active})) { $subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':''); - $errorprint = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir); + $module = GETPOST('printer', 'alpha'); + if ($module =='commande_fournisseur') { + $module = 'fournisseur'; + $subdir = 'commande'; + } + $errorprint = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir); //if ($errorprint < 0) { // setEventMessage($interface->errors, 'errors'); //} From b1c4e032fc09f5447058d11a4969deb9f952fa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:08:38 +0100 Subject: [PATCH 14/35] Update html.formfile.class.php --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 230ffa99504..59a7c183d76 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -285,7 +285,7 @@ class FormFile } $printer=0; - if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements + if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition', 'commande_fournisseur'))) // The direct print feature is implemented only for such elements { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } From ff9648eed9fa59ecb7e85a4f546b0303f424456d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:09:37 +0100 Subject: [PATCH 15/35] Update card.php --- htdocs/fourn/commande/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 37809f6bf87..cb1754fa8d3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -872,6 +872,8 @@ if (empty($reshook)) } } + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + /* * Create an order From 59714e4b32dae41aaa63f2945c4f82a9366d03ab Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 30 Oct 2015 12:41:36 +0100 Subject: [PATCH 16/35] Fix : migration wrong index --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index dac62a2a4b8..4f1e308b370 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -247,7 +247,7 @@ ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_pro -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_projet); +ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); From e01bdebc495996fa8f75159e72b980df11a9f636 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2015 14:37:19 +0100 Subject: [PATCH 17/35] Fix translation --- htdocs/admin/orderdet_extrafields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 8e542e3d871..8a9f0e52c0a 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -66,7 +66,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("OrderLines"); +$textobject=$langs->transnoentitiesnoconv("Orders"); llxHeader('',$langs->trans("OrdersSetup")); From a8d28b5e4649d700bb2ed94299be8f4351d961c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2015 19:16:02 +0100 Subject: [PATCH 18/35] NEW Add a filter field to restrict list of member when doing a LDAP list request. Use also this filter into ldap command line script making sync from ldap to dolibarr. --- htdocs/admin/ldap.php | 10 +++--- htdocs/admin/ldap_contacts.php | 16 ++++----- htdocs/admin/ldap_groups.php | 12 +++---- htdocs/admin/ldap_members.php | 33 ++++++++++++------- htdocs/admin/ldap_users.php | 30 +++++++++-------- htdocs/core/class/ldap.class.php | 28 +++++++++------- ...interface_50_modLdap_Ldapsynchro.class.php | 14 ++++---- .../members/sync_members_ldap2dolibarr.php | 7 ++-- scripts/user/sync_users_ldap2dolibarr.php | 5 +-- 9 files changed, 89 insertions(+), 66 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index bfccacc40ac..fadde40dbed 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -92,7 +92,6 @@ if (! function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); $var=true; $form=new Form($db); @@ -101,6 +100,8 @@ $form=new Form($db); print ''; print ''; +dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); + print ''; // Liste de synchro actives @@ -135,7 +136,7 @@ if (! empty($conf->societe->enabled)) print ''; } -// Synchro adherentt active +// Synchro member active if (! empty($conf->adherent->enabled)) { $var=!$var; @@ -143,6 +144,7 @@ if (! empty($conf->adherent->enabled)) $arraylist=array(); $arraylist['0']=$langs->trans("No"); $arraylist['1']=$langs->trans("DolibarrToLDAP"); + $arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; print $form->selectarray('activemembers',$arraylist,$conf->global->LDAP_MEMBER_ACTIVE); print ''; } @@ -239,12 +241,12 @@ print ''; print '
'.$langs->trans("LDAPDnContactActiveExample").'
'.$langs->trans("LDAPDnMemberActiveExample").'
secret
'; +dol_fiche_end(); + print '
'; print ''; -print ''; - print '
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 3af47f46aac..56b755bf64a 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -92,6 +92,8 @@ if ($action == 'setvalue' && $user->admin) * View */ +$form=new Form($db); + llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); $linkback=''.$langs->trans("BackToModuleList").''; @@ -114,8 +116,6 @@ print '
'; print '
'; print ''; -$form=new Form($db); - print ''; $var=true; @@ -263,16 +263,16 @@ print ''; print '"; print ''; - -$var=!$var; -print ''; print '
 global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COUNTRY?' checked':'').">
'; +print info_admin($langs->trans("LDAPDescValues")); + +dol_fiche_end(); + +print '
'; + print '
'; -print ''; - -print info_admin($langs->trans("LDAPDescValues")); /* * Test de la connexion diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index bba8f2109a3..20b94023358 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -177,16 +177,16 @@ print ''.$langs->trans("LDAPFieldGroupMembersExample").''; print 'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'').">"; print ''; - -$var=!$var; -print ''; print ''; +print info_admin($langs->trans("LDAPDescValues")); + +dol_fiche_end(); + +print '
'; + print ''; -print ''; - -print info_admin($langs->trans("LDAPDescValues")); /* * Test de la connexion diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index bd9eda149b4..52117961b54 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -53,6 +53,7 @@ if ($action == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',GETPOST("user"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_MEMBER_FILTER',GETPOST("filterconnection"),'chaine',0,'',$conf->entity)) $error++; // Members if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN',GETPOST("fieldlogin"),'chaine',0,'',$conf->entity)) $error++; @@ -107,6 +108,8 @@ if ($action == 'setvalue' && $user->admin) * View */ +$form=new Form($db); + llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); $linkback=''.$langs->trans("BackToModuleList").''; @@ -120,6 +123,9 @@ if (! function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } +print '
'; +print ''; + dol_fiche_head($head, 'members', $langs->trans("LDAPSetup")); @@ -127,11 +133,6 @@ print $langs->trans("LDAPDescMembers").'
'; print '
'; -print ''; -print ''; - -$form=new Form($db); - print ''; $var=true; @@ -156,6 +157,14 @@ print ''; print ''; print ''; +// Filter, used to filter search +$var=!$var; +print ''; +print ''; +print ''; + print '
'.$langs->trans("LDAPMemberObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; +print ''; +print ''.$langs->trans("LDAPFilterConnectionExample").'
'; print '
'; print ''; @@ -377,15 +386,16 @@ print ''; print ''; print ''; -$var=!$var; -print ''; print '
  
'; +print info_admin($langs->trans("LDAPDescValues")); + +dol_fiche_end(); + +print '
'; + print '
'; -print ''; - -print info_admin($langs->trans("LDAPDescValues")); /* @@ -454,6 +464,7 @@ if (function_exists("ldap_connect")) } -$db->close(); llxFooter(); + +$db->close(); diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 76d3bb9dfd0..70a94e5817a 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -63,7 +63,7 @@ if ($action == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++; @@ -93,6 +93,8 @@ if ($action == 'setvalue' && $user->admin) * Visu */ +$form=new Form($db); + llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); $linkback=''.$langs->trans("BackToModuleList").''; @@ -106,18 +108,19 @@ if (! function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } + +print '
'; +print ''; + + dol_fiche_head($head, 'users', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescUsers").'
'; print '
'; -print ''; -print ''; -$form=new Form($db); - print ''; $var=true; @@ -141,8 +144,7 @@ print ''; print ''; print ''; -// Filtre -//Utilise pour filtrer la recherche +// Filter, used to filter search $var=!$var; print ''; print '"; print ''; -$var=!$var; -print ''; print '
'.$langs->trans("LDAPUserObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; print ''; @@ -281,16 +283,16 @@ print ''.$langs->trans("LDAPFieldSidExample").'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked':'').">
'; -print '
'; - -print ''; - print info_admin($langs->trans("LDAPDescValues")); +dol_fiche_end(); + +print '
'; + +print ''; + /* * Test de la connexion @@ -392,7 +394,7 @@ if (function_exists("ldap_connect")) $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, $conf->global->LDAP_FIELD_PHONE, $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_SKYPE, + $conf->global->LDAP_FIELD_SKYPE, $conf->global->LDAP_FIELD_MOBILE, $conf->global->LDAP_FIELD_MAIL, $conf->global->LDAP_FIELD_TITLE, diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 400eb934e26..c081ed34a96 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -108,7 +108,7 @@ class Ldap { global $conf; - //Server + // Server if (! empty($conf->global->LDAP_SERVER_HOST)) $this->server[] = $conf->global->LDAP_SERVER_HOST; if (! empty($conf->global->LDAP_SERVER_HOST_SLAVE)) $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE; $this->serverPort = $conf->global->LDAP_SERVER_PORT; @@ -120,9 +120,11 @@ class Ldap $this->searchPassword = $conf->global->LDAP_ADMIN_PASS; $this->people = $conf->global->LDAP_USER_DN; $this->groups = $conf->global->LDAP_GROUP_DN; - $this->filter = $conf->global->LDAP_FILTER_CONNECTION; - //Users + $this->filter = $conf->global->LDAP_FILTER_CONNECTION; // Filter on user + $this->filtermember = $conf->global->LDAP_MEMBER_FILTER; // Filter on member + + // Users $this->attr_login = $conf->global->LDAP_FIELD_LOGIN; //unix $this->attr_sambalogin = $conf->global->LDAP_FIELD_LOGIN_SAMBA; //samba, activedirectory $this->attr_name = $conf->global->LDAP_FIELD_NAME; @@ -891,14 +893,14 @@ class Ldap } /** - * Returns an array containing a details of elements + * Returns an array containing a details or list of LDAP record(s) * ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword * - * @param string $search Valeur champ cle recherche, sinon '*' pour tous. + * @param string $search Value of fiel to search, '*' for all. Not used if $activefilter is set. * @param string $userDn DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org) * @param string $useridentifier Name of key field (Ex: uid) * @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword) - * @param int $activefilter 1=use field this->filter as filter instead of parameter $search + * @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'member'=use field this->filtermember as filter * @param array $attributeAsArray Array of fields wanted as an array not a string * @return array Array of [id_record][ldap_field]=value */ @@ -906,7 +908,7 @@ class Ldap { $fulllist=array(); - dol_syslog(get_class($this)."::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).")"); + dol_syslog(get_class($this)."::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).") activefilter=".$activefilter); // if the directory is AD, then bind first with the search user first if ($this->serverType == "activedirectory") @@ -916,15 +918,19 @@ class Ldap } // Define filter - if ($activefilter == 1) + if (! empty($activefilter)) { - if ($this->filter) + if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) { $filter = '('.$this->filter.')'; } - else + elseif (((string) $activefilter == 'member') && $this->filter) { - $filter='('.$useridentifier.'=*)'; + $filter = '('.$this->filtermember.')'; + } + else // If this->filter is empty, make fiter on * (all) + { + $filter = '('.$useridentifier.'=*)'; } } else diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 7a63a5cdeec..561ba330694 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -414,7 +414,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap=new Ldap(); $ldap->connect_bind(); @@ -433,7 +433,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If status field is setup to be synchronized if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) @@ -457,7 +457,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If subscriptions fields are setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE @@ -485,7 +485,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap=new Ldap(); $ldap->connect_bind(); @@ -522,7 +522,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If password field is setup to be synchronized if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) @@ -546,7 +546,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If status field is setup to be synchronized if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) @@ -570,7 +570,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap=new Ldap(); $ldap->connect_bind(); diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index cf18a75e508..b6a27250557 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -2,7 +2,7 @@ - * Copyright (C) 2006-2010 Laurent Destailleur + * Copyright (C) 2006-2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -115,7 +115,8 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n"; print "login=".$conf->global->LDAP_ADMIN_DN."\n"; print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n"; print "DN to extract=".$conf->global->LDAP_MEMBER_DN."\n"; -print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n"; +if (! empty($conf->global->LDAP_MEMBER_FILTER)) print 'Filter=('.$conf->global->LDAP_MEMBER_FILTER.')'."\n"; // Note: filter is defined into function getRecords +else print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n"; print "----- To Dolibarr database:\n"; print "type=".$conf->db->type."\n"; print "host=".$conf->db->host."\n"; @@ -191,7 +192,7 @@ if ($result >= 0) // We disable synchro Dolibarr-LDAP $conf->global->LDAP_MEMBER_ACTIVE=0; - $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 0); + $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 'member'); // Fiter on 'member' filter param if (is_array($ldaprecords)) { $db->begin(); diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 53a48cc03ca..48917cc1042 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -106,7 +106,8 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n"; print "login=".$conf->global->LDAP_ADMIN_DN."\n"; print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n"; print "DN to extract=".$conf->global->LDAP_USER_DN."\n"; -print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n"; +if (! empty($conf->global->LDAP_FILTER_CONNECTION)) print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords +else print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n"; print "----- To Dolibarr database:\n"; print "type=".$conf->db->type."\n"; print "host=".$conf->db->host."\n"; @@ -177,7 +178,7 @@ if ($result >= 0) // We disable synchro Dolibarr-LDAP $conf->global->LDAP_SYNCHRO_ACTIVE=0; - $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 0); + $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 'user'); // Fiter on 'user' filter param if (is_array($ldaprecords)) { $db->begin(); From 6482a4ee04034ab8c4d3028f5bddbff590266c18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2015 20:04:03 +0100 Subject: [PATCH 19/35] Minor css fix --- htdocs/core/ajax/selectsearchbox.php | 4 ++-- htdocs/core/lib/project.lib.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index f4db125ca78..0f00086dbf7 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,7 +92,7 @@ if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM } if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) { - $arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->askpricesupplier->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->askpricesupplier->lire) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 94b2de526dd..004ad3a619f 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -977,7 +977,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks= { $var=!$var; print ""; - print ''; + print ''; $projectstatic->ref=$objp->ref; print $projectstatic->getNomUrl(1); print ' - '.dol_trunc($objp->title,24).''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ce83c4c41f2..5bb00861ac2 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -641,7 +641,7 @@ div.divphotoref { div.statusref { float: right; padding-right: 12px; - margin-top: 6px; + margin-top: 7px; margin-bottom: 10px; } img.photoref { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 47da3176126..ab13c8a5f39 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -165,7 +165,7 @@ if ($tmpval <= 360) { $colortextbackvmenu='FFFFFF'; } else { $colortextbackvmenu='111111'; } $tmppart=explode(',',$colorbacktitle1); $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); -if ($tmpval <= 360) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; } +if ($tmpval <= 260) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; } else { $colortexttitle='111111'; $colorshadowtitle='FFFFFF'; } $tmppart=explode(',',$colorbacktabcard1); $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : ''); @@ -687,7 +687,7 @@ div.divphotoref { div.statusref { float: right; padding-right: 12px; - margin-top: 7px; + margin-top: 8px; margin-bottom: 10px; } img.photoref { From 975fe064ae812eb68fc63916ef8aac8dd3677dc9 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Fri, 30 Oct 2015 21:59:22 +0100 Subject: [PATCH 20/35] [Qual] Uniformize code --- htdocs/barcode/codeinit.php | 6 +++--- htdocs/barcode/printsheet.php | 10 +++++----- htdocs/bookmarks/admin/bookmark.php | 4 ++-- htdocs/bookmarks/card.php | 8 ++++---- htdocs/bookmarks/list.php | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 9251b5e7ac9..db662b6d9e4 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -92,7 +92,7 @@ if ($action == 'initbarcodeproducts') if (! is_object($modBarCodeProduct)) { $error++; - setEventMessage($langs->trans("NoBarcodeNumberingTemplateDefined"),'errors'); + setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors'); } if (! $error) @@ -109,7 +109,7 @@ if ($action == 'initbarcodeproducts') $resql=$db->query($sql); if ($resql) { - setEventMessage($langs->trans("AllBarcodeReset"),'mesgs'); + setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs'); } else { @@ -160,7 +160,7 @@ if ($action == 'initbarcodeproducts') if (! $error) { - setEventMessage($langs->trans("RecordsModified",$nbok),'mesgs'); + setEventMessages($langs->trans("RecordsModified",$nbok), null, 'mesgs'); } } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index f974bbec897..5cd45467f01 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -68,7 +68,7 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct')) if (empty($forbarcode) || empty($fk_barcode_type)) { - setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$producttmp->getNomUrl()), 'warnings'); + setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete",$producttmp->getNomUrl()), null, 'warnings'); } } } @@ -85,7 +85,7 @@ if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) if (empty($forbarcode) || empty($fk_barcode_type)) { - setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$thirdpartytmp->getNomUrl()), 'warnings'); + setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete",$thirdpartytmp->getNomUrl()), null, 'warnings'); } } } @@ -114,7 +114,7 @@ if ($action == 'builddoc') if ($result <= 0) { $error++; - setEventMessage('Failed to get bar code type information '.$stdobject->error, 'errors'); + setEventMessages('Failed to get bar code type information '.$stdobject->error, $stdobject->errors, 'errors'); } } @@ -158,13 +158,13 @@ if ($action == 'builddoc') if ($result <= 0 || ! dol_is_file($barcodeimage)) { $error++; - setEventMessage('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), 'errors'); + setEventMessages('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), null, 'errors'); } } else { $error++; - setEventMessage("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, 'errors'); + setEventMessages("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, null, 'errors'); } } else { $template = 'tcpdflabel'; diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 05691a227b7..bd249055773 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -42,12 +42,12 @@ if ($action == 'setvalue') if (! $error) { $db->commit(); - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 33a0f383fde..daacc4ca4da 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -78,12 +78,12 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if (! $title) { $error++; - setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors'); + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), null, 'errors'); } if (! $url) { $error++; - setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors'); + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), null, 'errors'); } if (! $error) @@ -104,11 +104,11 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->transnoentities("WarningBookmarkAlreadyExists"), 'warnings'); + setEventMessages($langs->transnoentities("WarningBookmarkAlreadyExists"), null, 'warnings'); } else { - setEventMessage($bookmark->error, 'errors'); + setEventMessages($bookmark->error, $bookmark->errors, 'errors'); } $action = $invertedaction; } diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index f8b7c21863d..425ae0079b6 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -60,7 +60,7 @@ if ($_GET["action"] == 'delete') } else { - setEventMessage($bookmark->error, 'errors'); + setEventMessages($bookmark->error, $bookmark->errors, 'errors'); } } From 8602d41a28dfbe3a4efab348d196f84845a54a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 09:46:56 +0100 Subject: [PATCH 21/35] Update COPYRIGHT --- COPYRIGHT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index 534770f0f75..66c74407fe7 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -56,7 +56,7 @@ JsTimezoneDetect 1.0.4 MIT License Yes Raven.js 1.1.19 MIT License Yes Used for client-side error logging with Sentry logger For licenses compatibility informations: -http://www.fsf.org/licensing/licenses/index_html +http://www.gnu.org/licenses/licenses.en.html Copyright From 41603426566875652229474f0a1c7002ac543320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 10:05:34 +0100 Subject: [PATCH 22/35] Update llx_c_hrm_function.sql --- htdocs/install/mysql/data/llx_c_hrm_function.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_hrm_function.sql b/htdocs/install/mysql/data/llx_c_hrm_function.sql index f8b56563689..dd5c6e832bd 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_function.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_function.sql @@ -26,9 +26,9 @@ INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5,'EXECBOARD', 'Executive board', 0, 1); INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1); INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 20, 'ENGAGDIR', 'Engagement director', 1, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 25, 'DIRECTOR', 'Director', 1, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 30, 'PROJMANAG', 'Project manager', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 35, 'DEPHEAD', 'Department head', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 40, 'SECRETAR', 'Secretary', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(9, 45, 'EMPLOYEE', 'Department employee', 0, 1); From 4108f55c1e728b912af614fab0ac060779a8d671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 10:07:13 +0100 Subject: [PATCH 23/35] Update 3.8.0-3.9.0.sql --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 4f1e308b370..1d6d7974285 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -134,12 +134,12 @@ CREATE TABLE IF NOT EXISTS llx_c_hrm_function INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1); INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1); INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1); -INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 20, 'ENGAGDIR', 'Engagement director', 1, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 25, 'DIRECTOR', 'Director', 1, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 30, 'PROJMANAG', 'Project manager', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 35, 'DEPHEAD', 'Department head', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 40, 'SECRETAR', 'Secretary', 0, 1); +INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(9, 45, 'EMPLOYEE', 'Department employee', 0, 1); CREATE TABLE IF NOT EXISTS llx_c_hrm_department ( From f3f83fa6c13099661cf8431611730fcfa123e971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 10:32:41 +0100 Subject: [PATCH 24/35] Remove incomplete llx_stock_lotserial migration There is two creation of this table in migration script, keeping the more complete --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 4f1e308b370..d82cae8f1cf 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -106,21 +106,6 @@ ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1; -create table llx_stock_lotserial -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - fk_user_creat integer, - fk_user_modif integer, - fk_product integer NOT NULL, -- Id of product - batch varchar(30) DEFAULT NULL, -- Lot or serial number - eatby date DEFAULT NULL, -- Eatby date - sellby date DEFAULT NULL -- Sellby date -) ENGINE=innodb; - - - CREATE TABLE IF NOT EXISTS llx_c_hrm_function ( rowid integer PRIMARY KEY, From 592348850fa4a2cb63099d7189784113388d8762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 31 Oct 2015 11:48:17 +0100 Subject: [PATCH 25/35] Added missing SQL statements + reordered them --- .../install/mysql/migration/3.8.0-3.9.0.sql | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 83013214eb3..1b383b80624 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -69,17 +69,8 @@ ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; -CREATE TABLE llx_product_pricerules -( - rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, - level INT NOT NULL, -- Which price level is this rule for? - fk_level INT NOT NULL, -- Price variations are made over price of X - var_percent FLOAT NOT NULL, -- Price variation over based price - var_min_percent FLOAT NOT NULL -- Min price discount over general price -); ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); - ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories (label, fk_parent, entity); --ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); @@ -263,4 +254,15 @@ ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY ( ALTER TABLE llx_c_typent ADD COLUMN position integer NOT NULL DEFAULT 0; ALTER TABLE llx_c_forme_juridique ADD COLUMN position integer NOT NULL DEFAULT 0; ALTER TABLE llx_c_type_fees ADD COLUMN position integer NOT NULL DEFAULT 0; -ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; \ No newline at end of file + +-- NEW Level multiprice generator based on per cent variations over base price +CREATE TABLE llx_product_pricerules +( + rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + level INT NOT NULL, -- Which price level is this rule for? + fk_level INT NOT NULL, -- Price variations are made over price of X + var_percent FLOAT NOT NULL, -- Price variation over based price + var_min_percent FLOAT NOT NULL -- Min price discount over general price +); +ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; +ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level); \ No newline at end of file From ff5fcbbc10f4c877c627c3b408a0137820c4bfd0 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sat, 31 Oct 2015 17:21:48 +0100 Subject: [PATCH 26/35] [Qual] Uniformize code --- htdocs/cashdesk/admin/cashdesk.php | 4 ++-- htdocs/categories/card.php | 2 +- htdocs/categories/categorie.php | 9 ++++---- htdocs/comm/action/card.php | 9 ++++---- htdocs/comm/askpricesupplier/card.php | 32 ++++++++++++++------------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 74560e8ff6a..fcafa84a5a2 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -66,12 +66,12 @@ if (GETPOST('action','alpha') == 'set') if (! $error) { $db->commit(); - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index f5921ac4d06..6281307218c 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -155,7 +155,7 @@ if ($action == 'add' && $user->rights->categorie->creer) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index aca45c5ca52..d86a351cdff 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -151,8 +151,7 @@ if (empty($reshook)) $result=$cat->del_type($object,$elementtype); if ($result < 0) { - setEventMessage($cat->error,'errors'); - setEventMessage($cat->errors,'errors'); + setEventMessages($cat->error, $cat->errors, 'errors'); } } @@ -199,17 +198,17 @@ if (empty($reshook)) $result=$cat->add_type($object,$elementtype); if ($result >= 0) { - setEventMessage($langs->trans("WasAddedSuccessfully",$cat->label)); + setEventMessages($langs->trans("WasAddedSuccessfully",$cat->label), null, 'mesgs'); } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); + setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { - setEventMessages( $cat->error, $cat->errors, 'errors' ); + setEventMessages($cat->error, $cat->errors, 'errors'); } } } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1f2f0c3b19e..2fe0df507cb 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -140,7 +140,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -151,7 +151,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } @@ -347,7 +347,7 @@ if ($action == 'add') $db->rollback(); $langs->load("errors"); $error=$langs->trans($object->error); - setEventMessage($error,'errors'); + setEventMessages($error, null, 'errors'); $action = 'create'; $donotclearsession=1; } } @@ -551,8 +551,7 @@ if ($action == 'mupdate') $result=$object->update($user); if ($result < 0) { - setEventMessage($object->error,'errors'); - setEventMessage($object->errors,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } if (! empty($backtopage)) diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php index f57cb16e0e0..d59922c1cb4 100644 --- a/htdocs/comm/askpricesupplier/card.php +++ b/htdocs/comm/askpricesupplier/card.php @@ -114,7 +114,7 @@ if (empty($reshook)) { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -123,8 +123,10 @@ if (empty($reshook)) if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); - } else { - setEventMessage($object->error, 'errors'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } @@ -140,7 +142,7 @@ if (empty($reshook)) exit(); } else { $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); + setEventMessages($langs->trans($object->error), null, 'errors'); } } @@ -198,8 +200,8 @@ if (empty($reshook)) } } else { $langs->load("errors"); - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); } } @@ -249,7 +251,7 @@ if (empty($reshook)) $id = $object->create_from($user); } else { - setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_askpricesupplier')), 'errors'); + setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_askpricesupplier')), null, 'errors'); } } else { $object->ref = GETPOST('ref'); @@ -484,7 +486,7 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->insert_discount($_POST["remise_id"]); if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -674,7 +676,7 @@ if (empty($reshook)) if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } else { // Insert line $ref_fourn = GETPOST('fourn_ref'); @@ -716,7 +718,7 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -774,7 +776,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error ++; } } else { @@ -823,7 +825,7 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -865,9 +867,9 @@ if (empty($reshook)) $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } @@ -1325,7 +1327,7 @@ if ($action == 'create') $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error ++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { $numref = $object->ref; From df3af6979e484a57cfa894974a4aabfb2172f72f Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 31 Oct 2015 21:43:59 +0100 Subject: [PATCH 27/35] Translation in paypal lib --- htdocs/langs/en_US/paypal.lang | 5 +++++ htdocs/paypal/lib/paypal.lib.php | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index b6b6d59d4a0..def6a08406f 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -23,3 +23,8 @@ PAYPAL_PAYONLINE_SENDEMAIL=EMail to warn after a payment (success or not) ReturnURLAfterPayment=Return URL after payment ValidationOfPaypalPaymentFailed=Validation of Paypal payment failed PaypalConfirmPaymentPageWasCalledButFailed=Payment confirmation page for Paypal was called by Paypal but confirmation failed +SetExpressCheckoutAPICallFailed=SetExpressCheckout API call failed. +DetailedErrorMessage=Detailed Error Message +ShortErrorMessage=Short Error Message +ErrorCode=Error Code +ErrorSeverityCode=Error Severity Code diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index f9ec79244a5..824f312a9af 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -406,11 +406,11 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - echo "SetExpressCheckout API call failed.
\n"; - echo "Detailed Error Message: " . $ErrorLongMsg."
\n"; - echo "Short Error Message: " . $ErrorShortMsg."
\n"; - echo "Error Code: " . $ErrorCode."
\n"; - echo "Error Severity Code: " . $ErrorSeverityCode."
\n"; + echo $langs->trans('SetExpressCheckoutAPICallFailed') . "
\n"; + echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; } } From 22d1cf860c70a375f4c83684d5d24e514cb30de3 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 31 Oct 2015 22:05:55 +0100 Subject: [PATCH 28/35] Add translation --- htdocs/langs/en_US/paypal.lang | 1 + htdocs/public/paypal/paymentok.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index def6a08406f..b2eadfce654 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -24,6 +24,7 @@ ReturnURLAfterPayment=Return URL after payment ValidationOfPaypalPaymentFailed=Validation of Paypal payment failed PaypalConfirmPaymentPageWasCalledButFailed=Payment confirmation page for Paypal was called by Paypal but confirmation failed SetExpressCheckoutAPICallFailed=SetExpressCheckout API call failed. +DoExpressCheckoutPaymentAPICallFailed=DoExpressCheckoutPayment API call failed. DetailedErrorMessage=Detailed Error Message ShortErrorMessage=Short Error Message ErrorCode=Error Code diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index f59bab46bd1..90f13aa6f17 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -224,11 +224,11 @@ if ($PAYPALTOKEN) $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - echo "DoExpressCheckoutPayment API call failed.
\n"; - echo "Detailed Error Message: " . $ErrorLongMsg."
\n"; - echo "Short Error Message: " . $ErrorShortMsg."
\n"; - echo "Error Code: " . $ErrorCode."
\n"; - echo "Error Severity Code: " . $ErrorSeverityCode."
\n"; + echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
\n"; + echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; From 0fd7ba478a79bc2cf6f675b4de07930dddd66fa4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Nov 2015 17:27:41 +0100 Subject: [PATCH 29/35] Fix: add Mac OS --- htdocs/core/lib/functions.lib.php | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b990ac509c..fcadfb9e521 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -179,6 +179,7 @@ function getBrowserInfo($user_agent) // OS if (preg_match('/linux/i', $user_agent)) { $os='linux'; } + elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } // Name if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } @@ -703,7 +704,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0) { global $conf,$langs, $hookmanager; - + $out="\n".'
'."\n"; // Show title @@ -733,7 +734,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $displaytab=0; $nbintab=0; $popuptab=0; - + for ($i = 0 ; $i <= $maxkey ; $i++) { if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) @@ -777,7 +778,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi else { // The popup with the other tabs - if (! $popuptab) + if (! $popuptab) { $popuptab=1; $outmore.='
'; @@ -795,13 +796,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $outmore.=''.$links[$i][1].''."\n"; $outmore.='
'; - + $nbintab++; } $displaytab=$i; } if ($popuptab) $outmore.='
'; - + if ($displaytab > $limittoshow) { $tabsname=str_replace("@", "", $picto); @@ -817,7 +818,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi } $out.="\n"; - + if (! $notab) $out.="\n".'
'."\n"; $parameters=array('tabname' => $active); @@ -900,7 +901,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r print '
'; print '
'; } - + /** * Show a string with the label tag dedicated to the HTML edit field. * @@ -1382,7 +1383,7 @@ function dol_print_size($size,$shortvalue=0,$shortunit=0) function dol_print_url($url,$target='_blank',$max=32,$withpicto=0) { global $langs; - + if (empty($url)) return ''; $link=''; return $out; @@ -2958,7 +2959,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so if ($cpt > 2) $pagelist.='dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...'; else if ($cpt == 2) $pagelist.='dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'':'data-role="button" ').'href="'.$file.'?page=1'.$options.'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">2'; } - + do { if ($cpt==$page) @@ -2972,7 +2973,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $cpt++; } while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); - + if ($cpt<$nbpages) { if ($cpt<$nbpages-2) $pagelist.= 'dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...'; @@ -4402,7 +4403,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) } else if ($nameorder == 2) { - $ret.=$firstname; + $ret.=$firstname; } else { @@ -5225,7 +5226,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) /** * Return the filename of file to get the thumbs - * + * * @param string $file Original filename * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') * @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image. @@ -5235,10 +5236,10 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') { $dirName = dirname($file); if ($dirName == '.') $dirName=''; - + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); - + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':''); @@ -5246,9 +5247,9 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':''); if (! $extImgTarget) return $file; - + $subdir=''; if ($extName) $subdir = 'thumbs/'; - + return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb } From 6df524bcb0278aba0f2915e6ffd5adba9d173599 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 1 Nov 2015 22:54:04 +0100 Subject: [PATCH 30/35] Remove blank page --- htdocs/core/modules/modWebsite.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 0e75daa26bd..7bb5a27a0c5 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -62,7 +62,7 @@ class modWebsite extends DolibarrModules // Config pages //------------- - $this->config_page_url = array("website.php"); + $this->config_page_url = array(); // Dependancies //------------- From cc257d8abc4a80c191f05b2affb93290bec937db Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 1 Nov 2015 22:54:33 +0100 Subject: [PATCH 31/35] Typo --- htdocs/societe/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index ebe4b4c0342..9556a95b826 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -60,7 +60,7 @@ print '
'; // Search thirdparty if (! empty($conf->societe->enabled) && $user->rights->societe->lire) { - $listofsearchfields['search_thirdparty']=array('text'=>'Thirdparty'); + $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); } // Search contact/address if (! empty($conf->societe->enabled) && $user->rights->societe->lire) From d8f77f58d7c5e961442658ca4bc04f5f9e2444a1 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 2 Nov 2015 06:42:17 +0100 Subject: [PATCH 32/35] Salaries : Replace "label for" by the function fieldLabel & add some notes --- htdocs/compta/salaries/card.php | 54 ++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index e658633e7b0..969b840aeb9 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -201,7 +201,11 @@ if ($id) } } -// Formulaire saisie salaire +/* ************************************************************************** */ +/* */ +/* create mode */ +/* */ +/* ************************************************************************** */ if ($action == 'create') { $year_current = strftime("%Y",dol_now()); @@ -231,50 +235,64 @@ if ($action == 'create') print ''; - print ""; - print ''; - print ''; // Employee - print ""; - print ''; // Label - print ''; + print ''; - print ""; - print ''; - print ''; // Amount - print ''; + print ''; // Bank if (! empty($conf->banque->enabled)) { - print ''; } // Type payment - print '\n"; - print ""; + print ''; + // Number if (! empty($conf->banque->enabled)) { // Number @@ -304,7 +322,7 @@ if ($action == 'create') /* ************************************************************************** */ /* */ -/* Barre d'action */ +/* View mode */ /* */ /* ************************************************************************** */ @@ -322,8 +340,8 @@ if ($id) print $object->ref; print ''; - // Person - print '
'; + // Date payment + print '
'; + print fieldLabel('DatePayment','datep',1).''; print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1); print '
'; + // Date value for bank + print '
'; + print fieldLabel('DateValue','datev',0).''; print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1); print '
'; + print '
'; + print fieldLabel('Employee','fk_user',1).''; print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1); print '
trans("SalaryPayment")).'">
'; + print fieldLabel('Label','label',1).''; + print 'trans("SalaryPayment")).'">'; + print '
'; + // Date start period + print '
'; + print fieldLabel('DateStartPeriod','datesp',1).''; print $form->select_date($datesp,"datesp",'','','','add'); print '
'; + // Date end period + print '
'; + print fieldLabel('DateEndPeriod','dateep',1).''; print $form->select_date($dateep,"dateep",'','','','add'); print '
'; + print fieldLabel('Amount','amount',1).''; + print ''; + print '
'; + print '
'; + print fieldLabel('Account','selectaccountid',1).''; $form->select_comptes($_POST["accountid"],"accountid",0,'',1); // Affiche liste des comptes courant print '
'; + print '
'; + print fieldLabel('PaymentMode','selectpaymenttype',1).''; $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); - print "
'.$langs->trans("Person").''; + // Employee + print '
'.$langs->trans("Employee").''; $usersal=new User($db); $usersal->fetch($object->fk_user); print $usersal->getNomUrl(1); From 6fe43cbbeb3ff804608ed25968a3639e1d757dd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Nov 2015 09:08:08 +0100 Subject: [PATCH 33/35] Removed dead code --- htdocs/core/lib/product.lib.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 8357f7a65ac..cb5201f59da 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -133,18 +133,6 @@ function product_prepare_head($object) $head[$h][2] = 'documents'; $h++; - - // More tabs from canvas - // TODO Is this still used ? - if (isset($object->onglets) && is_array($object->onglets)) - { - foreach ($object->onglets as $onglet) - { - $head[$h] = $onglet; - $h++; - } - } - complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove'); return $head; From a161e6d47a687e348de4c416a02fbee2b6deaa81 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Nov 2015 10:02:09 +0100 Subject: [PATCH 34/35] Continue debug of PRODUIT_MULTIPRICES option. Introduce option PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL to have relative caculation of multiprice not yet visible. --- htdocs/core/lib/product.lib.php | 3 ++- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/products.lang | 3 ++- htdocs/product/admin/price_rules.php | 33 ++++++++++++++++---------- htdocs/product/class/product.class.php | 12 ++++++---- htdocs/product/price.php | 30 +++++++++++++---------- 6 files changed, 51 insertions(+), 31 deletions(-) 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 ''; } } - else + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + if ($user->rights->produit->creer || $user->rights->service->creer) { + print ''; + } + } + + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; } if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; + print ''; } } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; - } - } 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 ''; From a658ff7e90f6a50170390af11ab72105d70c2297 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Mon, 2 Nov 2015 10:26:07 +0100 Subject: [PATCH 35/35] add commit or rollback if error --- .../fourn/class/fournisseur.product.class.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index acbeba8a720..ef776342aa5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -138,22 +138,21 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else + if (!$resql) { $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; + $error++; } } - else - { + + if (empty($error)){ + $this->db->commit(); + return 1; + }else{ + $this->db->rollback(); return -1; } + }
' . $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 '