31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/timespent.class.php';
45 public $element =
'project_task';
50 public $table_element =
'projet_task';
55 public $fk_element =
'fk_element';
60 public $picto =
'projecttask';
65 protected $childtables = array(
66 'element_time' => array(
'name' =>
'Task',
'parent' =>
'projet_task',
'parentkey' =>
'fk_element',
'parenttypefield' =>
'elementtype',
'parenttypevalue' =>
'task')
72 public $fk_task_parent = 0;
84 public $duration_effective;
85 public $planned_workload;
119 public $fk_user_creat;
124 public $fk_user_valid;
128 public $timespent_min_date;
129 public $timespent_max_date;
130 public $timespent_total_duration;
131 public $timespent_total_amount;
132 public $timespent_nblinesnull;
133 public $timespent_nblines;
137 public $timespent_id;
138 public $timespent_duration;
139 public $timespent_old_duration;
140 public $timespent_date;
141 public $timespent_datehour;
142 public $timespent_withhour;
143 public $timespent_fk_user;
144 public $timespent_thm;
145 public $timespent_note;
146 public $timespent_fk_product;
147 public $timespent_invoiceid;
148 public $timespent_invoicelineid;
150 public $comments = array();
158 public $projectstatus;
159 public $projectlabel;
162 public $fk_opp_status;
163 public $usage_bill_time;
165 public $array_options_project;
169 public $thirdparty_id;
170 public $thirdparty_name;
171 public $thirdparty_email;
174 public $task_parent_ref;
175 public $task_parent_position;
182 public $budget_amount;
187 public $project_budget_amount;
233 public function create($user, $notrigger = 0)
235 global $conf, $langs;
243 $this->label = trim($this->label);
245 $this->note_public = trim($this->note_public);
246 $this->note_private = trim($this->note_private);
248 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
249 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
254 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"projet_task (";
256 $sql .=
", fk_projet";
258 $sql .=
", fk_task_parent";
260 $sql .=
", description";
261 $sql .=
", note_public";
262 $sql .=
", note_private";
264 $sql .=
", fk_user_creat";
267 $sql .=
", planned_workload";
268 $sql .=
", progress";
269 $sql .=
", budget_amount";
270 $sql .=
", priority";
271 $sql .=
") VALUES (";
272 $sql .= (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity);
273 $sql .=
", ".((int) $this->fk_project);
274 $sql .=
", ".(!empty($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
'null');
275 $sql .=
", ".((int) $this->fk_task_parent);
276 $sql .=
", '".$this->db->escape($this->label).
"'";
277 $sql .=
", '".$this->db->escape($this->
description).
"'";
278 $sql .=
", '".$this->db->escape($this->note_public).
"'";
279 $sql .=
", '".$this->db->escape($this->note_private).
"'";
280 $sql .=
", '".$this->db->idate($now).
"'";
281 $sql .=
", ".((int) $user->id);
282 $sql .=
", ".($this->date_start ?
"'".$this->db->idate($this->date_start).
"'" :
'null');
283 $sql .=
", ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
'null');
284 $sql .=
", ".(($this->planned_workload !=
'' && $this->planned_workload >= 0) ? ((
int) $this->planned_workload) :
'null');
285 $sql .=
", ".(($this->progress !=
'' && $this->progress >= 0) ? ((
int) $this->progress) :
'null');
286 $sql .=
", ".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? ((
int) $this->budget_amount) :
'null');
287 $sql .=
", ".(($this->priority !=
'' && $this->priority >= 0) ? (
int) $this->priority :
'null');
292 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
293 $resql = $this->db->query($sql);
296 $this->errors[] =
"Error ".$this->db->lasterror();
300 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"projet_task");
321 foreach ($this->errors as $errmsg) {
322 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
323 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
325 $this->db->rollback();
342 public function fetch($id, $ref =
'', $loadparentdata = 0)
347 $sql .=
" t.entity,";
348 $sql .=
" t.fk_projet as fk_project,";
349 $sql .=
" t.fk_task_parent,";
351 $sql .=
" t.description,";
352 $sql .=
" t.duration_effective,";
353 $sql .=
" t.planned_workload,";
355 $sql .=
" t.dateo as date_start,";
356 $sql .=
" t.datee as date_end,";
357 $sql .=
" t.fk_user_creat,";
358 $sql .=
" t.fk_user_valid,";
359 $sql .=
" t.fk_statut as status,";
360 $sql .=
" t.progress,";
361 $sql .=
" t.budget_amount,";
362 $sql .=
" t.priority,";
363 $sql .=
" t.note_private,";
364 $sql .=
" t.note_public,";
366 if (!empty($loadparentdata)) {
367 $sql .=
", t2.ref as task_parent_ref";
368 $sql .=
", t2.rang as task_parent_position";
370 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t";
371 if (!empty($loadparentdata)) {
372 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t2 ON t.fk_task_parent = t2.rowid";
376 $sql .=
"entity IN (".getEntity(
'project').
")";
377 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
379 $sql .=
"t.rowid = ".((int) $id);
382 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
383 $resql = $this->db->query($sql);
385 $num_rows = $this->db->num_rows($resql);
388 $obj = $this->db->fetch_object($resql);
390 $this->
id = $obj->rowid;
391 $this->
ref = $obj->ref;
392 $this->entity = $obj->entity;
393 $this->fk_project = $obj->fk_project;
394 $this->fk_task_parent = $obj->fk_task_parent;
395 $this->label = $obj->label;
397 $this->duration_effective = $obj->duration_effective;
398 $this->planned_workload = $obj->planned_workload;
399 $this->date_c = $this->db->jdate($obj->datec);
400 $this->date_start = $this->db->jdate($obj->date_start);
401 $this->date_end = $this->db->jdate($obj->date_end);
402 $this->fk_user_creat = $obj->fk_user_creat;
403 $this->fk_user_valid = $obj->fk_user_valid;
404 $this->fk_statut = $obj->status;
405 $this->
status = $obj->status;
406 $this->progress = $obj->progress;
407 $this->budget_amount = $obj->budget_amount;
408 $this->priority = $obj->priority;
409 $this->note_private = $obj->note_private;
410 $this->note_public = $obj->note_public;
411 $this->rang = $obj->rang;
413 if (!empty($loadparentdata)) {
414 $this->task_parent_ref = $obj->task_parent_ref;
415 $this->task_parent_position = $obj->task_parent_position;
422 $this->db->free($resql);
430 $this->error =
"Error ".$this->db->lasterror();
443 public function update($user =
null, $notrigger = 0)
445 global $conf, $langs;
449 if (isset($this->fk_project)) {
450 $this->fk_project = (int) $this->fk_project;
452 if (isset($this->
ref)) {
453 $this->
ref = trim($this->
ref);
455 if (isset($this->fk_task_parent)) {
456 $this->fk_task_parent = (int) $this->fk_task_parent;
458 if (isset($this->label)) {
459 $this->label = trim($this->label);
464 if (isset($this->note_public)) {
465 $this->note_public = trim($this->note_public);
467 if (isset($this->note_private)) {
468 $this->note_private = trim($this->note_private);
470 if (isset($this->duration_effective)) {
471 $this->duration_effective = trim($this->duration_effective);
473 if (isset($this->planned_workload)) {
474 $this->planned_workload = trim($this->planned_workload);
476 if (isset($this->budget_amount)) {
477 $this->budget_amount = (float) $this->budget_amount;
480 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
481 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
489 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET";
490 $sql .=
" fk_projet=".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
491 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"'".$this->db->escape($this->
id).
"'").
",";
492 $sql .=
" fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent :
"null").
",";
493 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
494 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
495 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
496 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
497 $sql .=
" duration_effective=".(isset($this->duration_effective) ? $this->duration_effective :
"null").
",";
498 $sql .=
" planned_workload=".((isset($this->planned_workload) && $this->planned_workload !=
'') ? $this->planned_workload :
"null").
",";
499 $sql .=
" dateo=".($this->date_start !=
'' ?
"'".$this->db->idate($this->date_start).
"'" :
'null').
",";
500 $sql .=
" datee=".($this->date_end !=
'' ?
"'".$this->db->idate($this->date_end).
"'" :
'null').
",";
501 $sql .=
" progress=".(($this->progress !=
'' && $this->progress >= 0) ? $this->progress :
'null').
",";
502 $sql .=
" budget_amount=".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? $this->budget_amount :
'null').
",";
503 $sql .=
" rang=".((!empty($this->rang)) ? ((
int) $this->rang) :
"0").
",";
504 $sql .=
" priority=".((!empty($this->priority)) ? ((
int) $this->priority) :
"0");
505 $sql .=
" WHERE rowid=".((int) $this->
id);
509 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
510 $resql = $this->db->query($sql);
513 $this->errors[] =
"Error ".$this->db->lasterror();
526 $project =
new Project($this->db);
527 if ($project->fetch($this->fk_project) > 0) {
529 $project->getLinesArray(
null);
530 $projectCompleted = array_reduce(
537 static function ($allTasksCompleted, $task) {
538 return $allTasksCompleted && $task->progress >= 100;
542 if ($projectCompleted) {
543 if ($project->setClose($user) <= 0) {
552 $this->errors[] = $project->error;
567 if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
569 if ($conf->project->dir_output) {
570 $project =
new Project($this->db);
571 $project->fetch($this->fk_project);
575 if (file_exists($olddir)) {
576 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
579 $langs->load(
"errors");
580 $this->error = $langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir);
589 foreach ($this->errors as $errmsg) {
590 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
591 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
593 $this->db->rollback();
609 public function delete($user, $notrigger = 0)
612 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
619 dol_syslog(get_class($this).
"::delete Can't delete record as it has some sub tasks", LOG_WARNING);
620 $this->error =
'ErrorRecordHasSubTasks';
621 $this->db->rollback();
626 if (!empty($objectisused)) {
627 dol_syslog(get_class($this).
"::delete Can't delete record as it has some child", LOG_WARNING);
628 $this->error =
'ErrorRecordHasChildren';
629 $this->db->rollback();
637 $this->error =
'ErrorFailToDeleteLinkedContact';
639 $this->db->rollback();
645 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_time";
646 $sql .=
" WHERE fk_element = ".((int) $this->
id).
" AND elementtype = 'task'";
648 $resql = $this->db->query($sql);
651 $this->errors[] =
"Error ".$this->db->lasterror();
656 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task_extrafields";
657 $sql .=
" WHERE fk_object = ".((int) $this->
id);
659 $resql = $this->db->query($sql);
662 $this->errors[] =
"Error ".$this->db->lasterror();
667 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task";
668 $sql .=
" WHERE rowid=".((int) $this->
id);
670 $resql = $this->db->query($sql);
673 $this->errors[] =
"Error ".$this->db->lasterror();
690 foreach ($this->errors as $errmsg) {
691 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
692 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
694 $this->db->rollback();
698 if ($conf->project->dir_output) {
699 $projectstatic =
new Project($this->db);
700 $projectstatic->fetch($this->fk_project);
703 dol_syslog(get_class($this).
"::delete dir=".$dir, LOG_DEBUG);
704 if (file_exists($dir)) {
705 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
708 $this->error =
'ErrorFailToDeleteDir';
709 $this->db->rollback();
731 $sql =
"SELECT COUNT(*) as nb";
732 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
733 $sql .=
" WHERE fk_task_parent = ".((int) $this->
id);
735 dol_syslog(get_class($this).
"::hasChildren", LOG_DEBUG);
736 $resql = $this->db->query($sql);
739 $this->errors[] =
"Error ".$this->db->lasterror();
741 $obj = $this->db->fetch_object($resql);
745 $this->db->free($resql);
765 $sql =
"SELECT COUNT(*) as nb";
766 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time";
767 $sql .=
" WHERE fk_element = ".((int) $this->
id);
768 $sql .=
" AND elementtype = 'task'";
770 dol_syslog(get_class($this).
"::hasTimeSpent", LOG_DEBUG);
771 $resql = $this->db->query($sql);
774 $this->errors[] =
"Error ".$this->db->lasterror();
776 $obj = $this->db->fetch_object($resql);
780 $this->db->free($resql);
802 $langs->load(
'projects');
805 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Task").
'</u>';
806 if (!empty($this->
ref)) {
807 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
809 if (!empty($this->label)) {
810 $datas[
'label'] =
'<br><b>'.$langs->trans(
'LabelTask').
':</b> '.$this->label;
812 if ($this->date_start || $this->date_end) {
813 $datas[
'range'] =
"<br>".get_date_range($this->date_start, $this->date_end,
'', $langs, 0);
831 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'task', $addlabel = 0, $sep =
' - ', $notooltip = 0, $save_lastsearch_value = -1)
833 global $action, $conf, $hookmanager, $langs;
835 if (!empty($conf->dol_no_mouse_hover)) {
842 'objecttype' => $this->element,
844 $classfortooltip =
'classfortooltip';
847 $classfortooltip =
'classforajaxtooltip';
848 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
854 $url = DOL_URL_ROOT.
'/projet/tasks/'.$mode.
'.php?id='.$this->
id.($option ==
'withproject' ?
'&withproject=1' :
'');
856 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
857 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
858 $add_save_lastsearch_values = 1;
860 if ($add_save_lastsearch_values) {
861 $url .=
'&save_lastsearch_values=1';
865 if (empty($notooltip)) {
867 $label = $langs->trans(
"ShowTask");
868 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
870 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
871 $linkclose .= $dataparams.
' class="'.$classfortooltip.
' nowraponall"';
873 $linkclose .=
' class="nowraponall"';
876 $linkstart =
'<a href="'.$url.
'"';
877 $linkstart .= $linkclose.
'>';
880 $picto =
'projecttask';
882 $result .= $linkstart;
884 $result .=
img_object(($notooltip ?
'' : $label), $picto,
'class="paddingright"', 0, 0, $notooltip ? 0 : 1);
886 if ($withpicto != 2) {
887 $result .= $this->ref;
890 if ($withpicto != 2) {
891 $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) :
'');
894 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
895 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
897 $result = $hookmanager->resPrint;
899 $result .= $hookmanager->resPrint;
918 $this->fk_project = 0;
920 $this->fk_task_parent = 0;
921 $this->label =
'Specimen task TK01';
922 $this->duration_effective =
'';
923 $this->fk_user_creat = $user->id;
924 $this->progress =
'25';
927 $this->note_private =
'This is a specimen private note';
928 $this->note_public =
'This is a specimen public note';
956 public function getTasksArray($usert =
null, $userp =
null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj =
'', $filteronprojstatus =
'-1', $morewherefilter =
'', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields =
null, $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield =
'', $sortorder =
'')
966 if ($filteronprojuser > 0 || $filterontaskuser > 0) {
969 $sql .=
" p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,";
970 $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,";
971 $sql .=
" t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang, t.priority,";
972 $sql .=
" t.budget_amount,";
973 $sql .=
" t.note_public, t.note_private,";
974 $sql .=
" s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,";
975 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount as project_budget_amount";
977 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
978 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
979 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key.
" as options_".$key :
'');
982 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
983 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
984 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
988 if ($includebilltime) {
989 $sql .=
", SUM(tt.element_duration * ".$this->db->ifsql(
"invoice_id IS NULL",
"1",
"0").
") as tobill, SUM(tt.element_duration * ".$this->db->ifsql(
"invoice_id IS NULL",
"0",
"1").
") as billed";
992 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
993 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
995 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_extrafields as efp ON (p.rowid = efp.fk_object)";
999 if ($filteronprojuser > 0) {
1000 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1001 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1003 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1005 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
1007 if ($includebilltime) {
1008 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1010 if ($filterontaskuser > 0) {
1011 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1012 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1014 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1015 $sql .=
" AND t.fk_projet = p.rowid";
1016 } elseif ($mode == 1) {
1017 if ($filteronprojuser > 0) {
1018 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1019 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1021 if ($filterontaskuser > 0) {
1022 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1023 if ($includebilltime) {
1024 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1026 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1027 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1029 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
1030 if ($includebilltime) {
1031 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')";
1034 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1036 return 'BadValueForParameterMode';
1039 if ($filteronprojuser > 0) {
1040 $sql .=
" AND p.rowid = ec.element_id";
1041 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1042 $sql .=
" AND ctc.element = 'project'";
1043 $sql .=
" AND ec.fk_socpeople = ".((int) $filteronprojuser);
1044 $sql .=
" AND ec.statut = 4";
1045 $sql .=
" AND ctc.source = 'internal'";
1047 if ($filterontaskuser > 0) {
1048 $sql .=
" AND t.fk_projet = p.rowid";
1049 $sql .=
" AND p.rowid = ec2.element_id";
1050 $sql .=
" AND ctc2.rowid = ec2.fk_c_type_contact";
1051 $sql .=
" AND ctc2.element = 'project_task'";
1052 $sql .=
" AND ec2.fk_socpeople = ".((int) $filterontaskuser);
1053 $sql .=
" AND ec2.statut = 4";
1054 $sql .=
" AND ctc2.source = 'internal'";
1057 $sql .=
" AND p.fk_soc = ".((int) $socid);
1060 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1062 if ($filteronproj) {
1063 $sql .=
natural_search(array(
"p.ref",
"p.title"), $filteronproj);
1065 if ($filteronprojstatus && (
int) $filteronprojstatus !=
'-1') {
1066 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).
")";
1068 if ($morewherefilter) {
1069 $sql .= $morewherefilter;
1073 $extrafieldsobjectkey =
'projet_task';
1074 $extrafieldsobjectprefix =
'efpt.';
1076 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1079 $parameters = array();
1080 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1081 $sql .= $hookmanager->resPrint;
1082 if ($includebilltime) {
1083 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,";
1084 $sql .=
" t.datec, t.dateo, t.datee, t.tms,";
1085 $sql .=
" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,";
1086 $sql .=
" t.dateo, t.datee, t.planned_workload, t.rang, t.priority,";
1087 $sql .=
" t.budget_amount,";
1088 $sql .=
" t.note_public, t.note_private,";
1089 $sql .=
" s.rowid, s.nom, s.email,";
1090 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
1092 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1093 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1094 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key :
'');
1097 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1098 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1099 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key :
'');
1105 if ($sortfield && $sortorder) {
1106 $sql .= $this->db->order($sortfield, $sortorder);
1108 $sql .=
" ORDER BY p.ref, t.rang, t.dateo";
1112 dol_syslog(get_class($this).
"::getTasksArray", LOG_DEBUG);
1113 $resql = $this->db->query($sql);
1115 $num = $this->db->num_rows($resql);
1121 $obj = $this->db->fetch_object($resql);
1123 if ($loadRoleMode) {
1124 if ((!$obj->public) && (is_object($userp))) {
1129 if (is_object($usert)) {
1137 $tasks[$i] =
new Task($this->db);
1138 $tasks[$i]->id = $obj->taskid;
1139 $tasks[$i]->ref = $obj->taskref;
1140 $tasks[$i]->fk_project = $obj->projectid;
1143 $tasks[$i]->projectref = $obj->ref;
1144 $tasks[$i]->projectlabel = $obj->plabel;
1145 $tasks[$i]->projectstatus = $obj->projectstatus;
1146 $tasks[$i]->fk_opp_status = $obj->fk_opp_status;
1147 $tasks[$i]->opp_amount = $obj->opp_amount;
1148 $tasks[$i]->opp_percent = $obj->opp_percent;
1149 $tasks[$i]->budget_amount = $obj->budget_amount;
1150 $tasks[$i]->project_budget_amount = $obj->project_budget_amount;
1151 $tasks[$i]->usage_bill_time = $obj->usage_bill_time;
1153 $tasks[$i]->label = $obj->label;
1154 $tasks[$i]->description = $obj->description;
1156 $tasks[$i]->fk_task_parent = $obj->fk_task_parent;
1157 $tasks[$i]->note_public = $obj->note_public;
1158 $tasks[$i]->note_private = $obj->note_private;
1159 $tasks[$i]->duration_effective = $obj->duration_effective;
1160 $tasks[$i]->planned_workload = $obj->planned_workload;
1162 if ($includebilltime) {
1164 $tasks[$i]->tobill = $obj->tobill;
1165 $tasks[$i]->billed = $obj->billed;
1168 $tasks[$i]->progress = $obj->progress;
1169 $tasks[$i]->fk_statut = $obj->status;
1170 $tasks[$i]->status = $obj->status;
1171 $tasks[$i]->public = $obj->public;
1172 $tasks[$i]->date_start = $this->db->jdate($obj->date_start);
1173 $tasks[$i]->date_end = $this->db->jdate($obj->date_end);
1174 $tasks[$i]->rang = $obj->rang;
1175 $tasks[$i]->priority = $obj->priority;
1177 $tasks[$i]->socid = $obj->thirdparty_id;
1178 $tasks[$i]->thirdparty_id = $obj->thirdparty_id;
1179 $tasks[$i]->thirdparty_name = $obj->thirdparty_name;
1180 $tasks[$i]->thirdparty_email = $obj->thirdparty_email;
1183 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1184 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1185 if ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate') {
1186 $tmpvar =
'options_'.$key;
1187 $tasks[$i]->array_options_project[
'options_'.$key] = $obj->$tmpvar;
1194 $tasks[$i]->fetch_optionals();
1200 $this->db->free($resql);
1220 $arrayroles = array();
1222 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks userp=".json_encode(is_object($userp)).
" usert=".json_encode(is_object($usert)).
" projectid=".$projectid.
" taskid=".$taskid);
1225 if (empty($userp) && empty($usert)) {
1226 $this->error =
"CallWithWrongParameters";
1229 if (!empty($userp) && !empty($usert)) {
1230 $this->error =
"CallWithWrongParameters";
1237 $sql .=
" p.rowid as pid,";
1239 $sql .=
" pt.rowid as pid,";
1241 $sql .=
" ec.element_id, ctc.code, ctc.source";
1243 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1245 if ($usert && $filteronprojstatus > -1) {
1246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p, ".MAIN_DB_PREFIX.
"projet_task as pt";
1248 if ($usert && $filteronprojstatus <= -1) {
1249 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as pt";
1251 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1252 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1254 $sql .=
" WHERE p.rowid = ec.element_id";
1256 $sql .=
" WHERE pt.rowid = ec.element_id";
1258 if ($userp && $filteronprojstatus > -1) {
1259 $sql .=
" AND p.fk_statut = ".((int) $filteronprojstatus);
1261 if ($usert && $filteronprojstatus > -1) {
1262 $sql .=
" AND pt.fk_projet = p.rowid AND p.fk_statut = ".((int) $filteronprojstatus);
1265 $sql .=
" AND ctc.element = 'project'";
1268 $sql .=
" AND ctc.element = 'project_task'";
1270 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1272 $sql .=
" AND ec.fk_socpeople = ".((int) $userp->id);
1275 $sql .=
" AND ec.fk_socpeople = ".((int) $usert->id);
1277 $sql .=
" AND ec.statut = 4";
1278 $sql .=
" AND ctc.source = 'internal'";
1281 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1284 $sql .=
" AND pt.fk_projet IN (".$this->db->sanitize($projectid).
")";
1289 $sql .=
" ERROR SHOULD NOT HAPPENS";
1292 $sql .=
" AND pt.rowid = ".((int) $taskid);
1297 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG);
1298 $resql = $this->db->query($sql);
1300 $num = $this->db->num_rows($resql);
1303 $obj = $this->db->fetch_object($resql);
1304 if (empty($arrayroles[$obj->pid])) {
1305 $arrayroles[$obj->pid] = $obj->code;
1307 $arrayroles[$obj->pid] .=
','.$obj->code;
1311 $this->db->free($resql);
1328 $contactAlreadySelected = array();
1334 if ($source ==
'thirdparty') {
1335 $contactAlreadySelected[$i] = $tab[$i][
'socid'];
1337 $contactAlreadySelected[$i] = $tab[$i][
'id'];
1341 return $contactAlreadySelected;
1354 $origintask =
new Task($this->db);
1355 $result = $origintask->fetch($origin_id);
1361 $arraycontactorigin = array_merge($origintask->liste_contact(-1,
'internal'), $origintask->liste_contact(-1,
'external'));
1362 if (is_array($arraycontactorigin)) {
1363 foreach ($arraycontactorigin as $key => $contact) {
1364 $result = $this->
add_contact($contact[
"id"], $contact[
"fk_c_type_contact"], $contact[
"source"]);
1386 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"element_time as et";
1387 $sql .=
" SET et.fk_element = ".((int) $dest_id);
1388 $sql .=
" WHERE et.elementtype = 'task'";
1389 $sql .=
" AND et.fk_element = ".((int) $origin_id);
1391 dol_syslog(get_class($this).
"::mergeTimeSpentTask", LOG_DEBUG);
1392 if (!$this->db->query($sql)) {
1393 $this->error = $this->db->lasterror();
1398 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1399 $sql .=
" SET duration_effective = (SELECT SUM(element_duration) FROM ".MAIN_DB_PREFIX.
"element_time as ptt where ptt.elementtype = 'task' AND ptt.fk_element = ".((int) $dest_id).
")";
1400 $sql .=
" WHERE rowid = ".((int) $dest_id);
1402 dol_syslog(get_class($this).
"::mergeTimeSpentTask update project_task", LOG_DEBUG);
1403 if (!$this->db->query($sql)) {
1404 $this->error = $this->db->lasterror();
1410 $this->db->commit();
1412 $this->db->rollback();
1428 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1434 if (!is_object($user)) {
1435 dol_print_error(
null,
"Method addTimeSpent was called with wrong parameter user");
1440 if (isset($this->timespent_note)) {
1441 $this->timespent_note = trim($this->timespent_note);
1443 if (empty($this->timespent_datehour) || ($this->timespent_date != $this->timespent_datehour)) {
1444 $this->timespent_datehour = $this->timespent_date;
1448 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1451 if ($this->timespent_date < $restrictBefore) {
1452 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
1453 $this->errors[] = $this->error;
1461 $timespent->fk_element = $this->id;
1462 $timespent->elementtype =
'task';
1463 $timespent->element_date = $this->timespent_date;
1464 $timespent->element_datehour = $this->timespent_datehour;
1465 $timespent->element_date_withhour = $this->timespent_withhour;
1466 $timespent->element_duration = $this->timespent_duration;
1467 $timespent->fk_user = $this->timespent_fk_user;
1468 $timespent->fk_product = $this->timespent_fk_product;
1469 $timespent->note = $this->timespent_note;
1470 $timespent->datec = $this->db->idate($now);
1472 $result = $timespent->create($user);
1476 $this->timespent_id = $result;
1480 $result = $this->
call_trigger(
'TASK_TIMESPENT_CREATE', $user);
1487 $this->error = $this->db->lasterror();
1493 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1494 $sql .=
" SET duration_effective = (SELECT SUM(element_duration) FROM ".MAIN_DB_PREFIX.
"element_time as ptt where ptt.elementtype = 'task' AND ptt.fk_element = ".((int) $this->
id).
")";
1495 if (isset($this->progress)) {
1496 $sql .=
", progress = ".((float) $this->progress);
1498 $sql .=
" WHERE rowid = ".((int) $this->
id);
1500 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1501 if (!$this->db->query($sql)) {
1502 $this->error = $this->db->lasterror();
1507 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1508 if (!empty($resql_thm_user)) {
1509 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1510 $timespent->thm = $obj_thm_user->thm;
1512 $res_update = $timespent->update($user);
1514 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1515 if ($res_update <= 0) {
1516 $this->error = $this->db->lasterror();
1522 $this->db->commit();
1524 $this->db->rollback();
1537 $arrayres = array();
1540 $sql .=
" s.rowid as socid,";
1541 $sql .=
" s.nom as thirdparty_name,";
1542 $sql .=
" s.email as thirdparty_email,";
1543 $sql .=
" ptt.rowid,";
1544 $sql .=
" ptt.ref_ext,";
1545 $sql .=
" ptt.fk_element as fk_task,";
1546 $sql .=
" ptt.element_date as task_date,";
1547 $sql .=
" ptt.element_datehour as task_datehour,";
1548 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1549 $sql .=
" ptt.element_duration as task_duration,";
1550 $sql .=
" ptt.fk_user,";
1551 $sql .=
" ptt.note,";
1552 $sql .=
" ptt.thm,";
1553 $sql .=
" pt.rowid as task_id,";
1554 $sql .=
" pt.ref as task_ref,";
1555 $sql .=
" pt.label as task_label,";
1556 $sql .=
" p.rowid as project_id,";
1557 $sql .=
" p.ref as project_ref,";
1558 $sql .=
" p.title as project_label,";
1559 $sql .=
" p.public as public";
1560 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1561 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1562 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1563 $sql .=
" AND ptt.elementtype = 'task'";
1564 $sql .=
" AND pt.rowid = ".((int) $this->
id);
1565 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1566 if ($morewherefilter) {
1567 $sql .= $morewherefilter;
1570 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1571 $resql = $this->db->query($sql);
1573 $num = $this->db->num_rows($resql);
1577 $obj = $this->db->fetch_object($resql);
1581 $newobj->socid = $obj->socid;
1582 $newobj->thirdparty_name = $obj->thirdparty_name;
1583 $newobj->thirdparty_email = $obj->thirdparty_email;
1585 $newobj->fk_project = $obj->project_id;
1586 $newobj->project_ref = $obj->project_ref;
1587 $newobj->project_label = $obj->project_label;
1588 $newobj->public = $obj->project_public;
1590 $newobj->fk_task = $obj->task_id;
1591 $newobj->task_ref = $obj->task_ref;
1592 $newobj->task_label = $obj->task_label;
1594 $newobj->timespent_line_id = $obj->rowid;
1595 $newobj->timespent_line_ref_ext = $obj->ref_ext;
1596 $newobj->timespent_line_date = $this->db->jdate($obj->task_date);
1597 $newobj->timespent_line_datehour = $this->db->jdate($obj->task_datehour);
1598 $newobj->timespent_line_withhour = $obj->task_date_withhour;
1599 $newobj->timespent_line_duration = $obj->task_duration;
1600 $newobj->timespent_line_fk_user = $obj->fk_user;
1601 $newobj->timespent_line_thm = $obj->thm;
1602 $newobj->timespent_line_note = $obj->note;
1604 $arrayres[] = $newobj;
1609 $this->db->free($resql);
1611 $this->lines = $arrayres;
1615 $this->error =
"Error ".$this->db->lasterror();
1630 if (is_object($userobj)) {
1631 $userid = $userobj->id;
1637 if (empty($id) && empty($userid)) {
1638 dol_syslog(
"getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR);
1645 $sql .=
" MIN(t.element_datehour) as min_date,";
1646 $sql .=
" MAX(t.element_datehour) as max_date,";
1647 $sql .=
" SUM(t.element_duration) as total_duration,";
1648 $sql .=
" SUM(t.element_duration / 3600 * ".$this->db->ifsql(
"t.thm IS NULL", 0,
"t.thm").
") as total_amount,";
1649 $sql .=
" COUNT(t.rowid) as nblines,";
1650 $sql .=
" SUM(".$this->db->ifsql(
"t.thm IS NULL", 1, 0).
") as nblinesnull";
1651 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1652 $sql .=
" WHERE t.elementtype='task'";
1653 if ($morewherefilter) {
1654 $sql .= $morewherefilter;
1657 $sql .=
" AND t.fk_element = ".((int) $id);
1660 $sql .=
" AND t.fk_user = ".((int) $userid);
1663 dol_syslog(get_class($this).
"::getSummaryOfTimeSpent", LOG_DEBUG);
1664 $resql = $this->db->query($sql);
1666 $obj = $this->db->fetch_object($resql);
1668 $result[
'min_date'] = $obj->min_date;
1669 $result[
'max_date'] = $obj->max_date;
1670 $result[
'total_duration'] = $obj->total_duration;
1672 $this->timespent_min_date = $this->db->jdate($obj->min_date);
1673 $this->timespent_max_date = $this->db->jdate($obj->max_date);
1674 $this->timespent_total_duration = $obj->total_duration;
1675 $this->timespent_total_amount = $obj->total_amount;
1676 $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0);
1677 $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0);
1679 $this->db->free($resql);
1701 $sql .=
" SUM(t.element_duration) as nbseconds,";
1702 $sql .=
" SUM(t.element_duration / 3600 * ".$this->db->ifsql(
"t.thm IS NULL", 0,
"t.thm").
") as amount, SUM(".$this->db->ifsql(
"t.thm IS NULL", 1, 0).
") as nblinesnull";
1703 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1704 $sql .=
" WHERE t.elementtype='task' AND t.fk_element = ".((int) $id);
1705 if (is_object($fuser) && $fuser->id > 0) {
1706 $sql .=
" AND fk_user = ".((int) $fuser->id);
1709 $datefieldname =
"element_datehour";
1710 $sql .=
" AND (".$datefieldname.
" >= '".$this->db->idate($dates).
"' OR ".$datefieldname.
" IS NULL)";
1713 $datefieldname =
"element_datehour";
1714 $sql .=
" AND (".$datefieldname.
" <= '".$this->db->idate(
$datee).
"' OR ".$datefieldname.
" IS NULL)";
1718 dol_syslog(get_class($this).
"::getSumOfAmount", LOG_DEBUG);
1719 $resql = $this->db->query($sql);
1721 $obj = $this->db->fetch_object($resql);
1723 $result[
'amount'] = $obj->amount;
1724 $result[
'nbseconds'] = $obj->nbseconds;
1725 $result[
'nblinesnull'] = $obj->nblinesnull;
1727 $this->db->free($resql);
1744 $timespent->fetch($id);
1746 dol_syslog(get_class($this).
"::fetchTimeSpent", LOG_DEBUG);
1748 if ($timespent->id > 0) {
1749 $this->timespent_id = $timespent->id;
1750 $this->
id = $timespent->fk_element;
1751 $this->timespent_date = $timespent->element_date;
1752 $this->timespent_datehour = $timespent->element_datehour;
1753 $this->timespent_withhour = $timespent->element_date_withhour;
1754 $this->timespent_duration = $timespent->element_duration;
1755 $this->timespent_fk_user = $timespent->fk_user;
1756 $this->timespent_fk_product = $timespent->fk_product;
1757 $this->timespent_thm = $timespent->thm;
1758 $this->timespent_note = $timespent->note;
1775 $arrayres = array();
1778 $sql .=
" s.rowid as socid,";
1779 $sql .=
" s.nom as thirdparty_name,";
1780 $sql .=
" s.email as thirdparty_email,";
1781 $sql .=
" ptt.rowid,";
1782 $sql .=
" ptt.fk_element as fk_task,";
1783 $sql .=
" ptt.element_date as task_date,";
1784 $sql .=
" ptt.element_datehour as task_datehour,";
1785 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1786 $sql .=
" ptt.element_duration as task_duration,";
1787 $sql .=
" ptt.fk_user,";
1788 $sql .=
" ptt.note,";
1789 $sql .=
" ptt.thm,";
1790 $sql .=
" pt.rowid as task_id,";
1791 $sql .=
" pt.ref as task_ref,";
1792 $sql .=
" pt.label as task_label,";
1793 $sql .=
" p.rowid as project_id,";
1794 $sql .=
" p.ref as project_ref,";
1795 $sql .=
" p.title as project_label,";
1796 $sql .=
" p.public as public";
1797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1798 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1799 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1800 $sql .=
" AND ptt.elementtype = 'task'";
1801 $sql .=
" AND ptt.fk_user = ".((int) $userobj->id);
1802 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1803 if ($morewherefilter) {
1804 $sql .= $morewherefilter;
1807 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1808 $resql = $this->db->query($sql);
1810 $num = $this->db->num_rows($resql);
1814 $obj = $this->db->fetch_object($resql);
1818 $newobj->socid = $obj->socid;
1819 $newobj->thirdparty_name = $obj->thirdparty_name;
1820 $newobj->thirdparty_email = $obj->thirdparty_email;
1822 $newobj->fk_project = $obj->project_id;
1823 $newobj->project_ref = $obj->project_ref;
1824 $newobj->project_label = $obj->project_label;
1825 $newobj->public = $obj->project_public;
1827 $newobj->fk_task = $obj->task_id;
1828 $newobj->task_ref = $obj->task_ref;
1829 $newobj->task_label = $obj->task_label;
1831 $newobj->timespent_id = $obj->rowid;
1832 $newobj->timespent_date = $this->db->jdate($obj->task_date);
1833 $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour);
1834 $newobj->timespent_withhour = $obj->task_date_withhour;
1835 $newobj->timespent_duration = $obj->task_duration;
1836 $newobj->timespent_fk_user = $obj->fk_user;
1837 $newobj->timespent_thm = $obj->thm;
1838 $newobj->timespent_note = $obj->note;
1840 $arrayres[] = $newobj;
1845 $this->db->free($resql);
1848 $this->error =
"Error ".$this->db->lasterror();
1864 global $conf, $langs;
1869 if ($this->timespent_date ==
'') {
1870 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date"));
1873 if (!($this->timespent_fk_user > 0)) {
1874 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"User"));
1879 if (empty($this->timespent_datehour)) {
1880 $this->timespent_datehour = $this->timespent_date;
1882 if (isset($this->timespent_note)) {
1883 $this->timespent_note = trim($this->timespent_note);
1887 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1890 if ($this->timespent_date < $restrictBefore) {
1891 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
1892 $this->errors[] = $this->error;
1900 $timespent->fetch($this->timespent_id);
1901 $timespent->element_date = $this->timespent_date;
1902 $timespent->element_datehour = $this->timespent_datehour;
1903 $timespent->element_date_withhour = $this->timespent_withhour;
1904 $timespent->element_duration = $this->timespent_duration;
1905 $timespent->fk_user = $this->timespent_fk_user;
1906 $timespent->fk_product = $this->timespent_fk_product;
1907 $timespent->note = $this->timespent_note;
1908 $timespent->invoice_id = $this->timespent_invoiceid;
1909 $timespent->invoice_line_id = $this->timespent_invoicelineid;
1911 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
1912 if ($timespent->update($user) > 0) {
1915 $result = $this->
call_trigger(
'TASK_TIMESPENT_MODIFY', $user);
1917 $this->db->rollback();
1927 $this->error = $this->db->lasterror();
1928 $this->db->rollback();
1932 if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) ||
getDolGlobalString(
'TIMESPENT_ALWAYS_UPDATE_THM'))) {
1933 if ($this->timespent_old_duration != $this->timespent_duration) {
1935 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"projet_task";
1936 $sql .=
" SET duration_effective = (SELECT SUM(element_duration) FROM " . MAIN_DB_PREFIX .
"element_time as ptt where ptt.elementtype = 'task' AND ptt.fk_element = " . ((int) $this->
id) .
")";
1937 if (isset($this->progress)) {
1938 $sql .=
", progress = " . ((float) $this->progress);
1940 $sql .=
" WHERE rowid = " . ((int) $this->
id);
1942 dol_syslog(get_class($this) .
"::updateTimeSpent", LOG_DEBUG);
1943 if (!$this->db->query($sql)) {
1944 $this->error = $this->db->lasterror();
1945 $this->db->rollback();
1953 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1954 if (!empty($resql_thm_user)) {
1955 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1956 $timespent->thm = $obj_thm_user->thm;
1958 $res_update = $timespent->update($user);
1961 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
1962 if ($res_update <= 0) {
1963 $this->error = $this->db->lasterror();
1969 $this->db->commit();
1983 global $conf, $langs;
1988 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1991 if ($this->timespent_date < $restrictBefore) {
1992 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
1993 $this->errors[] = $this->error;
2002 $result = $this->
call_trigger(
'TASK_TIMESPENT_DELETE', $user);
2011 $timespent->fetch($this->timespent_id);
2013 $res_del = $timespent->delete($user);
2017 $this->errors[] =
"Error ".$this->db->lasterror();
2022 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
2023 $sql .=
" SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0);
2024 $sql .=
" WHERE rowid = ".((int) $this->
id);
2026 dol_syslog(get_class($this).
"::delTimeSpent", LOG_DEBUG);
2027 if ($this->db->query($sql)) {
2030 $this->error = $this->db->lasterror();
2037 foreach ($this->errors as $errmsg) {
2038 dol_syslog(get_class($this).
"::delTimeSpent ".$errmsg, LOG_ERR);
2039 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2041 $this->db->rollback();
2044 $this->db->commit();
2063 public function createFromClone(
User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt =
false, $clone_affectation =
false, $clone_time =
false, $clone_file =
false, $clone_note =
false, $clone_prog =
false)
2065 global $langs, $conf;
2074 $clone_task =
new Task($this->db);
2075 $origin_task =
new Task($this->db);
2077 $clone_task->context[
'createfromclone'] =
'createfromclone';
2082 $clone_task->fetch($fromid);
2083 $clone_task->fetch_optionals();
2086 $origin_task->fetch($fromid);
2089 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
2091 require_once DOL_DOCUMENT_ROOT.
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON').
'.php';
2092 $modTask =
new $obj();
2093 $defaultref = $modTask->getNextValue(0, $clone_task);
2096 $ori_project_id = $clone_task->fk_project;
2098 $clone_task->id = 0;
2099 $clone_task->ref = $defaultref;
2100 $clone_task->fk_project = $project_id;
2101 $clone_task->fk_task_parent = $parent_task_id;
2102 $clone_task->date_c = $datec;
2103 $clone_task->planned_workload = $origin_task->planned_workload;
2104 $clone_task->rang = $origin_task->rang;
2105 $clone_task->priority = $origin_task->priority;
2108 if ($clone_change_dt) {
2109 $projectstatic =
new Project($this->db);
2110 $projectstatic->fetch($ori_project_id);
2113 $orign_project_dt_start = $projectstatic->date_start;
2116 if (!empty($clone_task->date_start)) {
2117 $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
2121 if (!empty($clone_task->date_end)) {
2122 $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
2127 $clone_task->progress = 0;
2131 $result = $clone_task->create($user);
2135 $this->error = $clone_task->error;
2142 $clone_task_id = $clone_task->id;
2143 $clone_task_ref = $clone_task->ref;
2147 $clone_task->note_private =
'';
2148 $clone_task->note_public =
'';
2151 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_public, ENT_QUOTES | ENT_HTML5),
'_public');
2153 $this->error .= $clone_task->error;
2155 $this->db->rollback();
2157 $this->db->commit();
2161 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_private, ENT_QUOTES | ENT_HTML5),
'_private');
2163 $this->error .= $clone_task->error;
2165 $this->db->rollback();
2167 $this->db->commit();
2173 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2176 $projectstatic =
new Project($this->db);
2177 $projectstatic->fetch($ori_project_id);
2178 $ori_project_ref = $projectstatic->ref;
2180 if ($ori_project_id != $project_id) {
2181 $projectstatic->fetch($project_id);
2182 $clone_project_ref = $projectstatic->ref;
2184 $clone_project_ref = $ori_project_ref;
2190 $filearray =
dol_dir_list($ori_task_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
2191 foreach ($filearray as $key => $file) {
2192 if (!file_exists($clone_task_dir)) {
2194 $this->error .= $langs->trans(
'ErrorInternalErrorDetected').
':dol_mkdir';
2199 $rescopy =
dol_copy($ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name'], 0, 1);
2200 if (is_numeric($rescopy) && $rescopy < 0) {
2201 $this->error .= $langs->trans(
"ErrorFailToCopyFile", $ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name']);
2208 if ($clone_affectation) {
2209 $origin_task =
new Task($this->db);
2210 $origin_task->fetch($fromid);
2212 foreach (array(
'internal',
'external') as $source) {
2213 $tab = $origin_task->liste_contact(-1, $source);
2217 $clone_task->add_contact($tab[$i][
'id'], $tab[$i][
'code'], $tab[$i][
'source']);
2218 if ($clone_task->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2219 $langs->load(
"errors");
2220 $this->error .= $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
2223 if ($clone_task->error !=
'') {
2224 $this->error .= $clone_task->error;
2238 unset($clone_task->context[
'createfromclone']);
2241 $this->db->commit();
2242 return $clone_task_id;
2244 $this->db->rollback();
2245 dol_syslog(get_class($this).
"::createFromClone nbError: ".$error.
" error : ".$this->error, LOG_ERR);
2276 $this->labelStatus[0] =
'Draft';
2277 $this->labelStatus[1] =
'ToDo';
2278 $this->labelStatus[2] =
'Running';
2279 $this->labelStatus[3] =
'Finish';
2280 $this->labelStatus[4] =
'Transfered';
2281 $this->labelStatusShort[0] =
'Draft';
2282 $this->labelStatusShort[1] =
'ToDo';
2283 $this->labelStatusShort[2] =
'Running';
2284 $this->labelStatusShort[3] =
'Completed';
2285 $this->labelStatusShort[4] =
'Transfered';
2288 return $langs->trans($this->labelStatus[$status]);
2289 } elseif ($mode == 1) {
2290 return $langs->trans($this->labelStatusShort[$status]);
2291 } elseif ($mode == 2) {
2293 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatusShort[$status]);
2294 } elseif ($status == 1) {
2295 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatusShort[$status]);
2296 } elseif ($status == 2) {
2297 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatusShort[$status]);
2298 } elseif ($status == 3) {
2299 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2300 } elseif ($status == 4) {
2301 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2302 } elseif ($status == 5) {
2303 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatusShort[$status]);
2305 } elseif ($mode == 3) {
2307 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0');
2308 } elseif ($status == 1) {
2309 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1');
2310 } elseif ($status == 2) {
2311 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3');
2312 } elseif ($status == 3) {
2313 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2314 } elseif ($status == 4) {
2315 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2316 } elseif ($status == 5) {
2317 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5');
2319 } elseif ($mode == 4) {
2321 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatus[$status]);
2322 } elseif ($status == 1) {
2323 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatus[$status]);
2324 } elseif ($status == 2) {
2325 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatus[$status]);
2326 } elseif ($status == 3) {
2327 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2328 } elseif ($status == 4) {
2329 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2330 } elseif ($status == 5) {
2331 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatus[$status]);
2333 } elseif ($mode == 5) {
2343 } elseif ($mode == 6) {
2367 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2369 $outputlangs->load(
"projects");
2372 $modele =
'nodefault';
2374 if (!empty($this->model_pdf)) {
2375 $modele = $this->model_pdf;
2381 $modelpath =
"core/modules/project/task/doc/";
2383 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2397 global $conf, $langs;
2403 $projectstatic =
new Project($this->db);
2404 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
2407 $sql =
"SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
2408 $sql .=
" t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
2409 $sql .=
" t.dateo as date_start, t.datee as date_end";
2410 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2413 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2414 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2415 $sql .=
" AND p.fk_statut = 1";
2416 $sql .=
" AND t.fk_projet = p.rowid";
2417 $sql .=
" AND (t.progress IS NULL OR t.progress < 100)";
2418 if (!$user->hasRight(
'projet',
'all',
'lire')) {
2419 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2427 $resql = $this->db->query($sql);
2429 $task_static =
new Task($this->db);
2432 $response->warning_delay = $conf->project->task->warning_delay / 60 / 60 / 24;
2433 $response->label = $langs->trans(
"OpenedTasks");
2434 if ($user->hasRight(
"projet",
"all",
"lire")) {
2435 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mainmenu=project';
2437 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mode=mine&mainmenu=project';
2442 while ($obj = $this->db->fetch_object($resql)) {
2443 $response->nbtodo++;
2445 $task_static->projectstatus = $obj->projectstatus;
2446 $task_static->progress = $obj->progress;
2447 $task_static->fk_statut = $obj->status;
2448 $task_static->status = $obj->status;
2449 $task_static->date_start = $this->db->jdate($obj->date_start);
2450 $task_static->date_end = $this->db->jdate($obj->date_end);
2452 if ($task_static->hasDelay()) {
2453 $response->nbtodolate++;
2459 $this->error = $this->db->error();
2475 $socid = $user->socid;
2477 $projectstatic =
new Project($this->db);
2478 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid);
2481 $sql =
"SELECT count(p.rowid) as nb";
2482 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2483 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
2484 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2485 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = s.rowid";
2487 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2488 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2489 $sql .=
" AND t.fk_projet = p.rowid";
2490 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
2491 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2496 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
2498 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2499 $sql .=
" AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).
") OR (s.rowid IS NULL))";
2502 $resql = $this->db->query($sql);
2505 while ($obj = $this->db->fetch_object($resql)) {
2506 $this->nb[
"tasks"] = $obj->nb;
2508 $this->db->free($resql);
2512 $this->error = $this->db->error();
2526 if (!($this->progress >= 0 && $this->progress < 100)) {
2532 $datetouse = ($this->date_end > 0) ? $this->date_end : ((isset($this->datee) && $this->datee > 0) ? $this->datee : 0);
2534 return ($datetouse > 0 && ($datetouse < ($now - $conf->project->task->warning_delay)));
2546 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2548 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2549 $return .=
'<div class="info-box info-box-sm info-box-kanban">';
2550 $return .=
'<span class="info-box-icon bg-infobox-action">';
2553 $return .=
'</span>';
2554 $return .=
'<div class="info-box-content">';
2555 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
2556 if ($selected >= 0) {
2557 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2559 if (!empty($arraydata[
'projectlink'])) {
2562 $return .=
'<br><span class="info-box-status ">'.$arraydata[
'projectlink'].
'</span>';
2564 if (property_exists($this,
'budget_amount')) {
2567 if (property_exists($this,
'duration_effective')) {
2568 $return .=
'<br><div class="info-box-label progressinkanban paddingtop">'.getTaskProgressView($this,
false,
true).
'</div>';
2570 $return .=
'</div>';
2571 $return .=
'</div>';
2572 $return .=
'</div>';
2586 global $langs, $hookmanager, $user, $action;
2589 $task_origin =
new Task($this->db);
2591 dol_syslog(
"mergeTask merge task id=".$task_origin_id.
" (will be deleted) into the task id=".$this->id);
2593 $langs->load(
'error');
2595 if (!$error && $task_origin->fetch($task_origin_id) < 1) {
2596 $this->error = $langs->trans(
'ErrorRecordNotFound');
2604 $listofproperties = array(
2605 'label',
'description',
'duration_effective',
'planned_workload',
'datec',
'date_start',
2606 'date_end',
'fk_user_creat',
'fk_user_valid',
'fk_statut',
'progress',
'budget_amount',
2607 'priority',
'rang',
'fk_projet',
'fk_task_parent'
2609 foreach ($listofproperties as $property) {
2610 if (empty($this->$property)) {
2611 $this->$property = $task_origin->$property;
2616 $listofproperties = array(
2617 'note_public',
'note_private'
2619 foreach ($listofproperties as $property) {
2620 $this->$property =
dol_concatdesc($this->$property, $task_origin->$property);
2624 if (is_array($task_origin->array_options)) {
2625 foreach ($task_origin->array_options as $key => $val) {
2626 if (empty($this->array_options[$key])) {
2627 $this->array_options[$key] = $val;
2633 $result = $this->
update($user);
2642 if ($result !=
true) {
2650 if ($result !=
true) {
2657 $parameters = array(
'task_origin' => $task_origin->id,
'task_dest' => $this->id);
2658 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', $parameters, $this, $action);
2661 $this->error = $hookmanager->error;
2662 $this->errors = $hookmanager->errors;
2669 $this->context = array(
'merge' => 1,
'mergefromid' => $task_origin->id,
'mergefromref' => $task_origin->ref);
2681 if ($task_origin->delete($user) < 1) {
2682 $this->error = $task_origin->error;
2683 $this->errors = $task_origin->errors;
2689 $this->db->commit();
2692 $langs->load(
"errors");
2693 $this->error = $langs->trans(
'ErrorsTaskMerge');
2694 $this->db->rollback();
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
liste_contact($statusoflink=-1, $source='external', $list=0, $code='', $status=-1, $arrayoftcids=array())
Get array of all contacts for an object.
isObjectUsed($id=0, $entity=0)
Function to check if an object is used by others (by children).
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
delete_linked_contact($source='', $code='')
Delete all links between an object $this and all its contacts in llx_element_contact.
call_trigger($triggerName, $user)
Call trigger based on this instance.
add_contact($fk_socpeople, $type_contact, $source='external', $notrigger=0)
Add a link between element $this->element and a contact.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage projects.
const STATUS_VALIDATED
Open/Validated status.
create($user, $notrigger=0)
Create into database.
fetch($id, $ref='', $loadparentdata=0)
Load object in memory from database.
getLibStatut($mode=0)
Return status label of object.
mergeContactTask($origin_id, $dest_id)
Merge contact of tasks.
const STATUS_TRANSFERRED
Transferred status.
getSumOfAmount($fuser='', $dates='', $datee='')
Calculate quantity and value of time consumed using the thm (hourly amount value of work for user ent...
mergeTask($task_origin_id)
Merge a task with another one, deleting the given task.
__construct($db)
Constructor.
fetchTimeSpentOnTask($morewherefilter='')
Fetch records of time spent of this task.
const STATUS_VALIDATED
Validated status (To do).
hasTimeSpent()
Return nb of time spent.
getNomUrl($withpicto=0, $option='', $mode='task', $addlabel=0, $sep=' - ', $notooltip=0, $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
getListContactId($source='internal')
Return list of id of contacts of task.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
delTimeSpent($user, $notrigger=0)
Delete time spent.
mergeTimeSpentTask($origin_id, $dest_id)
Merge time spent of tasks.
const STATUS_DRAFT
Draft status.
fetchAllTimeSpent(User $userobj, $morewherefilter='')
Load all records of time spent.
load_board($user)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
getUserRolesForProjectsOrTasks($userp, $usert, $projectid='', $taskid=0, $filteronprojstatus=-1)
Return list of roles for a user for each projects or each tasks (or a particular project or a particu...
update($user=null, $notrigger=0)
Update database.
getSummaryOfTimeSpent($userobj=null, $morewherefilter='')
Calculate total of time spent for task.
getTooltipContentArray($params)
getTooltipContentArray
const STATUS_CANCELED
status canceled
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create an intervention document on disk using template defined into PROJECT_TASK_ADDON_PDF.
fetchTimeSpent($id)
Load properties of timespent of a task from the time spent ID.
updateTimeSpent($user, $notrigger=0)
Update time spent.
createFromClone(User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt=false, $clone_affectation=false, $clone_time=false, $clone_file=false, $clone_note=false, $clone_prog=false)
Load an object from its id and create a new one in database.
loadStateBoard()
Load indicators this->nb for state board.
initAsSpecimen()
Initialise an instance with random values.
getTasksArray($usert=null, $userp=null, $projectid=0, $socid=0, $mode=0, $filteronproj='', $filteronprojstatus='-1', $morewherefilter='', $filteronprojuser=0, $filterontaskuser=0, $extrafields=null, $includebilltime=0, $search_array_options=array(), $loadextras=0, $loadRoleMode=1, $sortfield='', $sortorder='')
Return list of tasks for all projects or for one particular project Sort order is on project,...
addTimeSpent($user, $notrigger=0)
Add time spent.
hasDelay()
Is the task delayed?
LibStatut($status, $mode=0)
Return status label for an object.
const STATUS_CLOSED
Finished status.
hasChildren()
Return nb of children.
Class to manage Dolibarr users.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_move_dir($srcdir, $destdir, $overwriteifexists=1, $indexdatabase=1, $renamedircontent=1)
Move a directory into another name.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)