diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4a03afcbb4b..b29e9da546d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3518,10 +3518,13 @@ class Form * @param string $prefix prefix * @param int $iSecond Default preselected duration (number of seconds) * @param int $disabled Disable the combo box + * @param string $typehour if select then hour in select if text input in text * @return void */ - function select_duration($prefix,$iSecond='',$disabled=0) + function select_duration($prefix,$iSecond='',$disabled=0,$typehour='select') { + global $langs; + if ($iSecond) { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -3529,19 +3532,27 @@ class Form $hourSelected = convertSecondToTime($iSecond,'hour'); $minSelected = convertSecondToTime($iSecond,'min'); } - - print ''; + for ($hour = 0; $hour < 24; $hour++) + { + print '"; + } + print ""; } - print ""; - print "H  "; + elseif ($typehour=='text') + { + $fullhours=convertSecondToTime($iSecond,'fullhour'); + print ''; + } + print $langs->trans('Hours'). " "; print '"; - print "M "; + print $langs->trans('Minutes'). " "; } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index c7a7e1240dd..29870c1ce95 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -287,6 +287,16 @@ function convertSecondToTime($iSecond,$format='all',$lengthOfDay=86400,$lengthOf { $sTime=dol_print_date($iSecond,'%H',true); } + else if ($format == 'fullhour') + { + if (!empty($iSecond)) { + $iSecond=$iSecond/3600; + } + else { + $iSecond=0; + } + $sTime=$iSecond; + } else if ($format == 'min') { $sTime=dol_print_date($iSecond,'%M',true); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ae124ebb484..8409eed5c6e 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -422,12 +422,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Planned Workload print ''; - if (!empty($lines[$i]->planned_workload)) { - $planned_workload_hours = intval($lines[$i]->planned_workload / 3600); - }else { - $planned_workload_hours = 0; - } - print $planned_workload_hours.' '.$langs->trans('Hours'); + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'all'); + else print '--:--'; print ''; // Progress diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 6ca7828f6c4..112816c9204 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -164,6 +164,7 @@ $sql.= " ORDER BY u.rowid, t.dateo, t.datee"; $userstatic=new User($db); +dol_syslog('projet:index.php: affectationpercent sql='.$sql,LOG_DEBUG); $resql = $db->query($sql); if ( $resql ) { @@ -192,7 +193,7 @@ if ( $resql ) } else { $percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload); } - print ''.$percentcompletion.' %'; + print ''.$percentcompletion.' %'; print "\n"; $i++; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index ccfb5087fc5..36ada461608 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -71,7 +71,7 @@ $hookmanager->initHooks(array('projecttaskcard')); $progress=GETPOST('progress', 'int'); $label=GETPOST('label', 'alpha'); $description=GETPOST('description'); -$planned_workload=GETPOST('planned_workload'); +$planned_workload=GETPOST('planned_workloadhour'); $userAccess=0; @@ -294,14 +294,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie print $form->select_date(($date_end?$date_end:-1),'datee',0,0,0,'',1,1); print ''; - // Duration planned + // planned workload print ''.$langs->trans("PlannedWorkload").''; - if (!empty($object->planned_workload)) { - $planned_workload_hours = intval($object->planned_workload / 3600); - }else { - $planned_workload_hours = 0; - } - print ' '.$langs->trans('Hours'); + print $form->select_duration('planned_workload',$object->planned_workload,0,'text'); print ''; // Progress @@ -403,7 +398,7 @@ else print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("DateStart").''; print ''.$langs->trans("DateEnd").''; - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("Progress").''; print ''.$langs->trans("TimeSpent").''; print ' '; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 5b42b76c221..cabcea2c48c 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -109,7 +109,7 @@ print ''; print ''; print ''; print ''; -print ''; +print ''; print ' '; print ''; print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index c99318e9221..858e4612f1a 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -36,7 +37,7 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $withproject=GETPOST('withproject','int'); $project_ref=GETPOST('project_ref','alpha'); -$planned_workload=GETPOST('planned_workload'); +$planned_workload=GETPOST('planned_workloadhour'); // Security check $socid=0; @@ -285,14 +286,9 @@ if ($id > 0 || ! empty($ref)) print $form->select_date($object->date_end?$object->date_end:-1,'datee'); print ''; - // Duration planned + // workload planned print ''.$langs->trans("PlannedWorkload").''; - if (!empty($object->planned_workload)) { - $planned_workload_hours = intval($object->planned_workload / 3600); - }else { - $planned_workload_hours = 0; - } - print ' '.$langs->trans('Hours'); + print $form->select_duration('planned_workload',$object->planned_workload,0,'text'); print ''; // Progress @@ -380,14 +376,9 @@ if ($id > 0 || ! empty($ref)) print dol_print_date($object->date_end,'day'); print ''; - // Duration planned + // planned Workload print ''.$langs->trans("PlannedWorkload").''; - if (!empty($object->planned_workload)) { - $planned_workload_hours = intval($object->planned_workload / 3600); - }else { - $planned_workload_hours = 0; - } - print $planned_workload_hours.' '.$langs->trans('Hours'); + print convertSecondToTime($object->planned_workload,'all'); print ''; // Progress diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 1c7cd1bc9cc..2b6306b5afd 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -56,7 +56,9 @@ if ($action == 'addtimespent' && $user->rights->projet->creer) { $error=0; - if (empty($_POST["timespent_durationhour"]) && empty($_POST["timespent_durationmin"])) + $timespent_durationhour = GETPOST('timespent_durationhour','int'); + $timespent_durationmin = GETPOST('timespent_durationmin','int'); + if (empty($timespent_durationhour) && empty($timespent_durationmin)) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'
'; $error++; @@ -264,13 +266,8 @@ if ($id > 0 || ! empty($ref)) // Label print ''.$langs->trans("Label").''.$object->label.''; - // Duration planned - if (!empty($object->planned_workload)) { - $planned_workload_hours = intval($object->planned_workload / 3600); - }else { - $planned_workload_hours = 0; - } - print ''.$langs->trans("PlannedWorkload").''.$planned_workload_hours.' '.$langs->trans('Hours').''; + // planned workload + print ''.$langs->trans("PlannedWorkload").''.convertSecondToTime($object->planned_workload,'all').''; // Project if (empty($withproject)) @@ -336,7 +333,7 @@ if ($id > 0 || ! empty($ref)) // Duration print ''; - print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:'')); + print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:''),0,'text'); print ''; print ''; @@ -443,7 +440,7 @@ if ($id > 0 || ! empty($ref)) if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) { print ''; - print $form->select_duration('new_duration',$task_time->task_duration); + print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); } else {