From be79c06c728e3051063a780d5f14b1e46a743561 Mon Sep 17 00:00:00 2001 From: fhenry Date: Sun, 4 Nov 2012 15:21:08 +0100 Subject: [PATCH 1/6] Set unique key index unique in db (Conform to SQL standard) and needed for migration to other SGBD --- htdocs/install/mysql/migration/3.1.0-3.2.0.sql | 9 +++++++++ htdocs/install/mysql/tables/llx_c_actioncomm.sql | 7 ++++--- htdocs/install/mysql/tables/llx_c_civilite.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_effectif.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_paiement.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_propalst.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_stcomm.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_type_fees.sql | 5 +++-- htdocs/install/mysql/tables/llx_c_typent.sql | 5 +++-- 9 files changed, 34 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index a7add395e4c..8bd69792d88 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -464,3 +464,12 @@ UPDATE llx_product SET canvas = NULL where canvas = 'service@product'; DELETE FROM llx_const WHERE __DECRYPT('name')__ = 'SOCIETE_CODECOMPTA_ADDON' AND __DECRYPT('value')__ = 'mod_codecompta_digitaria'; ALTER TABLE llx_c_barcode_type ADD UNIQUE INDEX uk_c_barcode_type(code, entity); + +ALTER TABLE llx_c_actioncomm DROP INDEX code, ADD UNIQUE uk_c_actioncomm (code); +ALTER TABLE llx_c_civilite DROP INDEX code, ADD UNIQUE uk_c_civilite (code); +ALTER TABLE llx_c_propalst DROP INDEX code, ADD UNIQUE uk_c_propalst (code); +ALTER TABLE llx_c_stcomm DROP INDEX code, ADD UNIQUE uk_c_stcomm (code); +ALTER TABLE llx_c_type_fees DROP INDEX code, ADD UNIQUE uk_c_type_fees (code); +ALTER TABLE llx_c_typent DROP INDEX code, ADD UNIQUE uk_c_typent (code); +ALTER TABLE llx_c_effectif DROP INDEX code, ADD UNIQUE uk_c_effectif (code); +ALTER TABLE llx_c_paiement DROP INDEX code, ADD UNIQUE uk_c_paiement (code); diff --git a/htdocs/install/mysql/tables/llx_c_actioncomm.sql b/htdocs/install/mysql/tables/llx_c_actioncomm.sql index 89ca529045e..a5b96b4ea10 100644 --- a/htdocs/install/mysql/tables/llx_c_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_c_actioncomm.sql @@ -20,11 +20,12 @@ create table llx_c_actioncomm ( id integer PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, type varchar(10) DEFAULT 'system' NOT NULL, libelle varchar(48) NOT NULL, - module varchar(16) DEFAULT NULL, + module varchar(16) DEFAULT NULL, active tinyint DEFAULT 1 NOT NULL, todo tinyint, - position integer NOT NULL DEFAULT 0 + position integer NOT NULL DEFAULT 0, + UNIQUE KEY uk_c_actioncomm (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_civilite.sql b/htdocs/install/mysql/tables/llx_c_civilite.sql index f3dfd71f66b..65d6542cc5a 100644 --- a/htdocs/install/mysql/tables/llx_c_civilite.sql +++ b/htdocs/install/mysql/tables/llx_c_civilite.sql @@ -20,9 +20,10 @@ create table llx_c_civilite ( rowid integer PRIMARY KEY, - code varchar(6) UNIQUE NOT NULL, + code varchar(6) NOT NULL, civilite varchar(50), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + module varchar(32) NULL, + UNIQUE KEY uk_c_civilite (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_effectif.sql b/htdocs/install/mysql/tables/llx_c_effectif.sql index 879507c1de7..ca3c64e710c 100644 --- a/htdocs/install/mysql/tables/llx_c_effectif.sql +++ b/htdocs/install/mysql/tables/llx_c_effectif.sql @@ -20,9 +20,10 @@ create table llx_c_effectif ( id integer PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + module varchar(32) NULL, + UNIQUE KEY uk_c_effectif (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 256308dcdea..5097d60f89e 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -27,11 +27,12 @@ create table llx_c_paiement ( id integer PRIMARY KEY, - code varchar(6) UNIQUE NOT NULL, + code varchar(6) NOT NULL, libelle varchar(30), type smallint, active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + module varchar(32) NULL, + UNIQUE KEY uk_c_paiement (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_propalst.sql b/htdocs/install/mysql/tables/llx_c_propalst.sql index 478176ea00f..64b34f3c9ad 100644 --- a/htdocs/install/mysql/tables/llx_c_propalst.sql +++ b/htdocs/install/mysql/tables/llx_c_propalst.sql @@ -20,8 +20,9 @@ create table llx_c_propalst ( id smallint PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, label varchar(30), - active tinyint DEFAULT 1 NOT NULL + active tinyint DEFAULT 1 NOT NULL, + UNIQUE KEY uk_c_propalst (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_stcomm.sql b/htdocs/install/mysql/tables/llx_c_stcomm.sql index 681ac2fc338..13616b8872b 100644 --- a/htdocs/install/mysql/tables/llx_c_stcomm.sql +++ b/htdocs/install/mysql/tables/llx_c_stcomm.sql @@ -20,8 +20,9 @@ create table llx_c_stcomm ( id integer PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, libelle varchar(30), - active tinyint default 1 NOT NULL + active tinyint default 1 NOT NULL, + UNIQUE KEY uk_c_stcomm (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_type_fees.sql b/htdocs/install/mysql/tables/llx_c_type_fees.sql index 1a40dff1016..f2154f475c6 100644 --- a/htdocs/install/mysql/tables/llx_c_type_fees.sql +++ b/htdocs/install/mysql/tables/llx_c_type_fees.sql @@ -20,8 +20,9 @@ create table llx_c_type_fees ( id integer AUTO_INCREMENT PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + module varchar(32) NULL, + UNIQUE KEY uk_c_type_fees (code) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_typent.sql b/htdocs/install/mysql/tables/llx_c_typent.sql index 151fab64de9..66c3c10bd41 100644 --- a/htdocs/install/mysql/tables/llx_c_typent.sql +++ b/htdocs/install/mysql/tables/llx_c_typent.sql @@ -20,8 +20,9 @@ create table llx_c_typent ( id integer PRIMARY KEY, - code varchar(12) UNIQUE NOT NULL, + code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + module varchar(32) NULL, + UNIQUE KEY uk_c_typent (code) )ENGINE=innodb; From 1f41547dc24ae578765e70a5e4cffbd441d2235a Mon Sep 17 00:00:00 2001 From: fhenry Date: Sun, 4 Nov 2012 15:55:12 +0100 Subject: [PATCH 2/6] Set unique key index unique in db (Conform to SQL standard) and needed for migration to other SGBD with key.sql file --- .../install/mysql/migration/3.1.0-3.2.0.sql | 9 -------- .../install/mysql/migration/3.2.0-3.3.0.sql | 11 ++++++++++ .../mysql/tables/llx_c_actioncomm.key.sql | 21 +++++++++++++++++++ .../install/mysql/tables/llx_c_actioncomm.sql | 4 ++-- .../mysql/tables/llx_c_civilite.key.sql | 19 +++++++++++++++++ .../install/mysql/tables/llx_c_civilite.sql | 3 +-- .../mysql/tables/llx_c_effectif.key.sql | 19 +++++++++++++++++ .../install/mysql/tables/llx_c_effectif.sql | 3 +-- .../mysql/tables/llx_c_paiement.key.sql | 19 +++++++++++++++++ .../install/mysql/tables/llx_c_paiement.sql | 3 +-- .../mysql/tables/llx_c_propalst.key.sql | 19 +++++++++++++++++ .../install/mysql/tables/llx_c_propalst.sql | 3 +-- .../install/mysql/tables/llx_c_stcomm.key.sql | 19 +++++++++++++++++ htdocs/install/mysql/tables/llx_c_stcomm.sql | 3 +-- .../mysql/tables/llx_c_type_fees.key.sql | 19 +++++++++++++++++ .../install/mysql/tables/llx_c_type_fees.sql | 3 +-- .../install/mysql/tables/llx_c_typent.key.sql | 19 +++++++++++++++++ htdocs/install/mysql/tables/llx_c_typent.sql | 3 +-- 18 files changed, 174 insertions(+), 25 deletions(-) create mode 100755 htdocs/install/mysql/tables/llx_c_actioncomm.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_civilite.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_effectif.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_paiement.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_propalst.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_stcomm.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_type_fees.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_typent.key.sql diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index 8bd69792d88..a7add395e4c 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -464,12 +464,3 @@ UPDATE llx_product SET canvas = NULL where canvas = 'service@product'; DELETE FROM llx_const WHERE __DECRYPT('name')__ = 'SOCIETE_CODECOMPTA_ADDON' AND __DECRYPT('value')__ = 'mod_codecompta_digitaria'; ALTER TABLE llx_c_barcode_type ADD UNIQUE INDEX uk_c_barcode_type(code, entity); - -ALTER TABLE llx_c_actioncomm DROP INDEX code, ADD UNIQUE uk_c_actioncomm (code); -ALTER TABLE llx_c_civilite DROP INDEX code, ADD UNIQUE uk_c_civilite (code); -ALTER TABLE llx_c_propalst DROP INDEX code, ADD UNIQUE uk_c_propalst (code); -ALTER TABLE llx_c_stcomm DROP INDEX code, ADD UNIQUE uk_c_stcomm (code); -ALTER TABLE llx_c_type_fees DROP INDEX code, ADD UNIQUE uk_c_type_fees (code); -ALTER TABLE llx_c_typent DROP INDEX code, ADD UNIQUE uk_c_typent (code); -ALTER TABLE llx_c_effectif DROP INDEX code, ADD UNIQUE uk_c_effectif (code); -ALTER TABLE llx_c_paiement DROP INDEX code, ADD UNIQUE uk_c_paiement (code); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index a4ccf505059..57ed77a5126 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -790,3 +790,14 @@ ALTER TABLE llx_categorie MODIFY COLUMN label varchar(255) NOT NULL; ALTER TABLE llx_categorie ADD UNIQUE INDEX uk_categorie_ref (entity, fk_parent, label, type); ALTER TABLE llx_categorie ADD INDEX idx_categorie_type (type); ALTER TABLE llx_categorie ADD INDEX idx_categorie_label (label); + +-- Change index name to be compliant with SQL standard, index name must be unique in database schema +ALTER TABLE llx_c_actioncomm DROP INDEX code, ADD UNIQUE uk_c_actioncomm (code); +ALTER TABLE llx_c_civilite DROP INDEX code, ADD UNIQUE uk_c_civilite (code); +ALTER TABLE llx_c_propalst DROP INDEX code, ADD UNIQUE uk_c_propalst (code); +ALTER TABLE llx_c_stcomm DROP INDEX code, ADD UNIQUE uk_c_stcomm (code); +ALTER TABLE llx_c_type_fees DROP INDEX code, ADD UNIQUE uk_c_type_fees (code); +ALTER TABLE llx_c_typent DROP INDEX code, ADD UNIQUE uk_c_typent (code); +ALTER TABLE llx_c_effectif DROP INDEX code, ADD UNIQUE uk_c_effectif (code); +ALTER TABLE llx_c_paiement DROP INDEX code, ADD UNIQUE uk_c_paiement (code); + diff --git a/htdocs/install/mysql/tables/llx_c_actioncomm.key.sql b/htdocs/install/mysql/tables/llx_c_actioncomm.key.sql new file mode 100755 index 00000000000..b2ac7ad3662 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_actioncomm.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2004-2005 Rodolphe Quiedeville +-- Copyright (C) 2005-2009 Laurent Destailleur +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_actioncomm ADD UNIQUE INDEX uk_c_actioncomm(code); diff --git a/htdocs/install/mysql/tables/llx_c_actioncomm.sql b/htdocs/install/mysql/tables/llx_c_actioncomm.sql index a5b96b4ea10..6cf9653e5f1 100644 --- a/htdocs/install/mysql/tables/llx_c_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_c_actioncomm.sql @@ -1,6 +1,7 @@ -- ======================================================================== -- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville -- Copyright (C) 2004-2010 Laurent Destailleur +-- Copyright (C) 2012 Florian Henry -- -- 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 @@ -26,6 +27,5 @@ create table llx_c_actioncomm module varchar(16) DEFAULT NULL, active tinyint DEFAULT 1 NOT NULL, todo tinyint, - position integer NOT NULL DEFAULT 0, - UNIQUE KEY uk_c_actioncomm (code) + position integer NOT NULL DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_civilite.key.sql b/htdocs/install/mysql/tables/llx_c_civilite.key.sql new file mode 100644 index 00000000000..dac2f39e437 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_civilite.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_civilite ADD UNIQUE INDEX uk_c_civilite(code); diff --git a/htdocs/install/mysql/tables/llx_c_civilite.sql b/htdocs/install/mysql/tables/llx_c_civilite.sql index 65d6542cc5a..18fdad2ca94 100644 --- a/htdocs/install/mysql/tables/llx_c_civilite.sql +++ b/htdocs/install/mysql/tables/llx_c_civilite.sql @@ -23,7 +23,6 @@ create table llx_c_civilite code varchar(6) NOT NULL, civilite varchar(50), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL, - UNIQUE KEY uk_c_civilite (code) + module varchar(32) NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_effectif.key.sql b/htdocs/install/mysql/tables/llx_c_effectif.key.sql new file mode 100644 index 00000000000..426ce9f4d0c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_effectif.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_effectif ADD UNIQUE INDEX uk_c_effectif(code); diff --git a/htdocs/install/mysql/tables/llx_c_effectif.sql b/htdocs/install/mysql/tables/llx_c_effectif.sql index ca3c64e710c..34ff9abd68d 100644 --- a/htdocs/install/mysql/tables/llx_c_effectif.sql +++ b/htdocs/install/mysql/tables/llx_c_effectif.sql @@ -23,7 +23,6 @@ create table llx_c_effectif code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL, - UNIQUE KEY uk_c_effectif (code) + module varchar(32) NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_paiement.key.sql b/htdocs/install/mysql/tables/llx_c_paiement.key.sql new file mode 100644 index 00000000000..662843c4a60 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_paiement.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_paiement ADD UNIQUE INDEX uk_c_paiement(code); diff --git a/htdocs/install/mysql/tables/llx_c_paiement.sql b/htdocs/install/mysql/tables/llx_c_paiement.sql index 5097d60f89e..5579db2a32a 100644 --- a/htdocs/install/mysql/tables/llx_c_paiement.sql +++ b/htdocs/install/mysql/tables/llx_c_paiement.sql @@ -31,8 +31,7 @@ create table llx_c_paiement libelle varchar(30), type smallint, active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL, - UNIQUE KEY uk_c_paiement (code) + module varchar(32) NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_propalst.key.sql b/htdocs/install/mysql/tables/llx_c_propalst.key.sql new file mode 100644 index 00000000000..5336f57b7d2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_propalst.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_propalst ADD UNIQUE INDEX uk_c_propalst(code); diff --git a/htdocs/install/mysql/tables/llx_c_propalst.sql b/htdocs/install/mysql/tables/llx_c_propalst.sql index 64b34f3c9ad..3c11aad7285 100644 --- a/htdocs/install/mysql/tables/llx_c_propalst.sql +++ b/htdocs/install/mysql/tables/llx_c_propalst.sql @@ -22,7 +22,6 @@ create table llx_c_propalst id smallint PRIMARY KEY, code varchar(12) NOT NULL, label varchar(30), - active tinyint DEFAULT 1 NOT NULL, - UNIQUE KEY uk_c_propalst (code) + active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_stcomm.key.sql b/htdocs/install/mysql/tables/llx_c_stcomm.key.sql new file mode 100644 index 00000000000..54b688bdb4f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_stcomm.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_stcomm ADD UNIQUE INDEX uk_c_stcomm(code); diff --git a/htdocs/install/mysql/tables/llx_c_stcomm.sql b/htdocs/install/mysql/tables/llx_c_stcomm.sql index 13616b8872b..8134eedea9d 100644 --- a/htdocs/install/mysql/tables/llx_c_stcomm.sql +++ b/htdocs/install/mysql/tables/llx_c_stcomm.sql @@ -22,7 +22,6 @@ create table llx_c_stcomm id integer PRIMARY KEY, code varchar(12) NOT NULL, libelle varchar(30), - active tinyint default 1 NOT NULL, - UNIQUE KEY uk_c_stcomm (code) + active tinyint default 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_type_fees.key.sql b/htdocs/install/mysql/tables/llx_c_type_fees.key.sql new file mode 100644 index 00000000000..2cb14835bad --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_fees.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_type_fees ADD UNIQUE INDEX uk_c_type_fees(code); diff --git a/htdocs/install/mysql/tables/llx_c_type_fees.sql b/htdocs/install/mysql/tables/llx_c_type_fees.sql index f2154f475c6..6a70a6dce8f 100644 --- a/htdocs/install/mysql/tables/llx_c_type_fees.sql +++ b/htdocs/install/mysql/tables/llx_c_type_fees.sql @@ -23,6 +23,5 @@ create table llx_c_type_fees code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL, - UNIQUE KEY uk_c_type_fees (code) + module varchar(32) NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_typent.key.sql b/htdocs/install/mysql/tables/llx_c_typent.key.sql new file mode 100644 index 00000000000..ac412c25d2e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_typent.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2012 Florian Henry +-- +-- 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 2 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_typent ADD UNIQUE INDEX uk_c_typent(code); diff --git a/htdocs/install/mysql/tables/llx_c_typent.sql b/htdocs/install/mysql/tables/llx_c_typent.sql index 66c3c10bd41..4fb1c3c6cec 100644 --- a/htdocs/install/mysql/tables/llx_c_typent.sql +++ b/htdocs/install/mysql/tables/llx_c_typent.sql @@ -23,6 +23,5 @@ create table llx_c_typent code varchar(12) NOT NULL, libelle varchar(30), active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL, - UNIQUE KEY uk_c_typent (code) + module varchar(32) NULL )ENGINE=innodb; From bebead8e54aa308abb621624624f3d6fe5834cd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Nov 2012 19:32:14 +0100 Subject: [PATCH 3/6] Fix: To fix database integrity problems (I didn't find how orphelins appears, but they appears on some plateform). --- htdocs/install/mysql/migration/repair.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index ac4d6f4d0a8..96b5da7d357 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -18,6 +18,10 @@ delete from llx_commandedet where fk_commande in (select rowid from llx_commande delete from llx_commande where ref = ''; delete from llx_propaldet where fk_propal in (select rowid from llx_propal where ref = ''); delete from llx_propal where ref = ''; +delete from llx_livraisondet where fk_livraison in (select rowid from llx_livraison where ref = ''); +delete from llx_livraison where ref = ''; +delete from llx_expeditiondet where fk_expedition in (select rowid from llx_expedition where ref = ''); +delete from llx_expedition where ref = ''; update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; @@ -46,15 +50,18 @@ delete from llx_product_extrafields where fk_object not in (select rowid from ll --delete from llx_societe_commerciaux where fk_soc not in (select rowid from llx_societe); +-- Fix: delete orphelin deliveries. Note: deliveries are linked to shipment by llx_element_element only. No other links. +delete from llx_livraisondet where fk_livraison not in (select fk_target from llx_element_element where targettype = 'delivery') AND fk_livraison not in (select fk_source from llx_element_element where sourcetype = 'delivery'); +delete from llx_livraison where rowid not in (select fk_target from llx_element_element where targettype = 'delivery') AND rowid not in (select fk_source from llx_element_element where sourcetype = 'delivery'); + + UPDATE llx_product SET canvas = NULL where canvas = 'default@product'; UPDATE llx_product SET canvas = NULL where canvas = 'service@product'; - DELETE FROM llx_boxes where box_id NOT IN (SELECT rowid FROM llx_boxes_def); DELETE FROM llx_document_model WHERE nom ='elevement' AND type='delivery'; - -- Fix: It seems this is missing for some users insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 1, 'AC_TEL', 'system', 'Phone call' ,NULL, 2); insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 2, 'AC_FAX', 'system', 'Send Fax' ,NULL, 3); From 88968039219ef84dbcbe10abdb3d8e477ec64676 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Nov 2012 21:19:12 +0100 Subject: [PATCH 4/6] New: We can use a dynamic value ($conf->global->XXX for example) into titles of menus. New: Can choose menu entry to show with external site module. --- ChangeLog | 2 + htdocs/core/class/translate.class.php | 21 ++++++----- htdocs/core/lib/functions.lib.php | 12 +++--- htdocs/core/modules/modExternalSite.class.php | 37 +++++++++++-------- htdocs/externalsite/admin/externalsite.php | 32 ++++++++++------ htdocs/langs/en_US/admin.lang | 2 +- 6 files changed, 62 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index f72d5f3e5a4..460e2dc73ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -57,6 +57,7 @@ For users: - New: Added ODT Template tag {object_total_discount} - New: Add new import options: Third parties bank details, warehouses and stocks, categories and suppliers prices - New: English bank account need a bank code (called sort code) to identify an account. +- New: Can choose menu entry to show with external site module. - New: Add hidden option MAIN_PDF_MARGIN_LEFT, MAIN_PDF_MARGIN_RIGHT, MAIN_PDF_MARGIN_TOP, MAIN_PDF_MARGIN_BOTTOM to force margins of generated PDF. New experimental modules: @@ -87,6 +88,7 @@ For developers: - New: Add ChromePHP output into syslog module. - New: Add PRODUCT_PRICE_MODIFY trigger. - New: Created function to retrieve total amount of discount of an invoice/proposal... +- New: We can use a dynamic value ($conf->global->XXX for example) into titles of menus. For translators: - New: Update language files (de, tr, pt, ca, es, en, fr). diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index c42b220bd98..d454cc3d005 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -152,7 +152,7 @@ class Translate * @param string $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US or fr_FR or es_ES) * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) * @param int $forcelangdir To force a different lang directory - * @return int <0 if KO, 0 if already loaded, >0 if OK + * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ function Load($domain,$alt=0,$stopafterdirection=0,$forcelangdir='') { @@ -164,7 +164,7 @@ class Translate dol_print_error('',get_class($this)."::Load ErrorWrongParameters"); exit; } - if ($this->defaultlang == 'none_NONE') return; // Special language code to not translate keys + if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); @@ -388,7 +388,7 @@ class Translate { $str=$this->tab_translate[$key]; - // Overwrite translation + // Overwrite translation (TODO Move this at a higher level when we load tab_translate to avoid doing it for each trans call) $overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 { @@ -399,7 +399,7 @@ class Translate if ($tmparray2[0]==$key) { $str=$tmparray2[1]; break; } } } - + if (! preg_match('/^Format/',$key)) $str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings. if ($maxsize) $str=dol_trunc($str,$maxsize); @@ -417,8 +417,7 @@ class Translate } else // Translation is not available { - //$str=$this->getTradFromKey($key); - //return $this->convToOutputCharset($str); + if ($key[0] == '$') { return dol_eval($key,1); } return $this->getTradFromKey($key); } } @@ -460,7 +459,7 @@ class Translate function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='') { global $conf; - + if (! empty($this->tab_translate[$key])) // Translation is available { $str=$this->tab_translate[$key]; @@ -476,14 +475,16 @@ class Translate if ($tmparray2[0]==$key) { $str=$tmparray2[1]; break; } } } - + if (! preg_match('/^Format/',$key)) $str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings. + + return $str; } else { - $str=$this->getTradFromKey($key); + if ($key[0] == '$') { return dol_eval($key,1); } + return $this->getTradFromKey($key); } - return $str; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0e4ca0113bb..4422e6d6453 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3874,12 +3874,13 @@ function verifCond($strRights) /** * Replace eval function to add more security. - * This function is called by verifCond() + * This function is called by verifCond() or trans() and transnoentitiesnoconv(). * - * @param string $s String to evaluate - * @return mixed Result of eval + * @param string $s String to evaluate + * @param int $returnvalue 0=No return (used to execute $a=something). 1=Value of eval is returned (used to eval $something). + * @return mixed Nothing or return of eval */ -function dol_eval($s) +function dol_eval($s,$returnvalue=0) { // Only global variables can be changed by eval function and returned to caller global $langs, $user, $conf; @@ -3887,7 +3888,8 @@ function dol_eval($s) global $rights; //print $s."
\n"; - eval($s); + if ($returnvalue) return eval('return '.$s.';'); + else eval($s); } /** diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index da66f18c2cb..cc0fa60c35a 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ class modExternalSite extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) - $this->description = "Include any external web site into Dolibarr menus and view it into a Dolibarr frame."; + $this->description = "This module include an external web site or page into Dolibarr menus and view it into a Dolibarr frame."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) @@ -63,7 +63,7 @@ class modExternalSite extends DolibarrModules // Name of png file (without png) used for this module $this->picto='bookmark'; // Call to inside lang's file - $this->langfiles = array("@externalsite"); + $this->langfiles = array("externalsite"); // Data directories to create when module is enabled $this->dirs = array(); @@ -76,7 +76,11 @@ class modExternalSite extends DolibarrModules $this->requiredby = array(); // List of modules id to disable if this one is disabled // Constants - $this->const = array(); // List of parameters + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) + // ); + $this->const = array(0=>array('EXTERNALSITE_LABEL','chaine','ExternalSite','To declare label to use into external site menu entry', 0)); // Boxes $this->boxes = array(); // List of boxes @@ -97,18 +101,19 @@ class modExternalSite extends DolibarrModules //------ $r=0; - $this->menu[$r]=array('fk_menu'=>0, - 'type'=>'top', - 'titre'=>'ExternalSites', - 'mainmenu'=>'externalsite', - 'url'=>'/externalsite/frames.php', - 'langs'=>'other', - 'position'=>100, - 'perms'=>'', - 'enabled'=>'$conf->externalsite->enabled', - 'target'=>'', - 'user'=>0 - ); + $this->menu[$r]=array( + 'fk_menu'=>0, + 'type'=>'top', + 'titre'=>'$conf->global->EXTERNALSITE_LABEL', + 'mainmenu'=>'externalsite', + 'url'=>'/externalsite/frames.php', + 'langs'=>'other', + 'position'=>100, + 'perms'=>'', + 'enabled'=>'$conf->externalsite->enabled', + 'target'=>'', + 'user'=>0 + ); $r++; } diff --git a/htdocs/externalsite/admin/externalsite.php b/htdocs/externalsite/admin/externalsite.php index 59a98ded0a2..dd212fdd63f 100644 --- a/htdocs/externalsite/admin/externalsite.php +++ b/htdocs/externalsite/admin/externalsite.php @@ -48,13 +48,15 @@ if ($action == 'update') $i=0; $db->begin(); - + + $label = GETPOST('EXTERNALSITE_LABEL','alpha'); $exturl = GETPOST('EXTERNALSITE_URL','alpha'); + $i+=dolibarr_set_const($db,'EXTERNALSITE_LABEL',trim($label),'chaine',0,'',$conf->entity); $i+=dolibarr_set_const($db,'EXTERNALSITE_URL',trim($exturl),'chaine',0,'',$conf->entity); //$i+=dolibarr_set_const($db,'EXTERNALSITE_LABEL',trim($_POST["EXTERNALSITE_LABEL"]),'chaine',0,'',$conf->entity); - if ($i >= 1) + if ($i >= 2) { $db->commit(); $mesg = "".$langs->trans("SetupSaved").""; @@ -75,8 +77,9 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("ExternalSiteSetup"),$linkback,'setup'); -print '
'; +print $langs->trans("Module100Desc")."
\n"; +print '
'; print '
'; print ''; @@ -89,17 +92,21 @@ print "".$langs->trans("Value").""; print "".$langs->trans("Examples").""; print ""; -/*print ""; -print "".$langs->trans("Label").""; -print "global->EXTERNALSITE_LABEL) . "\" size=\"40\">"; -print "My menu"; +$var=true; + +$var=!$var; +print ""; +print ''.$langs->trans("Label").""; +print "global->EXTERNALSITE_LABEL) || $conf->global->EXTERNALSITE_LABEL=='ExternalSite')?'':$conf->global->EXTERNALSITE_LABEL)) . "\" size=\"12\">"; +print "http://localhost/myurl/"; +print "
http://wikipedia.org/"; print ""; print ""; -*/ -print ""; -print "".$langs->trans("ExternalSiteURL").""; -print "global->EXTERNALSITE_URL) . "\" size=\"40\">"; +$var=!$var; +print ""; +print ''.$langs->trans("ExternalSiteURL").""; +print "global->EXTERNALSITE_URL)?'':$conf->global->EXTERNALSITE_URL)) . "\" size=\"40\">"; print "http://localhost/myurl/"; print "
http://wikipedia.org/"; print ""; @@ -117,7 +124,8 @@ print "
\n"; dol_htmloutput_mesg($mesg); -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 96985683d62..84a59052629 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -400,7 +400,7 @@ Module80Desc=Shipments and delivery order management Module85Name=Banks and cash Module85Desc=Management of bank or cash accounts Module100Name=External site -Module100Desc=Include any external web site into Dolibarr menus and view it into a Dolibarr frame +Module100Desc=This module include an external web site or page into Dolibarr menus and view it into a Dolibarr frame Module105Name=Mailman and SPIP Module105Desc=Mailman or SPIP interface for member module Module200Name=LDAP From 5d57677814eef50960d1bd80c7ab3b2ee5dc21be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Nov 2012 21:20:27 +0100 Subject: [PATCH 5/6] Fix: example --- htdocs/externalsite/admin/externalsite.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/externalsite/admin/externalsite.php b/htdocs/externalsite/admin/externalsite.php index dd212fdd63f..830d191bc82 100644 --- a/htdocs/externalsite/admin/externalsite.php +++ b/htdocs/externalsite/admin/externalsite.php @@ -98,9 +98,7 @@ $var=!$var; print ""; print ''.$langs->trans("Label").""; print "global->EXTERNALSITE_LABEL) || $conf->global->EXTERNALSITE_LABEL=='ExternalSite')?'':$conf->global->EXTERNALSITE_LABEL)) . "\" size=\"12\">"; -print "http://localhost/myurl/"; -print "
http://wikipedia.org/"; -print ""; +print "My menu entry"; print ""; $var=!$var; From 027ad065a53296a9744327c198f9b698a7fa5d85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Nov 2012 12:04:13 +0100 Subject: [PATCH 6/6] Removed TODO --- htdocs/fourn/facture/fiche.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index dfe8095d0e9..6218400d7ce 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1471,16 +1471,15 @@ else print ''.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).''; // Amount Local Taxes - // TODO I use here $societe->localtax1_assuj. Before it was $mysoc->localtax1_assuj, but this is a supplier invoice, so made by supplier, so depends on supplier properties if ($societe->localtax1_assuj=="1") //Localtax1 RE { - print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).''; + print ''.$langs->transcountry("AmountLT1",$societe->country_code).''; print ''.price($object->total_localtax1).''; print ''.$langs->trans("Currency".$conf->currency).''; } if ($societe->localtax2_assuj=="1") //Localtax2 IRPF { - print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).''; + print ''.$langs->transcountry("AmountLT2",$societe->country_code).''; print ''.price($object->total_localtax2).''; print ''.$langs->trans("Currency".$conf->currency).''; }