32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/timespent.class.php';
46 public $element =
'project_task';
51 public $table_element =
'projet_task';
56 public $fk_element =
'fk_element';
61 public $picto =
'projecttask';
66 protected $childtables = array(
67 'element_time' => array(
'name' =>
'Task',
'parent' =>
'projet_task',
'parentkey' =>
'fk_element',
'parenttypefield' =>
'elementtype',
'parenttypevalue' =>
'task')
73 public $fk_task_parent = 0;
88 public $duration_effective;
93 public $planned_workload;
152 public $fk_user_creat;
157 public $fk_user_valid;
164 public $timespent_min_date;
165 public $timespent_max_date;
166 public $timespent_total_duration;
167 public $timespent_total_amount;
168 public $timespent_nblinesnull;
169 public $timespent_nblines;
173 public $timespent_id;
174 public $timespent_duration;
175 public $timespent_old_duration;
176 public $timespent_date;
177 public $timespent_datehour;
178 public $timespent_withhour;
179 public $timespent_fk_user;
180 public $timespent_thm;
181 public $timespent_note;
182 public $timespent_fk_product;
183 public $timespent_invoiceid;
184 public $timespent_invoicelineid;
186 public $comments = array();
208 public $projectstatus;
213 public $projectlabel;
228 public $fk_opp_status;
230 public $usage_bill_time;
237 public $array_options_project;
251 public $thirdparty_id;
256 public $thirdparty_name;
261 public $thirdparty_email;
267 public $task_parent_ref;
272 public $task_parent_position;
278 public $billable = 1;
283 public $budget_amount;
288 public $project_budget_amount;
334 public function create($user, $notrigger = 0)
336 global $conf, $langs;
344 $this->label = trim($this->label);
346 $this->note_public = trim($this->note_public);
347 $this->note_private = trim($this->note_private);
349 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
350 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
355 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"projet_task (";
357 $sql .=
", fk_projet";
359 $sql .=
", fk_task_parent";
361 $sql .=
", description";
362 $sql .=
", note_public";
363 $sql .=
", note_private";
365 $sql .=
", fk_user_creat";
368 $sql .=
", planned_workload";
369 $sql .=
", progress";
370 $sql .=
", budget_amount";
371 $sql .=
", priority";
372 $sql .=
", billable";
373 $sql .=
") VALUES (";
374 $sql .= (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity);
375 $sql .=
", ".((int) $this->fk_project);
376 $sql .=
", ".(!empty($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
'null');
377 $sql .=
", ".((int) $this->fk_task_parent);
378 $sql .=
", '".$this->db->escape($this->label).
"'";
379 $sql .=
", '".$this->db->escape($this->
description).
"'";
380 $sql .=
", '".$this->db->escape($this->note_public).
"'";
381 $sql .=
", '".$this->db->escape($this->note_private).
"'";
382 $sql .=
", '".$this->db->idate($now).
"'";
383 $sql .=
", ".((int) $user->id);
384 $sql .=
", ".(isDolTms($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
'null');
385 $sql .=
", ".(isDolTms($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
'null');
386 $sql .=
", ".(($this->planned_workload !=
'' && $this->planned_workload >= 0) ? ((
int) $this->planned_workload) :
'null');
387 $sql .=
", ".(($this->progress !=
'' && $this->progress >= 0) ? ((
int) $this->progress) :
'null');
388 $sql .=
", ".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? ((
int) $this->budget_amount) :
'null');
389 $sql .=
", ".(($this->priority !=
'' && $this->priority >= 0) ? (
int) $this->priority :
'null');
390 $sql .=
", ".((int) $this->billable);
395 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
396 $resql = $this->db->query($sql);
399 $this->errors[] =
"Error ".$this->db->lasterror();
403 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"projet_task");
424 foreach ($this->errors as $errmsg) {
425 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
426 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
428 $this->db->rollback();
445 public function fetch($id, $ref =
'', $loadparentdata = 0)
450 $sql .=
" t.entity,";
451 $sql .=
" t.fk_projet as fk_project,";
452 $sql .=
" t.fk_task_parent,";
454 $sql .=
" t.description,";
455 $sql .=
" t.duration_effective,";
456 $sql .=
" t.planned_workload,";
458 $sql .=
" t.dateo as date_start,";
459 $sql .=
" t.datee as date_end,";
460 $sql .=
" t.fk_user_creat,";
461 $sql .=
" t.fk_user_valid,";
462 $sql .=
" t.fk_statut as status,";
463 $sql .=
" t.progress,";
464 $sql .=
" t.budget_amount,";
465 $sql .=
" t.priority,";
466 $sql .=
" t.note_private,";
467 $sql .=
" t.note_public,";
469 $sql .=
" t.billable";
470 if (!empty($loadparentdata)) {
471 $sql .=
", t2.ref as task_parent_ref";
472 $sql .=
", t2.rang as task_parent_position";
474 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t";
475 if (!empty($loadparentdata)) {
476 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t2 ON t.fk_task_parent = t2.rowid";
480 $sql .=
"entity IN (".getEntity(
'project').
")";
481 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
483 $sql .=
"t.rowid = ".((int) $id);
486 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
487 $resql = $this->db->query($sql);
489 $num_rows = $this->db->num_rows($resql);
492 $obj = $this->db->fetch_object($resql);
494 $this->
id = $obj->rowid;
495 $this->
ref = $obj->ref;
496 $this->entity = $obj->entity;
497 $this->fk_project = $obj->fk_project;
498 $this->fk_task_parent = $obj->fk_task_parent;
499 $this->label = $obj->label;
501 $this->duration_effective = $obj->duration_effective;
502 $this->planned_workload = $obj->planned_workload;
503 $this->date_c = $this->db->jdate($obj->datec);
504 $this->date_start = $this->db->jdate($obj->date_start);
505 $this->date_end = $this->db->jdate($obj->date_end);
506 $this->fk_user_creat = $obj->fk_user_creat;
507 $this->fk_user_valid = $obj->fk_user_valid;
508 $this->fk_statut = $obj->status;
509 $this->
status = $obj->status;
510 $this->progress = $obj->progress;
511 $this->budget_amount = $obj->budget_amount;
512 $this->priority = $obj->priority;
513 $this->note_private = $obj->note_private;
514 $this->note_public = $obj->note_public;
515 $this->rang = $obj->rang;
517 if (!empty($loadparentdata)) {
518 $this->task_parent_ref = $obj->task_parent_ref;
519 $this->task_parent_position = $obj->task_parent_position;
521 $this->billable = $obj->billable;
527 $this->db->free($resql);
535 $this->error =
"Error ".$this->db->lasterror();
548 public function update($user =
null, $notrigger = 0)
550 global $conf, $langs;
554 if (isset($this->fk_project)) {
555 $this->fk_project = (int) $this->fk_project;
557 if (isset($this->
ref)) {
558 $this->
ref = trim($this->
ref);
560 if (isset($this->fk_task_parent)) {
561 $this->fk_task_parent = (int) $this->fk_task_parent;
563 if (isset($this->label)) {
564 $this->label = trim($this->label);
569 if (isset($this->note_public)) {
570 $this->note_public = trim($this->note_public);
572 if (isset($this->note_private)) {
573 $this->note_private = trim($this->note_private);
575 if (isset($this->duration_effective)) {
576 $this->duration_effective = trim($this->duration_effective);
578 if (isset($this->planned_workload)) {
579 $this->planned_workload = trim($this->planned_workload);
581 if (isset($this->budget_amount)) {
582 $this->budget_amount = (float) $this->budget_amount;
585 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
586 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
594 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET";
595 $sql .=
" fk_projet=".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
596 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"'".$this->db->escape($this->
id).
"'").
",";
597 $sql .=
" fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent :
"null").
",";
598 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
599 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
600 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
601 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
602 $sql .=
" duration_effective=".(isset($this->duration_effective) ? $this->duration_effective :
"null").
",";
603 $sql .=
" planned_workload=".((isset($this->planned_workload) && $this->planned_workload !=
'') ? $this->planned_workload :
"null").
",";
604 $sql .=
" dateo=".(isDolTms($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
'null').
",";
605 $sql .=
" datee=".(isDolTms($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
'null').
",";
606 $sql .=
" progress=".(($this->progress !=
'' && $this->progress >= 0) ? $this->progress :
'null').
",";
607 $sql .=
" budget_amount=".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? $this->budget_amount :
'null').
",";
608 $sql .=
" rang=".((!empty($this->rang)) ? ((
int) $this->rang) :
"0").
",";
609 $sql .=
" priority=".((!empty($this->priority)) ? ((
int) $this->priority) :
"0").
",";
610 $sql .=
" billable=".((int) $this->billable);
611 $sql .=
" WHERE rowid=".((int) $this->
id);
615 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
616 $resql = $this->db->query($sql);
619 $this->errors[] =
"Error ".$this->db->lasterror();
632 $project =
new Project($this->db);
633 if ($project->fetch($this->fk_project) > 0) {
635 $project->getLinesArray(
null);
636 $projectCompleted = array_reduce(
643 static function ($allTasksCompleted, $task) {
644 return $allTasksCompleted && $task->progress >= 100;
648 if ($projectCompleted) {
649 if ($project->setClose($user) <= 0) {
658 $this->errors[] = $project->error;
673 if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
675 if ($conf->project->dir_output) {
676 $project =
new Project($this->db);
677 $project->fetch($this->fk_project);
681 if (file_exists($olddir)) {
682 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
685 $langs->load(
"errors");
686 $this->error = $langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir);
695 foreach ($this->errors as $errmsg) {
696 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
697 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
699 $this->db->rollback();
715 public function delete($user, $notrigger = 0)
718 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
725 dol_syslog(get_class($this).
"::delete Can't delete record as it has some sub tasks", LOG_WARNING);
726 $this->error =
'ErrorRecordHasSubTasks';
727 $this->db->rollback();
732 if (!empty($objectisused)) {
733 dol_syslog(get_class($this).
"::delete Can't delete record as it has some child", LOG_WARNING);
734 $this->error =
'ErrorRecordHasChildren';
735 $this->db->rollback();
743 $this->error =
'ErrorFailToDeleteLinkedContact';
745 $this->db->rollback();
751 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_time";
752 $sql .=
" WHERE fk_element = ".((int) $this->
id).
" AND elementtype = 'task'";
754 $resql = $this->db->query($sql);
757 $this->errors[] =
"Error ".$this->db->lasterror();
762 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task_extrafields";
763 $sql .=
" WHERE fk_object = ".((int) $this->
id);
765 $resql = $this->db->query($sql);
768 $this->errors[] =
"Error ".$this->db->lasterror();
773 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task";
774 $sql .=
" WHERE rowid=".((int) $this->
id);
776 $resql = $this->db->query($sql);
779 $this->errors[] =
"Error ".$this->db->lasterror();
796 foreach ($this->errors as $errmsg) {
797 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
798 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
800 $this->db->rollback();
804 if ($conf->project->dir_output) {
805 $projectstatic =
new Project($this->db);
806 $projectstatic->fetch($this->fk_project);
809 dol_syslog(get_class($this).
"::delete dir=".$dir, LOG_DEBUG);
810 if (file_exists($dir)) {
811 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
814 $this->error =
'ErrorFailToDeleteDir';
815 $this->db->rollback();
837 $sql =
"SELECT COUNT(*) as nb";
838 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
839 $sql .=
" WHERE fk_task_parent = ".((int) $this->
id);
841 dol_syslog(get_class($this).
"::hasChildren", LOG_DEBUG);
842 $resql = $this->db->query($sql);
845 $this->errors[] =
"Error ".$this->db->lasterror();
847 $obj = $this->db->fetch_object($resql);
851 $this->db->free($resql);
871 $sql =
"SELECT COUNT(*) as nb";
872 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time";
873 $sql .=
" WHERE fk_element = ".((int) $this->
id);
874 $sql .=
" AND elementtype = 'task'";
876 dol_syslog(get_class($this).
"::hasTimeSpent", LOG_DEBUG);
877 $resql = $this->db->query($sql);
880 $this->errors[] =
"Error ".$this->db->lasterror();
882 $obj = $this->db->fetch_object($resql);
886 $this->db->free($resql);
908 $langs->load(
'projects');
911 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Task").
'</u>';
912 if (!empty($this->
ref)) {
913 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
915 if (!empty($this->label)) {
916 $datas[
'label'] =
'<br><b>'.$langs->trans(
'LabelTask').
':</b> '.$this->label;
918 if ($this->date_start || $this->date_end) {
919 $datas[
'range'] =
"<br>".get_date_range($this->date_start, $this->date_end,
'', $langs, 0);
937 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'task', $addlabel = 0, $sep =
' - ', $notooltip = 0, $save_lastsearch_value = -1)
939 global $action, $conf, $hookmanager, $langs;
941 if (!empty($conf->dol_no_mouse_hover)) {
948 'objecttype' => $this->element,
950 $classfortooltip =
'classfortooltip';
953 $classfortooltip =
'classforajaxtooltip';
954 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
960 $url = DOL_URL_ROOT.
'/projet/tasks/'.$mode.
'.php?id='.$this->
id.($option ==
'withproject' ?
'&withproject=1' :
'');
962 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
963 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
964 $add_save_lastsearch_values = 1;
966 if ($add_save_lastsearch_values) {
967 $url .=
'&save_lastsearch_values=1';
971 if (empty($notooltip)) {
973 $label = $langs->trans(
"ShowTask");
974 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
976 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
977 $linkclose .= $dataparams.
' class="'.$classfortooltip.
' nowraponall"';
979 $linkclose .=
' class="nowraponall"';
982 $linkstart =
'<a href="'.$url.
'"';
983 $linkstart .= $linkclose.
'>';
986 $picto =
'projecttask';
988 $result .= $linkstart;
990 $result .=
img_object(($notooltip ?
'' : $label), $picto,
'class="paddingright"', 0, 0, $notooltip ? 0 : 1);
992 if ($withpicto != 2) {
993 $result .= $this->ref;
996 if ($withpicto != 2) {
997 $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) :
'');
1000 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1001 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1003 $result = $hookmanager->resPrint;
1005 $result .= $hookmanager->resPrint;
1024 $this->fk_project = 0;
1025 $this->
ref =
'TK01';
1026 $this->fk_task_parent = 0;
1027 $this->label =
'Specimen task TK01';
1028 $this->duration_effective =
'';
1029 $this->fk_user_creat = $user->id;
1030 $this->progress = 25;
1032 $this->priority = 0;
1033 $this->note_private =
'This is a specimen private note';
1034 $this->note_public =
'This is a specimen public note';
1035 $this->billable = 1;
1063 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 =
'')
1065 global $hookmanager;
1073 if ($filteronprojuser > 0 || $filterontaskuser > 0) {
1074 $sql .=
" DISTINCT";
1076 $sql .=
" p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,";
1077 $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,";
1078 $sql .=
" t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang, t.priority,";
1079 $sql .=
" t.budget_amount, t.billable,";
1080 $sql .=
" t.note_public, t.note_private,";
1081 $sql .=
" s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,";
1082 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount as project_budget_amount";
1084 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1085 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1086 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key.
" as options_".$key :
'');
1089 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1090 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1091 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1095 if ($includebilltime) {
1096 $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";
1099 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1102 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_extrafields as efp ON (p.rowid = efp.fk_object)";
1106 if ($filteronprojuser > 0) {
1107 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1108 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1110 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1112 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
1114 if ($includebilltime) {
1115 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1117 if ($filterontaskuser > 0) {
1118 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1119 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1121 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1122 $sql .=
" AND t.fk_projet = p.rowid";
1123 } elseif ($mode == 1) {
1124 if ($filteronprojuser > 0) {
1125 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1126 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1128 if ($filterontaskuser > 0) {
1129 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1130 if ($includebilltime) {
1131 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1133 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1134 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1136 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
1137 if ($includebilltime) {
1138 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')";
1141 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1143 return 'BadValueForParameterMode';
1146 if ($filteronprojuser > 0) {
1147 $sql .=
" AND p.rowid = ec.element_id";
1148 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1149 $sql .=
" AND ctc.element = 'project'";
1150 $sql .=
" AND ec.fk_socpeople = ".((int) $filteronprojuser);
1151 $sql .=
" AND ec.statut = 4";
1152 $sql .=
" AND ctc.source = 'internal'";
1154 if ($filterontaskuser > 0) {
1155 $sql .=
" AND t.fk_projet = p.rowid";
1156 $sql .=
" AND p.rowid = ec2.element_id";
1157 $sql .=
" AND ctc2.rowid = ec2.fk_c_type_contact";
1158 $sql .=
" AND ctc2.element = 'project_task'";
1159 $sql .=
" AND ec2.fk_socpeople = ".((int) $filterontaskuser);
1160 $sql .=
" AND ec2.statut = 4";
1161 $sql .=
" AND ctc2.source = 'internal'";
1164 $sql .=
" AND p.fk_soc = ".((int) $socid);
1167 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1169 if ($filteronproj) {
1170 $sql .=
natural_search(array(
"p.ref",
"p.title"), $filteronproj);
1172 if ($filteronprojstatus && (
int) $filteronprojstatus !=
'-1') {
1173 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).
")";
1175 if ($morewherefilter) {
1176 $sql .= $morewherefilter;
1180 $extrafieldsobjectkey =
'projet_task';
1181 $extrafieldsobjectprefix =
'efpt.';
1183 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1186 $parameters = array();
1187 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1188 $sql .= $hookmanager->resPrint;
1189 if ($includebilltime) {
1190 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,";
1191 $sql .=
" t.datec, t.dateo, t.datee, t.tms,";
1192 $sql .=
" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,";
1193 $sql .=
" t.dateo, t.datee, t.planned_workload, t.rang, t.priority,";
1194 $sql .=
" t.budget_amount, t.billable,";
1195 $sql .=
" t.note_public, t.note_private,";
1196 $sql .=
" s.rowid, s.nom, s.email,";
1197 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
1199 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1200 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1201 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key :
'');
1204 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1205 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1206 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key :
'');
1212 if ($sortfield && $sortorder) {
1213 $sql .= $this->db->order($sortfield, $sortorder);
1215 $sql .=
" ORDER BY p.ref, t.rang, t.dateo";
1219 dol_syslog(get_class($this).
"::getTasksArray", LOG_DEBUG);
1220 $resql = $this->db->query($sql);
1222 $num = $this->db->num_rows($resql);
1228 $obj = $this->db->fetch_object($resql);
1230 if ($loadRoleMode) {
1231 if ((!$obj->public) && (is_object($userp))) {
1236 if (is_object($usert)) {
1244 $tasks[$i] =
new Task($this->db);
1245 $tasks[$i]->id = $obj->taskid;
1246 $tasks[$i]->ref = $obj->taskref;
1247 $tasks[$i]->fk_project = $obj->projectid;
1250 $tasks[$i]->projectref = $obj->ref;
1251 $tasks[$i]->projectlabel = $obj->plabel;
1252 $tasks[$i]->projectstatus = $obj->projectstatus;
1253 $tasks[$i]->fk_opp_status = $obj->fk_opp_status;
1254 $tasks[$i]->opp_amount = $obj->opp_amount;
1255 $tasks[$i]->opp_percent = $obj->opp_percent;
1256 $tasks[$i]->budget_amount = $obj->budget_amount;
1257 $tasks[$i]->project_budget_amount = $obj->project_budget_amount;
1258 $tasks[$i]->usage_bill_time = $obj->usage_bill_time;
1260 $tasks[$i]->label = $obj->label;
1261 $tasks[$i]->description = $obj->description;
1263 $tasks[$i]->fk_task_parent = $obj->fk_task_parent;
1264 $tasks[$i]->note_public = $obj->note_public;
1265 $tasks[$i]->note_private = $obj->note_private;
1266 $tasks[$i]->duration_effective = $obj->duration_effective;
1267 $tasks[$i]->planned_workload = $obj->planned_workload;
1269 if ($includebilltime) {
1271 $tasks[$i]->tobill = $obj->tobill;
1272 $tasks[$i]->billed = $obj->billed;
1275 $tasks[$i]->progress = $obj->progress;
1276 $tasks[$i]->fk_statut = $obj->status;
1277 $tasks[$i]->status = $obj->status;
1278 $tasks[$i]->public = $obj->public;
1279 $tasks[$i]->date_start = $this->db->jdate($obj->date_start);
1280 $tasks[$i]->date_end = $this->db->jdate($obj->date_end);
1281 $tasks[$i]->rang = $obj->rang;
1282 $tasks[$i]->priority = $obj->priority;
1284 $tasks[$i]->socid = $obj->thirdparty_id;
1285 $tasks[$i]->thirdparty_id = $obj->thirdparty_id;
1286 $tasks[$i]->thirdparty_name = $obj->thirdparty_name;
1287 $tasks[$i]->thirdparty_email = $obj->thirdparty_email;
1289 $tasks[$i]->billable = $obj->billable;
1292 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1293 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1294 if ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate') {
1295 $tmpvar =
'options_'.$key;
1296 $tasks[$i]->array_options_project[
'options_'.$key] = $obj->$tmpvar;
1303 $tasks[$i]->fetch_optionals();
1309 $this->db->free($resql);
1329 $arrayroles = array();
1331 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks userp=".json_encode(is_object($userp)).
" usert=".json_encode(is_object($usert)).
" projectid=".$projectid.
" taskid=".$taskid);
1334 if (empty($userp) && empty($usert)) {
1335 $this->error =
"CallWithWrongParameters";
1338 if (!empty($userp) && !empty($usert)) {
1339 $this->error =
"CallWithWrongParameters";
1346 $sql .=
" p.rowid as pid,";
1348 $sql .=
" pt.rowid as pid,";
1350 $sql .=
" ec.element_id, ctc.code, ctc.source";
1352 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1354 if ($usert && $filteronprojstatus > -1) {
1355 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p, ".MAIN_DB_PREFIX.
"projet_task as pt";
1357 if ($usert && $filteronprojstatus <= -1) {
1358 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as pt";
1360 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1361 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1363 $sql .=
" WHERE p.rowid = ec.element_id";
1365 $sql .=
" WHERE pt.rowid = ec.element_id";
1367 if ($userp && $filteronprojstatus > -1) {
1368 $sql .=
" AND p.fk_statut = ".((int) $filteronprojstatus);
1370 if ($usert && $filteronprojstatus > -1) {
1371 $sql .=
" AND pt.fk_projet = p.rowid AND p.fk_statut = ".((int) $filteronprojstatus);
1374 $sql .=
" AND ctc.element = 'project'";
1377 $sql .=
" AND ctc.element = 'project_task'";
1379 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1381 $sql .=
" AND ec.fk_socpeople = ".((int) $userp->id);
1384 $sql .=
" AND ec.fk_socpeople = ".((int) $usert->id);
1386 $sql .=
" AND ec.statut = 4";
1387 $sql .=
" AND ctc.source = 'internal'";
1390 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1393 $sql .=
" AND pt.fk_projet IN (".$this->db->sanitize($projectid).
")";
1398 $sql .=
" ERROR SHOULD NOT HAPPENS";
1401 $sql .=
" AND pt.rowid = ".((int) $taskid);
1406 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG);
1407 $resql = $this->db->query($sql);
1409 $num = $this->db->num_rows($resql);
1412 $obj = $this->db->fetch_object($resql);
1413 if (empty($arrayroles[$obj->pid])) {
1414 $arrayroles[$obj->pid] = $obj->code;
1416 $arrayroles[$obj->pid] .=
','.$obj->code;
1420 $this->db->free($resql);
1437 $contactAlreadySelected = array();
1443 if ($source ==
'thirdparty') {
1444 $contactAlreadySelected[$i] = $tab[$i][
'socid'];
1446 $contactAlreadySelected[$i] = $tab[$i][
'id'];
1450 return $contactAlreadySelected;
1463 $origintask =
new Task($this->db);
1464 $result = $origintask->fetch($origin_id);
1470 $arraycontactorigin = array_merge($origintask->liste_contact(-1,
'internal'), $origintask->liste_contact(-1,
'external'));
1471 if (is_array($arraycontactorigin)) {
1472 foreach ($arraycontactorigin as $key => $contact) {
1473 $result = $this->
add_contact($contact[
"id"], $contact[
"fk_c_type_contact"], $contact[
"source"]);
1495 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"element_time as et";
1496 $sql .=
" SET et.fk_element = ".((int) $dest_id);
1497 $sql .=
" WHERE et.elementtype = 'task'";
1498 $sql .=
" AND et.fk_element = ".((int) $origin_id);
1500 dol_syslog(get_class($this).
"::mergeTimeSpentTask", LOG_DEBUG);
1501 if (!$this->db->query($sql)) {
1502 $this->error = $this->db->lasterror();
1507 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1508 $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).
")";
1509 $sql .=
" WHERE rowid = ".((int) $dest_id);
1511 dol_syslog(get_class($this).
"::mergeTimeSpentTask update project_task", LOG_DEBUG);
1512 if (!$this->db->query($sql)) {
1513 $this->error = $this->db->lasterror();
1519 $this->db->commit();
1521 $this->db->rollback();
1537 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1543 if (!is_object($user)) {
1544 dol_print_error(
null,
"Method addTimeSpent was called with wrong parameter user");
1549 if (isset($this->timespent_note)) {
1550 $this->timespent_note = trim($this->timespent_note);
1552 if (empty($this->timespent_datehour) || ($this->timespent_date != $this->timespent_datehour)) {
1553 $this->timespent_datehour = $this->timespent_date;
1557 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1560 if ($this->timespent_date < $restrictBefore) {
1561 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
1562 $this->errors[] = $this->error;
1570 $timespent->fk_element = $this->id;
1571 $timespent->elementtype =
'task';
1572 $timespent->element_date = $this->timespent_date;
1573 $timespent->element_datehour = $this->timespent_datehour;
1574 $timespent->element_date_withhour = $this->timespent_withhour;
1575 $timespent->element_duration = $this->timespent_duration;
1576 $timespent->fk_user = $this->timespent_fk_user;
1577 $timespent->fk_product = $this->timespent_fk_product;
1578 $timespent->note = $this->timespent_note;
1579 $timespent->datec = $this->db->idate($now);
1581 $result = $timespent->create($user);
1585 $this->timespent_id = $result;
1589 $result = $this->
call_trigger(
'TASK_TIMESPENT_CREATE', $user);
1596 $this->error = $this->db->lasterror();
1602 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1603 $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).
")";
1604 if (isset($this->progress)) {
1605 $sql .=
", progress = ".((float) $this->progress);
1607 $sql .=
" WHERE rowid = ".((int) $this->
id);
1609 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1610 if (!$this->db->query($sql)) {
1611 $this->error = $this->db->lasterror();
1616 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1617 if (!empty($resql_thm_user)) {
1618 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1619 $timespent->thm = $obj_thm_user->thm;
1621 $res_update = $timespent->update($user);
1623 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1624 if ($res_update <= 0) {
1625 $this->error = $this->db->lasterror();
1631 $this->db->commit();
1633 $this->db->rollback();
1646 $arrayres = array();
1649 $sql .=
" s.rowid as socid,";
1650 $sql .=
" s.nom as thirdparty_name,";
1651 $sql .=
" s.email as thirdparty_email,";
1652 $sql .=
" ptt.rowid,";
1653 $sql .=
" ptt.ref_ext,";
1654 $sql .=
" ptt.fk_element as fk_task,";
1655 $sql .=
" ptt.element_date as task_date,";
1656 $sql .=
" ptt.element_datehour as task_datehour,";
1657 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1658 $sql .=
" ptt.element_duration as task_duration,";
1659 $sql .=
" ptt.fk_user,";
1660 $sql .=
" ptt.note,";
1661 $sql .=
" ptt.thm,";
1662 $sql .=
" pt.rowid as task_id,";
1663 $sql .=
" pt.ref as task_ref,";
1664 $sql .=
" pt.label as task_label,";
1665 $sql .=
" p.rowid as project_id,";
1666 $sql .=
" p.ref as project_ref,";
1667 $sql .=
" p.title as project_label,";
1668 $sql .=
" p.public as public";
1669 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1670 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1671 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1672 $sql .=
" AND ptt.elementtype = 'task'";
1673 $sql .=
" AND pt.rowid = ".((int) $this->
id);
1674 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1675 if ($morewherefilter) {
1676 $sql .= $morewherefilter;
1679 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1680 $resql = $this->db->query($sql);
1682 $num = $this->db->num_rows($resql);
1686 $obj = $this->db->fetch_object($resql);
1690 $newobj->socid = $obj->socid;
1691 $newobj->thirdparty_name = $obj->thirdparty_name;
1692 $newobj->thirdparty_email = $obj->thirdparty_email;
1694 $newobj->fk_project = $obj->project_id;
1695 $newobj->project_ref = $obj->project_ref;
1696 $newobj->project_label = $obj->project_label;
1697 $newobj->public = $obj->project_public;
1699 $newobj->fk_task = $obj->task_id;
1700 $newobj->task_ref = $obj->task_ref;
1701 $newobj->task_label = $obj->task_label;
1703 $newobj->timespent_line_id = $obj->rowid;
1704 $newobj->timespent_line_ref_ext = $obj->ref_ext;
1705 $newobj->timespent_line_date = $this->db->jdate($obj->task_date);
1706 $newobj->timespent_line_datehour = $this->db->jdate($obj->task_datehour);
1707 $newobj->timespent_line_withhour = $obj->task_date_withhour;
1708 $newobj->timespent_line_duration = $obj->task_duration;
1709 $newobj->timespent_line_fk_user = $obj->fk_user;
1710 $newobj->timespent_line_thm = $obj->thm;
1711 $newobj->timespent_line_note = $obj->note;
1713 $arrayres[] = $newobj;
1718 $this->db->free($resql);
1720 $this->lines = $arrayres;
1724 $this->error =
"Error ".$this->db->lasterror();
1739 if (is_object($userobj)) {
1740 $userid = $userobj->id;
1746 if (empty($id) && empty($userid)) {
1747 dol_syslog(
"getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR);
1754 $sql .=
" MIN(t.element_datehour) as min_date,";
1755 $sql .=
" MAX(t.element_datehour) as max_date,";
1756 $sql .=
" SUM(t.element_duration) as total_duration,";
1757 $sql .=
" SUM(t.element_duration / 3600 * ".$this->db->ifsql(
"t.thm IS NULL", 0,
"t.thm").
") as total_amount,";
1758 $sql .=
" COUNT(t.rowid) as nblines,";
1759 $sql .=
" SUM(".$this->db->ifsql(
"t.thm IS NULL", 1, 0).
") as nblinesnull";
1760 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1761 $sql .=
" WHERE t.elementtype='task'";
1762 if ($morewherefilter) {
1763 $sql .= $morewherefilter;
1766 $sql .=
" AND t.fk_element = ".((int) $id);
1769 $sql .=
" AND t.fk_user = ".((int) $userid);
1772 dol_syslog(get_class($this).
"::getSummaryOfTimeSpent", LOG_DEBUG);
1773 $resql = $this->db->query($sql);
1775 $obj = $this->db->fetch_object($resql);
1777 $result[
'min_date'] = $obj->min_date;
1778 $result[
'max_date'] = $obj->max_date;
1779 $result[
'total_duration'] = $obj->total_duration;
1781 $this->timespent_min_date = $this->db->jdate($obj->min_date);
1782 $this->timespent_max_date = $this->db->jdate($obj->max_date);
1783 $this->timespent_total_duration = $obj->total_duration;
1784 $this->timespent_total_amount = $obj->total_amount;
1785 $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0);
1786 $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0);
1788 $this->db->free($resql);
1810 $sql .=
" SUM(t.element_duration) as nbseconds,";
1811 $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";
1812 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1813 $sql .=
" WHERE t.elementtype='task' AND t.fk_element = ".((int) $id);
1814 if (is_object($fuser) && $fuser->id > 0) {
1815 $sql .=
" AND fk_user = ".((int) $fuser->id);
1818 $datefieldname =
"element_datehour";
1819 $sql .=
" AND (".$datefieldname.
" >= '".$this->db->idate($dates).
"' OR ".$datefieldname.
" IS NULL)";
1822 $datefieldname =
"element_datehour";
1823 $sql .=
" AND (".$datefieldname.
" <= '".$this->db->idate($datee).
"' OR ".$datefieldname.
" IS NULL)";
1827 dol_syslog(get_class($this).
"::getSumOfAmount", LOG_DEBUG);
1828 $resql = $this->db->query($sql);
1830 $obj = $this->db->fetch_object($resql);
1832 $result[
'amount'] = $obj->amount;
1833 $result[
'nbseconds'] = $obj->nbseconds;
1834 $result[
'nblinesnull'] = $obj->nblinesnull;
1836 $this->db->free($resql);
1853 $timespent->fetch($id);
1855 dol_syslog(get_class($this).
"::fetchTimeSpent", LOG_DEBUG);
1857 if ($timespent->id > 0) {
1858 $this->timespent_id = $timespent->id;
1859 $this->
id = $timespent->fk_element;
1860 $this->timespent_date = $timespent->element_date;
1861 $this->timespent_datehour = $timespent->element_datehour;
1862 $this->timespent_withhour = $timespent->element_date_withhour;
1863 $this->timespent_duration = $timespent->element_duration;
1864 $this->timespent_fk_user = $timespent->fk_user;
1865 $this->timespent_fk_product = $timespent->fk_product;
1866 $this->timespent_thm = $timespent->thm;
1867 $this->timespent_note = $timespent->note;
1884 $arrayres = array();
1887 $sql .=
" s.rowid as socid,";
1888 $sql .=
" s.nom as thirdparty_name,";
1889 $sql .=
" s.email as thirdparty_email,";
1890 $sql .=
" ptt.rowid,";
1891 $sql .=
" ptt.fk_element as fk_task,";
1892 $sql .=
" ptt.element_date as task_date,";
1893 $sql .=
" ptt.element_datehour as task_datehour,";
1894 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1895 $sql .=
" ptt.element_duration as task_duration,";
1896 $sql .=
" ptt.fk_user,";
1897 $sql .=
" ptt.note,";
1898 $sql .=
" ptt.thm,";
1899 $sql .=
" pt.rowid as task_id,";
1900 $sql .=
" pt.ref as task_ref,";
1901 $sql .=
" pt.label as task_label,";
1902 $sql .=
" p.rowid as project_id,";
1903 $sql .=
" p.ref as project_ref,";
1904 $sql .=
" p.title as project_label,";
1905 $sql .=
" p.public as public";
1906 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1907 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1908 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1909 $sql .=
" AND ptt.elementtype = 'task'";
1910 $sql .=
" AND ptt.fk_user = ".((int) $userobj->id);
1911 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1912 if ($morewherefilter) {
1913 $sql .= $morewherefilter;
1916 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1917 $resql = $this->db->query($sql);
1919 $num = $this->db->num_rows($resql);
1923 $obj = $this->db->fetch_object($resql);
1927 $newobj->socid = $obj->socid;
1928 $newobj->thirdparty_name = $obj->thirdparty_name;
1929 $newobj->thirdparty_email = $obj->thirdparty_email;
1931 $newobj->fk_project = $obj->project_id;
1932 $newobj->project_ref = $obj->project_ref;
1933 $newobj->project_label = $obj->project_label;
1934 $newobj->public = $obj->project_public;
1936 $newobj->fk_task = $obj->task_id;
1937 $newobj->task_ref = $obj->task_ref;
1938 $newobj->task_label = $obj->task_label;
1940 $newobj->timespent_id = $obj->rowid;
1941 $newobj->timespent_date = $this->db->jdate($obj->task_date);
1942 $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour);
1943 $newobj->timespent_withhour = $obj->task_date_withhour;
1944 $newobj->timespent_duration = $obj->task_duration;
1945 $newobj->timespent_fk_user = $obj->fk_user;
1946 $newobj->timespent_thm = $obj->thm;
1947 $newobj->timespent_note = $obj->note;
1949 $arrayres[] = $newobj;
1954 $this->db->free($resql);
1957 $this->error =
"Error ".$this->db->lasterror();
1973 global $conf, $langs;
1978 if ($this->timespent_date ==
'') {
1979 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date"));
1982 if (!($this->timespent_fk_user > 0)) {
1983 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"User"));
1988 if (empty($this->timespent_datehour)) {
1989 $this->timespent_datehour = $this->timespent_date;
1991 if (isset($this->timespent_note)) {
1992 $this->timespent_note = trim($this->timespent_note);
1996 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1999 if ($this->timespent_date < $restrictBefore) {
2000 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
2001 $this->errors[] = $this->error;
2009 $timespent->fetch($this->timespent_id);
2010 $timespent->element_date = $this->timespent_date;
2011 $timespent->element_datehour = $this->timespent_datehour;
2012 $timespent->element_date_withhour = $this->timespent_withhour;
2013 $timespent->element_duration = $this->timespent_duration;
2014 $timespent->fk_user = $this->timespent_fk_user;
2015 $timespent->fk_product = $this->timespent_fk_product;
2016 $timespent->note = $this->timespent_note;
2017 $timespent->invoice_id = $this->timespent_invoiceid;
2018 $timespent->invoice_line_id = $this->timespent_invoicelineid;
2020 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
2021 if ($timespent->update($user) > 0) {
2024 $result = $this->
call_trigger(
'TASK_TIMESPENT_MODIFY', $user);
2026 $this->db->rollback();
2036 $this->error = $this->db->lasterror();
2037 $this->db->rollback();
2041 if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) ||
getDolGlobalString(
'TIMESPENT_ALWAYS_UPDATE_THM'))) {
2042 if ($this->timespent_old_duration != $this->timespent_duration) {
2044 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"projet_task";
2045 $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) .
")";
2046 if (isset($this->progress)) {
2047 $sql .=
", progress = " . ((float) $this->progress);
2049 $sql .=
" WHERE rowid = " . ((int) $this->
id);
2051 dol_syslog(get_class($this) .
"::updateTimeSpent", LOG_DEBUG);
2052 if (!$this->db->query($sql)) {
2053 $this->error = $this->db->lasterror();
2054 $this->db->rollback();
2062 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
2063 if (!empty($resql_thm_user)) {
2064 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
2065 $timespent->thm = $obj_thm_user->thm;
2067 $res_update = $timespent->update($user);
2070 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
2071 if ($res_update <= 0) {
2072 $this->error = $this->db->lasterror();
2078 $this->db->commit();
2092 global $conf, $langs;
2097 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2100 if ($this->timespent_date < $restrictBefore) {
2101 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
2102 $this->errors[] = $this->error;
2111 $result = $this->
call_trigger(
'TASK_TIMESPENT_DELETE', $user);
2120 $timespent->fetch($this->timespent_id);
2122 $res_del = $timespent->delete($user);
2126 $this->errors[] =
"Error ".$this->db->lasterror();
2131 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
2132 $sql .=
" SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0);
2133 $sql .=
" WHERE rowid = ".((int) $this->
id);
2135 dol_syslog(get_class($this).
"::delTimeSpent", LOG_DEBUG);
2136 if ($this->db->query($sql)) {
2139 $this->error = $this->db->lasterror();
2146 foreach ($this->errors as $errmsg) {
2147 dol_syslog(get_class($this).
"::delTimeSpent ".$errmsg, LOG_ERR);
2148 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2150 $this->db->rollback();
2153 $this->db->commit();
2172 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)
2174 global $langs, $conf;
2183 $clone_task =
new Task($this->db);
2184 $origin_task =
new Task($this->db);
2186 $clone_task->context[
'createfromclone'] =
'createfromclone';
2191 $clone_task->fetch($fromid);
2192 $clone_task->fetch_optionals();
2195 $origin_task->fetch($fromid);
2198 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
2200 require_once DOL_DOCUMENT_ROOT.
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON').
'.php';
2201 $modTask =
new $obj();
2202 '@phan-var-force ModeleNumRefTask $modTask';
2203 $defaultref = $modTask->getNextValue(0, $clone_task);
2206 $ori_project_id = $clone_task->fk_project;
2208 $clone_task->id = 0;
2209 $clone_task->ref = $defaultref;
2210 $clone_task->fk_project = $project_id;
2211 $clone_task->fk_task_parent = $parent_task_id;
2212 $clone_task->date_c = $datec;
2213 $clone_task->planned_workload = $origin_task->planned_workload;
2214 $clone_task->rang = $origin_task->rang;
2215 $clone_task->priority = $origin_task->priority;
2218 if ($clone_change_dt) {
2219 $projectstatic =
new Project($this->db);
2220 $projectstatic->fetch($ori_project_id);
2223 $orign_project_dt_start = $projectstatic->date_start;
2226 if (!empty($clone_task->date_start)) {
2227 $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
2231 if (!empty($clone_task->date_end)) {
2232 $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
2237 $clone_task->progress = 0;
2241 $result = $clone_task->create($user);
2245 $this->error = $clone_task->error;
2252 $clone_task_id = $clone_task->id;
2253 $clone_task_ref = $clone_task->ref;
2257 $clone_task->note_private =
'';
2258 $clone_task->note_public =
'';
2261 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_public, ENT_QUOTES | ENT_HTML5),
'_public');
2263 $this->error .= $clone_task->error;
2265 $this->db->rollback();
2267 $this->db->commit();
2271 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_private, ENT_QUOTES | ENT_HTML5),
'_private');
2273 $this->error .= $clone_task->error;
2275 $this->db->rollback();
2277 $this->db->commit();
2283 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2286 $projectstatic =
new Project($this->db);
2287 $projectstatic->fetch($ori_project_id);
2288 $ori_project_ref = $projectstatic->ref;
2290 if ($ori_project_id != $project_id) {
2291 $projectstatic->fetch($project_id);
2292 $clone_project_ref = $projectstatic->ref;
2294 $clone_project_ref = $ori_project_ref;
2300 $filearray =
dol_dir_list($ori_task_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
2301 foreach ($filearray as $key => $file) {
2302 if (!file_exists($clone_task_dir)) {
2304 $this->error .= $langs->trans(
'ErrorInternalErrorDetected').
':dol_mkdir';
2309 $rescopy =
dol_copy($ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name'], 0, 1);
2310 if (is_numeric($rescopy) && $rescopy < 0) {
2311 $this->error .= $langs->trans(
"ErrorFailToCopyFile", $ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name']);
2318 if ($clone_affectation) {
2319 $origin_task =
new Task($this->db);
2320 $origin_task->fetch($fromid);
2322 foreach (array(
'internal',
'external') as $source) {
2323 $tab = $origin_task->liste_contact(-1, $source);
2327 $clone_task->add_contact($tab[$i][
'id'], $tab[$i][
'code'], $tab[$i][
'source']);
2328 if ($clone_task->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2329 $langs->load(
"errors");
2330 $this->error .= $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
2333 if ($clone_task->error !=
'') {
2334 $this->error .= $clone_task->error;
2348 unset($clone_task->context[
'createfromclone']);
2351 $this->db->commit();
2352 return $clone_task_id;
2354 $this->db->rollback();
2355 dol_syslog(get_class($this).
"::createFromClone nbError: ".$error.
" error : ".$this->error, LOG_ERR);
2386 $this->labelStatus[0] =
'Draft';
2387 $this->labelStatus[1] =
'ToDo';
2388 $this->labelStatus[2] =
'Running';
2389 $this->labelStatus[3] =
'Finish';
2390 $this->labelStatus[4] =
'Transfered';
2391 $this->labelStatusShort[0] =
'Draft';
2392 $this->labelStatusShort[1] =
'ToDo';
2393 $this->labelStatusShort[2] =
'Running';
2394 $this->labelStatusShort[3] =
'Completed';
2395 $this->labelStatusShort[4] =
'Transfered';
2398 return $langs->trans($this->labelStatus[$status]);
2399 } elseif ($mode == 1) {
2400 return $langs->trans($this->labelStatusShort[$status]);
2401 } elseif ($mode == 2) {
2403 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatusShort[$status]);
2404 } elseif ($status == 1) {
2405 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatusShort[$status]);
2406 } elseif ($status == 2) {
2407 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatusShort[$status]);
2408 } elseif ($status == 3) {
2409 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2410 } elseif ($status == 4) {
2411 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2412 } elseif ($status == 5) {
2413 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatusShort[$status]);
2415 } elseif ($mode == 3) {
2417 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0');
2418 } elseif ($status == 1) {
2419 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1');
2420 } elseif ($status == 2) {
2421 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3');
2422 } elseif ($status == 3) {
2423 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2424 } elseif ($status == 4) {
2425 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2426 } elseif ($status == 5) {
2427 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5');
2429 } elseif ($mode == 4) {
2431 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatus[$status]);
2432 } elseif ($status == 1) {
2433 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatus[$status]);
2434 } elseif ($status == 2) {
2435 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatus[$status]);
2436 } elseif ($status == 3) {
2437 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2438 } elseif ($status == 4) {
2439 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2440 } elseif ($status == 5) {
2441 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatus[$status]);
2443 } elseif ($mode == 5) {
2453 } elseif ($mode == 6) {
2477 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2479 $outputlangs->load(
"projects");
2482 $modele =
'nodefault';
2484 if (!empty($this->model_pdf)) {
2485 $modele = $this->model_pdf;
2491 $modelpath =
"core/modules/project/task/doc/";
2493 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2507 global $conf, $langs;
2513 $projectstatic =
new Project($this->db);
2514 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
2517 $sql =
"SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
2518 $sql .=
" t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
2519 $sql .=
" t.dateo as date_start, t.datee as date_end";
2520 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2523 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2524 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2525 $sql .=
" AND p.fk_statut = 1";
2526 $sql .=
" AND t.fk_projet = p.rowid";
2527 $sql .=
" AND (t.progress IS NULL OR t.progress < 100)";
2528 if (!$user->hasRight(
'projet',
'all',
'lire')) {
2529 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2537 $resql = $this->db->query($sql);
2539 $task_static =
new Task($this->db);
2542 $response->warning_delay = $conf->project->task->warning_delay / 60 / 60 / 24;
2543 $response->label = $langs->trans(
"OpenedTasks");
2544 if ($user->hasRight(
"projet",
"all",
"lire")) {
2545 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mainmenu=project';
2547 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mode=mine&mainmenu=project';
2552 while ($obj = $this->db->fetch_object($resql)) {
2553 $response->nbtodo++;
2555 $task_static->projectstatus = $obj->projectstatus;
2556 $task_static->progress = $obj->progress;
2557 $task_static->fk_statut = $obj->status;
2558 $task_static->status = $obj->status;
2559 $task_static->date_start = $this->db->jdate($obj->date_start);
2560 $task_static->date_end = $this->db->jdate($obj->date_end);
2562 if ($task_static->hasDelay()) {
2563 $response->nbtodolate++;
2569 $this->error = $this->db->error();
2585 $socid = $user->socid;
2587 $projectstatic =
new Project($this->db);
2588 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid);
2591 $sql =
"SELECT count(p.rowid) as nb";
2592 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2593 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
2594 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2595 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = s.rowid";
2597 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2598 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2599 $sql .=
" AND t.fk_projet = p.rowid";
2600 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
2601 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2606 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
2608 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2609 $sql .=
" AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).
") OR (s.rowid IS NULL))";
2612 $resql = $this->db->query($sql);
2615 while ($obj = $this->db->fetch_object($resql)) {
2616 $this->nb[
"tasks"] = $obj->nb;
2618 $this->db->free($resql);
2622 $this->error = $this->db->error();
2636 if (!($this->progress >= 0 && $this->progress < 100)) {
2642 $datetouse = ($this->date_end > 0) ? $this->date_end : ((isset($this->datee) && $this->datee > 0) ? $this->datee : 0);
2644 return ($datetouse > 0 && ($datetouse < ($now - $conf->project->task->warning_delay)));
2656 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2658 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2659 $return .=
'<div class="info-box info-box-sm info-box-kanban">';
2660 $return .=
'<span class="info-box-icon bg-infobox-action">';
2663 $return .=
'</span>';
2664 $return .=
'<div class="info-box-content">';
2665 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
2666 if ($selected >= 0) {
2667 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2669 if (!empty($arraydata[
'projectlink'])) {
2672 $return .=
'<br><span class="info-box-status ">'.$arraydata[
'projectlink'].
'</span>';
2674 if (property_exists($this,
'budget_amount')) {
2677 if (property_exists($this,
'duration_effective')) {
2678 $return .=
'<br><div class="info-box-label progressinkanban paddingtop">'.getTaskProgressView($this,
false,
true).
'</div>';
2680 $return .=
'</div>';
2681 $return .=
'</div>';
2682 $return .=
'</div>';
2696 global $langs, $hookmanager, $user, $action;
2699 $task_origin =
new Task($this->db);
2701 dol_syslog(
"mergeTask merge task id=".$task_origin_id.
" (will be deleted) into the task id=".$this->id);
2703 $langs->load(
'error');
2705 if (!$error && $task_origin->fetch($task_origin_id) < 1) {
2706 $this->error = $langs->trans(
'ErrorRecordNotFound');
2714 $listofproperties = array(
2715 'label',
'description',
'duration_effective',
'planned_workload',
'datec',
'date_start',
2716 'date_end',
'fk_user_creat',
'fk_user_valid',
'fk_statut',
'progress',
'budget_amount',
2717 'priority',
'rang',
'fk_projet',
'fk_task_parent'
2719 foreach ($listofproperties as $property) {
2720 if (empty($this->$property)) {
2721 $this->$property = $task_origin->$property;
2726 $listofproperties = array(
2727 'note_public',
'note_private'
2729 foreach ($listofproperties as $property) {
2730 $this->$property =
dol_concatdesc($this->$property, $task_origin->$property);
2734 if (is_array($task_origin->array_options)) {
2735 foreach ($task_origin->array_options as $key => $val) {
2736 if (empty($this->array_options[$key])) {
2737 $this->array_options[$key] = $val;
2743 $result = $this->
update($user);
2752 if ($result !=
true) {
2760 if ($result !=
true) {
2767 $parameters = array(
'task_origin' => $task_origin->id,
'task_dest' => $this->id);
2768 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', $parameters, $this, $action);
2771 $this->error = $hookmanager->error;
2772 $this->errors = $hookmanager->errors;
2779 $this->context = array(
'merge' => 1,
'mergefromid' => $task_origin->id,
'mergefromref' => $task_origin->ref);
2791 if ($task_origin->delete($user) < 1) {
2792 $this->error = $task_origin->error;
2793 $this->errors = $task_origin->errors;
2799 $this->db->commit();
2802 $langs->load(
"errors");
2803 $this->error = $langs->trans(
'ErrorsTaskMerge');
2804 $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 clickable name (with picto eventually)
getListContactId($source='internal')
Return list of id of contacts of task.
getKanbanView($option='', $arraydata=null)
Return clickable 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 a 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)