diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 895fb425c05..b8c6cb63687 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -228,7 +228,7 @@ class ActionComm extends CommonObject } else if ($reshook < 0) $error++; - if (! $notrigger) + if (! $error && ! $notrigger) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -240,8 +240,16 @@ class ActionComm extends CommonObject // Fin appel triggers } - $this->db->commit(); - return $this->id; + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } } else { @@ -591,7 +599,7 @@ class ActionComm extends CommonObject $now=dol_now(); $this->nbtodo=$this->nbtodolate=0; - + $sql = "SELECT a.id, a.datep as dp"; $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ")"; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 8342613208e..21c887d285c 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -243,19 +243,19 @@ if ($action == 'add_action') } else { - // Si erreur + // If error $db->rollback(); - $id=$idaction; $langs->load("errors"); $error=$langs->trans($actioncomm->error); + $action = 'create'; } } else { $db->rollback(); - $id=$idaction; $langs->load("errors"); $error=$langs->trans($actioncomm->error); + $action = 'create'; } } } @@ -619,7 +619,7 @@ if ($action == 'create') print $extrafields->showInputField($key,$value); print ''."\n"; } - print '

'; + print '
'; } print '

'; @@ -632,7 +632,7 @@ if ($action == 'create') } // View or edit -if ($id) +if ($id > 0) { if ($error) { 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 1f8a79372df..7b55bcd164b 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 @@ -264,9 +264,20 @@ create table llx_socpeople_extrafields fk_object integer NOT NULL, import_key varchar(14) -- import key ) ENGINE=innodb; - ALTER TABLE llx_socpeople_extrafields ADD INDEX idx_socpeople_extrafields (fk_object); +create table llx_actioncomm_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; +ALTER TABLE llx_actioncomm_extrafields ADD INDEX idx_actioncomm_extrafields (fk_object); + + + + UPDATE llx_c_actioncomm set type = 'systemauto' where code IN ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV'); diff --git a/htdocs/install/mysql/tables/llx_actioncomm_extrafields.key.sql b/htdocs/install/mysql/tables/llx_actioncomm_extrafields.key.sql new file mode 100755 index 00000000000..239084c5f6b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_actioncomm_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2011 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 +-- 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_actioncomm_extrafields ADD INDEX idx_actioncomm_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_actioncomm_extrafields.sql b/htdocs/install/mysql/tables/llx_actioncomm_extrafields.sql new file mode 100755 index 00000000000..f0e2809ab64 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_actioncomm_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2011 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 +-- 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 . +-- +-- ======================================================================== + +create table llx_actioncomm_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; +