From 10e9f4372b012ef40dfe6095b9cee1f62ecadcb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Sep 2016 16:42:45 +0200 Subject: [PATCH] NEW Show total line (planned workload and time spent) on on list of tasks. --- htdocs/projet/tasks/list.php | 71 +++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 47083e9032d..dd97f0a7a15 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -545,7 +545,15 @@ if ($resql) print ''; - $i = 0; + $plannedworkloadoutputformat='allhourmin'; + $timespentoutputformat='allhourmin'; + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + + $now = dol_now(); + $i=0; + $var=true; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -578,6 +586,7 @@ if ($resql) print $projectstatic->getNomUrl(1, 'task'); if ($projectstatic->hasDelay()) print img_warning("Late"); print ''; + if (! $i) $totalarray['nbfield']++; } // Title if (! empty($arrayfields['p.title']['checked'])) @@ -585,6 +594,7 @@ if ($resql) print ''; print dol_trunc($obj->projecttitle,80); print ''; + if (! $i) $totalarray['nbfield']++; } // Company if (! empty($arrayfields['s.nom']['checked'])) @@ -601,6 +611,7 @@ if ($resql) print ' '; } print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['p.fk_statut']['checked'])) @@ -608,6 +619,7 @@ if ($resql) print ''; print $projectstatic->getLibStatut(1); print ''; + if (! $i) $totalarray['nbfield']++; } // Ref if (! empty($arrayfields['t.ref']['checked'])) @@ -616,6 +628,7 @@ if ($resql) print $taskstatic->getNomUrl(1,'withproject'); if ($taskstatic->hasDelay()) print img_warning("Late"); print ''; + if (! $i) $totalarray['nbfield']++; } // Label if (! empty($arrayfields['t.label']['checked'])) @@ -623,6 +636,7 @@ if ($resql) print ''; print $taskstatic->label; print ''; + if (! $i) $totalarray['nbfield']++; } // Date start if (! empty($arrayfields['t.dateo']['checked'])) @@ -630,20 +644,17 @@ if ($resql) print ''; print dol_print_date($db->jdate($obj->date_start),'day'); print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Date end if (! empty($arrayfields['t.datee']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_end),'day'); print ''; + if (! $i) $totalarray['nbfield']++; } - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; - // Planned workload if (! empty($arrayfields['t.planned_workload']['checked'])) { @@ -658,6 +669,9 @@ if ($resql) } //else print '--:--'; print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; + $totalarray['totalplannedworkload'] += $obj->planned_workload; } // Time spent if (! empty($arrayfields['t.duration_effective']['checked'])) @@ -671,6 +685,9 @@ if ($resql) if ($showlineingray) print ''; else print ''; print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; + $totalarray['totaldurationeffective'] += $obj->duration_effective; } // Calculated progress if (! empty($arrayfields['t.progress_calculated']['checked'])) @@ -682,6 +699,7 @@ if ($resql) else print $langs->trans('WorkloadNotDefined'); } print ''; + if (! $i) $totalarray['nbfield']++; } // Declared progress if (! empty($arrayfields['t.progress']['checked'])) @@ -692,6 +710,7 @@ if ($resql) print $obj->progress.' %'; } print ''; + if (! $i) $totalarray['nbfield']++; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -707,6 +726,7 @@ if ($resql) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -720,6 +740,7 @@ if ($resql) print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['t.tms']['checked'])) @@ -727,6 +748,7 @@ if ($resql) print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Status /*if (! empty($arrayfields['p.fk_statut']['checked'])) @@ -734,9 +756,17 @@ if ($resql) $projectstatic->statut = $obj->fk_statut; print ''.$projectstatic->getLibStatut(5).''; }*/ - // Action column - print ''; - + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; //print projectLinesa(); @@ -744,6 +774,27 @@ if ($resql) $i++; } + + // Show total line + if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield'])) + { + 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['totalplannedworkloadfield'] == $i) print ''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''; + elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).''; + else print ''; + } + print ''; + } + $db->free($resql); $parameters=array('sql' => $sql);