Can filter on project category on project list
This commit is contained in:
parent
d1c4f02bf7
commit
7e24f449d2
@ -63,6 +63,7 @@ $pageprev = $page - 1;
|
|||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
$search_all=GETPOST("search_all");
|
$search_all=GETPOST("search_all");
|
||||||
|
$search_categ=GETPOST("search_categ",'alpha');
|
||||||
$search_ref=GETPOST("search_ref");
|
$search_ref=GETPOST("search_ref");
|
||||||
$search_label=GETPOST("search_label");
|
$search_label=GETPOST("search_label");
|
||||||
$search_societe=GETPOST("search_societe");
|
$search_societe=GETPOST("search_societe");
|
||||||
@ -147,6 +148,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
|||||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||||
{
|
{
|
||||||
$search_all='';
|
$search_all='';
|
||||||
|
$search_categ='';
|
||||||
$search_ref="";
|
$search_ref="";
|
||||||
$search_label="";
|
$search_label="";
|
||||||
$search_societe="";
|
$search_societe="";
|
||||||
@ -204,11 +206,14 @@ if ($resql)
|
|||||||
else dol_print_error($db);
|
else dol_print_error($db);
|
||||||
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found
|
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[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.
|
$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 projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
|
$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
|
||||||
$sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
|
$sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
|
||||||
$sql.= ", s.nom as name, s.rowid as socid";
|
$sql.= ", s.nom as name, s.rowid as socid";
|
||||||
$sql.= ", cls.code as opp_status_code";
|
$sql.= ", cls.code as opp_status_code";
|
||||||
|
// We'll need these fields in order to filter by categ
|
||||||
|
if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project";
|
||||||
// Add fields for extrafields
|
// Add fields for extrafields
|
||||||
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
|
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
|
||||||
// Add fields from hooks
|
// Add fields from hooks
|
||||||
@ -219,6 +224,8 @@ $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
|||||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)";
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
|
||||||
|
// We'll need this table joined to the select in order to filter by categ
|
||||||
|
if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ
|
||||||
// We'll need this table joined to the select in order to filter by sale
|
// We'll need this table joined to the select in order to filter by sale
|
||||||
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
||||||
if ($search_user > 0)
|
if ($search_user > 0)
|
||||||
@ -229,6 +236,8 @@ $sql.= " WHERE p.entity IN (".getEntity('project',1).')';
|
|||||||
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
|
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
|
||||||
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
||||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||||
|
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
|
||||||
|
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||||
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
||||||
if ($search_label) $sql .= natural_search('p.title', $search_label);
|
if ($search_label) $sql .= natural_search('p.title', $search_label);
|
||||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||||
@ -372,6 +381,8 @@ if ($resql)
|
|||||||
print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
|
print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$moreforfilter='';
|
||||||
|
|
||||||
// If the user can view thirdparties other than his'
|
// If the user can view thirdparties other than his'
|
||||||
if ($user->rights->societe->client->voir || $socid)
|
if ($user->rights->societe->client->voir || $socid)
|
||||||
{
|
{
|
||||||
@ -390,6 +401,16 @@ if ($resql)
|
|||||||
$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||||
$moreforfilter.='</div>';
|
$moreforfilter.='</div>';
|
||||||
|
|
||||||
|
// Filter on categories
|
||||||
|
if (! empty($conf->categorie->enabled))
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
$moreforfilter.='<div class="divsearchfield">';
|
||||||
|
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||||
|
$moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1);
|
||||||
|
$moreforfilter.='</div>';
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($moreforfilter))
|
if (! empty($moreforfilter))
|
||||||
{
|
{
|
||||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user