From d8d4b669ab32087131224143dddcd6b65177ce64 Mon Sep 17 00:00:00 2001 From: fhenry Date: Tue, 12 Feb 2013 09:49:27 +0100 Subject: [PATCH] Task [ task #711 ] --- htdocs/core/class/html.form.class.php | 15 ++++++++-- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/societe/admin/societe.php | 43 +++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f31cb0f741e..71673aca078 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -823,11 +823,13 @@ class Form * @param string $showfunction Add function into label * @param string $moreclass Add more class to class style * @param string $showsoc Add company into label + * @param int $forcecombo Force to use combo box + * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK */ - function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0) + function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $event=array()) { - print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc); + print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc, $forcecombo, $event); return $this->num; } @@ -844,9 +846,11 @@ class Form * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) * @param string $showsoc Add company into label + * @param int $forcecombo Force to use combo box + * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0) + function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $event=array()) { global $conf,$langs; @@ -872,6 +876,11 @@ class Form if ($resql) { $num=$this->db->num_rows($resql); + + if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo) + { + $out.= ajax_combobox($htmlname, $event); + } if ($htmlname != 'none' || $options_only) $out.= ''; +print ''; +print ""; +print ''.$langs->trans("UseSearchToSelectContact").''; +if (! $conf->use_javascript_ajax) +{ + print ''; + print $langs->trans("NotAvailableWhenAjaxDisabled"); + print ""; +} +else +{ + print ''; + $arrval=array('0'=>$langs->trans("No"), + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', + ); + print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT",$arrval,$conf->global->CONTACT_USE_SEARCH_TO_SELECT); + print ''; + print ''; + print ""; +} +print ''; print ''; + dol_fiche_end(); $db->close();