diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index e7c5a2a3509..1e8786cea5f 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -571,7 +571,7 @@ if ($action == 'create') if (GETPOST("contactid") > 0 || GETPOST("socid") > 0) { print ''.$langs->trans("ActionOnContact").''; - $html->select_contacts(GETPOST("socid"),GETPOST('contactid'),'contactid',1,1); + $html->select_contacts(GETPOST("socid"),GETPOST('contactid'),'contactid',1); print ''; } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 38bb0e86d7c..fec9b2e0421 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -284,8 +284,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - //$contactAlreadySelected = $propal->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 4a020bf4cdb..5455b22a395 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -281,8 +281,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index df365b6d365..61071567483 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1164,6 +1164,9 @@ if ($action == 'create' && $user->rights->commande->creer) $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1,'external',1); } } else @@ -1207,7 +1210,7 @@ if ($action == 'create' && $user->rights->commande->creer) * Contact de la commande */ print "".$langs->trans("DefaultContact").''; - $html->select_contacts($soc->id,$setcontact,'contactidp',1); + $html->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); print ''; // Ligne info remises tiers diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 64706086d08..1e6c47056a8 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -276,8 +276,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 0a427cfd24c..62709273bb4 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -279,8 +279,7 @@ if ($id > 0) print ''; print ''; - //$contactAlreadySelected = $contrat->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 73646dd9a1f..1d0420f3a09 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -261,12 +261,13 @@ class CommonObject } /** - * \brief Get array of all contacts for an object - * \param statut Status of lines to get (-1=all) - * \param source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) - * \return array Array of id of contacts + * Get array of all contacts for an object + * @param statut Status of lines to get (-1=all) + * @param source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) + * @param list 0:all, 1:just id + * @return array Array of contacts */ - function liste_contact($statut=-1,$source='external') + function liste_contact($statut=-1,$source='external',$list=0) { global $langs; @@ -300,12 +301,21 @@ class CommonObject { $obj = $this->db->fetch_object($resql); - $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom, 'firstname'=>$obj->firstname, - 'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut); + if (! $list) + { + $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; + $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); + $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom, 'firstname'=>$obj->firstname, + 'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut); + } + else + { + $tab[$i]=$obj->id; + } + $i++; } + return $tab; } else diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fb14f2915d7..686b5a7b42a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -680,18 +680,11 @@ class Form { global $conf,$langs; - // Permettre l'exclusion de contacts - if (is_array($exclude)) - { - $excludeContacts = implode("','",$exclude); - } - // On recherche les societes $sql = "SELECT s.rowid, s.name, s.firstname, s.poste FROM"; $sql.= " ".MAIN_DB_PREFIX ."socpeople as s"; $sql.= " WHERE entity = ".$conf->entity; if ($socid) $sql.= " AND fk_soc=".$socid; - if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')"; $sql.= " ORDER BY s.name ASC"; dol_syslog("Form::select_contacts sql=".$sql); @@ -721,6 +714,7 @@ class Form if ($htmlname != 'none') { $disabled=0; + if (is_array($exclude) && sizeof($exclude) && in_array($obj->rowid,$exclude)) $disabled=1; if (is_array($limitto) && sizeof($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; if ($selected && $selected == $obj->rowid) { diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 1f420d9bd16..0ea01a46ee6 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -266,8 +266,7 @@ if ($id > 0) print ''; print ''; - //$contactAlreadySelected = $fichinter->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 495044dd350..5caad39fd0b 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -273,8 +273,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index d9fc7320f29..9fcd533b320 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -266,8 +266,7 @@ if ($id > 0) print ''; print ''; - //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index e0e3c3fe84e..3a83720074a 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -296,7 +296,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print '';