FIX select of project using ajax autocomplete option

This commit is contained in:
Laurent Destailleur 2015-10-04 16:02:50 +02:00
parent 8c17668665
commit 75e337e8d9
2 changed files with 21 additions and 17 deletions

View File

@ -101,17 +101,18 @@ class FormProjets
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only) * @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled * @param int $disabled Disabled
* @param int $mode 0 for HTML mode and 1 for JSON mode * @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example)
* @param string $filterkey Key to filter * @param string $filterkey Key to filter
* @return int Nber of project if OK, <0 if KO * @return int Nb of project if OK, <0 if KO
*/ */
function select_projects_list($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '') function select_projects_list($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey = '')
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$out=''; $out='';
$outarray=array();
$hideunselectables = false; $hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;

View File

@ -38,6 +38,7 @@ $socid=GETPOST('socid','int');
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$id=GETPOST('id', 'int'); $id=GETPOST('id', 'int');
/* /*
* View * View
*/ */
@ -60,9 +61,11 @@ if (! GETPOST($htmlname) && ! GETPOST($idprod)) return;
// When used from jQuery, the search term is added as GET param "term". // When used from jQuery, the search term is added as GET param "term".
$searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); $searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):''));
$form = new FormProjets($db); $form = new FormProjets($db);
$arrayresult=$form->select_projects_list($socid, '', $htmlname, '', 0, 0, array(), 0, 1, $searchkey); $arrayresult=$form->select_projects_list($socid, '', $htmlname, 0, 0, 1, 0, 0, 0, 1, $searchkey);
$db->close(); $db->close();
print json_encode($arrayresult); print json_encode($arrayresult);