From 1ffb013371beb35ebb1d12c78bd76d11ca0c1be8 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 12 Aug 2019 15:24:07 +0200 Subject: [PATCH] add filter --- htdocs/core/boxes/box_task.php | 54 +++++++++++++++++++++++---------- htdocs/core/lib/project.lib.php | 7 +++-- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 5d06e618237..3a0b2c67af9 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -83,17 +83,25 @@ class box_task extends ModeleBoxes require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; $projectstatic = new Project($this->db); $taskstatic=new Task($db); + $form= new Form($db); $cookie_name='boxfilter_task'; + $boxcontent=''; $textHead = $langs->trans("CurentlyOpenedTasks"); $filterValue='all'; if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){ $filterValue = GETPOST($cookie_name); - $textHead.= ' : '.$langs->trans("WhichIamLinkedTo"); } elseif(!empty($_COOKIE[$cookie_name])){ $filterValue = $_COOKIE[$cookie_name]; + } + + + if($filterValue == 'im_task_contact'){ + $textHead.= ' : '.$langs->trans("WhichIamLinkedTo"); + } + elseif($filterValue == 'im_project_contact'){ $textHead.= ' : '.$langs->trans("WhichIamLinkedToProject"); } @@ -110,12 +118,28 @@ class box_task extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { + $boxcontent.= '
'."\n"; + $boxcontent.= '
'."\n"; + $boxcontent.= '
boxcode.'">'."\n"; + $boxcontent.= ''."\n"; + $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); + $boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue); + $boxcontent.= ''; + $boxcontent.= '
'."\n"; + $boxcontent.= '
'."\n"; + $boxcontent.= ''; - $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; + + $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; $sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; $sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; @@ -157,19 +181,7 @@ class box_task extends ModeleBoxes $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - - $text = getTaskProgressView($taskstatic, $label); - - // set cookie by js - if(empty($i)){ - $text.=''; - } - - - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => $text, - ); + $boxcontent.= getTaskProgressView($taskstatic, $label, true, false, true); $i++; } @@ -177,6 +189,16 @@ class box_task extends ModeleBoxes dol_print_error($this->db); } } + + // set cookie by js + if(empty($i)){ + $boxcontent.=''; + } + + $this->info_box_contents[0][] = array( + 'td' => '', + 'text' => $boxcontent, + ); } /** diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 7f238d9d736..04a3a13cc91 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1957,9 +1957,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks * @param $label string|bool true = auto, false = dont display, string = replace output * @param $progressNumber string|bool true = auto, false = dont display, string = replace output * @param $hideOnProgressNull bool + * @param $showPercent bool + * @param $spaced bool * @return string */ -function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $showPercent = false) +function getTaskProgressView($task, $label = true, $progressNumber = true, $hideOnProgressNull = false, $spaced = false) { global $langs, $conf; @@ -1974,6 +1976,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide return ''; } + $spaced = !empty($spaced)?'spaced':''; $diff = ''; @@ -2049,7 +2052,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out.= ''; - $out.= '
'; + $out.= '
'; $out.= '
'; $out.= '
'; $out.= '
';