';
+}
+
/*
* Migration directory
*/
diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang
index d9d77c9f3c5..545babe32cb 100644
--- a/htdocs/langs/en_US/install.lang
+++ b/htdocs/langs/en_US/install.lang
@@ -214,3 +214,6 @@ MigrationProjectTaskActors=Data migration for llx_projet_task_actors table
# Migration project user resp
MigrationProjectUserResp=Data migration field fk_user_resp of llx_projet to llx_element_contact
+
+# Migration project task time
+MigrationProjectTaskTime=Update time spent in seconds
diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang
index 10f25e82974..727a3e4c20b 100644
--- a/htdocs/langs/fr_FR/install.lang
+++ b/htdocs/langs/fr_FR/install.lang
@@ -194,25 +194,28 @@ MigrationReopenedContractsNumber=%s contrats modifiés
MigrationReopeningContractsNothingToUpdate=Pas ou plus de contrats à réouvrir.
# Migration transfert
-MigrationBankTransfertsUpdate=Mise a jour des liens entre ecriture bancaire et un transfert entre compte
+MigrationBankTransfertsUpdate=Mise à jour des liens entre écriture bancaire et un transfert entre compte
MigrationBankTransfertsNothingToUpdate=Aucun lien non à jour
# Migration delivery
-MigrationShipmentOrderMatching=Mise a jour bon expedition
-MigrationDeliveryOrderMatching=Mise a jour bon reception
-MigrationDeliveryDetail=Mise a jour bon reception
+MigrationShipmentOrderMatching=Mise à jour bon expédition
+MigrationDeliveryOrderMatching=Mise à jour bon réception
+MigrationDeliveryDetail=Mise à jour bon réception
# Migration stock
-MigrationStockDetail=Mise a jour valeur en stock des produits
+MigrationStockDetail=Mise à jour valeur en stock des produits
# Migration menus
-MigrationMenusDetail=Mise a jour table des menus dynamiques
+MigrationMenusDetail=Mise à jour table des menus dynamiques
# Migration delivery address
-MigrationDeliveryAddress=Mise a jour des adresses de livraison dans les bons d'expedition
+MigrationDeliveryAddress=Mise à jour des adresses de livraison dans les bons d'expédition
# Migration project task actors
MigrationProjectTaskActors=Migration de la table llx_projet_task_actors
# Migration project user resp
MigrationProjectUserResp=Migration du champ fk_user_resp de llx_projet vers llx_element_contact
+
+# Migration project task time
+MigrationProjectTaskTime=Mise à jour du temps consommé en secondes
diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php
index 36149fa7a08..f6d038c5af7 100644
--- a/htdocs/projet/tasks/task.class.php
+++ b/htdocs/projet/tasks/task.class.php
@@ -60,7 +60,7 @@ class Task extends CommonObject
var $timespent_id;
var $timespent_duration;
var $timespent_date;
- var $timespent_user;
+ var $timespent_fk_user;
var $timespent_note;
@@ -589,9 +589,8 @@ class Task extends CommonObject
/**
* \brief Add time spent
- * \param user Id utilisateur qui cree
- * \param time Time spent
- * \param date date
+ * \param user user id
+ * \param notrigger 0=launch triggers after, 1=disable triggers
*/
function addTimeSpent($user, $notrigger=0)
{
@@ -704,6 +703,66 @@ class Task extends CommonObject
}
}
+ /**
+ * \brief Update time spent
+ * \param user User id
+ * \param notrigger 0=launch triggers after, 1=disable triggers
+ */
+ function updateTimeSpent($user, $notrigger=0)
+ {
+ $ret = 0;
+
+ // Clean parameters
+ $this->timespent_duration = intval($this->timespent_duration)+(($this->timespent_duration-intval($this->timespent_duration))*(1+2/3));
+ $this->timespent_duration = price2num($this->timespent_duration);
+ if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
+ $sql.= " task_date = '".$this->db->idate($this->timespent_date)."',";
+ $sql.= " task_duration = ".$this->timespent_duration.",";
+ $sql.= " fk_user = ".$this->timespent_fk_user.",";
+ $sql.= " note = ".(isset($this->timespent_note)?"'".addslashes($this->timespent_note)."'":"null");
+ $sql.= " WHERE rowid = ".$this->timespent_id;
+
+ dol_syslog(get_class($this)."::updateTimeSpent sql=".$sql, LOG_DEBUG);
+ if ($this->db->query($sql) )
+ {
+ if (! $notrigger)
+ {
+ // Call triggers
+ include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('TASK_TIMESPENT_MODIFY',$this,$user,$langs,$conf);
+ if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // End call triggers
+ }
+ $ret = 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::addTimeSpent error -1 ".$this->error,LOG_ERR);
+ $ret = -1;
+ }
+/*
+ if ($ret >= 0)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
+ $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'";
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG);
+ if (! $this->db->query($sql) )
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::addTimeSpent error -2 ".$this->error, LOG_ERR);
+ $ret = -2;
+ }
+ }
+*/
+ return $ret;
+ }
+
/**
* \brief Delete time spent
* \param user User that delete
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 55f421f0fef..7e80f109a6d 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -53,6 +53,7 @@ if ($_POST["action"] == 'addtimespent' && $user->rights->projet->creer)
$task->timespent_note = $_POST["timespent_note"];
$task->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds
+ $task->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds
$task->timespent_date = dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
$task->timespent_fk_user = $_POST["userid"];
@@ -74,7 +75,39 @@ if ($_POST["action"] == 'addtimespent' && $user->rights->projet->creer)
if ($_POST["action"] == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->creer)
{
+ $error=0;
+ if (empty($_POST["timespent_duration_linehour"]) && empty($_POST["timespent_duration_linemin"]))
+ {
+ $mesg='