From 31f782ffe9119db94683f06bac91bf727f550487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Dec 2014 14:58:18 +0100 Subject: [PATCH] Fix: Several fixes into tasks and time spent management --- htdocs/core/class/html.form.class.php | 82 ++++++++++++++++++--------- htdocs/core/lib/project.lib.php | 20 ++++--- htdocs/projet/activity/list.php | 2 +- htdocs/projet/tasks/contact.php | 2 - htdocs/projet/tasks/document.php | 2 - htdocs/projet/tasks/note.php | 2 - htdocs/projet/tasks/task.php | 8 +-- htdocs/projet/tasks/time.php | 11 ++-- 8 files changed, 75 insertions(+), 54 deletions(-) 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 ''; for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours { - print '"; + $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) + { + $retstring.='