diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 057c86c1038..9d986abc6f0 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -272,12 +272,15 @@ if ($id > 0) print ''; // On récupère les id des contacts déjà sélectionnés //$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 - $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; $propal->selectTypeContact($propal, '', 'type','external'); print ''; - print ''; + print ''; print ''; print ""; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index ab69ba7918f..63e8d98050d 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -274,12 +274,15 @@ if ($id > 0) print ''; // On récupère les id des contacts déjà sélectionnés // $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 - $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; $commande->selectTypeContact($commande, '', 'type','external'); print ''; - print ''; + print ''; print ''; print ""; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e007380a61d..69fd86617c4 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -786,8 +786,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''.$langs->trans('Customer').''.$soc->getNomUrl(1).''; /* - * Contact de la commande - */ + * Contact de la commande + */ print "".$langs->trans("DefaultContact").''; $html->select_contacts($soc->id,$setcontact,'contactidp',1); print ''; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 279a1f3e67c..d11475fa55d 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -254,12 +253,15 @@ if ($id > 0) print ''; // On récupère les id des contacts déjà sélectionnés //$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 - $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; $facture->selectTypeContact($facture, '', 'type','external'); print ''; - print ''; + print ''; print ''; print ""; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 27dd0ddfb06..0f75dd27bbd 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -275,12 +275,15 @@ if ($id > 0) print ''; // On récupère les id des contacts déjà sélectionnés //$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 - $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; $contrat->selectTypeContact($contrat, '', 'type','external'); print ''; - print ''; + print ''; print ''; print ""; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 90a4c82e20d..232d8abdb1d 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2007 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 @@ -259,12 +260,15 @@ if ($id > 0) print ''; // On récupère les id des contacts déjà sélectionnés //$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 - $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; $fichinter->selectTypeContact($fichinter, '', 'type','external'); print ''; - print ''; + print ''; print ''; print ""; diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index 5f4c526678c..9abe36c70bb 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -18,8 +18,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ - * */ /** diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index eed674266a0..a5b1eb80588 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -792,65 +792,65 @@ class Form * \param htmlname Nom champ formulaire ('none' pour champ non editable) * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue * \param exclude Liste des id contacts à exclure - * \return int <0 si ko, >=0 si ok + * \return int <0 if KO, Nb of contact in list if OK */ function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='') - { - // Permettre l'exclusion de contacts - if (is_array($exclude)) - { - $excludeContacts = implode("','",$exclude); - } - - // On recherche les societes - $sql = "SELECT s.rowid, s.name, s.firstname FROM"; - $sql.= " ".MAIN_DB_PREFIX ."socpeople as s"; - $sql.= " WHERE fk_soc=".$socid; - if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')"; - $sql.= " ORDER BY s.name ASC"; - - $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows(); - if ($num==0) return 0; - - if ($htmlname != 'none') print ''; + if ($showempty) print ''; + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($htmlname != 'none') + { + if ($selected && $selected == $obj->rowid) + { + print ''; + } else { - if ($selected == $obj->rowid) print $obj->name.' '.$obj->firstname; + print ''; } - $i++; } + else + { + if ($selected == $obj->rowid) print $obj->name.' '.$obj->firstname; + } + $i++; } - if ($htmlname != 'none') print ''; - return 1; } - else - { - dolibarr_print_error($this->db); - return -1; - } - } + if ($htmlname != 'none') print ''; + return $num; + } + else + { + dolibarr_print_error($this->db); + return -1; + } + } /** diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 97e56401145..72de4006594 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -125,6 +125,7 @@ Supplier=Supplier CompanyList=Companies' list AddContact=Add contact Contact=Contact +NoContactDefined=No contact defined for this third party DefaultContact=Default contact AddCompany=Add company AddThirdParty=Add third party diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 2c5948ef86c..9b659c60e9a 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -125,6 +125,7 @@ Supplier=Fournisseur CompanyList=Liste des sociétés AddContact=Créer contact Contact=Contact +NoContactDefined=Aucun contact défini pour ce tiers DefaultContact=Contact par défaut AddCompany=Créer société AddThirdParty=Créer tiers