diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 445aa827416ddc7f37394c9a135872b9ccec1e22..61d1c08f2aa599aa39e4197ed6bbdf136a8c190a 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.='<select'.($disabled?' disabled="disabled"':'').' class="flat" name="'.$prefix.'day">'; - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.='<option value="0" selected="selected"> </option>'; } @@ -3919,7 +3926,7 @@ class Form $retstring.="</select>"; $retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat" name="'.$prefix.'month">'; - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.='<option value="0" selected="selected"> </option>'; } @@ -3934,7 +3941,7 @@ class Form $retstring.="</select>"; // Year - if ($empty || $set_time == -1) + if ($emptydate || $set_time == -1) { $retstring.='<input'.($disabled?' disabled="disabled"':'').' placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" class="flat" type="text" size="3" maxlength="4" name="'.$prefix.'year" value="'.$syear.'">'; } @@ -3957,7 +3964,7 @@ class Form { // Show hour $retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'hour':'').'" name="'.$prefix.'hour">'; - if ($empty) $retstring.='<option value="-1"> </option>'; + if ($emptyhours) $retstring.='<option value="-1"> </option>'; for ($hour = 0; $hour < 24; $hour++) { if (strlen($hour) < 2) $hour = "0" . $hour; @@ -3971,7 +3978,7 @@ class Form { // Show minutes $retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'min':'').'" name="'.$prefix.'min">'; - if ($empty) $retstring.='<option value="-1"> </option>'; + if ($emptyhours) $retstring.='<option value="-1"> </option>'; 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 '<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').'>'; + $retstring.='<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').'>'; for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours { - print '<option value="'.$hour.'"'; + $retstring.='<option value="'.$hour.'"'; if ($hourSelected == $hour) { - print " selected=\"true\""; + $retstring.=" selected=\"true\""; } - print ">".$hour."</option>"; + $retstring.=">".$hour."</option>"; } - print "</select>"; + $retstring.="</select>"; } elseif ($typehour=='text') { - print '<input type="text" size="3" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').' class="flat" value="'.((int) $hourSelected).'">'; + $retstring.='<input type="text" size="2" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').' class="flat" value="'.($hourSelected?((int) $hourSelected):'').'">'; } - print ' '.$langs->trans('HourShort'); + else return 'BadValueForParameterTypeHour'; - if ($minunderhours) print '<br>'; - else print " "; + $retstring.=' '.$langs->trans('HourShort'); - print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>'; - for ($min = 0; $min <= 55; $min=$min+5) + if ($minunderhours) $retstring.='<br>'; + else $retstring.=" "; + + if ($typehour=='select') + { + $retstring.='<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>'; + for ($min = 0; $min <= 55; $min=$min+5) + { + $retstring.='<option value="'.$min.'"'; + if ($minSelected == $min) $retstring.=' selected="selected"'; + $retstring.='>'.$min.'</option>'; + } + $retstring.="</select>"; + } + elseif ($typehour=='text') { - print '<option value="'.$min.'"'; - if ($minSelected == $min) print ' selected="selected"'; - print '>'.$min.'</option>'; + $retstring.='<input type="text" size="2" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').' class="flat" value="'.($minSelected?((int) $minSelected):'').'">'; } - print "</select>"; - print ' '.$langs->trans('MinuteShort'). " "; + $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 637d5e6cccae9c733b148e5602dba0c99bc63a00..a2c6cca18eb64064352e2dfba6c3f9dd372c26f9 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 '</a>'; print '</td>'; - // Progress calculated - // Note: ->duration is in fact time spent i think + // Progress calculated (Note: ->duration is time spent) print '<td align="right">'; - 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 '</td>'; // 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 '</td>'; print '<td align="right" class="nowrap liste_total">'; - 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 '</td>'; if ($addordertick) print '<td class="hideonsmartphone"></td>'; print '</tr>'; @@ -562,13 +565,16 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr $disabledtask=1; } - print '<td class="nowrap">'; - $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); + // Form to add new time + print '<td class="nowrap" align="right">'; + $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.=' <input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">'; print $s; print '</td>'; + print '<td align="right">'; 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 0c2cebc2e27998589601694e1fd3b75b908099da..692e4ab08b40c6842a6425a865ca2d3eb3b3fffc 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -181,7 +181,7 @@ print '<td align="center">'.$langs->trans("DateEnd").'</td>'; print '<td align="right">'.$langs->trans("PlannedWorkload").'</td>'; print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; -print '<td colspan="2">'.$langs->trans("AddDuration").'</td>'; +print '<td colspan="2" align="right">'.$langs->trans("NewTimeSpent").'</td>'; print "</tr>\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 efec0f682230ec4af32c2cbbb469cc3995b07d9a..cd736acf3f7d02cbb364b6d945746760721966a1 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -215,8 +215,6 @@ if ($id > 0 || ! empty($ref)) print '</table>'; dol_fiche_end(); - - print '<br>'; } // To verify role of users diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index e75278e9631153284969e84388d4c33b14241be5..ee3b9288d3c988a0cfa46e65c889b3254256aab1 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -179,8 +179,6 @@ if ($object->id > 0) print '</table>'; dol_fiche_end(); - - print '<br>'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 30e6c3fe291d0db47e85ae05966a068a04f5bf91..5b479085f6136bf36bba2ce33e17bea708c93745 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -161,8 +161,6 @@ if ($object->id > 0) print '</table>'; dol_fiche_end(); - - print '<br>'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2dc0adaa5002681696a141554030ecf951226a1b..11bc8ffea096bc293bcb9c96c758b0d3ab7fd20b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -262,8 +262,6 @@ if ($id > 0 || ! empty($ref)) print '</table>'; dol_fiche_end(); - - print '<br>'; } /* @@ -305,7 +303,7 @@ if ($id > 0 || ! empty($ref)) print '<input type="hidden" name="id" value="'.$object->id.'">'; dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); - + print '<table class="border" width="100%">'; // Ref @@ -372,7 +370,7 @@ if ($id > 0 || ! empty($ref)) print '</table>'; dol_fiche_end(); - + print '<div align="center">'; print '<input type="submit" class="button" name="update" value="'.$langs->trans("Modify").'"> '; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; @@ -389,7 +387,7 @@ if ($id > 0 || ! empty($ref)) $linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; 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 09ffb36ce530d76878086ec859569b166a5d183e..d489581e078a6f44be76bb19f277d3060bd50b8d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -259,8 +259,6 @@ if ($id > 0 || ! empty($ref)) print '</table>'; dol_fiche_end(); - - print '<br>'; } $head=task_prepare_head($object); @@ -362,8 +360,7 @@ if ($id > 0 || ! empty($ref)) print '<td>'.$langs->trans("By").'</td>'; print '<td>'.$langs->trans("Note").'</td>'; print '<td>'.$langs->trans("ProgressDeclared").'</td>'; - print '<td align="right">'.$langs->trans("Duration").'</td>'; - print '<td width="80"> </td>'; + print '<td align="right" colspan="2">'.$langs->trans("NewTimeSpent").'</td>'; print "</tr>\n"; print '<tr '.$bc[false].'>'; @@ -396,7 +393,7 @@ if ($id > 0 || ! empty($ref)) print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); print '</td>'; - // Duration + // Duration - Time spent print '<td class="nowrap" align="right">'; print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); print '</td>'; @@ -446,13 +443,13 @@ if ($id > 0 || ! empty($ref)) print '<input type="hidden" name="action" value="updateline">'; print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="withproject" value="'.$withproject.'">'; - + print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td width="100">'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("By").'</td>'; print '<td align="left">'.$langs->trans("Note").'</td>'; - print '<td align="right">'.$langs->trans("Duration").'</td>'; + print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td> </td>'; print "</tr>\n";