|
@@ -43,6 +43,7 @@ class Task extends CommonObject
|
|
|
var $date_start;
|
|
|
var $date_end;
|
|
|
var $progress;
|
|
|
+ var $fk_statut;
|
|
|
var $priority;
|
|
|
var $fk_user_creat;
|
|
|
var $fk_user_valid;
|
|
@@ -535,13 +536,14 @@ class Task extends CommonObject
|
|
|
$this->id=0;
|
|
|
|
|
|
$this->fk_projet='';
|
|
|
- $this->ref='';
|
|
|
+ $this->ref='TK01';
|
|
|
$this->fk_task_parent='';
|
|
|
- $this->title='';
|
|
|
+ $this->title='Specimen task TK01';
|
|
|
$this->duration_effective='';
|
|
|
$this->fk_user_creat='';
|
|
|
- $this->statut='';
|
|
|
- $this->note='';
|
|
|
+ $this->progress='25';
|
|
|
+ $this->fk_statut='';
|
|
|
+ $this->note='This is a specimen task not';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -569,8 +571,8 @@ class Task extends CommonObject
|
|
|
//print $usert.'-'.$userp.'-'.$projectid.'-'.$socid.'-'.$mode.'<br>';
|
|
|
|
|
|
// List of tasks (does not care about permissions. Filtering will be done later)
|
|
|
- $sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut,";
|
|
|
- $sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress,";
|
|
|
+ $sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus,";
|
|
|
+ $sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,";
|
|
|
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang";
|
|
|
if ($mode == 0)
|
|
|
{
|
|
@@ -674,13 +676,14 @@ class Task extends CommonObject
|
|
|
$tasks[$i]->fk_project = $obj->projectid;
|
|
|
$tasks[$i]->projectref = $obj->ref;
|
|
|
$tasks[$i]->projectlabel = $obj->plabel;
|
|
|
- $tasks[$i]->projectstatus = $obj->fk_statut;
|
|
|
+ $tasks[$i]->projectstatus = $obj->projectstatus;
|
|
|
$tasks[$i]->label = $obj->label;
|
|
|
$tasks[$i]->description = $obj->description;
|
|
|
$tasks[$i]->fk_parent = $obj->fk_task_parent;
|
|
|
$tasks[$i]->duration = $obj->duration_effective;
|
|
|
$tasks[$i]->planned_workload= $obj->planned_workload;
|
|
|
$tasks[$i]->progress = $obj->progress;
|
|
|
+ $tasks[$i]->fk_statut = $obj->status;
|
|
|
$tasks[$i]->public = $obj->public;
|
|
|
$tasks[$i]->date_start = $this->db->jdate($obj->date_start);
|
|
|
$tasks[$i]->date_end = $this->db->jdate($obj->date_end);
|
|
@@ -1542,4 +1545,91 @@ class Task extends CommonObject
|
|
|
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
|
|
+ *
|
|
|
+ * @param User $user Objet user
|
|
|
+ * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
|
|
+ */
|
|
|
+ function load_board($user)
|
|
|
+ {
|
|
|
+ global $conf, $langs;
|
|
|
+
|
|
|
+ $mine=0; $socid=$user->societe_id;
|
|
|
+
|
|
|
+ $projectstatic = new Project($this->db);
|
|
|
+ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
|
|
|
+
|
|
|
+ // List of tasks (does not care about permissions. Filtering will be done later)
|
|
|
+ $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
|
|
|
+ $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
|
|
|
+ $sql.= " t.dateo as date_start, t.datee as datee";
|
|
|
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
|
|
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
|
|
+ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
|
|
+ $sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
|
|
|
+ $sql.= " WHERE p.entity IN (".getEntity('project').')';
|
|
|
+ $sql.= " AND p.fk_statut = 1";
|
|
|
+ $sql.= " AND t.fk_projet = p.rowid";
|
|
|
+ $sql.= " AND t.progress < 100"; // tasks to do
|
|
|
+ if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
|
|
+ // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
|
|
+ //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
|
|
+ if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
|
|
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
|
|
|
+ //print $sql;
|
|
|
+ $resql=$this->db->query($sql);
|
|
|
+ if ($resql)
|
|
|
+ {
|
|
|
+ $task_static = new Task($this->db);
|
|
|
+
|
|
|
+ $response = new WorkboardResponse();
|
|
|
+ $response->warning_delay = $conf->projet->task->warning_delay/60/60/24;
|
|
|
+ $response->label = $langs->trans("OpenedTasks");
|
|
|
+ if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project';
|
|
|
+ else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project';
|
|
|
+ $response->img = img_object($langs->trans("Tasks"),"task");
|
|
|
+
|
|
|
+ // This assignment in condition is not a bug. It allows walking the results.
|
|
|
+ while ($obj=$this->db->fetch_object($resql))
|
|
|
+ {
|
|
|
+ $response->nbtodo++;
|
|
|
+
|
|
|
+ $task_static->projectstatus = $obj->projectstatus;
|
|
|
+ $task_static->progress = $obj->progress;
|
|
|
+ $task_static->fk_statut = $obj->status;
|
|
|
+ $task_static->datee = $this->db->jdate($obj->datee);
|
|
|
+
|
|
|
+ if ($task_static->hasDelay()) {
|
|
|
+ $response->nbtodolate++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $this->error=$this->db->error();
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Is the action delayed?
|
|
|
+ *
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function hasDelay()
|
|
|
+ {
|
|
|
+ global $conf;
|
|
|
+
|
|
|
+ if (! ($this->progress >= 0 && $this->progress < 100)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $now = dol_now();
|
|
|
+
|
|
|
+ return ($this->datee > 0 && $this->datee < ($now - $conf->projet->task->warning_delay));
|
|
|
+ }
|
|
|
}
|