From 0f88bdd971936eb5faaf883e3b3c83cd7fc60118 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Oct 2016 12:15:59 +0200 Subject: [PATCH] NEW Can filter on project ref on the "new time consumed" page. --- htdocs/projet/activity/perday.php | 54 +++++++++++++++++++++--- htdocs/projet/activity/perweek.php | 66 +++++++++++++++++++++++------- 2 files changed, 100 insertions(+), 20 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index aa5044da610..012a71f21a0 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -62,6 +62,7 @@ $month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("mo $day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); $monthofday=GETPOST('addtimemonth'); @@ -79,6 +80,17 @@ $object=new Task($db); * Actions */ +// Purge criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $action = ''; + $search_project_ref = ''; +} +if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) +{ + $action = ''; +} + if (GETPOST('submitdateselect')) { $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); @@ -253,6 +265,8 @@ $formproject=new FormProjets($db); $projectstatic=new Project($db); $project = new Project($db); $taskstatic = new Task($db); +$thirdpartystatic = new Societe($db); + $prev = dol_getdate($daytoparse - (24 * 3600)); $prev_year = $prev['year']; @@ -278,7 +292,8 @@ if ($id) } $onlyopenedproject=1; // or -1 -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. +$morewherefilter=''; +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); //var_dump($tasksarray); @@ -290,12 +305,14 @@ llxHeader("",$title,""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); -$param=($mode?'&mode='.$mode:''); +$param=''; +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); // Show navigation bar -$nav ="".img_previous($langs->trans("Previous"))."\n"; +$nav =''.img_previous($langs->trans("Previous"))."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"day")." \n"; -$nav.="".img_next($langs->trans("Next"))."\n"; +$nav.=''.img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; $nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; $nav.=' '; @@ -362,6 +379,9 @@ print "\n"; //print ''; //print ''; //print ''; + +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. + print '
'; print $langs->trans("AssignTaskToMe").'
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); @@ -370,15 +390,18 @@ print ''.$nav.'
'; print '
'; print ''; print ''; -print ''; print ''; print ''; +print ''; +if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) +{ + print ''; +} print ''; print ''; print ''; @@ -389,6 +412,25 @@ print ''; print ''; print "\n"; +print ''; +print ''; +print ''; +print ''; +if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Action column +print ''; +print "\n"; + + // By default, we can edit only tasks we are assigned to $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index cb525842f61..396eb352d3b 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -58,11 +58,12 @@ $nowtmp=dol_getdate($now); $nowday=$nowtmp['mday']; $nowmonth=$nowtmp['mon']; $nowyear=$nowtmp['year']; -$year=GETPOST('reyear')?GETPOST('reyear'):(GETPOST("year","int")?GETPOST("year","int"):date("Y")); -$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):date("m")); -$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d")); +$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); +$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); +$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); $startdayarray=dol_get_first_day_week($day, $month, $year); @@ -93,6 +94,17 @@ $object=new Task($db); * Actions */ +// Purge criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $action = ''; + $search_project_ref = ''; +} +if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) +{ + $action = ''; +} + if (GETPOST('submitdateselect')) { $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); @@ -103,7 +115,7 @@ if (GETPOST('submitdateselect')) if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) { $action = 'assigntask'; - + if ($taskid > 0) { $result = $object->fetch($taskid, $ref); @@ -119,6 +131,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } + if (! $error) { $idfortaskuser=$user->id; @@ -176,7 +189,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action=''; } -if ($action == 'addtime' && $user->rights->projet->lire) +if ($weclickonassign && $action == 'addtime' && $user->rights->projet->lire) { $timetoadd=$_POST['task']; if (empty($timetoadd)) @@ -276,7 +289,8 @@ if ($id) } $onlyopenedproject=1; // or -1 -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. +$morewherefilter=''; +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); //var_dump($tasksarray); @@ -288,12 +302,14 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); -$param=($mode?'&mode='.$mode:''); +$param=''; +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); // Show navigation bar -$nav ="".img_previous($langs->trans("Previous"))."\n"; +$nav =''.img_previous($langs->trans("Previous"))."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.="".img_next($langs->trans("Next"))."\n"; +$nav.=''.img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; $nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; $nav.=' '; @@ -358,6 +374,9 @@ print "\n"; //print ''; //print ''; //print ''; + +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. + print '
'; print $langs->trans("AssignTaskToMe").'
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); @@ -366,19 +385,19 @@ print ''.$nav.'
'; print '
'; print '
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("Duration").''.$langs->trans("Note").'
'; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'; + print ''; +print ''; +print ''; +print ''; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) { print ''; } -print ''; -print ''; -print ''; print ''; print ''; print ''; @@ -389,10 +408,29 @@ $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['fi for($i=0;$i<7;$i++) { - print ''; + print ''; } print ''; +print "\n"; +print ''; +print ''; +print ''; +print ''; +if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; +print ''; +print ''; +print ''; +print ''; +for($i=0;$i<7;$i++) +{ + print ''; +} +// Action column +print ''; print "\n"; // By default, we can edit only tasks we are assigned to
'.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').'
'.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').'
'; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '