From 81f1a341120a85e97c718571ca5bf447a74c08c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 13:06:35 +0200 Subject: [PATCH 01/10] Revert "Fix SPEC #7013 : use database type "numeric" to store monetary values" --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 ------------------- .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 28 insertions(+), 92 deletions(-) delete mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql deleted file mode 100644 index 545b52ea4a7..00000000000 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ /dev/null @@ -1,64 +0,0 @@ --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 6.0.0 or higher. --- --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table --- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex --- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y --- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE --- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; --- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; --- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; --- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- Note: fields with type BLOB/TEXT can't have default value. --- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); --- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); - - --- Clean corrupted values for tms --- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- Remove default not null on date_fin --- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; --- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; - --- Move real to numeric for more precision for storing monetary amounts (no rouding) --- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); -ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); -ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); -ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 01ced5b07f4..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit numeric(24,8) NOT NULL, -- FEC:Debit - credit numeric(24,8) NOT NULL, -- FEC:Credit - montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) + debit double NOT NULL, -- FEC:Debit + credit double NOT NULL, -- FEC:Credit + montant double NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount numeric(24,8), -- FEC:Montantdevise + multicurrency_amount double, -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index 59c8e262817..ae696a0d6d1 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts numeric(24,8) NOT NULL, + amounts real NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 093b635a964..519ceacc9e5 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount numeric(24,8) default 0 NOT NULL, + amount real default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 6964abdcd57..98740c232ac 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 24158903eb1..6d291dcfa00 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 63b2cd111ea..b7b7c89f9cd 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index eb43238255a..c682b22f276 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 086bafae0fa..2efca933dba 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 16d63a32076..0e9b1885c97 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount numeric(24,8) DEFAULT 0, -- montant + amount real DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index 1859c7aa796..afa5075cd4e 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 1857246e22e..40e39771978 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index 3b6111a7b2f..d023c039391 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 3b6da16b9cb..38364c6812e 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary numeric(24,8), -- salary of user when payment was done - amount numeric(24,8) NOT NULL DEFAULT 0, + salary real, -- salary of user when payment was done + amount real NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index 40fff2e842d..e92342eb001 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount numeric(24,8) DEFAULT 0, -- montant total du prelevement + amount real DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 1d1b59bf3f5..3bdc0e2ed81 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount numeric(24,8) NOT NULL, + amount real NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 448b3846d71..04b6e1ebf5e 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 7c88a74de07..20440b692d7 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital numeric(24,8), -- capital de la societe + capital real, -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index d2a7b67c835..9abf63d6ad9 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount numeric(24,8) NOT NULL DEFAULT 0, + amount real NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From f0e234eef2e2fbc9c2425bdc7311d64f0768a1f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 17:01:43 +0200 Subject: [PATCH 02/10] Fix: missing hookmanager init --- htdocs/admin/defaultvalues.php | 6 +++++- htdocs/admin/modules.php | 36 ++++++++++++++++++++++------------ htdocs/admin/translation.php | 7 +++++-- htdocs/user/group/index.php | 2 +- htdocs/user/perms.php | 12 ++++++------ 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 94682cd502f..53c22353b92 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * 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 @@ -60,6 +61,9 @@ $urlpage = GETPOST('urlpage'); $key = GETPOST('key'); $value = GETPOST('value'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admindefaultvalues','globaladmin')); + /* * Actions diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..1aebae10947 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1,12 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud * * 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 @@ -75,11 +75,18 @@ if ($search_version) $param.='&search_version='.urlencode($search_version); $dirins=DOL_DOCUMENT_ROOT.'/custom'; $urldolibarrmodules='https://www.dolistore.com/'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('adminmodules','globaladmin')); + /* * Actions */ +$parameters=array(); +$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 (GETPOST('buttonreset')) { $search_keyword=''; @@ -204,7 +211,7 @@ if ($action == 'set' && $user->admin) setEventMessages($msg, null, 'warnings'); } } - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -212,7 +219,7 @@ if ($action == 'reset' && $user->admin) { $result=unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -474,10 +481,13 @@ if ($mode == 'common') print $hookmanager->resPrint; } + $moreforfilter=''; print '

