From 313d9ddacdf5f59577d2560999e6dcbc74ccc8bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Sep 2015 22:04:03 +0200 Subject: [PATCH] FIX #3534 --- htdocs/admin/dict.php | 1 + htdocs/commande/card.php | 12 ++++++++---- htdocs/core/class/commonobject.class.php | 14 ++++++++++---- htdocs/core/tpl/contacts.tpl.php | 7 ++++++- htdocs/expedition/contact.php | 10 +++++----- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index f9137a06acf..17c8bcae048 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -445,6 +445,7 @@ if ($id == 11) $langs->load("interventions"); $elementList = array( '' => '', + 'societe' => $langs->trans('ThirdParty'), // 'proposal' => $langs->trans('Proposal'), // 'order' => $langs->trans('Order'), // 'invoice' => $langs->trans('Bill'), diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index bd76ec1646d..1d418ac295c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1165,8 +1165,10 @@ if (empty($reshook)) - if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) { - if ($action == 'addcontact') { + if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) + { + if ($action == 'addcontact') + { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); @@ -1186,7 +1188,8 @@ if (empty($reshook)) } // bascule du statut d'un contact - else if ($action == 'swapstatut') { + else if ($action == 'swapstatut') + { if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -1195,7 +1198,8 @@ if (empty($reshook)) } // Efface un contact - else if ($action == 'deletecontact') { + else if ($action == 'deletecontact') + { $result = $object->delete_contact($lineid); if ($result >= 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 65ece020ac8..16ebb0e77e9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -452,13 +452,15 @@ abstract class CommonObject // Check parameters if ($fk_socpeople <= 0) { - $this->error=$langs->trans("ErrorWrongValueForParameter","1"); + $langs->load("errors"); + $this->error=$langs->trans("ErrorWrongValueForParameterX","1"); dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR); return -1; } if (! $type_contact) { - $this->error=$langs->trans("ErrorWrongValueForParameter","2"); + $langs->load("errors"); + $this->error=$langs->trans("ErrorWrongValueForParameterX","2"); dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR); return -2; } @@ -486,7 +488,7 @@ abstract class CommonObject } $datecreate = dol_now(); - + $this->db->begin(); // Insertion dans la base @@ -504,7 +506,11 @@ abstract class CommonObject if (! $notrigger) { $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); - if ($result < 0) { $this->db->rollback(); return -1; } + if ($result < 0) + { + $this->db->rollback(); + return -1; + } } $this->db->commit(); diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 382abbe81c0..5abdfc124e4 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -72,7 +72,12 @@ $userstatic=new User($db);
trans("Users"); ?>
global->MAIN_INFO_SOCIETE_NOM; ?>
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?>
-
selectTypeContact($object, '', 'type','internal'); ?>
+
+ element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc; + echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal'); + ?>
 
">
diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index c09b3e415cd..039af2cd0ec 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -77,7 +77,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { if ($result > 0 && $id > 0) { - $result = $objectsrc->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]); } if ($result >= 0) @@ -87,14 +87,15 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) } else { - if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { $langs->load("errors"); $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); } else { $mesg = $objectsrc->error; + $mesgs = $objectsrc->errors; } - - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); } } @@ -236,7 +237,6 @@ if ($id > 0 || ! empty($ref)) // Lignes de contacts echo '
'; - // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir)