diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 8c23135ddbd..a190d86dcc9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -153,7 +153,7 @@ PlannedWorkload=Planned workload PlannedWorkloadShort=Workload ProjectReferers=Related items ProjectMustBeValidatedFirst=Project must be validated first -FirstAddRessourceToAllocateTime=Associate a resource to allocate time +FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time InputPerDay=Input per day InputPerWeek=Input per week InputPerAction=Input per action diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 5418a4c8f48..0caf1461e88 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -347,7 +347,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_print_date($projectstatic->date_end,'day'); print ''; - if (! $id && ! $ref) // Not a dedicated task + if ((! $id && ! $ref) || ! empty($projectidforalltimes)) // Not a dedicated task { // Budget print ''.$langs->trans("Budget").''; @@ -371,7 +371,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* * Actions */ - if (empty($id) && empty($ref)) + + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { print '
'; @@ -563,7 +564,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Definition of fields for list $arrayfields=array(); $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); - if (! $id && ! $ref) // Not a dedicated task + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { $arrayfields['t.task_ref']=array('label'=>$langs->trans("Task"), 'checked'=>1); } @@ -591,8 +592,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; + else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; if ($search_ref) $sql .= natural_search('c.ref', $search_ref); - + if ($search_note) $sql .= natural_search('t.note', $search_note); $sql .= $db->order($sortfield, $sortorder); $var=true; @@ -640,7 +642,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); }*/ - if ($projectstatic->id) $params.='&projectid='.$projectstatic->id; + if ($id) $params.='&id='.$id; + if ($projectid) $params.='&projectid='.$projectid; if ($withproject) $params.='&withproject='.$withproject; @@ -658,7 +661,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($optioncss != '') print ''; print ''; print ''; - print ''; + if ($action == 'editline') print ''; + else print ''; print ''; print ''; @@ -687,7 +691,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder); - if (! $id && ! $ref) // Not a dedicated task + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); } @@ -719,7 +723,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; // LIST_OF_TD_TITLE_SEARCH if (! empty($arrayfields['t.task_date']['checked'])) print ''; - if (! $id && ! $ref) // Not a dedicated task + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { if (! empty($arrayfields['t.task_ref']['checked'])) print ''; } @@ -764,8 +768,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $tasktmp = new Task($db); + $i = 0; $total = 0; $totalvalue = 0; + $totalarray=array(); foreach ($tasks as $task_time) { $var=!$var; @@ -787,12 +793,13 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); } print ''; + if (! $i) $totalarray['nbfield']++; } // Task if (! empty($arrayfields['t.task_ref']['checked'])) { - if (! $id && ! $ref) // Not a dedicated task + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { print ''; $tasktmp->id = $task_time->fk_task; @@ -800,6 +807,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $tasktmp->label = $task_time->label; print $tasktmp->getNomUrl(1, 'withproject', 'time'); print ''; + if (! $i) $totalarray['nbfield']++; } } @@ -829,6 +837,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print $userstatic->getNomUrl(1); } print ''; + if (! $i) $totalarray['nbfield']++; } // Note @@ -844,6 +853,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_nl2br($task_time->note); } print ''; + if (! $i) $totalarray['nbfield']++; } // Time spent @@ -860,15 +870,22 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print convertSecondToTime($task_time->task_duration,'allhourmin'); } print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; + $totalarray['totalduration'] += $task_time->task_duration; } // Value spent if (! empty($arrayfields['value']['checked'])) { print ''; - print price(price2num($task_time->thm * $task_time->task_duration / 3600), 1, $langs, 1, -1, -1, $conf->currency); + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 1, $langs, 1, -1, -1, $conf->currency); print ''; - } + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; + $totalarray['totalvalue'] += $value; + } // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); @@ -896,20 +913,34 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print img_delete(); print ''; } - print ''; - + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; - $total += $task_time->task_duration; - $totalvalue += price2num($task_time->thm * $task_time->task_duration / 3600); + + $i++; } - print ''.$langs->trans("Total").''; - print ''.convertSecondToTime($total,'allhourmin').''; - if ($conf->salaries->enabled) + // Show total line + if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) { - print ''.price($totalvalue, 1, $langs, 1, -1, -1, $conf->currency).''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + elseif ($totalarray['totaldurationfield'] == $i) print ''.convertSecondToTime($totalarray['totalduration'],'allhourmin').''; + elseif ($totalarray['totalvaluefield'] == $i) print ''.price($totalarray['totalvalue']).''; + else print ''; + } + print ''; } - print ' '; + print ''; print "";