'; - $moreforfilter=''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Show list of modules @@ -657,7 +667,7 @@ if ($mode == 'common') } else { - print ''; + print ''; print img_picto($langs->trans("Activated"),'switch_on'); print ''; } @@ -749,7 +759,7 @@ if ($mode == 'common') } } print ''."\n"; - print ''; print img_picto($langs->trans("Disabled"),'switch_off'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 8a6c38ffe46..be48bd0c8f4 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2007-2016 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin * * 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 @@ -56,6 +56,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='lang,transkey'; if (! $sortorder) $sortorder='ASC'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admintranslation','globaladmin')); + /* * Actions diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 06e11caced9..e8d37801998 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -203,7 +203,7 @@ if ($resql) print ''; print "\n"; - $db->free(); + $db->free($resql); } else { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 5d87232c928..6f89e49af5e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -1,10 +1,10 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2012 Juanjo Menent +/* Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * 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 From 5320ebc0515e865553004f2febe718b3a46b9620 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:16:52 +0200 Subject: [PATCH 03/10] getTotalWeightVolume : add conversion Lb & oz to KG New conversion value : Oz once Little az a wizzard... --- htdocs/core/class/commonobject.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3ac7cb6ffb3..bd5d8a6b831 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3097,9 +3097,18 @@ abstract class CommonObject $trueWeightUnit=pow(10, $weightUnit); $totalWeight += $weight * $qty * $trueWeightUnit; } - else - { - $totalWeight += $weight * $qty; // This may be wrong if we mix different units + else { + if ($weight_units == 99) { + // conversion 1 Livre = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 once = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else + $totalWeight += $weight * $qty; // This may be wrong if we mix different units } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { From e98bc90489b8c9085904ffc7762cd0b63e48ada8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:18:59 +0200 Subject: [PATCH 04/10] introduce OZ : once weight --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 01064c8ffa3..1dbfbc7662f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -307,7 +307,7 @@ class FormProduct $return=''; $measuring_units=array(); - if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,99=>1); + if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1); else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3 From 17247c64f0fbe50c0720e5c13c70965892ae18e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:26:01 +0200 Subject: [PATCH 05/10] add WeightUnitonce --- htdocs/core/lib/product.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 5aec64f3ce0..16bedc4d346 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,8 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') { From f0bc72cda4aa3864dcfaba252537a3005027bad8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:27:00 +0200 Subject: [PATCH 06/10] WeightUnitonce translation --- htdocs/langs/en_US/other.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..120b1dcd790 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,6 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound +WeightUnitonce=once Length=Length LengthUnitm=m LengthUnitdm=dm From 12cab2dfe08695f75199afb84779c84b897101e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:03 +0200 Subject: [PATCH 07/10] Once to Ounce --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 16bedc4d346..7048b8570c6 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,7 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') From db173632674e7fd6ae22c0965ae8e9361b607502 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:37 +0200 Subject: [PATCH 08/10] Update other.lang --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 120b1dcd790..bf01ba734f3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,7 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound -WeightUnitonce=once +WeightUnitounce=ounce Length=Length LengthUnitm=m LengthUnitdm=dm From fcdf68db6a1175f2faa5e9a95afef05398c29fb5 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:31:54 +0200 Subject: [PATCH 09/10] Update commonobject.class.php --- 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 bd5d8a6b831..b87b3d28ea8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3099,11 +3099,11 @@ abstract class CommonObject } else { if ($weight_units == 99) { - // conversion 1 Livre = 0.45359237 KG + // conversion 1 Pound = 0.45359237 KG $trueWeightUnit = 0.45359237; $totalWeight += $weight * $qty * $trueWeightUnit; } elseif ($weight_units == 98) { - // conversion 1 once = 0.0283495 KG + // conversion 1 Ounce = 0.0283495 KG $trueWeightUnit = 0.0283495; $totalWeight += $weight * $qty * $trueWeightUnit; } From 04821376200381ef232947147b8063bf189c2f9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 18:03:53 +0200 Subject: [PATCH 10/10] Fix warning --- htdocs/install/inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index dc7e29b19f5..b9efc4eb8a4 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -385,12 +385,12 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='',$css // We force the content charset header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -453,7 +453,7 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0) print '
'; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'

'; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'

'; } print '"';