diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 22e7bf7087f..838f76aa296 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,16 +1,16 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2011 Remy Younes - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro - * Copyright (C) 2015 Ferran Marcet - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011 Remy Younes + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2016 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 diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5113c9f1d96..454607d7dd1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -102,18 +102,21 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) /** * Get list of entity id to use. * - * @param string $element Current element - * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', - * 'product', 'productprice', 'stock', - * 'propal', 'supplier_proposal', 'facture', 'facture_fourn', - * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', - * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', - * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', - * 'email_template', 'event', - * @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only + * @param string $element Current element + * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', + * 'product', 'productprice', 'stock', + * 'propal', 'supplier_proposal', 'facture', 'facture_fourn', + * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', + * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', + * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', + * 'email_template', 'event', + * @param int $shared 0=Return id of current entity only, + * 1=Return id of current entity + shared entities (default), + * 2=Return id of current entity OR $forceentity value (eg. dictionnary share) + * @param int $forceentity Entity id * @return mixed Entity id(s) to use */ -function getEntity($element=false, $shared=1) +function getEntity($element=false, $shared=1, $forceentity=null) { global $conf, $mc; @@ -124,14 +127,23 @@ function getEntity($element=false, $shared=1) if (is_object($mc)) { - return $mc->getEntity($element, $shared); + return $mc->getEntity($element, $shared, $forceentity); } else { $out=''; - $addzero = array('user', 'usergroup', 'email_template', 'default_values'); - if (in_array($element, $addzero)) $out.= '0,'; - $out.= $conf->entity; + + if ($shared == 2) + { + $out.= $forceentity; + } + else + { + $addzero = array('user', 'usergroup', 'email_template', 'default_values'); + if (in_array($element, $addzero)) $out.= '0,'; + $out.= $conf->entity; + } + return $out; } } diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 317fb6b7ff2..db67c58e51a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -380,4 +380,12 @@ create table llx_loan_schedule fk_user_modif integer )ENGINE=innodb; -ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; \ No newline at end of file +ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; + +ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; +ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement; +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); + +ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; +ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); + diff --git a/htdocs/install/mysql/tables/llx_c_paiement.key.sql b/htdocs/install/mysql/tables/llx_c_paiement.key.sql index 0d6686a774c..8c944e0c34d 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.key.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.key.sql @@ -1,5 +1,6 @@ -- ======================================================================== --- Copyright (C) 2012 Florian Henry +-- Copyright (C) 2012 Florian Henry +-- 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 @@ -16,4 +17,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(code); +ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 1759af781f8..85e3cfb404d 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -1,7 +1,8 @@ -- ======================================================================== --- Copyright (C) 2001-2004 Rodolphe Quiedeville --- Copyright (C) 2004-2014 Laurent Destailleur --- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2004-2014 Laurent Destailleur +-- Copyright (C) 2014 Alexandre Spangaro +-- 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 @@ -21,6 +22,7 @@ create table llx_c_paiement ( id integer PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id code varchar(6) NOT NULL, libelle varchar(62), type smallint, -- 0: input money, 1: output money, 2: input and output, 3: other @@ -28,6 +30,3 @@ create table llx_c_paiement accountancy_code varchar(32) NULL, module varchar(32) NULL )ENGINE=innodb; - - - diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.key.sql b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql new file mode 100644 index 00000000000..e5977adf3cd --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_payment_term.key.sql @@ -0,0 +1,20 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- 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 +-- 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_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_payment_term.sql b/htdocs/install/mysql/tables/llx_c_payment_term.sql index a2d79af2502..6c55a6742b2 100644 --- a/htdocs/install/mysql/tables/llx_c_payment_term.sql +++ b/htdocs/install/mysql/tables/llx_c_payment_term.sql @@ -1,6 +1,7 @@ -- ============================================================================ --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2016 Laurent Destailleur +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2016 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 @@ -19,14 +20,15 @@ create table llx_c_payment_term ( - rowid integer PRIMARY KEY, - code varchar(16), - sortorder smallint, - active tinyint DEFAULT 1, - libelle varchar(255), - libelle_facture text, - type_cdr tinyint, -- Type of change date reckoning. 1=Payment at end of current month, 2=the Nth of next month - nbjour smallint, - decalage smallint, - module varchar(32) NULL + rowid integer PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + code varchar(16), + sortorder smallint, + active tinyint DEFAULT 1, + libelle varchar(255), + libelle_facture text, + type_cdr tinyint, -- Type of change date reckoning. 1=Payment at end of current month, 2=the Nth of next month + nbjour smallint, + decalage smallint, + module varchar(32) NULL )ENGINE=innodb;