Merge pull request #19746 from atm-quentin/NEW_contact_pj_filter_list

NEW : Contact filter project list
This commit is contained in:
Laurent Destailleur 2022-01-25 16:06:31 +01:00 committed by GitHub
commit 243999d223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 7 deletions

View File

@ -1690,11 +1690,17 @@ class Form
$out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.(($num || empty($disableifempty)) ? '' : ' disabled').($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
}
if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
if ($showempty && ! is_numeric($showempty)) {
$textforempty = $showempty;
$out .= '<option class="optiongrey" value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'>'.$textforempty.'</option>';
}
if ($showempty == 2) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
else {
if (($showempty == 1 || ($showempty == 3 && $num > 1)) && ! $multiple) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
}
if ($showempty == 2) {
$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
}
}
$i = 0;

View File

@ -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

View File

@ -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

View File

@ -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 .= '</div>';
$moreforfilter .= '<div class="divsearchfield">';
$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 .= '</div>';
// If the user can view thirdparties other than his'
if ($user->rights->societe->client->voir || $socid) {
$langs->load("commercial");