NEW: Show difference between timespent by everybody and time spent by
user making timesheet into timesheet pages. NEW: Can enter start hours of task when creating timesheet
This commit is contained in:
parent
8b5dd4910f
commit
d7ab3f112c
@ -177,15 +177,21 @@ function project_timesheet_prepare_head($mode)
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
|
||||
$head[$h][1] = $langs->trans("InputPerDay");
|
||||
$head[$h][2] = 'inputperday';
|
||||
$h++;
|
||||
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERDAY))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
|
||||
$head[$h][1] = $langs->trans("InputPerDay");
|
||||
$head[$h][2] = 'inputperday';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
|
||||
$head[$h][1] = $langs->trans("InputPerTime");
|
||||
$head[$h][2] = 'inputpertime';
|
||||
$h++;
|
||||
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
|
||||
$head[$h][1] = $langs->trans("InputPerTime");
|
||||
$head[$h][2] = 'inputpertime';
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet');
|
||||
|
||||
@ -524,20 +530,22 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
|
||||
// If we want all or we have a role on task, we show it
|
||||
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
|
||||
{
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
|
||||
// Project
|
||||
print "<td>";
|
||||
$projectstatic->id=$lines[$i]->fk_project;
|
||||
$projectstatic->ref=$lines[$i]->projectref;
|
||||
$projectstatic->public=$lines[$i]->public;
|
||||
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
|
||||
|
||||
$taskstatic->id=$lines[$i]->id;
|
||||
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
|
||||
// Project
|
||||
print "<td>";
|
||||
print $projectstatic->getNomUrl(1);
|
||||
print "</td>";
|
||||
|
||||
// Ref
|
||||
print '<td>';
|
||||
$taskstatic->id=$lines[$i]->id;
|
||||
$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
|
||||
print $taskstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
@ -564,8 +572,9 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
|
||||
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
|
||||
print '</td>';
|
||||
|
||||
// Time spent
|
||||
// Time spent by everybody
|
||||
print '<td align="right">';
|
||||
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
|
||||
if ($lines[$i]->duration)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
|
||||
@ -575,6 +584,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
|
||||
else print '--:--';
|
||||
print "</td>\n";
|
||||
|
||||
// Time spent by user
|
||||
print '<td align="right">';
|
||||
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
|
||||
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
|
||||
else print '--:--';
|
||||
print "</td>\n";
|
||||
|
||||
$disabledproject=1;$disabledtask=1;
|
||||
//print "x".$lines[$i]->fk_project;
|
||||
//var_dump($lines[$i]);
|
||||
@ -592,11 +608,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
|
||||
}
|
||||
|
||||
// Form to add new time
|
||||
print '<td class="nowrap" align="right">';
|
||||
print '<td class="nowrap" align="center">';
|
||||
$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',0,1);
|
||||
$s.=$form->select_date('',$lines[$i]->id,1,1,2,"addtime",1,0,1,$disabledtask);
|
||||
print $s;
|
||||
print '</td><td align="right">';
|
||||
//$s.=' ';
|
||||
$s=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
|
||||
$s.=' <input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
|
||||
print $s;
|
||||
print '</td>';
|
||||
@ -713,9 +731,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
|
||||
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
|
||||
print '</td>';
|
||||
|
||||
// Time spent
|
||||
/*
|
||||
// Time spent by everybody
|
||||
print '<td align="right">';
|
||||
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
|
||||
if ($lines[$i]->duration)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
|
||||
@ -724,7 +742,13 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
|
||||
}
|
||||
else print '--:--';
|
||||
print "</td>\n";
|
||||
*/
|
||||
|
||||
// Time spent by user
|
||||
print '<td align="right">';
|
||||
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
|
||||
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
|
||||
else print '--:--';
|
||||
print "</td>\n";
|
||||
|
||||
$disabledproject=1;$disabledtask=1;
|
||||
//print "x".$lines[$i]->fk_project;
|
||||
|
||||
@ -19,6 +19,10 @@
|
||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||
|
||||
|
||||
UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL;
|
||||
ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour;
|
||||
|
||||
|
||||
ALTER TABLE llx_commande_fournisseur MODIFY COLUMN date_livraison datetime;
|
||||
|
||||
-- Add id commandefourndet in llx_commande_fournisseur_dispatch to correct /fourn/commande/dispatch.php display when several times same product in supplier order
|
||||
|
||||
@ -20,8 +20,9 @@ create table llx_projet_task_time
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_task integer NOT NULL,
|
||||
task_date date, -- only the day
|
||||
task_datehour datetime, -- day + hour
|
||||
task_date date, -- only the day
|
||||
task_datehour datetime, -- day + hour
|
||||
task_date_withhour integer DEFAULT 0; -- 0 by default, 1 if date was entered with start hour
|
||||
task_duration double,
|
||||
fk_user integer,
|
||||
thm double(24,8),
|
||||
|
||||
@ -220,6 +220,7 @@ Cards=Cards
|
||||
Card=Card
|
||||
Now=Now
|
||||
Date=Date
|
||||
DateAndHour=Date and hour
|
||||
DateStart=Date start
|
||||
DateEnd=Date end
|
||||
DateCreation=Creation date
|
||||
|
||||
@ -31,6 +31,8 @@ NoProject=No project defined or owned
|
||||
NbOpenTasks=Nb of opened tasks
|
||||
NbOfProjects=Nb of projects
|
||||
TimeSpent=Time spent
|
||||
TimeSpentByYou=Time spent by you
|
||||
TimeSpentByUser=Time spent by user
|
||||
TimesSpent=Time spent
|
||||
RefTask=Ref. task
|
||||
LabelTask=Label task
|
||||
|
||||
@ -83,8 +83,10 @@ $taskstatic = new Task($db);
|
||||
$title=$langs->trans("TimeSpent");
|
||||
if ($mine) $title=$langs->trans("MyTimeSpent");
|
||||
|
||||
$usertoprocess=$user;
|
||||
|
||||
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
|
||||
|
||||
if ($id)
|
||||
{
|
||||
@ -94,8 +96,8 @@ if ($id)
|
||||
|
||||
$onlyopened=1; // or -1
|
||||
$tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
|
||||
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($user,0,($project->id?$project->id:$projectsListId),0);
|
||||
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$project->id:$projectsListId),0);
|
||||
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,0,($project->id?$project->id:$projectsListId),0);
|
||||
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$usertoprocess,($project->id?$project->id:$projectsListId),0);
|
||||
//var_dump($tasksarray);
|
||||
//var_dump($projectsrole);
|
||||
//var_dump($taskrole);
|
||||
@ -184,7 +186,9 @@ print '<td>'.$langs->trans("RefTask").'</td>';
|
||||
print '<td>'.$langs->trans("LabelTask").'</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 align="right">'.$langs->trans("TimeSpent").'</td>';
|
||||
if ($usertoprocess->id == $user->id) print '<td align="right">'.$langs->trans("TimeSpentByYou").'</td>';
|
||||
else print '<td align="right">'.$langs->trans("TimeSpentByUser").'</td>';
|
||||
|
||||
$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
|
||||
|
||||
@ -204,7 +208,7 @@ if (count($tasksarray) > 0)
|
||||
projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
|
||||
|
||||
print '<tr class="liste_total">
|
||||
<td class="liste_total" colspan="5" align="right">'.$langs->trans("Total").'</td>
|
||||
<td class="liste_total" colspan="7" align="right">'.$langs->trans("Total").'</td>
|
||||
<td class="liste_total" width="7%" align="center"><div id="totalDay[0]"> </div></td>
|
||||
<td class="liste_total" width="7%" align="center"><div id="totalDay[1]"> </div></td>
|
||||
<td class="liste_total" width="7%" align="center"><div id="totalDay[2]"> </div></td>
|
||||
|
||||
@ -62,8 +62,8 @@ if ($action == 'addtime' && $user->rights->projet->creer)
|
||||
{
|
||||
if (intval($time) > 0)
|
||||
{
|
||||
// Hours or minutes
|
||||
if (preg_match("/([0-9]+)(hour|min)/",$key,$matches))
|
||||
// Hours or minutes of duration
|
||||
if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches))
|
||||
{
|
||||
$id = $matches[1];
|
||||
if ($id > 0)
|
||||
@ -86,15 +86,33 @@ if ($action == 'addtime' && $user->rights->projet->creer)
|
||||
$task->progress = GETPOST($key . 'progress', 'int');
|
||||
$task->timespent_duration = $val;
|
||||
$task->timespent_fk_user = $user->id;
|
||||
$task->timespent_date = dol_mktime(12,0,0,$_POST["{$key}month"],$_POST["{$key}day"],$_POST["{$key}year"]);
|
||||
$task->addTimeSpent($user);
|
||||
if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered
|
||||
{
|
||||
$task->timespent_date = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,GETPOST($key."month"),GETPOST($key."day"),GETPOST($key."year"));
|
||||
$task->timespent_withhour = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$task->timespent_date = dol_mktime(12,0,0,GETPOST($key."month"),GETPOST($key."day"),GETPOST($key."year"));
|
||||
}
|
||||
|
||||
$result=$task->addTimeSpent($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($task->error, $task->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setEventMessage($langs->trans("RecordSaved"));
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("RecordSaved"));
|
||||
|
||||
// Redirect to avoid submit twice on back
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:''));
|
||||
exit;
|
||||
// Redirect to avoid submit twice on back
|
||||
header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,8 +134,9 @@ $taskstatic = new Task($db);
|
||||
$title=$langs->trans("TimeSpent");
|
||||
if ($mine) $title=$langs->trans("MyTimeSpent");
|
||||
|
||||
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
|
||||
$usertoprocess = $user;
|
||||
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
|
||||
|
||||
if ($id)
|
||||
{
|
||||
@ -127,8 +146,8 @@ if ($id)
|
||||
|
||||
$onlyopened=1; // or -1
|
||||
$tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
|
||||
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($user,0,($project->id?$project->id:$projectsListId),0);
|
||||
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$project->id:$projectsListId),0);
|
||||
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,0,($project->id?$project->id:$projectsListId),0);
|
||||
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$usertoprocess,($project->id?$project->id:$projectsListId),0);
|
||||
//var_dump($tasksarray);
|
||||
//var_dump($projectsrole);
|
||||
//var_dump($taskrole);
|
||||
@ -184,7 +203,10 @@ print '<td>'.$langs->trans("LabelTask").'</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" align="right">'.$langs->trans("NewTimeSpent").'</td>';
|
||||
if ($usertoprocess->id == $user->id) print '<td align="right">'.$langs->trans("TimeSpentByYou").'</td>';
|
||||
else print '<td align="right">'.$langs->trans("TimeSpentByUser").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateAndHour").'</td>';
|
||||
print '<td align="center" colspan="2">'.$langs->trans("Duration").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// By default, we can edit only tasks we are assigned to
|
||||
|
||||
@ -61,6 +61,7 @@ class Task extends CommonObject
|
||||
var $timespent_old_duration;
|
||||
var $timespent_date;
|
||||
var $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds)
|
||||
var $timespent_withhour; // 1 = we entered also start hours for timesheet line
|
||||
var $timespent_fk_user;
|
||||
var $timespent_note;
|
||||
|
||||
@ -780,6 +781,7 @@ class Task extends CommonObject
|
||||
$sql.= "fk_task";
|
||||
$sql.= ", task_date";
|
||||
$sql.= ", task_datehour";
|
||||
$sql.= ", task_date_withhour";
|
||||
$sql.= ", task_duration";
|
||||
$sql.= ", fk_user";
|
||||
$sql.= ", note";
|
||||
@ -787,6 +789,7 @@ class Task extends CommonObject
|
||||
$sql.= $this->id;
|
||||
$sql.= ", '".$this->db->idate($this->timespent_date)."'";
|
||||
$sql.= ", '".$this->db->idate($this->timespent_datehour)."'";
|
||||
$sql.= ", ".(empty($this->timespent_withhour)?0:1);
|
||||
$sql.= ", ".$this->timespent_duration;
|
||||
$sql.= ", ".$this->timespent_fk_user;
|
||||
$sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null");
|
||||
@ -816,7 +819,6 @@ class Task extends CommonObject
|
||||
{
|
||||
// Recalculate amount of time spent for task and update denormalized field
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
|
||||
//$sql.= " SET duration_effective = (".$this->db->ifsql('duration_effective IS NULL', 0, 'duration_effective').") + ".price2num($this->timespent_duration);
|
||||
$sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")";
|
||||
if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
@ -906,6 +908,8 @@ class Task extends CommonObject
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.fk_task,";
|
||||
$sql.= " t.task_date,";
|
||||
$sql.= " t.task_datehour,";
|
||||
$sql.= " t.task_date_withhour,";
|
||||
$sql.= " t.task_duration,";
|
||||
$sql.= " t.fk_user,";
|
||||
$sql.= " t.note";
|
||||
@ -922,7 +926,9 @@ class Task extends CommonObject
|
||||
|
||||
$this->timespent_id = $obj->rowid;
|
||||
$this->id = $obj->fk_task;
|
||||
$this->timespent_date = $obj->task_date;
|
||||
$this->timespent_date = $this->db->jdate($obj->task_date);
|
||||
$this->timespent_datehour = $this->db->jdate($obj->task_datehour);
|
||||
$this->timespent_withhour = $obj->task_date_withhour;
|
||||
$this->timespent_duration = $obj->task_duration;
|
||||
$this->timespent_fk_user = $obj->fk_user;
|
||||
$this->timespent_note = $obj->note;
|
||||
@ -961,6 +967,7 @@ class Task extends CommonObject
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
|
||||
$sql.= " task_date = '".$this->db->idate($this->timespent_date)."',";
|
||||
$sql.= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',";
|
||||
$sql.= " task_date_withhour = ".(empty($this->timespent_withhour)?0:1);
|
||||
$sql.= " task_duration = ".$this->timespent_duration.",";
|
||||
$sql.= " fk_user = ".$this->timespent_fk_user.",";
|
||||
$sql.= " note = ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null");
|
||||
@ -995,7 +1002,7 @@ class Task extends CommonObject
|
||||
$newDuration = $this->timespent_duration - $this->timespent_old_duration;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
|
||||
$sql.= " SET duration_effective = duration_effective + '".$newDuration."'";
|
||||
$sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG);
|
||||
|
||||
@ -87,7 +87,15 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
|
||||
$object->progress = GETPOST('progress', 'int');
|
||||
$object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds
|
||||
$object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds
|
||||
$object->timespent_date = dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
|
||||
if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered
|
||||
{
|
||||
$object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear"));
|
||||
$object->timespent_withhour = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->timespent_date = dol_mktime(12,0,0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear"));
|
||||
}
|
||||
$object->timespent_fk_user = $_POST["userid"];
|
||||
$result=$object->addTimeSpent($user);
|
||||
if ($result >= 0)
|
||||
@ -126,7 +134,15 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
|
||||
$object->timespent_old_duration = $_POST["old_duration"];
|
||||
$object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds
|
||||
$object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds
|
||||
$object->timespent_date = dol_mktime(12,0,0,$_POST["timelinemonth"],$_POST["timelineday"],$_POST["timelineyear"]);
|
||||
if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered
|
||||
{
|
||||
$object->timespent_date = dol_mktime(GETPOST("timelinehour"),GETPOST("timelinemin"),0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear"));
|
||||
$object->timespent_withhour = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->timespent_date = dol_mktime(12,0,0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear"));
|
||||
}
|
||||
$object->timespent_fk_user = $_POST["userid_line"];
|
||||
|
||||
$result=$object->updateTimeSpent($user);
|
||||
@ -341,7 +357,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
|
||||
/*
|
||||
* Add time spent
|
||||
* Form to add time spent
|
||||
*/
|
||||
if ($user->rights->projet->creer)
|
||||
{
|
||||
@ -367,8 +383,9 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Date
|
||||
print '<td class="nowrap">';
|
||||
$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
|
||||
print $form->select_date($newdate,'time','','','',"timespent_date");
|
||||
//$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
|
||||
$newdate='';
|
||||
print $form->select_date($newdate,'time',1,1,2,"timespent_date");
|
||||
print '</td>';
|
||||
|
||||
// Contributor
|
||||
@ -410,13 +427,13 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* List of time spent
|
||||
*/
|
||||
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
|
||||
$sql = "SELECT t.rowid, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note";
|
||||
$sql.= ", u.lastname, u.firstname";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE t.fk_task =".$object->id;
|
||||
$sql .= " AND t.fk_user = u.rowid";
|
||||
$sql .= " ORDER BY t.task_date DESC";
|
||||
$sql .= " ORDER BY t.task_date DESC, t.task_datehour DESC, t.rowid DESC";
|
||||
|
||||
$var=true;
|
||||
$resql = $db->query($sql);
|
||||
@ -459,15 +476,18 @@ if ($id > 0 || ! empty($ref))
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
$date1=$db->jdate($task_time->task_date);
|
||||
$date2=$db->jdate($task_time->task_datehour);
|
||||
|
||||
// Date
|
||||
print '<td>';
|
||||
print '<td class="nowrap">';
|
||||
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
|
||||
{
|
||||
print $form->select_date($db->jdate($task_time->task_date),'timeline','','','',"timespent_date");
|
||||
print $form->select_date($db->jdate($date2?$date2:$date1),'timeline',1,1,2,"timespent_date");
|
||||
}
|
||||
else
|
||||
{
|
||||
print dol_print_date($db->jdate($task_time->task_date),'day');
|
||||
print dol_print_date($date2?$date2:$date1,($task_time->task_date_withhour?'dayhour':'day'));
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -480,6 +500,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$contactsoftask[]=$task_time->fk_user;
|
||||
}
|
||||
if (count($contactsoftask)>0) {
|
||||
print img_object('','user','class="hideonsmartphone"');
|
||||
print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask);
|
||||
}else {
|
||||
print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user