From e1ae97e66123b1565eb2769d98f199526ac7e2b3 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 4 Jul 2017 10:34:59 +0200 Subject: [PATCH 1/4] Fix return method --- htdocs/contrat/class/contrat.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a1696c749f8..f1c0f1343b7 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -228,7 +228,7 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); } @@ -243,7 +243,7 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); } From a072b23a5e5df764de2a2e08d874d59b25bf3ce6 Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 6 Jul 2017 00:47:26 +0200 Subject: [PATCH 2/4] FIX #7075 : bad path for document --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index bc3c0822207..b46b9fde5cd 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -878,7 +878,7 @@ if (empty($reshook)) } // Actions to build doc - $upload_dir = $conf->commande->dir_output; + $upload_dir = $conf->fournisseur->dir_output.'/commande'; $permissioncreate = $user->rights->fournisseur->commande->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; From a6f1e08c194e7b8f3b3ebf191eaa0f10c57ad7bb Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 7 Jul 2017 11:46:19 +0200 Subject: [PATCH 3/4] FIX : we have to check if contact doesn't already exist on add_contact() function --- htdocs/core/class/commonobject.class.php | 92 ++++++++++++++---------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2d52a7ee2d1..8e9cdbfc4d5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -599,48 +599,64 @@ abstract class CommonObject } $datecreate = dol_now(); - - $this->db->begin(); - - // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; - $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; - $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; - $sql.= "'".$this->db->idate($datecreate)."'"; - $sql.= ", 4, ". $id_type_contact; - $sql.= ")"; - - $resql=$this->db->query($sql); - if ($resql) - { - if (! $notrigger) - { - $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); - if ($result < 0) + + // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error + $TListeContacts=$this->liste_contact(-1, $source); + $already_added=false; + if(!empty($TListeContacts)) { + foreach($TListeContacts as $array_contact) { + if($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) { + $already_added=true; + break; + } + } + } + + if(!$already_added) { + + $this->db->begin(); + + // Insertion dans la base + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; + $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; + $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; + $sql.= "'".$this->db->idate($datecreate)."'"; + $sql.= ", 4, ". $id_type_contact; + $sql.= ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + if (! $notrigger) { + $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + } + + $this->db->commit(); + return 1; + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $this->error=$this->db->errno(); + $this->db->rollback(); + echo 'err rollback'; + return -2; + } + else + { + $this->error=$this->db->error(); $this->db->rollback(); return -1; } - } - - $this->db->commit(); - return 1; - } - else - { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$this->db->errno(); - $this->db->rollback(); - return -2; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + } + } else return 0; } /** From bd0dba6439d57508ff8f4a14cd7ead54e735b88e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jul 2017 20:14:47 +0200 Subject: [PATCH 4/4] Update card.php Better fix for future --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index b46b9fde5cd..bbc91bc3871 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -878,7 +878,7 @@ if (empty($reshook)) } // Actions to build doc - $upload_dir = $conf->fournisseur->dir_output.'/commande'; + $upload_dir = $conf->fournisseur->commande->dir_output; $permissioncreate = $user->rights->fournisseur->commande->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';