diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 05c235f5f51..d29fd0d5e15 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1690,11 +1690,17 @@ class Form $out .= ''; } - if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) { - $out .= ' '; + if ($showempty && ! is_numeric($showempty)) { + $textforempty = $showempty; + $out .= ''.$textforempty.''; } - if ($showempty == 2) { - $out .= '-- '.$langs->trans("Internal").' --'; + else { + if (($showempty == 1 || ($showempty == 3 && $num > 1)) && ! $multiple) { + $out .= ' '; + } + if ($showempty == 2) { + $out .= '-- '.$langs->trans("Internal").' --'; + } } $i = 0; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e73a21dea26..77eabd20221 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -197,6 +197,7 @@ InputPerMonth=Input per month InputDetail=Input detail TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s ProjectsWithThisUserAsContact=Projects with this user as contact +ProjectsWithThisContact=Projects with this contact TasksWithThisUserAsContact=Tasks assigned to this user ResourceNotAssignedToProject=Not assigned to project ResourceNotAssignedToTheTask=Not assigned to the task diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 950462968ed..ee3736acef0 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -197,6 +197,7 @@ InputPerMonth=Saisie par mois InputDetail=Saisir le détail TimeAlreadyRecorded=C'est le temps passé déjà enregistré pour cette tâche/jour et pour l'utilisateur %s ProjectsWithThisUserAsContact=Projets avec cet utilisateur comme contact +ProjectsWithThisContact=Projets avec ce contact TasksWithThisUserAsContact=Tâches assignées à cet utilisateur ResourceNotAssignedToProject=Non assigné au projet ResourceNotAssignedToTheTask=Non assigné à la tache diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6019011956a..b19bc407537 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -98,6 +98,7 @@ $search_opp_amount = GETPOST("search_opp_amount", 'alpha'); $search_budget_amount = GETPOST("search_budget_amount", 'alpha'); $search_public = GETPOST("search_public", 'int'); $search_project_user = GETPOST('search_project_user', 'int'); +$search_project_contact = GETPOST('search_project_contact', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int'); $search_usage_task = GETPOST('search_usage_task', 'int'); @@ -253,6 +254,7 @@ if (empty($reshook)) { $search_public = ""; $search_sale = ""; $search_project_user = ''; + $search_project_contact = ''; $search_sday = ""; $search_smonth = ""; $search_syear = ""; @@ -364,13 +366,14 @@ if (empty($user->rights->projet->all->lire)) { // Get id of types of contacts for projects (This list never contains a lot of elements) $listofprojectcontacttype = array(); -$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; +$listofprojectcontacttypeexternal = array(); +$sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'"; -$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid] = $obj->code; + if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code; + else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code; } } else { dol_print_error($db); @@ -378,6 +381,9 @@ if ($resql) { if (count($listofprojectcontacttype) == 0) { $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found } +if (count($listofprojectcontacttypeexternal) == 0) { + $listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found +} $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,"; @@ -418,6 +424,9 @@ if ($search_sale > 0) { if ($search_project_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; } +if ($search_project_contact > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact"; +} $sql .= " WHERE p.entity IN (".getEntity('project').')'; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array); @@ -502,6 +511,9 @@ if ($search_sale > 0) { if ($search_project_user > 0) { $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user); } +if ($search_project_contact > 0) { + $sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact); +} if ($search_opp_amount != '') { $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); } @@ -690,6 +702,9 @@ if ($search_public != '') { if ($search_project_user != '') { $param .= '&search_project_user='.urlencode($search_project_user); } +if ($search_project_contact != '') { + $param .= '&search_project_user='.urlencode($search_project_contact); +} if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); } @@ -809,6 +824,11 @@ if (empty($user->rights->user->user->lire)) { $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= ''; +$moreforfilter .= ''; +$tmptitle = $langs->trans('ProjectsWithThisContact'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle); +$moreforfilter .= ''; + // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial");