From e06087888beb13dab9a6519729e6dcf04483a181 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Nov 2017 22:55:04 +0100 Subject: [PATCH] NEW Show line "other filtered task" when using filter on timesheet. --- htdocs/core/js/timesheet.js | 8 +- htdocs/core/lib/project.lib.php | 39 +++++++-- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/projects.lang | 3 +- htdocs/projet/activity/perday.php | 110 ++++++++++++++++++++------ htdocs/projet/activity/perweek.php | 109 +++++++++++++++++++------ htdocs/projet/class/project.class.php | 12 +-- 7 files changed, 218 insertions(+), 64 deletions(-) diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index a55424f8e8c..ba3f8b2edd1 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -113,15 +113,15 @@ function parseTime(timeStr, dt) function updateTotal(days,mode) { console.log('updateTotal days='+days+' mode='+mode); - if(mode=="hours") + if (mode=="hours") { var total = new Date(0); total.setHours(0); total.setMinutes(0); var nbline = document.getElementById('numberOfLines').value; - for (var i=0;i'; $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; + $totalforeachday[$preselectedday]+=$dayWorkLoad; + $alreadyspent=''; if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); @@ -822,8 +825,17 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $level++; if ($lines[$i]->id > 0) { - if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); - else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); + //var_dump($totalforeachday); + $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); + //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); + //var_dump($ret); + foreach($ret as $key => $val) + { + $totalforeachday[$key]+=$val; + } + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); + //var_dump($totalforeachday); } $level--; } @@ -833,7 +845,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr } } - return $inc; + return $totalforeachday; } @@ -852,7 +864,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon * @param int $oldprojectforbreak Old project id of last project break - * @return $inc + * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0) { @@ -863,6 +875,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $lastprojectid=0; $workloadforid=array(); + $totalforeachday=array(); $lineswithoutlevel0=array(); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. @@ -1037,6 +1050,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $tmparray=dol_getdate($tmpday); $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; + $totalforeachday[$tmpday]+=$dayWorkLoad; $alreadyspent=''; if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); @@ -1078,8 +1092,17 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $level++; if ($lines[$i]->id > 0) { - if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); - else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); + //var_dump($totalforeachday); + $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); + //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); + //var_dump($ret); + foreach($ret as $key => $val) + { + $totalforeachday[$key]+=$val; + } + //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); + //var_dump($totalforeachday); } $level--; } @@ -1089,7 +1112,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } } - return $inc; + return $totalforeachday; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 379027b6561..274000b9e2d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -897,3 +897,4 @@ NbComments=Number of comments CommentPage=Comments space CommentAdded=Comment added CommentDeleted=Comment deleted +Everybody=Everybody diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 696c4e849c8..dd7f15aa61b 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -21,7 +21,7 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st ClosedProjectsAreHidden=Closed projects are not visible. TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). -AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. +AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to selected user. Assign task if you need to enter time on it. OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it. ImportDatasetTasks=Tasks of projects ProjectCategories=Project tags/categories @@ -211,6 +211,7 @@ OppStatusLOST=Lost Budget=Budget LatestProjects=Latest %s projects LatestModifiedProjects=Latest %s modified projects +OtherFilteredTasks=Other filtered tasks # Comments trans AllowCommentOnTask=Allow user comments on tasks AllowCommentOnProject=Allow user comments on projects diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 39c3be794b0..35848589298 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -59,9 +59,9 @@ $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'):(GETPOST("year","int")?GETPOST("year","int"):(GETPOST("addtimeyear","int")?GETPOST("addtimeyear","int"):date("Y"))); +$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):(GETPOST("addtimemonth","int")?GETPOST("addtimemonth","int"):date("m"))); +$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):(GETPOST("addtimeday","int")?GETPOST("addtimeday","int"):date("d"))); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); @@ -80,6 +80,7 @@ $daytoparse = $now; if ($yearofday && $monthofday && $dayofday) $daytoparse=dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' + if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess=$user; @@ -121,7 +122,10 @@ if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || if (GETPOST('submitdateselect')) { - $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + if (GETPOST('remonth','int') && GETPOST('reday','int') && GETPOST('reyear','int')) + { + $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); + } $action = ''; } @@ -238,7 +242,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $object->fetch($key); $object->progress = GETPOST($key.'progress', 'int'); $object->timespent_duration = $val; - $object->timespent_fk_user = $user->id; + $object->timespent_fk_user = $usertoprocess->id; $object->timespent_note = GETPOST($key.'note'); if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered { @@ -329,6 +333,10 @@ if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +if ($morewherefilter) // Get all task with no filter so we can show total of time spent for not visible tasks +{ + $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. 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); @@ -342,7 +350,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde $param=''; $param.=($mode?'&mode='.$mode:''); $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); -$param.=($search_userassignedid > 0?'&search_userassignedid='.$search_usertoprocessid:''); +$param.=($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:''); $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); $param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); $param.=($search_task_label?'&search_task_label='.$search_task_label:''); @@ -473,7 +481,7 @@ print ''.$langs->trans("ProgressDeclared") if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; -print ''.$langs->trans("TimeSpent").''; +print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').''; print ''.$langs->trans("HourStart").''; print ''.$langs->trans("Duration").''; print ''.$langs->trans("Note").''; @@ -494,11 +502,62 @@ $isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek if (count($tasksarray) > 0) { $j=0; - projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable); + $totalforvisibletasks = projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0); + //var_dump($totalforvisibletasks); + + // Show total for all other tasks + + // Calculate total for all tasks + $listofdistinctprojectid=array(); // List of all distinct projects + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) + { + foreach($tasksarraywithoutfilter as $tmptask) + { + $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + } + } + //var_dump($listofdistinctprojectid); + $totalforeachday=array(); + foreach($listofdistinctprojectid as $tmpprojectid) + { + $lineother=''; + $projectstatic->id=$tmpprojectid; + $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + for ($idw = 0; $idw < 7; $idw++) + { + $tmpday=dol_time_plus_duree($daytoparse, $idw, 'd'); + $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + } + } + $lineother=''; + //var_dump($totalforeachday); $colspan = 8; - print ' + // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user + if (count($totalforeachday)) + { + print ''; + print ''; + print $langs->trans("OtherFilteredTasks"); + print ''; + print ''; + $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + //if ($timeonothertasks) + //{ + print ''; + //} + print ''; + print ' '; + print ' '; + print ''; + } + + if ($conf->use_javascript_ajax) + { + print ' '; print $langs->trans("Total"); //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; @@ -507,6 +566,7 @@ if (count($tasksarray) > 0) '; + } } else { @@ -525,22 +585,24 @@ print ''; $modeinput='hours'; -print "\n\n"; -print ''; +if ($conf->use_javascript_ajax) +{ + print "\n\n"; + print ''; +} llxFooter(); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b7fc2b32376..08b59ffafbc 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -286,7 +286,9 @@ if ($action == 'addtime' && $user->rights->projet->lire) $param=''; $param.=($mode?'&mode='.$mode:''); - $param.=($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''); + $param.=($projectid?'id='.$projectid:''); + $param.=($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:''); + $param.=($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''); $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); @@ -333,6 +335,10 @@ if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +if ($morewherefilter) // Get all task with no filter so we can show total of time spent for not visible tasks +{ + $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. 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); @@ -478,7 +484,7 @@ print ''.$langs->trans("ProgressDeclared"). if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; -print ''.$langs->trans("TimeSpent").''; +print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').''; $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); @@ -515,11 +521,65 @@ if (count($tasksarray) > 0) $j=0; $level=0; - projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable); + $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0); + //var_dump($totalforvisibletasks); + + // Show total for all other tasks + + // Calculate total for all tasks + $listofdistinctprojectid=array(); // List of all distinct projects + if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) + { + foreach($tasksarraywithoutfilter as $tmptask) + { + $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + } + } + //var_dump($listofdistinctprojectid); + $totalforeachday=array(); + foreach($listofdistinctprojectid as $tmpprojectid) + { + $lineother=''; + $projectstatic->id=$tmpprojectid; + $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + for ($idw = 0; $idw < 7; $idw++) + { + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + } + } + $lineother=''; + //var_dump($totalforeachday); $colspan=7; - print ' + // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user + if (count($totalforeachday)) + { + print ''; + print ''; + print $langs->trans("OtherFilteredTasks"); + print ''; + for ($idw = 0; $idw < 7; $idw++) + { + print ''; + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + if ($timeonothertasks) + { + print ''; + } + print ''; + } + print ' '; + print ''; + } + + if ($conf->use_javascript_ajax) + { + print ' '; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; @@ -532,7 +592,8 @@ if (count($tasksarray) > 0)
 
 
- '; + '; + } } else { @@ -551,25 +612,29 @@ print ''."\n\n"; $modeinput='hours'; -print "\n\n"; -print ''; } -print "\n});\n"; -print ''; llxFooter(); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 74b274d5f3a..da754176386 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1652,7 +1652,8 @@ class Project extends CommonObject /** - * Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project + * Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project. + * Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call. * * @param int $datestart First day of week (use dol_get_first_day to find this date) * @param int $taskid Filter on a task id @@ -1663,9 +1664,12 @@ class Project extends CommonObject { $error=0; + $this->weekWorkLoad=array(); + $this->weekWorkLoadPerTask=array(); + if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); - $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.fk_task"; + $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; $sql.= " WHERE ptt.fk_task = pt.rowid"; $sql.= " AND pt.fk_projet = ".$this->id; @@ -1678,8 +1682,6 @@ class Project extends CommonObject $resql=$this->db->query($sql); if ($resql) { - //unset($this->weekWorkLoad[$day]); - //unset($this->weekWorkLoadPerTask[$day]); $daylareadyfound=array(); $num = $this->db->num_rows($resql); @@ -1688,7 +1690,7 @@ class Project extends CommonObject while ($i < $num) { $obj=$this->db->fetch_object($resql); - $day=$this->db->jdate($obj->task_date); + $day=$this->db->jdate($obj->task_date); // task_date is date without hours if (empty($daylareadyfound[$day])) { $this->weekWorkLoad[$day] = $obj->task_duration;