Fix: Several fixes into tasks and time spent management

This commit is contained in:
Laurent Destailleur 2014-12-21 14:58:18 +01:00
parent bdb47921e7
commit 31f782ffe9
8 changed files with 75 additions and 54 deletions

View File

@ -3800,7 +3800,7 @@ class Form
* @param string $prefix Prefix for fields name * @param string $prefix Prefix for fields name
* @param int $h 1=Show also hours * @param int $h 1=Show also hours
* @param int $m 1=Show also minutes * @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 string $form_name Not used
* @param int $d 1=Show days, month, years * @param int $d 1=Show days, month, years
* @param int $addnowbutton Add a button "Now" * @param int $addnowbutton Add a button "Now"
@ -3819,9 +3819,13 @@ class Form
if($prefix=='') $prefix='re'; if($prefix=='') $prefix='re';
if($h == '') $h=0; if($h == '') $h=0;
if($m == '') $m=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'; 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 $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"); $syear = dol_print_date($set_time, "%Y");
$smonth = dol_print_date($set_time, "%m"); $smonth = dol_print_date($set_time, "%m");
$sday = dol_print_date($set_time, "%d"); $sday = dol_print_date($set_time, "%d");
$shour = dol_print_date($set_time, "%H"); if ($orig_set_time != '')
$smin = dol_print_date($set_time, "%M"); {
$shour = dol_print_date($set_time, "%H");
$smin = dol_print_date($set_time, "%M");
}
} }
else else
{ {
@ -3906,7 +3913,7 @@ class Form
// Day // Day
$retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat" name="'.$prefix.'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">&nbsp;</option>'; $retstring.='<option value="0" selected="selected">&nbsp;</option>';
} }
@ -3919,7 +3926,7 @@ class Form
$retstring.="</select>"; $retstring.="</select>";
$retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat" name="'.$prefix.'month">'; $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">&nbsp;</option>'; $retstring.='<option value="0" selected="selected">&nbsp;</option>';
} }
@ -3934,7 +3941,7 @@ class Form
$retstring.="</select>"; $retstring.="</select>";
// Year // 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.'">'; $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 // Show hour
$retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'hour':'').'" name="'.$prefix.'hour">'; $retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'hour':'').'" name="'.$prefix.'hour">';
if ($empty) $retstring.='<option value="-1">&nbsp;</option>'; if ($emptyhours) $retstring.='<option value="-1">&nbsp;</option>';
for ($hour = 0; $hour < 24; $hour++) for ($hour = 0; $hour < 24; $hour++)
{ {
if (strlen($hour) < 2) $hour = "0" . $hour; if (strlen($hour) < 2) $hour = "0" . $hour;
@ -3971,7 +3978,7 @@ class Form
{ {
// Show minutes // Show minutes
$retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'min':'').'" name="'.$prefix.'min">'; $retstring.='<select'.($disabled?' disabled="disabled"':'').' class="flat '.($fullday?$fullday.'min':'').'" name="'.$prefix.'min">';
if ($empty) $retstring.='<option value="-1">&nbsp;</option>'; if ($emptyhours) $retstring.='<option value="-1">&nbsp;</option>';
for ($min = 0; $min < 60 ; $min++) for ($min = 0; $min < 60 ; $min++)
{ {
if (strlen($min) < 2) $min = "0" . $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 * 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 $iSecond Default preselected duration (number of seconds)
* @param int $disabled Disable the combo box * @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 $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 string $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it
* @return void * @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; global $langs;
$retstring='';
$hourSelected=0; $minSelected=0; $hourSelected=0; $minSelected=0;
if ($iSecond) if ($iSecond)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -4052,36 +4063,51 @@ class Form
if ($typehour=='select') 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 for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours
{ {
print '<option value="'.$hour.'"'; $retstring.='<option value="'.$hour.'"';
if ($hourSelected == $hour) if ($hourSelected == $hour)
{ {
print " selected=\"true\""; $retstring.=" selected=\"true\"";
} }
print ">".$hour."</option>"; $retstring.=">".$hour."</option>";
} }
print "</select>"; $retstring.="</select>";
} }
elseif ($typehour=='text') 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>'; $retstring.=' '.$langs->trans('HourShort');
else print "&nbsp;";
print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>'; if ($minunderhours) $retstring.='<br>';
for ($min = 0; $min <= 55; $min=$min+5) else $retstring.="&nbsp;";
if ($typehour=='select')
{ {
print '<option value="'.$min.'"'; $retstring.='<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>';
if ($minSelected == $min) print ' selected="selected"'; for ($min = 0; $min <= 55; $min=$min+5)
print '>'.$min.'</option>'; {
$retstring.='<option value="'.$min.'"';
if ($minSelected == $min) $retstring.=' selected="selected"';
$retstring.='>'.$min.'</option>';
}
$retstring.="</select>";
} }
print "</select>"; elseif ($typehour=='text')
print ' '.$langs->trans('MinuteShort'). "&nbsp;"; {
$retstring.='<input type="text" size="2" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').' class="flat" value="'.($minSelected?((int) $minSelected):'').'">';
}
$retstring.=' '.$langs->trans('MinuteShort');
$retstring.="&nbsp;";
if (! empty($nooutput)) return $retstring;
print $retstring;
return;
} }

