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 '