NEW Add filter on task ref and task label into list of tasks
This commit is contained in:
parent
7fd2247297
commit
4f3fe82e93
@ -4957,9 +4957,10 @@ function dol_getmypid()
|
|||||||
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
|
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
|
||||||
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
|
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
|
||||||
* @param integer $numeric 0=value is list of keywords, 1=value is a numeric test
|
* @param integer $numeric 0=value is list of keywords, 1=value is a numeric test
|
||||||
|
* @param integer $nofinaland Do now output the final 'AND'
|
||||||
* @return string $res The statement to append to the SQL query
|
* @return string $res The statement to append to the SQL query
|
||||||
*/
|
*/
|
||||||
function natural_search($fields, $value, $numeric=0)
|
function natural_search($fields, $value, $numeric=0, $nofinaland)
|
||||||
{
|
{
|
||||||
global $db,$langs;
|
global $db,$langs;
|
||||||
|
|
||||||
@ -5014,7 +5015,7 @@ function natural_search($fields, $value, $numeric=0)
|
|||||||
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
|
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
$res = " AND (" . $res . ")";
|
$res = ($nofinaland?"":" AND ")."(" . $res . ")";
|
||||||
//print 'xx'.$res.'yy';
|
//print 'xx'.$res.'yy';
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -561,9 +561,10 @@ class Task extends CommonObject
|
|||||||
* @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
|
* @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
|
* @param string $filteronprojref Filter on project ref
|
||||||
* @param string $filteronprojstatus Filter on project status
|
* @param string $filteronprojstatus Filter on project status
|
||||||
|
* @param string $morewherefilter Add more filter into where SQL request
|
||||||
* @return array Array of tasks
|
* @return array Array of tasks
|
||||||
*/
|
*/
|
||||||
function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='', $filteronprojstatus=-1)
|
function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='', $filteronprojstatus=-1, $morewherefilter='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -573,8 +574,8 @@ class Task extends CommonObject
|
|||||||
|
|
||||||
// List of tasks (does not care about permissions. Filtering will be done later)
|
// List of tasks (does not care about permissions. Filtering will be done later)
|
||||||
$sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut,";
|
$sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut,";
|
||||||
$sql.= " t.rowid as taskid, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress,";
|
$sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress,";
|
||||||
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.ref as ref_task,t.rang";
|
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang";
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||||
@ -594,6 +595,7 @@ class Task extends CommonObject
|
|||||||
}
|
}
|
||||||
if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$filteronprojref."%'";
|
if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$filteronprojref."%'";
|
||||||
if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus;
|
if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus;
|
||||||
|
if ($morewherefilter) $sql.=" AND (".$morewherefilter.")";
|
||||||
$sql.= " ORDER BY p.ref, t.rang, t.dateo";
|
$sql.= " ORDER BY p.ref, t.rang, t.dateo";
|
||||||
|
|
||||||
//print $sql;exit;
|
//print $sql;exit;
|
||||||
@ -629,7 +631,7 @@ class Task extends CommonObject
|
|||||||
{
|
{
|
||||||
$tasks[$i] = new Task($this->db);
|
$tasks[$i] = new Task($this->db);
|
||||||
$tasks[$i]->id = $obj->taskid;
|
$tasks[$i]->id = $obj->taskid;
|
||||||
$tasks[$i]->ref = $obj->ref_task;
|
$tasks[$i]->ref = $obj->taskref;
|
||||||
$tasks[$i]->fk_project = $obj->projectid;
|
$tasks[$i]->fk_project = $obj->projectid;
|
||||||
$tasks[$i]->projectref = $obj->ref;
|
$tasks[$i]->projectref = $obj->ref;
|
||||||
$tasks[$i]->projectlabel = $obj->plabel;
|
$tasks[$i]->projectlabel = $obj->plabel;
|
||||||
|
|||||||
@ -36,6 +36,8 @@ $id=GETPOST('id','int');
|
|||||||
$search_project=GETPOST('search_project');
|
$search_project=GETPOST('search_project');
|
||||||
if (! isset($_GET['search_status']) && ! isset($_POST['search_status'])) $search_status=1;
|
if (! isset($_GET['search_status']) && ! isset($_POST['search_status'])) $search_status=1;
|
||||||
else $search_status=GETPOST('search_status');
|
else $search_status=GETPOST('search_status');
|
||||||
|
$search_task_ref=GETPOST('search_task_ref');
|
||||||
|
$search_task_label=GETPOST('search_task_label');
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -56,9 +58,19 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|||||||
{
|
{
|
||||||
$search_project="";
|
$search_project="";
|
||||||
$search_status="";
|
$search_status="";
|
||||||
|
$search_task_ref="";
|
||||||
|
$search_task_label="";
|
||||||
}
|
}
|
||||||
if (empty($search_status)) $search_status=1;
|
if (empty($search_status)) $search_status=1;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// None
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -93,7 +105,10 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$so
|
|||||||
|
|
||||||
// Get list of tasks in tasksarray and taskarrayfiltered
|
// Get list of tasks in tasksarray and taskarrayfiltered
|
||||||
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
|
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
|
||||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status);
|
$morewherefilter='';
|
||||||
|
if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref, 0, 1);
|
||||||
|
if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label, 0, 1);
|
||||||
|
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter);
|
||||||
// We load also tasks limited to a particular user
|
// We load also tasks limited to a particular user
|
||||||
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
|
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
|
||||||
|
|
||||||
@ -126,7 +141,13 @@ $listofstatus=array(-1=>' ');
|
|||||||
foreach($projectstatic->statuts_short as $key => $val) $listofstatus[$key]=$langs->trans($val);
|
foreach($projectstatic->statuts_short as $key => $val) $listofstatus[$key]=$langs->trans($val);
|
||||||
print $form->selectarray('search_status', $listofstatus, $search_status);
|
print $form->selectarray('search_status', $listofstatus, $search_status);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="liste_titre" colspan="7">';
|
print '<td class="liste_titre">';
|
||||||
|
print '<input type="text" class="flat" name="search_task_ref" value="'.$search_task_ref.'" size="4">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '<input type="text" class="flat" name="search_task_label" value="'.$search_task_label.'" size="8">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre" colspan="5">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<td class="liste_titre nowrap" align="right">';
|
print '<td class="liste_titre nowrap" align="right">';
|
||||||
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user