View File

@ -384,10 +384,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
else print '</a>'; else print '</a>';
print '</td>'; print '</td>';
// Progress calculated // Progress calculated (Note: ->duration is time spent)
// Note: ->duration is in fact time spent i think
print '<td align="right">'; 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>'; print '</td>';
// Tick to drag and drop // 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 convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
print '</td>'; print '</td>';
print '<td align="right" class="nowrap liste_total">'; 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>'; print '</td>';
if ($addordertick) print '<td class="hideonsmartphone"></td>'; if ($addordertick) print '<td class="hideonsmartphone"></td>';
print '</tr>'; print '</tr>';
@ -562,13 +565,16 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
$disabledtask=1; $disabledtask=1;
} }
print '<td class="nowrap">'; // Form to add new time
$s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); print '<td class="nowrap" align="right">';
$s='';
$s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask);
$s.='&nbsp;&nbsp;&nbsp;'; $s.='&nbsp;&nbsp;&nbsp;';
$s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text'); $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1);
$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">'; $s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s; print $s;
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));

View File

@ -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("PlannedWorkload").'</td>';
print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>'; print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</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"; print "</tr>\n";
// By default, we can edit only tasks we are assigned to // By default, we can edit only tasks we are assigned to

View File

@ -215,8 +215,6 @@ if ($id > 0 || ! empty($ref))
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<br>';
} }
// To verify role of users // To verify role of users

View File

@ -179,8 +179,6 @@ if ($object->id > 0)
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<br>';
} }
$head = task_prepare_head($object); $head = task_prepare_head($object);

View File

@ -161,8 +161,6 @@ if ($object->id > 0)
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<br>';
} }
$head = task_prepare_head($object); $head = task_prepare_head($object);

View File

@ -262,8 +262,6 @@ if ($id > 0 || ! empty($ref))
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<br>';
} }
/* /*

View File

@ -259,8 +259,6 @@ if ($id > 0 || ! empty($ref))
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<br>';
} }
$head=task_prepare_head($object); $head=task_prepare_head($object);
@ -362,8 +360,7 @@ if ($id > 0 || ! empty($ref))
print '<td>'.$langs->trans("By").'</td>'; print '<td>'.$langs->trans("By").'</td>';
print '<td>'.$langs->trans("Note").'</td>'; print '<td>'.$langs->trans("Note").'</td>';
print '<td>'.$langs->trans("ProgressDeclared").'</td>'; print '<td>'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("Duration").'</td>'; print '<td align="right" colspan="2">'.$langs->trans("NewTimeSpent").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr '.$bc[false].'>'; 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 $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress');
print '</td>'; print '</td>';
// Duration // Duration - Time spent
print '<td class="nowrap" align="right">'; print '<td class="nowrap" align="right">';
print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text');
print '</td>'; print '</td>';
@ -452,7 +449,7 @@ if ($id > 0 || ! empty($ref))
print '<td width="100">'.$langs->trans("Date").'</td>'; print '<td width="100">'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("By").'</td>'; print '<td>'.$langs->trans("By").'</td>';
print '<td align="left">'.$langs->trans("Note").'</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>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";