diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 445aa827416..61d1c08f2aa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3800,7 +3800,7 @@ class Form * @param string $prefix Prefix for fields name * @param int $h 1=Show also hours * @param int $m 1=Show also minutes - * @param int $empty 0=Fields required, 1=Empty input is allowed + * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @param string $form_name Not used * @param int $d 1=Show days, month, years * @param int $addnowbutton Add a button "Now" @@ -3819,9 +3819,13 @@ class Form if($prefix=='') $prefix='re'; if($h == '') $h=0; if($m == '') $m=0; - if($empty == '') $empty=0; + $emptydate=0; + $emptyhours=0; + if ($empty == 1) { $emptydate=1; $emptyhours=1; } + if ($empty == 2) { $emptydate=0; $emptyhours=1; } + $orig_set_time=$set_time; - if ($set_time === '' && $empty == 0) + if ($set_time === '' && $emptydate == 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $set_time = dol_now('tzuser')-(getServerTimeZoneInt('now')*3600); // set_time must be relative to PHP server timezone @@ -3843,8 +3847,11 @@ class Form $syear = dol_print_date($set_time, "%Y"); $smonth = dol_print_date($set_time, "%m"); $sday = dol_print_date($set_time, "%d"); - $shour = dol_print_date($set_time, "%H"); - $smin = dol_print_date($set_time, "%M"); + if ($orig_set_time != '') + { + $shour = dol_print_date($set_time, "%H"); + $smin = dol_print_date($set_time, "%M"); + } } else { @@ -3906,7 +3913,7 @@ class Form // Day $retstring.=''; - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.=' '; } @@ -3919,7 +3926,7 @@ class Form $retstring.=""; $retstring.=''; - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.=' '; } @@ -3934,7 +3941,7 @@ class Form $retstring.=""; // Year - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.=''; } @@ -3957,7 +3964,7 @@ class Form { // Show hour $retstring.=''; - if ($empty) $retstring.=' '; + if ($emptyhours) $retstring.=' '; for ($hour = 0; $hour < 24; $hour++) { if (strlen($hour) < 2) $hour = "0" . $hour; @@ -3971,7 +3978,7 @@ class Form { // Show minutes $retstring.=''; - if ($empty) $retstring.=' '; + if ($emptyhours) $retstring.=' '; for ($min = 0; $min < 60 ; $min++) { if (strlen($min) < 2) $min = "0" . $min; @@ -4030,18 +4037,22 @@ class Form /** * Function to show a form to select a duration on a page * - * @param string $prefix Prefix + * @param string $prefix Prefix for input fields * @param int $iSecond Default preselected duration (number of seconds) * @param int $disabled Disable the combo box * @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo * @param string $minunderhours If 1, show minutes selection under the hours + * @param int $nooutput Do not output html string but return it * @return void */ - function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', $minunderhours=0) + function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', $minunderhours=0, $nooutput=0) { global $langs; + $retstring=''; + $hourSelected=0; $minSelected=0; + if ($iSecond) { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -4052,36 +4063,51 @@ class Form if ($typehour=='select') { - print ''; + $retstring.=''; for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours { - print '".$hour.""; + $retstring.=">".$hour.""; } - print ""; + $retstring.=""; } elseif ($typehour=='text') { - print ''; + $retstring.=''; } - print ' '.$langs->trans('HourShort'); + else return 'BadValueForParameterTypeHour'; - if ($minunderhours) print ''; - else print " "; + $retstring.=' '.$langs->trans('HourShort'); - print ''; - for ($min = 0; $min <= 55; $min=$min+5) + if ($minunderhours) $retstring.=''; + else $retstring.=" "; + + if ($typehour=='select') { - print ''.$min.''; + $retstring.=''; + for ($min = 0; $min <= 55; $min=$min+5) + { + $retstring.=''.$min.''; + } + $retstring.=""; } - print ""; - print ' '.$langs->trans('MinuteShort'). " "; + elseif ($typehour=='text') + { + $retstring.=''; + } + $retstring.=' '.$langs->trans('MinuteShort'); + $retstring.=" "; + + if (! empty($nooutput)) return $retstring; + + print $retstring; + return; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 637d5e6ccca..a2c6cca18eb 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -384,10 +384,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t else print ''; print ''; - // Progress calculated - // Note: ->duration is in fact time spent i think + // Progress calculated (Note: ->duration is time spent) print ''; - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; + if ($lines[$i]->planned_workload || $lines[$i]->duration) + { + if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; + else print $langs->trans('WorkloadNotDefined'); + } print ''; // Tick to drag and drop @@ -430,7 +433,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); print ''; print ''; - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent_if_planned / $total_projectlinesa_planned,2).' %'; + if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; print ''; if ($addordertick) print ''; print ''; @@ -562,13 +565,16 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr $disabledtask=1; } - print ''; - $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); + // Form to add new time + print ''; + $s=''; + $s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask); $s.=' '; - $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text'); + $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1); $s.=' '; print $s; print ''; + print ''; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php index 0c2cebc2e27..692e4ab08b4 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -181,7 +181,7 @@ print ''.$langs->trans("DateEnd").''; print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("ProgressDeclared").''; print ''.$langs->trans("TimeSpent").''; -print ''.$langs->trans("AddDuration").''; +print ''.$langs->trans("NewTimeSpent").''; print "\n"; // By default, we can edit only tasks we are assigned to diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index efec0f68223..cd736acf3f7 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -215,8 +215,6 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_end(); - - print ''; } // To verify role of users diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index e75278e9631..ee3b9288d3c 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -179,8 +179,6 @@ if ($object->id > 0) print ''; dol_fiche_end(); - - print ''; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 30e6c3fe291..5b479085f61 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -161,8 +161,6 @@ if ($object->id > 0) print ''; dol_fiche_end(); - - print ''; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2dc0adaa500..11bc8ffea09 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -262,8 +262,6 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_end(); - - print ''; } /* @@ -305,7 +303,7 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); - + print ''; // Ref @@ -372,7 +370,7 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_end(); - + print ''; print ' '; print ''; @@ -389,7 +387,7 @@ if ($id > 0 || ! empty($ref)) $linkback=$withproject?''.$langs->trans("BackToList").'':''; dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); - + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject,$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete"); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 09ffb36ce53..d489581e078 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -259,8 +259,6 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_end(); - - print ''; } $head=task_prepare_head($object); @@ -362,8 +360,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("By").''; print ''.$langs->trans("Note").''; print ''.$langs->trans("ProgressDeclared").''; - print ''.$langs->trans("Duration").''; - print ' '; + print ''.$langs->trans("NewTimeSpent").''; print "\n"; print ''; @@ -396,7 +393,7 @@ if ($id > 0 || ! empty($ref)) print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); print ''; - // Duration + // Duration - Time spent print ''; print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); print ''; @@ -446,13 +443,13 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print ''; print ''; print ''.$langs->trans("Date").''; print ''.$langs->trans("By").''; print ''.$langs->trans("Note").''; - print ''.$langs->trans("Duration").''; + print ''.$langs->trans("TimeSpent").''; print ' '; print "\n";