\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
index 4f3c802a9da..3233022d3f9 100755
--- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
+++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
@@ -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
diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql
index d5d89812b4a..d58b35146a7 100644
--- a/htdocs/install/mysql/tables/llx_projet_task_time.sql
+++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql
@@ -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),
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index ba7353b015d..be893d52569 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -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
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 936e86ad692..53e7140be08 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -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
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index 692267d6965..9ca8f95ac45 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -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 '
diff --git a/htdocs/projet/activity/pertime.php b/htdocs/projet/activity/pertime.php
index 9d277251772..9f2dc3e99ca 100644
--- a/htdocs/projet/activity/pertime.php
+++ b/htdocs/projet/activity/pertime.php
@@ -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 '
'.$langs->trans("LabelTask").'
';
print '
'.$langs->trans("PlannedWorkload").'
';
print '
'.$langs->trans("ProgressDeclared").'
';
print '
'.$langs->trans("TimeSpent").'
';
-print '
'.$langs->trans("NewTimeSpent").'
';
+if ($usertoprocess->id == $user->id) print '
'.$langs->trans("TimeSpentByYou").'
';
+else print '
'.$langs->trans("TimeSpentByUser").'
';
+print '
'.$langs->trans("DateAndHour").'
';
+print '
'.$langs->trans("Duration").'
';
print "
\n";
// By default, we can edit only tasks we are assigned to
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 4c3e3995b03..f9e07ab6e9d 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -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);
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 9951902ec5b..20ef1714164 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -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 '