Ajout fonction CreateTask et TaskAddTime
This commit is contained in:
parent
d6b26f67e6
commit
76d39158ca
@ -138,11 +138,18 @@ class Project {
|
|||||||
$this->societe->id = $obj->fk_soc;
|
$this->societe->id = $obj->fk_soc;
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $this->db->error();
|
print $this->db->error();
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,5 +328,110 @@ class Project {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Crée une tache dans le projet
|
||||||
|
* \param user Id utilisateur qui crée
|
||||||
|
* \param title titre de la tâche
|
||||||
|
* \param parent tache parente
|
||||||
|
*/
|
||||||
|
function CreateTask($user, $title, $parent = 0)
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
if (trim($title))
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat) ";
|
||||||
|
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.") ;";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Project::CreateTask error -2");
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result ==0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) ";
|
||||||
|
$sql .= " VALUES (".$task_id.",".$user->id.") ;";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Project::CreateTask error -3");
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Project::CreateTask error -1 ref null");
|
||||||
|
$result = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* \brief Crée une tache dans le projet
|
||||||
|
* \param user Id utilisateur qui crée
|
||||||
|
* \param title titre de la tâche
|
||||||
|
* \param parent tache parente
|
||||||
|
*/
|
||||||
|
function TaskAddTime($user, $task, $time)
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (fk_task, task_date, task_duration, fk_user)";
|
||||||
|
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.") ;";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Project::CreateTask error -2");
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result ==0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
|
||||||
|
$sql .= " SET duration_effective = duration_effective + '".ereg_replace(",",".",$time)."'";
|
||||||
|
$sql .= " WHERE rowid = '".$task."';";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Project::CreateTask error -3");
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user