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;
167 public $timespent_min_date;
171 public $timespent_max_date;
175 public $timespent_total_duration;
179 public $timespent_total_amount;
183 public $timespent_nblinesnull;
187 public $timespent_nblines;
194 public $timespent_id;
198 public $timespent_duration;
202 public $timespent_old_duration;
206 public $timespent_date;
210 public $timespent_datehour;
214 public $timespent_withhour;
218 public $timespent_fk_user;
222 public $timespent_thm;
226 public $timespent_note;
230 public $timespent_fk_product;
234 public $timespent_invoiceid;
238 public $timespent_invoicelineid;
240 public $comments = array();
262 public $projectstatus;
267 public $projectlabel;
282 public $fk_opp_status;
287 public $usage_bill_time;
297 public $array_options_project;
311 public $thirdparty_id;
316 public $thirdparty_name;
321 public $thirdparty_email;
327 public $task_parent_ref;
332 public $task_parent_position;
338 public $billable = 1;
343 public $budget_amount;
348 public $project_budget_amount;
394 public function create($user, $notrigger = 0)
396 global
$conf, $langs;
404 $this->label = trim($this->label);
406 $this->note_public = trim($this->note_public);
407 $this->note_private = trim($this->note_private);
409 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
410 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
415 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"projet_task (";
417 $sql .=
", fk_projet";
419 $sql .=
", fk_task_parent";
421 $sql .=
", description";
422 $sql .=
", note_public";
423 $sql .=
", note_private";
425 $sql .=
", fk_user_creat";
428 $sql .=
", planned_workload";
429 $sql .=
", progress";
430 $sql .=
", budget_amount";
431 $sql .=
", priority";
432 $sql .=
", billable";
433 $sql .=
") VALUES (";
434 $sql .= (!empty($this->entity) ? (int) $this->entity : (int)
$conf->entity);
435 $sql .=
", ".((int) $this->fk_project);
436 $sql .=
", ".(!empty($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
'null');
437 $sql .=
", ".((int) $this->fk_task_parent);
438 $sql .=
", '".$this->db->escape($this->label).
"'";
439 $sql .=
", '".$this->db->escape($this->
description).
"'";
440 $sql .=
", '".$this->db->escape($this->note_public).
"'";
441 $sql .=
", '".$this->db->escape($this->note_private).
"'";
442 $sql .=
", '".$this->db->idate($now).
"'";
443 $sql .=
", ".((int) $user->id);
444 $sql .=
", ".(isDolTms($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
'null');
445 $sql .=
", ".(isDolTms($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
'null');
446 $sql .=
", ".(($this->planned_workload !=
'' && $this->planned_workload >= 0) ? ((
int) $this->planned_workload) :
'null');
447 $sql .=
", ".(($this->progress !=
'' && $this->progress >= 0) ? ((
int) $this->progress) :
'null');
448 $sql .=
", ".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? ((
int) $this->budget_amount) :
'null');
449 $sql .=
", ".(($this->priority !=
'' && $this->priority >= 0) ? (
int) $this->priority :
'null');
450 $sql .=
", ".((int) $this->billable);
455 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
456 $resql = $this->db->query($sql);
459 $this->errors[] =
"Error ".$this->db->lasterror();
463 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"projet_task");
484 foreach ($this->errors as $errmsg) {
485 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
486 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
488 $this->db->rollback();
505 public function fetch($id, $ref =
'', $loadparentdata = 0)
510 $sql .=
" t.entity,";
511 $sql .=
" t.fk_projet as fk_project,";
512 $sql .=
" t.fk_task_parent,";
514 $sql .=
" t.description,";
515 $sql .=
" t.duration_effective,";
516 $sql .=
" t.planned_workload,";
518 $sql .=
" t.dateo as date_start,";
519 $sql .=
" t.datee as date_end,";
520 $sql .=
" t.fk_user_creat,";
521 $sql .=
" t.fk_user_valid,";
522 $sql .=
" t.fk_statut as status,";
523 $sql .=
" t.progress,";
524 $sql .=
" t.budget_amount,";
525 $sql .=
" t.priority,";
526 $sql .=
" t.note_private,";
527 $sql .=
" t.note_public,";
529 $sql .=
" t.billable";
530 if (!empty($loadparentdata)) {
531 $sql .=
", t2.ref as task_parent_ref";
532 $sql .=
", t2.rang as task_parent_position";
534 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t";
535 if (!empty($loadparentdata)) {
536 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t2 ON t.fk_task_parent = t2.rowid";
540 $sql .=
"entity IN (".getEntity(
'project').
")";
541 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
543 $sql .=
"t.rowid = ".((int) $id);
546 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
547 $resql = $this->db->query($sql);
549 $num_rows = $this->db->num_rows($resql);
552 $obj = $this->db->fetch_object($resql);
554 $this->
id = $obj->rowid;
555 $this->
ref = $obj->ref;
556 $this->entity = $obj->entity;
557 $this->fk_project = $obj->fk_project;
558 $this->fk_task_parent = $obj->fk_task_parent;
559 $this->label = $obj->label;
561 $this->duration_effective = $obj->duration_effective;
562 $this->planned_workload = $obj->planned_workload;
563 $this->date_c = $this->db->jdate($obj->datec);
564 $this->date_start = $this->db->jdate($obj->date_start);
565 $this->date_end = $this->db->jdate($obj->date_end);
566 $this->fk_user_creat = $obj->fk_user_creat;
567 $this->fk_user_valid = $obj->fk_user_valid;
568 $this->fk_statut = $obj->status;
569 $this->
status = $obj->status;
570 $this->progress = $obj->progress;
571 $this->budget_amount = $obj->budget_amount;
572 $this->priority = $obj->priority;
573 $this->note_private = $obj->note_private;
574 $this->note_public = $obj->note_public;
575 $this->rang = $obj->rang;
577 if (!empty($loadparentdata)) {
578 $this->task_parent_ref = $obj->task_parent_ref;
579 $this->task_parent_position = $obj->task_parent_position;
581 $this->billable = $obj->billable;
587 $this->db->free($resql);
595 $this->error =
"Error ".$this->db->lasterror();
608 public function update($user =
null, $notrigger = 0)
610 global
$conf, $langs;
614 if (isset($this->fk_project)) {
615 $this->fk_project = (int) $this->fk_project;
617 if (isset($this->
ref)) {
618 $this->
ref = trim($this->
ref);
620 if (isset($this->fk_task_parent)) {
621 $this->fk_task_parent = (int) $this->fk_task_parent;
623 if (isset($this->label)) {
624 $this->label = trim($this->label);
629 if (isset($this->note_public)) {
630 $this->note_public = trim($this->note_public);
632 if (isset($this->note_private)) {
633 $this->note_private = trim($this->note_private);
635 if (isset($this->duration_effective)) {
636 $this->duration_effective = trim($this->duration_effective);
638 if (isset($this->planned_workload)) {
639 $this->planned_workload = trim($this->planned_workload);
641 if (isset($this->budget_amount)) {
642 $this->budget_amount = (float) $this->budget_amount;
645 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
646 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
654 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET";
655 $sql .=
" fk_projet=".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
656 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"'".$this->db->escape($this->
id).
"'").
",";
657 $sql .=
" fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent :
"null").
",";
658 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
659 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
660 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
661 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
662 $sql .=
" duration_effective=".(isset($this->duration_effective) ? $this->duration_effective :
"null").
",";
663 $sql .=
" planned_workload=".((isset($this->planned_workload) && $this->planned_workload !=
'') ? $this->planned_workload :
"null").
",";
664 $sql .=
" dateo=".(isDolTms($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
'null').
",";
665 $sql .=
" datee=".(isDolTms($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
'null').
",";
666 $sql .=
" progress=".(($this->progress !=
'' && $this->progress >= 0) ? $this->progress :
'null').
",";
667 $sql .=
" budget_amount=".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? $this->budget_amount :
'null').
",";
668 $sql .=
" rang=".((!empty($this->rang)) ? ((
int) $this->rang) :
"0").
",";
669 $sql .=
" priority=".((!empty($this->priority)) ? ((
int) $this->priority) :
"0").
",";
670 $sql .=
" billable=".((int) $this->billable);
671 $sql .=
" WHERE rowid=".((int) $this->
id);
675 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
676 $resql = $this->db->query($sql);
679 $this->errors[] =
"Error ".$this->db->lasterror();
692 $project =
new Project($this->db);
693 if ($project->fetch($this->fk_project) > 0) {
695 $project->getLinesArray(
null);
696 $projectCompleted = array_reduce(
703 static function ($allTasksCompleted, $task) {
704 return $allTasksCompleted && $task->progress >= 100;
708 if ($projectCompleted) {
709 if ($project->setClose($user) <= 0) {
718 $this->errors[] = $project->error;
733 if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
735 if (
$conf->project->dir_output) {
736 $project =
new Project($this->db);
737 $project->fetch($this->fk_project);
741 if (file_exists($olddir)) {
742 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
745 $langs->load(
"errors");
746 $this->error = $langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir);
755 foreach ($this->errors as $errmsg) {
756 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
757 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
759 $this->db->rollback();
775 public function delete($user, $notrigger = 0)
778 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
785 dol_syslog(get_class($this).
"::delete Can't delete record as it has some sub tasks", LOG_WARNING);
786 $this->error =
'ErrorRecordHasSubTasks';
787 $this->db->rollback();
792 if (!empty($objectisused)) {
793 dol_syslog(get_class($this).
"::delete Can't delete record as it has some child", LOG_WARNING);
794 $this->error =
'ErrorRecordHasChildren';
795 $this->db->rollback();
803 $this->error =
'ErrorFailToDeleteLinkedContact';
805 $this->db->rollback();
811 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_time";
812 $sql .=
" WHERE fk_element = ".((int) $this->
id).
" AND elementtype = 'task'";
814 $resql = $this->db->query($sql);
817 $this->errors[] =
"Error ".$this->db->lasterror();
822 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task_extrafields";
823 $sql .=
" WHERE fk_object = ".((int) $this->
id);
825 $resql = $this->db->query($sql);
828 $this->errors[] =
"Error ".$this->db->lasterror();
833 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task";
834 $sql .=
" WHERE rowid=".((int) $this->
id);
836 $resql = $this->db->query($sql);
839 $this->errors[] =
"Error ".$this->db->lasterror();
856 foreach ($this->errors as $errmsg) {
857 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
858 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
860 $this->db->rollback();
864 if (
$conf->project->dir_output) {
865 $projectstatic =
new Project($this->db);
866 $projectstatic->fetch($this->fk_project);
869 dol_syslog(get_class($this).
"::delete dir=".$dir, LOG_DEBUG);
870 if (file_exists($dir)) {
871 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
874 $this->error =
'ErrorFailToDeleteDir';
875 $this->db->rollback();
897 $sql =
"SELECT COUNT(*) as nb";
898 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
899 $sql .=
" WHERE fk_task_parent = ".((int) $this->
id);
901 dol_syslog(get_class($this).
"::hasChildren", LOG_DEBUG);
902 $resql = $this->db->query($sql);
905 $this->errors[] =
"Error ".$this->db->lasterror();
907 $obj = $this->db->fetch_object($resql);
911 $this->db->free($resql);
931 $sql =
"SELECT COUNT(*) as nb";
932 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time";
933 $sql .=
" WHERE fk_element = ".((int) $this->
id);
934 $sql .=
" AND elementtype = 'task'";
936 dol_syslog(get_class($this).
"::hasTimeSpent", LOG_DEBUG);
937 $resql = $this->db->query($sql);
940 $this->errors[] =
"Error ".$this->db->lasterror();
942 $obj = $this->db->fetch_object($resql);
946 $this->db->free($resql);
967 $langs->load(
'projects');
970 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Task").
'</u>';
971 if (!empty($this->
ref)) {
972 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
974 if (!empty($this->label)) {
975 $datas[
'label'] =
'<br><b>'.$langs->trans(
'LabelTask').
':</b> '.$this->label;
977 if ($this->date_start || $this->date_end) {
978 $datas[
'range'] =
"<br>".get_date_range($this->date_start, $this->date_end,
'', $langs, 0);
996 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'task', $addlabel = 0, $sep =
' - ', $notooltip = 0, $save_lastsearch_value = -1)
998 global $action,
$conf, $hookmanager, $langs;
1000 if (!empty(
$conf->dol_no_mouse_hover)) {
1007 'objecttype' => $this->element,
1009 $classfortooltip =
'classfortooltip';
1012 $classfortooltip =
'classforajaxtooltip';
1013 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1019 $url = DOL_URL_ROOT.
'/projet/tasks/'.$mode.
'.php?id='.$this->
id.($option ==
'withproject' ?
'&withproject=1' :
'');
1021 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1022 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1023 $add_save_lastsearch_values = 1;
1025 if ($add_save_lastsearch_values) {
1026 $url .=
'&save_lastsearch_values=1';
1030 if (empty($notooltip)) {
1032 $label = $langs->trans(
"ShowTask");
1033 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1035 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1036 $linkclose .= $dataparams.
' class="'.$classfortooltip.
' nowraponall"';
1038 $linkclose .=
' class="nowraponall"';
1041 $linkstart =
'<a href="'.$url.
'"';
1042 $linkstart .= $linkclose.
'>';
1045 $picto =
'projecttask';
1047 $result .= $linkstart;
1049 $result .=
img_object(($notooltip ?
'' : $label), $picto,
'class="paddingright"', 0, 0, $notooltip ? 0 : 1);
1051 if ($withpicto != 2) {
1052 $result .= $this->ref;
1054 $result .= $linkend;
1055 if ($withpicto != 2) {
1056 $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) :
'');
1059 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1060 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1062 $result = $hookmanager->resPrint;
1064 $result .= $hookmanager->resPrint;
1083 $this->fk_project = 0;
1084 $this->
ref =
'TK01';
1085 $this->fk_task_parent = 0;
1086 $this->label =
'Specimen task TK01';
1087 $this->duration_effective =
'';
1088 $this->fk_user_creat = $user->id;
1089 $this->progress = 25;
1091 $this->priority = 0;
1092 $this->note_private =
'This is a specimen private note';
1093 $this->note_public =
'This is a specimen public note';
1094 $this->billable = 1;
1122 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 =
'')
1124 global $hookmanager;
1132 if ($filteronprojuser > 0 || $filterontaskuser > 0) {
1133 $sql .=
" DISTINCT";
1135 $sql .=
" p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,";
1136 $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,";
1137 $sql .=
" t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang, t.priority,";
1138 $sql .=
" t.budget_amount, t.billable,";
1139 $sql .=
" t.note_public, t.note_private,";
1140 $sql .=
" s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,";
1141 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount as project_budget_amount";
1143 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1144 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1145 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key.
" as options_".$key :
'');
1148 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1149 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1150 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
1154 if ($includebilltime) {
1155 $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";
1158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1159 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1161 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_extrafields as efp ON (p.rowid = efp.fk_object)";
1165 if ($filteronprojuser > 0) {
1166 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1167 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1169 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1171 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
1173 if ($includebilltime) {
1174 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1176 if ($filterontaskuser > 0) {
1177 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1178 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1180 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1181 $sql .=
" AND t.fk_projet = p.rowid";
1182 } elseif ($mode == 1) {
1183 if ($filteronprojuser > 0) {
1184 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1185 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1187 if ($filterontaskuser > 0) {
1188 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
1189 if ($includebilltime) {
1190 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
1192 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
1193 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
1195 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
1196 if ($includebilltime) {
1197 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')";
1200 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1202 return 'BadValueForParameterMode';
1205 if ($filteronprojuser > 0) {
1206 $sql .=
" AND p.rowid = ec.element_id";
1207 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1208 $sql .=
" AND ctc.element = 'project'";
1209 $sql .=
" AND ec.fk_socpeople = ".((int) $filteronprojuser);
1210 $sql .=
" AND ec.statut = 4";
1211 $sql .=
" AND ctc.source = 'internal'";
1213 if ($filterontaskuser > 0) {
1214 $sql .=
" AND t.fk_projet = p.rowid";
1215 $sql .=
" AND p.rowid = ec2.element_id";
1216 $sql .=
" AND ctc2.rowid = ec2.fk_c_type_contact";
1217 $sql .=
" AND ctc2.element = 'project_task'";
1218 $sql .=
" AND ec2.fk_socpeople = ".((int) $filterontaskuser);
1219 $sql .=
" AND ec2.statut = 4";
1220 $sql .=
" AND ctc2.source = 'internal'";
1223 $sql .=
" AND p.fk_soc = ".((int) $socid);
1226 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1228 if ($filteronproj) {
1229 $sql .=
natural_search(array(
"p.ref",
"p.title"), $filteronproj);
1231 if ($filteronprojstatus && (
int) $filteronprojstatus !=
'-1') {
1232 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).
")";
1234 if ($morewherefilter) {
1235 $sql .= $morewherefilter;
1239 $extrafieldsobjectkey =
'projet_task';
1240 $extrafieldsobjectprefix =
'efpt.';
1242 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1245 $parameters = array();
1246 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1247 $sql .= $hookmanager->resPrint;
1248 if ($includebilltime) {
1249 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,";
1250 $sql .=
" t.datec, t.dateo, t.datee, t.tms,";
1251 $sql .=
" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,";
1252 $sql .=
" t.dateo, t.datee, t.planned_workload, t.rang, t.priority,";
1253 $sql .=
" t.budget_amount, t.billable,";
1254 $sql .=
" t.note_public, t.note_private,";
1255 $sql .=
" s.rowid, s.nom, s.email,";
1256 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
1258 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1259 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1260 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key :
'');
1263 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1264 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1265 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key :
'');
1271 if ($sortfield && $sortorder) {
1272 $sql .= $this->db->order($sortfield, $sortorder);
1274 $sql .=
" ORDER BY p.ref, t.rang, t.dateo";
1278 dol_syslog(get_class($this).
"::getTasksArray", LOG_DEBUG);
1279 $resql = $this->db->query($sql);
1281 $num = $this->db->num_rows($resql);
1287 $obj = $this->db->fetch_object($resql);
1289 if ($loadRoleMode) {
1290 if ((!$obj->public) && (is_object($userp))) {
1295 if (is_object($usert)) {
1303 $tasks[$i] =
new Task($this->db);
1304 $tasks[$i]->id = $obj->taskid;
1305 $tasks[$i]->ref = $obj->taskref;
1306 $tasks[$i]->fk_project = $obj->projectid;
1309 $tasks[$i]->projectref = $obj->ref;
1310 $tasks[$i]->projectlabel = $obj->plabel;
1311 $tasks[$i]->projectstatus = $obj->projectstatus;
1312 $tasks[$i]->fk_opp_status = $obj->fk_opp_status;
1313 $tasks[$i]->opp_amount = $obj->opp_amount;
1314 $tasks[$i]->opp_percent = $obj->opp_percent;
1315 $tasks[$i]->budget_amount = $obj->budget_amount;
1316 $tasks[$i]->project_budget_amount = $obj->project_budget_amount;
1317 $tasks[$i]->usage_bill_time = $obj->usage_bill_time;
1319 $tasks[$i]->label = $obj->label;
1320 $tasks[$i]->description = $obj->description;
1322 $tasks[$i]->fk_task_parent = $obj->fk_task_parent;
1323 $tasks[$i]->note_public = $obj->note_public;
1324 $tasks[$i]->note_private = $obj->note_private;
1325 $tasks[$i]->duration_effective = $obj->duration_effective;
1326 $tasks[$i]->planned_workload = $obj->planned_workload;
1328 if ($includebilltime) {
1330 $tasks[$i]->tobill = $obj->tobill;
1331 $tasks[$i]->billed = $obj->billed;
1334 $tasks[$i]->progress = $obj->progress;
1335 $tasks[$i]->fk_statut = $obj->status;
1336 $tasks[$i]->status = $obj->status;
1337 $tasks[$i]->public = $obj->public;
1338 $tasks[$i]->date_start = $this->db->jdate($obj->date_start);
1339 $tasks[$i]->date_end = $this->db->jdate($obj->date_end);
1340 $tasks[$i]->rang = $obj->rang;
1341 $tasks[$i]->priority = $obj->priority;
1343 $tasks[$i]->socid = $obj->thirdparty_id;
1344 $tasks[$i]->thirdparty_id = $obj->thirdparty_id;
1345 $tasks[$i]->thirdparty_name = $obj->thirdparty_name;
1346 $tasks[$i]->thirdparty_email = $obj->thirdparty_email;
1348 $tasks[$i]->billable = $obj->billable;
1351 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1352 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1353 if ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate') {
1354 $tmpvar =
'options_'.$key;
1355 $tasks[$i]->array_options_project[
'options_'.$key] = $obj->$tmpvar;
1362 $tasks[$i]->fetch_optionals();
1368 $this->db->free($resql);
1388 $arrayroles = array();
1390 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks userp=".json_encode(is_object($userp)).
" usert=".json_encode(is_object($usert)).
" projectid=".$projectid.
" taskid=".$taskid);
1393 if (empty($userp) && empty($usert)) {
1394 $this->error =
"CallWithWrongParameters";
1397 if (!empty($userp) && !empty($usert)) {
1398 $this->error =
"CallWithWrongParameters";
1405 $sql .=
" p.rowid as pid,";
1407 $sql .=
" pt.rowid as pid,";
1409 $sql .=
" ec.element_id, ctc.code, ctc.source";
1411 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1413 if ($usert && $filteronprojstatus > -1) {
1414 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p, ".MAIN_DB_PREFIX.
"projet_task as pt";
1416 if ($usert && $filteronprojstatus <= -1) {
1417 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as pt";
1419 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1420 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1422 $sql .=
" WHERE p.rowid = ec.element_id";
1424 $sql .=
" WHERE pt.rowid = ec.element_id";
1426 if ($userp && $filteronprojstatus > -1) {
1427 $sql .=
" AND p.fk_statut = ".((int) $filteronprojstatus);
1429 if ($usert && $filteronprojstatus > -1) {
1430 $sql .=
" AND pt.fk_projet = p.rowid AND p.fk_statut = ".((int) $filteronprojstatus);
1433 $sql .=
" AND ctc.element = 'project'";
1436 $sql .=
" AND ctc.element = 'project_task'";
1438 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1440 $sql .=
" AND ec.fk_socpeople = ".((int) $userp->id);
1443 $sql .=
" AND ec.fk_socpeople = ".((int) $usert->id);
1445 $sql .=
" AND ec.statut = 4";
1446 $sql .=
" AND ctc.source = 'internal'";
1449 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1452 $sql .=
" AND pt.fk_projet IN (".$this->db->sanitize($projectid).
")";
1457 $sql .=
" ERROR SHOULD NOT HAPPENS";
1460 $sql .=
" AND pt.rowid = ".((int) $taskid);
1465 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG);
1466 $resql = $this->db->query($sql);
1468 $num = $this->db->num_rows($resql);
1471 $obj = $this->db->fetch_object($resql);
1472 if (empty($arrayroles[$obj->pid])) {
1473 $arrayroles[$obj->pid] = $obj->code;
1475 $arrayroles[$obj->pid] .=
','.$obj->code;
1479 $this->db->free($resql);
1496 $contactAlreadySelected = array();
1502 if ($source ==
'thirdparty') {
1503 $contactAlreadySelected[$i] = $tab[$i][
'socid'];
1505 $contactAlreadySelected[$i] = $tab[$i][
'id'];
1509 return $contactAlreadySelected;
1522 $origintask =
new Task($this->db);
1523 $result = $origintask->fetch($origin_id);
1529 $arraycontactorigin = array_merge($origintask->liste_contact(-1,
'internal'), $origintask->liste_contact(-1,
'external'));
1530 if (is_array($arraycontactorigin)) {
1531 foreach ($arraycontactorigin as $key => $contact) {
1532 $result = $this->
add_contact($contact[
"id"], $contact[
"fk_c_type_contact"], $contact[
"source"]);
1554 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"element_time as et";
1555 $sql .=
" SET et.fk_element = ".((int) $dest_id);
1556 $sql .=
" WHERE et.elementtype = 'task'";
1557 $sql .=
" AND et.fk_element = ".((int) $origin_id);
1559 dol_syslog(get_class($this).
"::mergeTimeSpentTask", LOG_DEBUG);
1560 if (!$this->db->query($sql)) {
1561 $this->error = $this->db->lasterror();
1566 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1567 $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).
")";
1568 $sql .=
" WHERE rowid = ".((int) $dest_id);
1570 dol_syslog(get_class($this).
"::mergeTimeSpentTask update project_task", LOG_DEBUG);
1571 if (!$this->db->query($sql)) {
1572 $this->error = $this->db->lasterror();
1578 $this->db->commit();
1580 $this->db->rollback();
1596 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1602 if (!is_object($user)) {
1603 dol_print_error(
null,
"Method addTimeSpent was called with wrong parameter user");
1608 if (isset($this->timespent_note)) {
1609 $this->timespent_note = trim($this->timespent_note);
1611 if (empty($this->timespent_datehour) || ($this->timespent_date != $this->timespent_datehour)) {
1612 $this->timespent_datehour = $this->timespent_date;
1616 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1619 if ($this->timespent_date < $restrictBefore) {
1620 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
1621 $this->errors[] = $this->error;
1629 $timespent->fk_element = $this->id;
1630 $timespent->elementtype =
'task';
1631 $timespent->element_date = $this->timespent_date;
1632 $timespent->element_datehour = $this->timespent_datehour;
1633 $timespent->element_date_withhour = $this->timespent_withhour;
1634 $timespent->element_duration = $this->timespent_duration;
1635 $timespent->fk_user = $this->timespent_fk_user;
1636 $timespent->fk_product = $this->timespent_fk_product;
1637 $timespent->note = $this->timespent_note;
1638 $timespent->datec = $this->db->idate($now);
1640 $result = $timespent->create($user);
1644 $this->timespent_id = $result;
1648 $result = $this->
call_trigger(
'TASK_TIMESPENT_CREATE', $user);
1655 $this->error = $this->db->lasterror();
1661 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1662 $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).
")";
1663 if (isset($this->progress)) {
1664 $sql .=
", progress = ".((float) $this->progress);
1666 $sql .=
" WHERE rowid = ".((int) $this->
id);
1668 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1669 if (!$this->db->query($sql)) {
1670 $this->error = $this->db->lasterror();
1675 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1676 if (!empty($resql_thm_user)) {
1677 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1678 $timespent->thm = $obj_thm_user->thm;
1680 $res_update = $timespent->update($user);
1682 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1683 if ($res_update <= 0) {
1684 $this->error = $this->db->lasterror();
1690 $this->db->commit();
1692 $this->db->rollback();
1705 $arrayres = array();
1708 $sql .=
" s.rowid as socid,";
1709 $sql .=
" s.nom as thirdparty_name,";
1710 $sql .=
" s.email as thirdparty_email,";
1711 $sql .=
" ptt.rowid,";
1712 $sql .=
" ptt.ref_ext,";
1713 $sql .=
" ptt.fk_element as fk_task,";
1714 $sql .=
" ptt.element_date as task_date,";
1715 $sql .=
" ptt.element_datehour as task_datehour,";
1716 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1717 $sql .=
" ptt.element_duration as task_duration,";
1718 $sql .=
" ptt.fk_user,";
1719 $sql .=
" ptt.note,";
1720 $sql .=
" ptt.thm,";
1721 $sql .=
" pt.rowid as task_id,";
1722 $sql .=
" pt.ref as task_ref,";
1723 $sql .=
" pt.label as task_label,";
1724 $sql .=
" p.rowid as project_id,";
1725 $sql .=
" p.ref as project_ref,";
1726 $sql .=
" p.title as project_label,";
1727 $sql .=
" p.public as public";
1728 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1729 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1730 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1731 $sql .=
" AND ptt.elementtype = 'task'";
1732 $sql .=
" AND pt.rowid = ".((int) $this->
id);
1733 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1734 if ($morewherefilter) {
1735 $sql .= $morewherefilter;
1738 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1739 $resql = $this->db->query($sql);
1741 $num = $this->db->num_rows($resql);
1745 $obj = $this->db->fetch_object($resql);
1749 $newobj->socid = $obj->socid;
1750 $newobj->thirdparty_name = $obj->thirdparty_name;
1751 $newobj->thirdparty_email = $obj->thirdparty_email;
1753 $newobj->fk_project = $obj->project_id;
1754 $newobj->project_ref = $obj->project_ref;
1755 $newobj->project_label = $obj->project_label;
1756 $newobj->public = $obj->project_public;
1758 $newobj->fk_task = $obj->task_id;
1759 $newobj->task_ref = $obj->task_ref;
1760 $newobj->task_label = $obj->task_label;
1762 $newobj->timespent_line_id = $obj->rowid;
1763 $newobj->timespent_line_ref_ext = $obj->ref_ext;
1764 $newobj->timespent_line_date = $this->db->jdate($obj->task_date);
1765 $newobj->timespent_line_datehour = $this->db->jdate($obj->task_datehour);
1766 $newobj->timespent_line_withhour = $obj->task_date_withhour;
1767 $newobj->timespent_line_duration = $obj->task_duration;
1768 $newobj->timespent_line_fk_user = $obj->fk_user;
1769 $newobj->timespent_line_thm = $obj->thm;
1770 $newobj->timespent_line_note = $obj->note;
1772 $arrayres[] = $newobj;
1777 $this->db->free($resql);
1779 $this->lines = $arrayres;
1783 $this->error =
"Error ".$this->db->lasterror();
1798 if (is_object($userobj)) {
1799 $userid = $userobj->id;
1805 if (empty($id) && empty($userid)) {
1806 dol_syslog(
"getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR);
1813 $sql .=
" MIN(t.element_datehour) as min_date,";
1814 $sql .=
" MAX(t.element_datehour) as max_date,";
1815 $sql .=
" SUM(t.element_duration) as total_duration,";
1816 $sql .=
" SUM(t.element_duration / 3600 * ".$this->db->ifsql(
"t.thm IS NULL", 0,
"t.thm").
") as total_amount,";
1817 $sql .=
" COUNT(t.rowid) as nblines,";
1818 $sql .=
" SUM(".$this->db->ifsql(
"t.thm IS NULL", 1, 0).
") as nblinesnull";
1819 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1820 $sql .=
" WHERE t.elementtype='task'";
1821 if ($morewherefilter) {
1822 $sql .= $morewherefilter;
1825 $sql .=
" AND t.fk_element = ".((int) $id);
1828 $sql .=
" AND t.fk_user = ".((int) $userid);
1831 dol_syslog(get_class($this).
"::getSummaryOfTimeSpent", LOG_DEBUG);
1832 $resql = $this->db->query($sql);
1834 $obj = $this->db->fetch_object($resql);
1836 $result[
'min_date'] = $obj->min_date;
1837 $result[
'max_date'] = $obj->max_date;
1838 $result[
'total_duration'] = $obj->total_duration;
1840 $this->timespent_min_date = $this->db->jdate($obj->min_date);
1841 $this->timespent_max_date = $this->db->jdate($obj->max_date);
1842 $this->timespent_total_duration = $obj->total_duration;
1843 $this->timespent_total_amount = $obj->total_amount;
1844 $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0);
1845 $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0);
1847 $this->db->free($resql);
1869 $sql .=
" SUM(t.element_duration) as nbseconds,";
1870 $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";
1871 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1872 $sql .=
" WHERE t.elementtype='task' AND t.fk_element = ".((int) $id);
1873 if (is_object($fuser) && $fuser->id > 0) {
1874 $sql .=
" AND fk_user = ".((int) $fuser->id);
1877 $datefieldname =
"element_datehour";
1878 $sql .=
" AND (".$datefieldname.
" >= '".$this->db->idate($dates).
"' OR ".$datefieldname.
" IS NULL)";
1881 $datefieldname =
"element_datehour";
1882 $sql .=
" AND (".$datefieldname.
" <= '".$this->db->idate($datee).
"' OR ".$datefieldname.
" IS NULL)";
1886 dol_syslog(get_class($this).
"::getSumOfAmount", LOG_DEBUG);
1887 $resql = $this->db->query($sql);
1889 $obj = $this->db->fetch_object($resql);
1891 $result[
'amount'] = $obj->amount;
1892 $result[
'nbseconds'] = $obj->nbseconds;
1893 $result[
'nblinesnull'] = $obj->nblinesnull;
1895 $this->db->free($resql);
1912 $timespent->fetch($id);
1914 dol_syslog(get_class($this).
"::fetchTimeSpent", LOG_DEBUG);
1916 if ($timespent->id > 0) {
1917 $this->timespent_id = $timespent->id;
1918 $this->
id = $timespent->fk_element;
1919 $this->timespent_date = $timespent->element_date;
1920 $this->timespent_datehour = $timespent->element_datehour;
1921 $this->timespent_withhour = $timespent->element_date_withhour;
1922 $this->timespent_duration = $timespent->element_duration;
1923 $this->timespent_fk_user = $timespent->fk_user;
1924 $this->timespent_fk_product = $timespent->fk_product;
1925 $this->timespent_thm = $timespent->thm;
1926 $this->timespent_note = $timespent->note;
1943 $arrayres = array();
1946 $sql .=
" s.rowid as socid,";
1947 $sql .=
" s.nom as thirdparty_name,";
1948 $sql .=
" s.email as thirdparty_email,";
1949 $sql .=
" ptt.rowid,";
1950 $sql .=
" ptt.fk_element as fk_task,";
1951 $sql .=
" ptt.element_date as task_date,";
1952 $sql .=
" ptt.element_datehour as task_datehour,";
1953 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1954 $sql .=
" ptt.element_duration as task_duration,";
1955 $sql .=
" ptt.fk_user,";
1956 $sql .=
" ptt.note,";
1957 $sql .=
" ptt.thm,";
1958 $sql .=
" pt.rowid as task_id,";
1959 $sql .=
" pt.ref as task_ref,";
1960 $sql .=
" pt.label as task_label,";
1961 $sql .=
" p.rowid as project_id,";
1962 $sql .=
" p.ref as project_ref,";
1963 $sql .=
" p.title as project_label,";
1964 $sql .=
" p.public as public";
1965 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1966 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1967 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1968 $sql .=
" AND ptt.elementtype = 'task'";
1969 $sql .=
" AND ptt.fk_user = ".((int) $userobj->id);
1970 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1971 if ($morewherefilter) {
1972 $sql .= $morewherefilter;
1975 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1976 $resql = $this->db->query($sql);
1978 $num = $this->db->num_rows($resql);
1982 $obj = $this->db->fetch_object($resql);
1986 $newobj->socid = $obj->socid;
1987 $newobj->thirdparty_name = $obj->thirdparty_name;
1988 $newobj->thirdparty_email = $obj->thirdparty_email;
1990 $newobj->fk_project = $obj->project_id;
1991 $newobj->project_ref = $obj->project_ref;
1992 $newobj->project_label = $obj->project_label;
1993 $newobj->public = $obj->project_public;
1995 $newobj->fk_task = $obj->task_id;
1996 $newobj->task_ref = $obj->task_ref;
1997 $newobj->task_label = $obj->task_label;
1999 $newobj->timespent_id = $obj->rowid;
2000 $newobj->timespent_date = $this->db->jdate($obj->task_date);
2001 $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour);
2002 $newobj->timespent_withhour = $obj->task_date_withhour;
2003 $newobj->timespent_duration = $obj->task_duration;
2004 $newobj->timespent_fk_user = $obj->fk_user;
2005 $newobj->timespent_thm = $obj->thm;
2006 $newobj->timespent_note = $obj->note;
2008 $arrayres[] = $newobj;
2013 $this->db->free($resql);
2016 $this->error =
"Error ".$this->db->lasterror();
2032 global
$conf, $langs;
2037 if ($this->timespent_date ==
'') {
2038 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date"));
2041 if (!($this->timespent_fk_user > 0)) {
2042 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"User"));
2047 if (empty($this->timespent_datehour)) {
2048 $this->timespent_datehour = $this->timespent_date;
2050 if (isset($this->timespent_note)) {
2051 $this->timespent_note = trim($this->timespent_note);
2055 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2058 if ($this->timespent_date < $restrictBefore) {
2059 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
2060 $this->errors[] = $this->error;
2068 $timespent->fetch($this->timespent_id);
2069 $timespent->element_date = $this->timespent_date;
2070 $timespent->element_datehour = $this->timespent_datehour;
2071 $timespent->element_date_withhour = $this->timespent_withhour;
2072 $timespent->element_duration = $this->timespent_duration;
2073 $timespent->fk_user = $this->timespent_fk_user;
2074 $timespent->fk_product = $this->timespent_fk_product;
2075 $timespent->note = $this->timespent_note;
2076 $timespent->invoice_id = $this->timespent_invoiceid;
2077 $timespent->invoice_line_id = $this->timespent_invoicelineid;
2079 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
2080 if ($timespent->update($user) > 0) {
2083 $result = $this->
call_trigger(
'TASK_TIMESPENT_MODIFY', $user);
2085 $this->db->rollback();
2095 $this->error = $this->db->lasterror();
2096 $this->db->rollback();
2100 if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) ||
getDolGlobalString(
'TIMESPENT_ALWAYS_UPDATE_THM'))) {
2101 if ($this->timespent_old_duration != $this->timespent_duration) {
2103 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"projet_task";
2104 $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) .
")";
2105 if (isset($this->progress)) {
2106 $sql .=
", progress = " . ((float) $this->progress);
2108 $sql .=
" WHERE rowid = " . ((int) $this->
id);
2110 dol_syslog(get_class($this) .
"::updateTimeSpent", LOG_DEBUG);
2111 if (!$this->db->query($sql)) {
2112 $this->error = $this->db->lasterror();
2113 $this->db->rollback();
2121 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
2122 if (!empty($resql_thm_user)) {
2123 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
2124 $timespent->thm = $obj_thm_user->thm;
2126 $res_update = $timespent->update($user);
2129 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
2130 if ($res_update <= 0) {
2131 $this->error = $this->db->lasterror();
2137 $this->db->commit();
2151 global
$conf, $langs;
2156 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2159 if ($this->timespent_date < $restrictBefore) {
2160 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack',
getDolGlobalString(
'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS'));
2161 $this->errors[] = $this->error;
2170 $result = $this->
call_trigger(
'TASK_TIMESPENT_DELETE', $user);
2179 $timespent->fetch($this->timespent_id);
2181 $res_del = $timespent->delete($user);
2185 $this->errors[] =
"Error ".$this->db->lasterror();
2190 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
2191 $sql .=
" SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0);
2192 $sql .=
" WHERE rowid = ".((int) $this->
id);
2194 dol_syslog(get_class($this).
"::delTimeSpent", LOG_DEBUG);
2195 if ($this->db->query($sql)) {
2198 $this->error = $this->db->lasterror();
2205 foreach ($this->errors as $errmsg) {
2206 dol_syslog(get_class($this).
"::delTimeSpent ".$errmsg, LOG_ERR);
2207 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2209 $this->db->rollback();
2212 $this->db->commit();
2231 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)
2233 global $langs,
$conf;
2242 $clone_task =
new Task($this->db);
2243 $origin_task =
new Task($this->db);
2245 $clone_task->context[
'createfromclone'] =
'createfromclone';
2250 $clone_task->fetch($fromid);
2251 $clone_task->fetch_optionals();
2254 $origin_task->fetch($fromid);
2259 require_once DOL_DOCUMENT_ROOT.
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON').
'.php';
2260 $modTask =
new $obj();
2261 '@phan-var-force ModeleNumRefTask $modTask';
2262 $defaultref = $modTask->getNextValue(0, $clone_task);
2265 $ori_project_id = $clone_task->fk_project;
2267 $clone_task->id = 0;
2268 $clone_task->ref = $defaultref;
2269 $clone_task->fk_project = $project_id;
2270 $clone_task->fk_task_parent = $parent_task_id;
2271 $clone_task->date_c = $datec;
2272 $clone_task->planned_workload = $origin_task->planned_workload;
2273 $clone_task->rang = $origin_task->rang;
2274 $clone_task->priority = $origin_task->priority;
2277 if ($clone_change_dt) {
2278 $projectstatic =
new Project($this->db);
2279 $projectstatic->fetch($ori_project_id);
2282 $orign_project_dt_start = (!isset($projectstatic->date_start) || $projectstatic->date_start ==
'') ? $projectstatic->date_c : $projectstatic->date_start;
2285 if (!empty($clone_task->date_start)) {
2286 $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
2290 if (!empty($clone_task->date_end)) {
2291 $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
2296 $clone_task->progress = 0;
2300 $result = $clone_task->create($user);
2304 $this->error = $clone_task->error;
2311 $clone_task_id = $clone_task->id;
2312 $clone_task_ref = $clone_task->ref;
2316 $clone_task->note_private =
'';
2317 $clone_task->note_public =
'';
2320 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_public, ENT_QUOTES | ENT_HTML5),
'_public');
2322 $this->error .= $clone_task->error;
2324 $this->db->rollback();
2326 $this->db->commit();
2330 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_private, ENT_QUOTES | ENT_HTML5),
'_private');
2332 $this->error .= $clone_task->error;
2334 $this->db->rollback();
2336 $this->db->commit();
2342 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2345 $projectstatic =
new Project($this->db);
2346 $projectstatic->fetch($ori_project_id);
2347 $ori_project_ref = $projectstatic->ref;
2349 if ($ori_project_id != $project_id) {
2350 $projectstatic->fetch($project_id);
2351 $clone_project_ref = $projectstatic->ref;
2353 $clone_project_ref = $ori_project_ref;
2359 $filearray =
dol_dir_list($ori_task_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
2360 foreach ($filearray as $file) {
2361 if (!file_exists($clone_task_dir)) {
2363 $this->error .= $langs->trans(
'ErrorInternalErrorDetected').
':dol_mkdir';
2368 $rescopy =
dol_copy($ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name'],
'0', 1);
2369 if (is_numeric($rescopy) && $rescopy < 0) {
2370 $this->error .= $langs->trans(
"ErrorFailToCopyFile", $ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name']);
2377 if ($clone_affectation) {
2378 $origin_task =
new Task($this->db);
2379 $origin_task->fetch($fromid);
2381 foreach (array(
'internal',
'external') as $source) {
2382 $tab = $origin_task->liste_contact(-1, $source);
2386 $clone_task->add_contact($tab[$i][
'id'], $tab[$i][
'code'], $tab[$i][
'source']);
2387 if ($clone_task->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2388 $langs->load(
"errors");
2389 $this->error .= $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
2392 if ($clone_task->error !=
'') {
2393 $this->error .= $clone_task->error;
2407 unset($clone_task->context[
'createfromclone']);
2410 $this->db->commit();
2411 return $clone_task_id;
2413 $this->db->rollback();
2414 dol_syslog(get_class($this).
"::createFromClone nbError: ".$error.
" error : ".$this->error, LOG_ERR);
2445 $this->labelStatus[0] =
'Draft';
2446 $this->labelStatus[1] =
'ToDo';
2447 $this->labelStatus[2] =
'Running';
2448 $this->labelStatus[3] =
'Finish';
2449 $this->labelStatus[4] =
'Transfered';
2450 $this->labelStatusShort[0] =
'Draft';
2451 $this->labelStatusShort[1] =
'ToDo';
2452 $this->labelStatusShort[2] =
'Running';
2453 $this->labelStatusShort[3] =
'Completed';
2454 $this->labelStatusShort[4] =
'Transfered';
2457 return $langs->trans($this->labelStatus[$status]);
2458 } elseif ($mode == 1) {
2459 return $langs->trans($this->labelStatusShort[$status]);
2460 } elseif ($mode == 2) {
2462 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatusShort[$status]);
2463 } elseif ($status == 1) {
2464 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatusShort[$status]);
2465 } elseif ($status == 2) {
2466 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatusShort[$status]);
2467 } elseif ($status == 3) {
2468 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2469 } elseif ($status == 4) {
2470 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2471 } elseif ($status == 5) {
2472 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatusShort[$status]);
2474 } elseif ($mode == 3) {
2476 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0');
2477 } elseif ($status == 1) {
2478 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1');
2479 } elseif ($status == 2) {
2480 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3');
2481 } elseif ($status == 3) {
2482 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2483 } elseif ($status == 4) {
2484 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2485 } elseif ($status == 5) {
2486 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5');
2488 } elseif ($mode == 4) {
2490 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatus[$status]);
2491 } elseif ($status == 1) {
2492 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatus[$status]);
2493 } elseif ($status == 2) {
2494 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatus[$status]);
2495 } elseif ($status == 3) {
2496 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2497 } elseif ($status == 4) {
2498 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2499 } elseif ($status == 5) {
2500 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatus[$status]);
2502 } elseif ($mode == 5) {
2512 } elseif ($mode == 6) {
2536 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2538 $outputlangs->load(
"projects");
2541 $modele =
'nodefault';
2543 if (!empty($this->model_pdf)) {
2544 $modele = $this->model_pdf;
2550 $modelpath =
"core/modules/project/task/doc/";
2552 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2566 global
$conf, $langs;
2572 $projectstatic =
new Project($this->db);
2573 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
2576 $sql =
"SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
2577 $sql .=
" t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
2578 $sql .=
" t.dateo as date_start, t.datee as date_end";
2579 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2582 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2583 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2584 $sql .=
" AND p.fk_statut = 1";
2585 $sql .=
" AND t.fk_projet = p.rowid";
2586 $sql .=
" AND (t.progress IS NULL OR t.progress < 100)";
2587 if (!$user->hasRight(
'projet',
'all',
'lire')) {
2588 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2596 $resql = $this->db->query($sql);
2598 $task_static =
new Task($this->db);
2601 $response->warning_delay =
$conf->project->task->warning_delay / 60 / 60 / 24;
2602 $response->label = $langs->trans(
"OpenedTasks");
2603 if ($user->hasRight(
"projet",
"all",
"lire")) {
2604 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mainmenu=project';
2606 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mode=mine&mainmenu=project';
2611 while ($obj = $this->db->fetch_object($resql)) {
2612 $response->nbtodo++;
2614 $task_static->projectstatus = $obj->projectstatus;
2615 $task_static->progress = $obj->progress;
2616 $task_static->fk_statut = $obj->status;
2617 $task_static->status = $obj->status;
2618 $task_static->date_start = $this->db->jdate($obj->date_start);
2619 $task_static->date_end = $this->db->jdate($obj->date_end);
2621 if ($task_static->hasDelay()) {
2622 $response->nbtodolate++;
2628 $this->error = $this->db->error();
2644 $socid = $user->socid;
2646 $projectstatic =
new Project($this->db);
2647 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid);
2650 $sql =
"SELECT count(p.rowid) as nb";
2651 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2652 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
2653 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2654 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = s.rowid";
2656 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2657 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2658 $sql .=
" AND t.fk_projet = p.rowid";
2659 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
2660 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2665 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
2667 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2668 $sql .=
" AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).
") OR (s.rowid IS NULL))";
2671 $resql = $this->db->query($sql);
2674 while ($obj = $this->db->fetch_object($resql)) {
2675 $this->nb[
"tasks"] = $obj->nb;
2677 $this->db->free($resql);
2681 $this->error = $this->db->error();
2695 if (!($this->progress >= 0 && $this->progress < 100)) {
2701 $datetouse = ($this->date_end > 0) ? $this->date_end : ((isset($this->datee) && $this->datee > 0) ? $this->datee : 0);
2703 return ($datetouse > 0 && ($datetouse < ($now -
$conf->project->task->warning_delay)));
2715 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2717 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2718 $return .=
'<div class="info-box info-box-sm info-box-kanban">';
2719 $return .=
'<span class="info-box-icon bg-infobox-action">';
2722 $return .=
'</span>';
2723 $return .=
'<div class="info-box-content">';
2724 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
2725 if ($selected >= 0) {
2726 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2728 if (!empty($arraydata[
'projectlink'])) {
2731 $return .=
'<br><span class="info-box-status ">'.$arraydata[
'projectlink'].
'</span>';
2736 if (property_exists($this,
'duration_effective')) {
2737 $return .=
'<br><div class="info-box-label progressinkanban paddingtop">'.getTaskProgressView($this,
false,
true).
'</div>';
2739 $return .=
'</div>';
2740 $return .=
'</div>';
2741 $return .=
'</div>';
2755 global $langs, $hookmanager, $user, $action;
2758 $task_origin =
new Task($this->db);
2760 dol_syslog(
"mergeTask merge task id=".$task_origin_id.
" (will be deleted) into the task id=".$this->id);
2762 $langs->load(
'error');
2764 if (!$error && $task_origin->fetch($task_origin_id) < 1) {
2765 $this->error = $langs->trans(
'ErrorRecordNotFound');
2773 $listofproperties = array(
2774 'label',
'description',
'duration_effective',
'planned_workload',
'datec',
'date_start',
2775 'date_end',
'fk_user_creat',
'fk_user_valid',
'fk_statut',
'progress',
'budget_amount',
2776 'priority',
'rang',
'fk_projet',
'fk_task_parent'
2778 foreach ($listofproperties as $property) {
2779 if (empty($this->$property)) {
2780 $this->$property = $task_origin->$property;
2785 $listofproperties = array(
2786 'note_public',
'note_private'
2788 foreach ($listofproperties as $property) {
2789 $this->$property =
dol_concatdesc($this->$property, $task_origin->$property);
2793 if (is_array($task_origin->array_options)) {
2794 foreach ($task_origin->array_options as $key => $val) {
2795 if (empty($this->array_options[$key])) {
2796 $this->array_options[$key] = $val;
2802 $result = $this->
update($user);
2811 if ($result !=
true) {
2819 if ($result !=
true) {
2826 $parameters = array(
'task_origin' => $task_origin->id,
'task_dest' => $this->id);
2827 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', $parameters, $this, $action);
2830 $this->error = $hookmanager->error;
2831 $this->errors = $hookmanager->errors;
2838 $this->context = array(
'merge' => 1,
'mergefromid' => $task_origin->id,
'mergefromref' => $task_origin->ref);
2850 if ($task_origin->delete($user) < 1) {
2851 $this->error = $task_origin->error;
2852 $this->errors = $task_origin->errors;
2858 $this->db->commit();
2861 $langs->load(
"errors");
2862 $this->error = $langs->trans(
'ErrorsTaskMerge');
2863 $this->db->rollback();
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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...