From 99d740fd2f9358e006bf410fd69648c0f5b424a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2012 14:44:27 +0100 Subject: [PATCH] New: [ task #285 ] Add search filter on project in tasks list. --- ChangeLog | 1 + htdocs/projet/class/project.class.php | 14 ++++++------- htdocs/projet/class/task.class.php | 16 +++++++------- htdocs/projet/liste.php | 30 ++++++++++++++++----------- htdocs/projet/tasks/index.php | 26 ++++++++++++++++++++--- 5 files changed, 57 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a2aa8006e8..3d54d0197c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ For users: - New: Default output charset are utf8 into backup tool. - New: Add brazilian states. - New: Increase usability of module project. +- New: [ task #285 ] Add search filter on project in tasks list. - New: Automatic list of documents in ECM module is ok for customers, suppliers invoice, orders, customers orders, proposals and social contributions. - New: All professional id can contains up to 128 chars instead of 32. diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 3a911be8bbe..7dae924c364 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -843,11 +843,11 @@ class Project extends CommonObject /** * Return array of projects a user has permission on, is affected to, or all projects * - * @param User $user User object - * @param int $mode 0=All project I have permission on, 1=Projects affected to me only, 2=Will return list of all projects with no test on contacts - * @param int $list 0=Return array,1=Return string list - * @param int $socid 0=No filter on third party, id of third party - * @return array Array of projects + * @param User $user User object + * @param int $mode 0=All project I have permission on, 1=Projects affected to me only, 2=Will return list of all projects with no test on contacts + * @param int $list 0=Return array,1=Return string list + * @param int $socid 0=No filter on third party, id of third party + * @return array Array of projects */ function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0) { @@ -864,11 +864,9 @@ class Project extends CommonObject $sql.= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } $sql.= " WHERE p.entity = " . $conf->entity; - // Internal users must see project he is contact to even if project linked to a third party he can't see. //if ($socid || ! $user->rights->societe->client->voir) $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 ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; if ($mode == 0) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 86419a9926f..d1b8c41cb78 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -458,14 +458,15 @@ class Task extends CommonObject * Return list of tasks for all projects or for one particular project * Sort order is on project, TODO then of position of task, and last on title of first level task * - * @param User $usert Object user to limit tasks affected to a particular user - * @param User $userp Object user to limit projects of a particular user and public projects - * @param int $projectid Project id - * @param int $socid Third party id - * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists - * @return array Array of tasks + * @param User $usert Object user to limit tasks affected to a particular user + * @param User $userp Object user to limit projects of a particular user and public projects + * @param int $projectid Project id + * @param int $socid Third party id + * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists + * @param string $filteronprojref Filter on project ref + * @return array Array of tasks */ - function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0) + function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='') { global $conf; @@ -494,6 +495,7 @@ class Task extends CommonObject if ($socid) $sql.= " AND p.fk_soc = ".$socid; if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; } + if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$filteronprojref."%'"; $sql.= " ORDER BY p.ref, t.label"; //print $sql; diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php index 34b131196ad..8d82e9e5bcb 100644 --- a/htdocs/projet/liste.php +++ b/htdocs/projet/liste.php @@ -55,16 +55,21 @@ $pagenext = $page + 1; $mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$search_ref=GETPOST("search_ref"); +$search_label=GETPOST("search_label"); +$search_societe=GETPOST("search_societe"); + /* * View */ -llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); - $projectstatic = new Project($db); $socstatic = new Societe($db); +llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); + + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1,$socid); $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.public, p.fk_user_creat"; @@ -79,15 +84,15 @@ if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$pro if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($_GET["search_ref"]) { - $sql.= " AND p.ref LIKE '%".$db->escape($_GET["search_ref"])."%'"; + $sql.= " AND p.ref LIKE '%".$db->escape($search_ref)."%'"; } if ($_GET["search_label"]) { - $sql.= " AND p.title LIKE '%".$db->escape($_GET["search_label"])."%'"; + $sql.= " AND p.title LIKE '%".$db->escape($search_label)."%'"; } if ($_GET["search_societe"]) { - $sql.= " AND s.nom LIKE '%".$db->escape($_GET["search_societe"])."%'"; + $sql.= " AND s.nom LIKE '%".$db->escape($search_societe)."%'"; } $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -111,6 +116,8 @@ if ($resql) else print $langs->trans("ProjectsPublicDesc").'

'; } + print '
'; + print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","","","",$sortfield,$sortorder); @@ -120,16 +127,15 @@ if ($resql) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"","",'align="right"',$sortfield,$sortorder); print "\n"; - print ''; print ''; - print ''; - print ''; - print ''; print ''; print ''; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 94bb854e933..40e2fcef507 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -33,6 +33,8 @@ $langs->load('projects'); $langs->load('users'); $id=GETPOST('id','int'); +$search_product=GETPOST('search_product'); + // Security check $socid=0; @@ -48,6 +50,7 @@ $page = $page == -1 ? 0 : $page; $mine = $_REQUEST['mode']=='mine' ? 1 : 0; + /* * View */ @@ -79,14 +82,18 @@ else // Get list of project id allowed to user $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); + // Get list of tasks in tasksarray and taskarrayfiltered -// We need all tasks (even not limited to a user because a task to user -// can have a parent that is not affected to him). -$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0); +// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). +$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_product); // We load also tasks limited to a particular user $tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : ''); +print ''; +print ''; + print '
'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; + print ''; print ' 
'; + print ''; print ''; print ''; @@ -96,11 +103,24 @@ print ''; print ''; print ''; print "\n"; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Show all lines in taskarray (recursive function to go down on tree) $j=0; $level=0; $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId); print "
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("DateEnd").''.$langs->trans("Progress").''.$langs->trans("TimeSpent").'
'; +print ''; +print ''; +print ' '; +print '
"; +print '
'; + print ''; /*