Fix: management of time spent in task card
Fix: Update time spent in seconds
This commit is contained in:
parent
703e35ad73
commit
dd588bda19
@ -2552,7 +2552,7 @@ class Form
|
||||
* \param prefix prefix
|
||||
* \param iSecond Nombre de secondes
|
||||
*/
|
||||
function select_duree($prefix,$iSecond='')
|
||||
function select_duree($prefix,$iSecond='',$default=1,$disabled=0)
|
||||
{
|
||||
if ($iSecond)
|
||||
{
|
||||
@ -2562,11 +2562,11 @@ class Form
|
||||
$minSelected = ConvertSecondToTime($iSecond,'min');
|
||||
}
|
||||
|
||||
print '<select class="flat" name="'.$prefix.'hour">';
|
||||
print '<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="true"':'').'>';
|
||||
for ($hour = 0; $hour < 24; $hour++)
|
||||
{
|
||||
print '<option value="'.$hour.'"';
|
||||
if ($hourSelected == $hour || ($iSecond == '' && $hour == 1))
|
||||
if ($hourSelected == $hour || ($iSecond == '' && $hour == $default))
|
||||
{
|
||||
print " selected=\"true\"";
|
||||
}
|
||||
@ -2574,7 +2574,7 @@ class Form
|
||||
}
|
||||
print "</select>";
|
||||
print "H ";
|
||||
print '<select class="flat" name="'.$prefix.'min">';
|
||||
print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="true"':'').'>';
|
||||
for ($min = 0; $min <= 55; $min=$min+5)
|
||||
{
|
||||
print '<option value="'.$min.'"';
|
||||
|
||||
@ -254,14 +254,14 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole)
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
|
||||
print $lines[$i]->label;
|
||||
print "</td>\n";
|
||||
|
||||
$heure = intval($lines[$i]->duration);
|
||||
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
|
||||
$minutes = substr("00"."$minutes", -2);
|
||||
print '<td align="right">'.$heure." h ".$minutes."</td>\n";
|
||||
// Time spent
|
||||
print '<td align="right">';
|
||||
if ($lines[$i]->duration) print ConvertSecondToTime($lines[$i]->duration,'all');
|
||||
else print '--:--';
|
||||
print "</td>\n";
|
||||
|
||||
$disabled=1;
|
||||
//print "x".$lines[$i]->projectid;
|
||||
@ -272,7 +272,8 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole)
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print $form->select_date('',$lines[$i]->id,'','','',"addtime");
|
||||
print ' <input size="4" type="text" class="flat"'.($disabled?' disabled="true"':'').' name="task'.$lines[$i]->id.'" value="">';
|
||||
print ' ';
|
||||
print $form->select_duree($lines[$i]->id,'',0,$disabled);
|
||||
print ' <input type="submit" class="button"'.($disabled?' disabled="true"':'').' value="'.$langs->trans("Add").'">';
|
||||
if ((! $lines[$i]->public) && $disabled) print '('.$langs->trans("YouAreNotContactOfProject").')';
|
||||
print '</td>';
|
||||
@ -401,13 +402,12 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole
|
||||
else print '</a>';
|
||||
print "</td>\n";
|
||||
|
||||
$heure = intval($lines[$i]->duration);
|
||||
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
|
||||
$minutes = substr("00"."$minutes", -2);
|
||||
// Time spent
|
||||
print '<td align="right">';
|
||||
if ($showlineingray) print '<i>';
|
||||
else print '<a href="time.php?id='.$lines[$i]->id.'">';
|
||||
print $heure." h ".$minutes;
|
||||
if ($lines[$i]->duration) print ConvertSecondToTime($lines[$i]->duration,'all');
|
||||
else print '--:--';
|
||||
if ($showlineingray) print '</i>';
|
||||
else print '</a>';
|
||||
print '</td>';
|
||||
|
||||
@ -29,6 +29,9 @@ require ("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
$langs->load('projects');
|
||||
|
||||
$mode=$_REQUEST["mode"];
|
||||
|
||||
@ -62,20 +65,23 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
|
||||
|
||||
if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
|
||||
{
|
||||
// TODO probleme si que des minutes
|
||||
foreach ($_POST as $key => $time)
|
||||
{
|
||||
if (substr($key,0,4) == 'task')
|
||||
if (substr($key,-4) == 'hour')
|
||||
{
|
||||
if ($time > 0)
|
||||
if ($time > 0)
|
||||
{
|
||||
$id = str_replace("task","",$key);
|
||||
$id = str_replace("hour","",$key);
|
||||
|
||||
$task = new Task($db);
|
||||
$task->fetch($id);
|
||||
|
||||
$task->timespent_duration = $time;
|
||||
$task->timespent_fk_user = $user->id;
|
||||
$task->timespent_duration = $_POST[$id."hour"]*60*60; // We store duration in seconds
|
||||
$task->timespent_duration+= $_POST[$id."min"]*60; // We store duration in seconds
|
||||
$task->timespent_date = dol_mktime(12,0,0,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]);
|
||||
|
||||
|
||||
$task->addTimeSpent($user);
|
||||
}
|
||||
else
|
||||
|
||||
@ -29,6 +29,7 @@ require ("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
$langs->load('projects');
|
||||
|
||||
|
||||
@ -741,7 +741,7 @@ class Task extends CommonObject
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::addTimeSpent error -1 ".$this->error,LOG_ERR);
|
||||
dol_syslog(get_class($this)."::updateTimeSpent error -1 ".$this->error,LOG_ERR);
|
||||
$ret = -1;
|
||||
}
|
||||
/*
|
||||
|
||||
@ -31,6 +31,8 @@ require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
$langs->load('projects');
|
||||
|
||||
if (!$user->rights->projet->lire) accessforbidden();
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user