30require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/timespent.class.php';
44 public $element =
'project_task';
49 public $table_element =
'projet_task';
54 public $fk_element =
'fk_element';
59 public $picto =
'projecttask';
64 protected $childtables = array(
65 'element_time' => array(
'name' =>
'Task',
'parent' =>
'projet_task',
'parentkey' =>
'fk_element',
'parenttypefield' =>
'elementtype',
'parenttypevalue' =>
'task')
71 public $fk_task_parent = 0;
83 public $duration_effective;
84 public $planned_workload;
105 public $fk_user_creat;
110 public $fk_user_valid;
114 public $timespent_min_date;
115 public $timespent_max_date;
116 public $timespent_total_duration;
117 public $timespent_total_amount;
118 public $timespent_nblinesnull;
119 public $timespent_nblines;
123 public $timespent_id;
124 public $timespent_duration;
125 public $timespent_old_duration;
126 public $timespent_date;
127 public $timespent_datehour;
128 public $timespent_withhour;
129 public $timespent_fk_user;
130 public $timespent_thm;
131 public $timespent_note;
132 public $timespent_fk_product;
133 public $timespent_invoiceid;
134 public $timespent_invoicelineid;
136 public $comments = array();
146 public $labelStatusShort;
154 public $projectstatus;
155 public $projectlabel;
158 public $fk_opp_status;
159 public $usage_bill_time;
161 public $array_options_project;
165 public $thirdparty_id;
166 public $thirdparty_name;
167 public $thirdparty_email;
170 public $task_parent_ref;
171 public $task_parent_position;
178 public $budget_amount;
183 public $project_budget_amount;
205 public function create($user, $notrigger = 0)
207 global $conf, $langs;
215 $this->label = trim($this->label);
217 $this->note_public = trim($this->note_public);
218 $this->note_private = trim($this->note_private);
220 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
221 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
229 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"projet_task (";
231 $sql .=
", fk_projet";
233 $sql .=
", fk_task_parent";
235 $sql .=
", description";
236 $sql .=
", note_public";
237 $sql .=
", note_private";
239 $sql .=
", fk_user_creat";
242 $sql .=
", planned_workload";
243 $sql .=
", progress";
244 $sql .=
", budget_amount";
245 $sql .=
", priority";
246 $sql .=
") VALUES (";
247 $sql .= (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity);
248 $sql .=
", ".((int) $this->fk_project);
249 $sql .=
", ".(!empty($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
'null');
250 $sql .=
", ".((int) $this->fk_task_parent);
251 $sql .=
", '".$this->db->escape($this->label).
"'";
252 $sql .=
", '".$this->db->escape($this->
description).
"'";
253 $sql .=
", '".$this->db->escape($this->note_public).
"'";
254 $sql .=
", '".$this->db->escape($this->note_private).
"'";
255 $sql .=
", '".$this->db->idate($now).
"'";
256 $sql .=
", ".((int) $user->id);
257 $sql .=
", ".($this->date_start ?
"'".$this->db->idate($this->date_start).
"'" :
'null');
258 $sql .=
", ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
'null');
259 $sql .=
", ".(($this->planned_workload !=
'' && $this->planned_workload >= 0) ? ((
int) $this->planned_workload) :
'null');
260 $sql .=
", ".(($this->progress !=
'' && $this->progress >= 0) ? ((
int) $this->progress) :
'null');
261 $sql .=
", ".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? ((
int) $this->budget_amount) :
'null');
262 $sql .=
", ".(($this->priority !=
'' && $this->priority >= 0) ? (
int) $this->priority :
'null');
267 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
268 $resql = $this->db->query($sql);
271 $this->errors[] =
"Error ".$this->db->lasterror();
275 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"projet_task");
296 foreach ($this->errors as $errmsg) {
297 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
298 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
300 $this->db->rollback();
317 public function fetch($id, $ref =
'', $loadparentdata = 0)
319 global $langs, $conf;
324 $sql .=
" t.entity,";
325 $sql .=
" t.fk_projet as fk_project,";
326 $sql .=
" t.fk_task_parent,";
328 $sql .=
" t.description,";
329 $sql .=
" t.duration_effective,";
330 $sql .=
" t.planned_workload,";
334 $sql .=
" t.fk_user_creat,";
335 $sql .=
" t.fk_user_valid,";
336 $sql .=
" t.fk_statut,";
337 $sql .=
" t.progress,";
338 $sql .=
" t.budget_amount,";
339 $sql .=
" t.priority,";
340 $sql .=
" t.note_private,";
341 $sql .=
" t.note_public,";
343 if (!empty($loadparentdata)) {
344 $sql .=
", t2.ref as task_parent_ref";
345 $sql .=
", t2.rang as task_parent_position";
347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as t";
348 if (!empty($loadparentdata)) {
349 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t2 ON t.fk_task_parent = t2.rowid";
353 $sql .=
"entity IN (".getEntity(
'project').
")";
354 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
356 $sql .=
"t.rowid = ".((int) $id);
359 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
360 $resql = $this->db->query($sql);
362 $num_rows = $this->db->num_rows($resql);
365 $obj = $this->db->fetch_object($resql);
367 $this->
id = $obj->rowid;
368 $this->
ref = $obj->ref;
369 $this->entity = $obj->entity;
370 $this->fk_project = $obj->fk_project;
371 $this->fk_task_parent = $obj->fk_task_parent;
372 $this->label = $obj->label;
374 $this->duration_effective = $obj->duration_effective;
375 $this->planned_workload = $obj->planned_workload;
376 $this->date_c = $this->db->jdate($obj->datec);
377 $this->date_start = $this->db->jdate($obj->dateo);
378 $this->date_end = $this->db->jdate($obj->datee);
379 $this->fk_user_creat = $obj->fk_user_creat;
380 $this->fk_user_valid = $obj->fk_user_valid;
381 $this->fk_statut = $obj->fk_statut;
382 $this->progress = $obj->progress;
383 $this->budget_amount = $obj->budget_amount;
384 $this->priority = $obj->priority;
385 $this->note_private = $obj->note_private;
386 $this->note_public = $obj->note_public;
387 $this->rang = $obj->rang;
389 if (!empty($loadparentdata)) {
390 $this->task_parent_ref = $obj->task_parent_ref;
391 $this->task_parent_position = $obj->task_parent_position;
398 $this->db->free($resql);
406 $this->error =
"Error ".$this->db->lasterror();
419 public function update($user =
null, $notrigger = 0)
421 global $conf, $langs;
425 if (isset($this->fk_project)) {
426 $this->fk_project = trim($this->fk_project);
428 if (isset($this->
ref)) {
429 $this->
ref = trim($this->
ref);
431 if (isset($this->fk_task_parent)) {
432 $this->fk_task_parent = (int) $this->fk_task_parent;
434 if (isset($this->label)) {
435 $this->label = trim($this->label);
440 if (isset($this->note_public)) {
441 $this->note_public = trim($this->note_public);
443 if (isset($this->note_private)) {
444 $this->note_private = trim($this->note_private);
446 if (isset($this->duration_effective)) {
447 $this->duration_effective = trim($this->duration_effective);
449 if (isset($this->planned_workload)) {
450 $this->planned_workload = trim($this->planned_workload);
452 if (isset($this->budget_amount)) {
453 $this->budget_amount = trim($this->budget_amount);
456 if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) {
457 $this->errors[] = $langs->trans(
'StartDateCannotBeAfterEndDate');
465 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET";
466 $sql .=
" fk_projet=".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
467 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"'".$this->db->escape($this->
id).
"'").
",";
468 $sql .=
" fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent :
"null").
",";
469 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
470 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
471 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
472 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
473 $sql .=
" duration_effective=".(isset($this->duration_effective) ? $this->duration_effective :
"null").
",";
474 $sql .=
" planned_workload=".((isset($this->planned_workload) && $this->planned_workload !=
'') ? $this->planned_workload :
"null").
",";
475 $sql .=
" dateo=".($this->date_start !=
'' ?
"'".$this->db->idate($this->date_start).
"'" :
'null').
",";
476 $sql .=
" datee=".($this->date_end !=
'' ?
"'".$this->db->idate($this->date_end).
"'" :
'null').
",";
477 $sql .=
" progress=".(($this->progress !=
'' && $this->progress >= 0) ? $this->progress :
'null').
",";
478 $sql .=
" budget_amount=".(($this->budget_amount !=
'' && $this->budget_amount >= 0) ? $this->budget_amount :
'null').
",";
479 $sql .=
" rang=".((!empty($this->rang)) ? ((
int) $this->rang) :
"0").
",";
480 $sql .=
" priority=".((!empty($this->priority)) ? ((
int) $this->priority) :
"0");
481 $sql .=
" WHERE rowid=".((int) $this->
id);
485 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
486 $resql = $this->db->query($sql);
489 $this->errors[] =
"Error ".$this->db->lasterror();
502 $project =
new Project($this->db);
503 if ($project->fetch($this->fk_project) > 0) {
505 $project->getLinesArray(
null);
506 $projectCompleted = array_reduce(
508 function ($allTasksCompleted, $task) {
509 return $allTasksCompleted && $task->progress >= 100;
513 if ($projectCompleted) {
514 if ($project->setClose($user) <= 0) {
523 $this->errors[] = $project->error;
538 if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
540 if ($conf->project->dir_output) {
541 $project =
new Project($this->db);
542 $project->fetch($this->fk_project);
546 if (file_exists($olddir)) {
547 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
550 $langs->load(
"errors");
551 $this->error = $langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir);
560 foreach ($this->errors as $errmsg) {
561 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
562 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
564 $this->db->rollback();
580 public function delete($user, $notrigger = 0)
582 global $conf, $langs;
583 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
590 dol_syslog(get_class($this).
"::delete Can't delete record as it has some sub tasks", LOG_WARNING);
591 $this->error =
'ErrorRecordHasSubTasks';
592 $this->db->rollback();
597 if (!empty($objectisused)) {
598 dol_syslog(get_class($this).
"::delete Can't delete record as it has some child", LOG_WARNING);
599 $this->error =
'ErrorRecordHasChildren';
600 $this->db->rollback();
608 $this->error =
'ErrorFailToDeleteLinkedContact';
610 $this->db->rollback();
616 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_time";
617 $sql .=
" WHERE fk_element = ".((int) $this->
id).
" AND elementtype = 'task'";
619 $resql = $this->db->query($sql);
622 $this->errors[] =
"Error ".$this->db->lasterror();
627 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task_extrafields";
628 $sql .=
" WHERE fk_object = ".((int) $this->
id);
630 $resql = $this->db->query($sql);
633 $this->errors[] =
"Error ".$this->db->lasterror();
638 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"projet_task";
639 $sql .=
" WHERE rowid=".((int) $this->
id);
641 $resql = $this->db->query($sql);
644 $this->errors[] =
"Error ".$this->db->lasterror();
661 foreach ($this->errors as $errmsg) {
662 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
663 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
665 $this->db->rollback();
669 if ($conf->project->dir_output) {
670 $projectstatic =
new Project($this->db);
671 $projectstatic->fetch($this->fk_project);
674 dol_syslog(get_class($this).
"::delete dir=".$dir, LOG_DEBUG);
675 if (file_exists($dir)) {
676 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
679 $this->error =
'ErrorFailToDeleteDir';
680 $this->db->rollback();
702 $sql =
"SELECT COUNT(*) as nb";
703 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
704 $sql .=
" WHERE fk_task_parent = ".((int) $this->
id);
706 dol_syslog(get_class($this).
"::hasChildren", LOG_DEBUG);
707 $resql = $this->db->query($sql);
710 $this->errors[] =
"Error ".$this->db->lasterror();
712 $obj = $this->db->fetch_object($resql);
716 $this->db->free($resql);
736 $sql =
"SELECT COUNT(*) as nb";
737 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time";
738 $sql .=
" WHERE fk_element = ".((int) $this->
id);
739 $sql .=
" AND elementtype = 'task'";
741 dol_syslog(get_class($this).
"::hasTimeSpent", LOG_DEBUG);
742 $resql = $this->db->query($sql);
745 $this->errors[] =
"Error ".$this->db->lasterror();
747 $obj = $this->db->fetch_object($resql);
751 $this->db->free($resql);
773 $langs->load(
'projects');
776 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Task").
'</u>';
777 if (!empty($this->
ref)) {
778 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
780 if (!empty($this->label)) {
781 $datas[
'label'] =
'<br><b>'.$langs->trans(
'LabelTask').
':</b> '.$this->label;
783 if ($this->date_start || $this->date_end) {
784 $datas[
'range'] =
"<br>".get_date_range($this->date_start, $this->date_end,
'', $langs, 0);
802 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'task', $addlabel = 0, $sep =
' - ', $notooltip = 0, $save_lastsearch_value = -1)
804 global $action, $conf, $hookmanager, $langs;
806 if (!empty($conf->dol_no_mouse_hover)) {
813 'objecttype' => $this->element,
815 $classfortooltip =
'classfortooltip';
818 $classfortooltip =
'classforajaxtooltip';
819 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
825 $url = DOL_URL_ROOT.
'/projet/tasks/'.$mode.
'.php?id='.$this->
id.($option ==
'withproject' ?
'&withproject=1' :
'');
827 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
828 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
829 $add_save_lastsearch_values = 1;
831 if ($add_save_lastsearch_values) {
832 $url .=
'&save_lastsearch_values=1';
836 if (empty($notooltip)) {
838 $label = $langs->trans(
"ShowTask");
839 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
841 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
842 $linkclose .= $dataparams.
' class="'.$classfortooltip.
' nowraponall"';
844 $linkclose .=
' class="nowraponall"';
847 $linkstart =
'<a href="'.$url.
'"';
848 $linkstart .= $linkclose.
'>';
851 $picto =
'projecttask';
853 $result .= $linkstart;
855 $result .=
img_object(($notooltip ?
'' : $label), $picto,
'class="paddingright"', 0, 0, $notooltip ? 0 : 1);
857 if ($withpicto != 2) {
858 $result .= $this->ref;
861 if ($withpicto != 2) {
862 $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) :
'');
865 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
866 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
868 $result = $hookmanager->resPrint;
870 $result .= $hookmanager->resPrint;
887 $this->fk_project =
'';
889 $this->fk_task_parent =
null;
890 $this->label =
'Specimen task TK01';
891 $this->duration_effective =
'';
892 $this->fk_user_creat =
null;
893 $this->progress =
'25';
895 $this->fk_statut =
null;
896 $this->note =
'This is a specimen task not';
922 public function getTasksArray($usert =
null, $userp =
null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj =
'', $filteronprojstatus =
'-1', $morewherefilter =
'', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield =
'', $sortorder =
'')
924 global $conf, $hookmanager;
932 if ($filteronprojuser > 0 || $filterontaskuser > 0) {
935 $sql .=
" p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,";
936 $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,";
937 $sql .=
" t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang, t.priority,";
938 $sql .=
" t.budget_amount,";
939 $sql .=
" t.note_public, t.note_private,";
940 $sql .=
" s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,";
941 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount as project_budget_amount";
943 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
944 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
945 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key.
" as options_".$key :
'');
948 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
949 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
950 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key.
" as options_".$key :
'');
954 if ($includebilltime) {
955 $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";
958 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
959 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
961 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_extrafields as efp ON (p.rowid = efp.fk_object)";
965 if ($filteronprojuser > 0) {
966 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
967 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
969 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
971 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
973 if ($includebilltime) {
974 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
976 if ($filterontaskuser > 0) {
977 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
978 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
980 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
981 $sql .=
" AND t.fk_projet = p.rowid";
982 } elseif ($mode == 1) {
983 if ($filteronprojuser > 0) {
984 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
985 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
987 if ($filterontaskuser > 0) {
988 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
989 if ($includebilltime) {
990 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')";
992 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec2";
993 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc2";
995 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as t on t.fk_projet = p.rowid";
996 if ($includebilltime) {
997 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')";
1000 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
1002 return 'BadValueForParameterMode';
1005 if ($filteronprojuser > 0) {
1006 $sql .=
" AND p.rowid = ec.element_id";
1007 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1008 $sql .=
" AND ctc.element = 'project'";
1009 $sql .=
" AND ec.fk_socpeople = ".((int) $filteronprojuser);
1010 $sql .=
" AND ec.statut = 4";
1011 $sql .=
" AND ctc.source = 'internal'";
1013 if ($filterontaskuser > 0) {
1014 $sql .=
" AND t.fk_projet = p.rowid";
1015 $sql .=
" AND p.rowid = ec2.element_id";
1016 $sql .=
" AND ctc2.rowid = ec2.fk_c_type_contact";
1017 $sql .=
" AND ctc2.element = 'project_task'";
1018 $sql .=
" AND ec2.fk_socpeople = ".((int) $filterontaskuser);
1019 $sql .=
" AND ec2.statut = 4";
1020 $sql .=
" AND ctc2.source = 'internal'";
1023 $sql .=
" AND p.fk_soc = ".((int) $socid);
1026 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectid).
")";
1028 if ($filteronproj) {
1029 $sql .=
natural_search(array(
"p.ref",
"p.title"), $filteronproj);
1031 if ($filteronprojstatus && $filteronprojstatus !=
'-1') {
1032 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).
")";
1034 if ($morewherefilter) {
1035 $sql .= $morewherefilter;
1038 $extrafieldsobjectkey =
'projet_task';
1039 $extrafieldsobjectprefix =
'efpt.';
1041 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1043 $parameters = array();
1044 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
1045 $sql .= $hookmanager->resPrint;
1046 if ($includebilltime) {
1047 $sql .=
" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,";
1048 $sql .=
" t.datec, t.dateo, t.datee, t.tms,";
1049 $sql .=
" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,";
1050 $sql .=
" t.dateo, t.datee, t.planned_workload, t.rang, t.priority,";
1051 $sql .=
" t.budget_amount,";
1052 $sql .=
" t.note_public, t.note_private,";
1053 $sql .=
" s.rowid, s.nom, s.email,";
1054 $sql .=
" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
1056 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1057 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1058 $sql .= ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate' ?
",efp.".$key :
'');
1061 if (!empty($extrafields->attributes[
'projet_task'][
'label'])) {
1062 foreach ($extrafields->attributes[
'projet_task'][
'label'] as $key => $val) {
1063 $sql .= ($extrafields->attributes[
'projet_task'][
'type'][$key] !=
'separate' ?
",efpt.".$key :
'');
1069 if ($sortfield && $sortorder) {
1070 $sql .= $this->db->order($sortfield, $sortorder);
1072 $sql .=
" ORDER BY p.ref, t.rang, t.dateo";
1076 dol_syslog(get_class($this).
"::getTasksArray", LOG_DEBUG);
1077 $resql = $this->db->query($sql);
1079 $num = $this->db->num_rows($resql);
1085 $obj = $this->db->fetch_object($resql);
1087 if ($loadRoleMode) {
1088 if ((!$obj->public) && (is_object($userp))) {
1093 if (is_object($usert)) {
1101 $tasks[$i] =
new Task($this->db);
1102 $tasks[$i]->id = $obj->taskid;
1103 $tasks[$i]->ref = $obj->taskref;
1104 $tasks[$i]->fk_project = $obj->projectid;
1107 $tasks[$i]->projectref = $obj->ref;
1108 $tasks[$i]->projectlabel = $obj->plabel;
1109 $tasks[$i]->projectstatus = $obj->projectstatus;
1110 $tasks[$i]->fk_opp_status = $obj->fk_opp_status;
1111 $tasks[$i]->opp_amount = $obj->opp_amount;
1112 $tasks[$i]->opp_percent = $obj->opp_percent;
1113 $tasks[$i]->budget_amount = $obj->budget_amount;
1114 $tasks[$i]->project_budget_amount = $obj->project_budget_amount;
1115 $tasks[$i]->usage_bill_time = $obj->usage_bill_time;
1117 $tasks[$i]->label = $obj->label;
1118 $tasks[$i]->description = $obj->description;
1120 $tasks[$i]->fk_task_parent = $obj->fk_task_parent;
1121 $tasks[$i]->note_public = $obj->note_public;
1122 $tasks[$i]->note_private = $obj->note_private;
1123 $tasks[$i]->duration_effective = $obj->duration_effective;
1124 $tasks[$i]->planned_workload = $obj->planned_workload;
1126 if ($includebilltime) {
1128 $tasks[$i]->tobill = $obj->tobill;
1129 $tasks[$i]->billed = $obj->billed;
1132 $tasks[$i]->progress = $obj->progress;
1133 $tasks[$i]->fk_statut = $obj->status;
1134 $tasks[$i]->public = $obj->public;
1135 $tasks[$i]->date_start = $this->db->jdate($obj->date_start);
1136 $tasks[$i]->date_end = $this->db->jdate($obj->date_end);
1137 $tasks[$i]->rang = $obj->rang;
1138 $tasks[$i]->priority = $obj->priority;
1140 $tasks[$i]->socid = $obj->thirdparty_id;
1141 $tasks[$i]->thirdparty_id = $obj->thirdparty_id;
1142 $tasks[$i]->thirdparty_name = $obj->thirdparty_name;
1143 $tasks[$i]->thirdparty_email = $obj->thirdparty_email;
1146 if (!empty($extrafields->attributes[
'projet'][
'label'])) {
1147 foreach ($extrafields->attributes[
'projet'][
'label'] as $key => $val) {
1148 if ($extrafields->attributes[
'projet'][
'type'][$key] !=
'separate') {
1149 $tmpvar =
'options_'.$key;
1150 $tasks[$i]->array_options_project[
'options_'.$key] = $obj->$tmpvar;
1157 $tasks[$i]->fetch_optionals();
1160 $tasks[$i]->obj = $obj;
1165 $this->db->free($resql);
1185 $arrayroles = array();
1187 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks userp=".is_object($userp).
" usert=".is_object($usert).
" projectid=".$projectid.
" taskid=".$taskid);
1190 if (empty($userp) && empty($usert)) {
1191 $this->error =
"CallWithWrongParameters";
1194 if (!empty($userp) && !empty($usert)) {
1195 $this->error =
"CallWithWrongParameters";
1200 $sql =
"SELECT pt.rowid as pid, ec.element_id, ctc.code, ctc.source";
1202 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as pt";
1204 if ($usert && $filteronprojstatus > -1) {
1205 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p, ".MAIN_DB_PREFIX.
"projet_task as pt";
1207 if ($usert && $filteronprojstatus <= -1) {
1208 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as pt";
1210 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
1211 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as ctc";
1212 $sql .=
" WHERE pt.rowid = ec.element_id";
1213 if ($userp && $filteronprojstatus > -1) {
1214 $sql .=
" AND pt.fk_statut = ".((int) $filteronprojstatus);
1216 if ($usert && $filteronprojstatus > -1) {
1217 $sql .=
" AND pt.fk_projet = p.rowid AND p.fk_statut = ".((int) $filteronprojstatus);
1220 $sql .=
" AND ctc.element = 'project'";
1223 $sql .=
" AND ctc.element = 'project_task'";
1225 $sql .=
" AND ctc.rowid = ec.fk_c_type_contact";
1227 $sql .=
" AND ec.fk_socpeople = ".((int) $userp->id);
1230 $sql .=
" AND ec.fk_socpeople = ".((int) $usert->id);
1232 $sql .=
" AND ec.statut = 4";
1233 $sql .=
" AND ctc.source = 'internal'";
1236 $sql .=
" AND pt.rowid IN (".$this->db->sanitize($projectid).
")";
1239 $sql .=
" AND pt.fk_projet IN (".$this->db->sanitize($projectid).
")";
1244 $sql .=
" ERROR SHOULD NOT HAPPENS";
1247 $sql .=
" AND pt.rowid = ".((int) $taskid);
1252 dol_syslog(get_class($this).
"::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG);
1253 $resql = $this->db->query($sql);
1255 $num = $this->db->num_rows($resql);
1258 $obj = $this->db->fetch_object($resql);
1259 if (empty($arrayroles[$obj->pid])) {
1260 $arrayroles[$obj->pid] = $obj->code;
1262 $arrayroles[$obj->pid] .=
','.$obj->code;
1266 $this->db->free($resql);
1283 $contactAlreadySelected = array();
1289 if ($source ==
'thirdparty') {
1290 $contactAlreadySelected[$i] = $tab[$i][
'socid'];
1292 $contactAlreadySelected[$i] = $tab[$i][
'id'];
1296 return $contactAlreadySelected;
1309 global $conf, $langs;
1311 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1317 if (!is_object($user)) {
1318 dol_print_error(
'',
"Method addTimeSpent was called with wrong parameter user");
1323 if (isset($this->timespent_note)) {
1324 $this->timespent_note = trim($this->timespent_note);
1326 if (empty($this->timespent_datehour) || ($this->timespent_date != $this->timespent_datehour)) {
1327 $this->timespent_datehour = $this->timespent_date;
1331 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1334 if ($this->timespent_date < $restrictBefore) {
1335 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
1336 $this->errors[] = $this->error;
1345 $timespent->fk_element = $this->id;
1346 $timespent->elementtype =
'task';
1347 $timespent->element_date = $this->timespent_date;
1348 $timespent->element_datehour = $this->timespent_datehour;
1349 $timespent->element_date_withhour = $this->timespent_withhour;
1350 $timespent->element_duration = $this->timespent_duration;
1351 $timespent->fk_user = $this->timespent_fk_user;
1352 $timespent->fk_product = $this->timespent_fk_product;
1353 $timespent->note = $this->timespent_note;
1354 $timespent->datec = $this->db->idate($now);
1356 $result = $timespent->create($user);
1360 $this->timespent_id = $result;
1364 $result = $this->
call_trigger(
'TASK_TIMESPENT_CREATE', $user);
1371 $this->error = $this->db->lasterror();
1377 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1378 $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).
")";
1379 if (isset($this->progress)) {
1380 $sql .=
", progress = ".((float) $this->progress);
1382 $sql .=
" WHERE rowid = ".((int) $this->
id);
1384 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1385 if (!$this->db->query($sql)) {
1386 $this->error = $this->db->lasterror();
1391 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1392 if (!empty($resql_thm_user)) {
1393 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1394 $timespent->thm = $obj_thm_user->thm;
1396 $res_update = $timespent->update($user);
1398 dol_syslog(get_class($this).
"::addTimeSpent", LOG_DEBUG);
1399 if ($res_update <= 0) {
1400 $this->error = $this->db->lasterror();
1406 $this->db->commit();
1408 $this->db->rollback();
1423 $arrayres = array();
1426 $sql .=
" s.rowid as socid,";
1427 $sql .=
" s.nom as thirdparty_name,";
1428 $sql .=
" s.email as thirdparty_email,";
1429 $sql .=
" ptt.rowid,";
1430 $sql .=
" ptt.ref_ext,";
1431 $sql .=
" ptt.fk_element as fk_task,";
1432 $sql .=
" ptt.element_date as task_date,";
1433 $sql .=
" ptt.element_datehour as task_datehour,";
1434 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1435 $sql .=
" ptt.element_duration as task_duration,";
1436 $sql .=
" ptt.fk_user,";
1437 $sql .=
" ptt.note,";
1438 $sql .=
" ptt.thm,";
1439 $sql .=
" pt.rowid as task_id,";
1440 $sql .=
" pt.ref as task_ref,";
1441 $sql .=
" pt.label as task_label,";
1442 $sql .=
" p.rowid as project_id,";
1443 $sql .=
" p.ref as project_ref,";
1444 $sql .=
" p.title as project_label,";
1445 $sql .=
" p.public as public";
1446 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1447 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1448 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1449 $sql .=
" AND ptt.elementtype = 'task'";
1450 $sql .=
" AND pt.rowid = ".((int) $this->
id);
1451 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1452 if ($morewherefilter) {
1453 $sql .= $morewherefilter;
1456 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1457 $resql = $this->db->query($sql);
1459 $num = $this->db->num_rows($resql);
1463 $obj = $this->db->fetch_object($resql);
1467 $newobj->socid = $obj->socid;
1468 $newobj->thirdparty_name = $obj->thirdparty_name;
1469 $newobj->thirdparty_email = $obj->thirdparty_email;
1471 $newobj->fk_project = $obj->project_id;
1472 $newobj->project_ref = $obj->project_ref;
1473 $newobj->project_label = $obj->project_label;
1474 $newobj->public = $obj->project_public;
1476 $newobj->fk_task = $obj->task_id;
1477 $newobj->task_ref = $obj->task_ref;
1478 $newobj->task_label = $obj->task_label;
1480 $newobj->timespent_line_id = $obj->rowid;
1481 $newobj->timespent_line_ref_ext = $obj->ref_ext;
1482 $newobj->timespent_line_date = $this->db->jdate($obj->task_date);
1483 $newobj->timespent_line_datehour = $this->db->jdate($obj->task_datehour);
1484 $newobj->timespent_line_withhour = $obj->task_date_withhour;
1485 $newobj->timespent_line_duration = $obj->task_duration;
1486 $newobj->timespent_line_fk_user = $obj->fk_user;
1487 $newobj->timespent_line_thm = $obj->thm;
1488 $newobj->timespent_line_note = $obj->note;
1490 $arrayres[] = $newobj;
1495 $this->db->free($resql);
1497 $this->lines = $arrayres;
1501 $this->error =
"Error ".$this->db->lasterror();
1516 if (is_object($userobj)) {
1517 $userid = $userobj->id;
1523 if (empty($id) && empty($userid)) {
1524 dol_syslog(
"getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR);
1531 $sql .=
" MIN(t.element_datehour) as min_date,";
1532 $sql .=
" MAX(t.element_datehour) as max_date,";
1533 $sql .=
" SUM(t.element_duration) as total_duration,";
1534 $sql .=
" SUM(t.element_duration / 3600 * ".$this->db->ifsql(
"t.thm IS NULL", 0,
"t.thm").
") as total_amount,";
1535 $sql .=
" COUNT(t.rowid) as nblines,";
1536 $sql .=
" SUM(".$this->db->ifsql(
"t.thm IS NULL", 1, 0).
") as nblinesnull";
1537 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1538 $sql .=
" WHERE t.elementtype='task'";
1539 if ($morewherefilter) {
1540 $sql .= $morewherefilter;
1543 $sql .=
" AND t.fk_element = ".((int) $id);
1546 $sql .=
" AND t.fk_user = ".((int) $userid);
1549 dol_syslog(get_class($this).
"::getSummaryOfTimeSpent", LOG_DEBUG);
1550 $resql = $this->db->query($sql);
1552 $obj = $this->db->fetch_object($resql);
1554 $result[
'min_date'] = $obj->min_date;
1555 $result[
'max_date'] = $obj->max_date;
1556 $result[
'total_duration'] = $obj->total_duration;
1558 $this->timespent_min_date = $this->db->jdate($obj->min_date);
1559 $this->timespent_max_date = $this->db->jdate($obj->max_date);
1560 $this->timespent_total_duration = $obj->total_duration;
1561 $this->timespent_total_amount = $obj->total_amount;
1562 $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0);
1563 $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0);
1565 $this->db->free($resql);
1587 $sql .=
" SUM(t.element_duration) as nbseconds,";
1588 $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";
1589 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
1590 $sql .=
" WHERE t.elementtype='task' AND t.fk_element = ".((int) $id);
1591 if (is_object($fuser) && $fuser->id > 0) {
1592 $sql .=
" AND fk_user = ".((int) $fuser->id);
1595 $datefieldname =
"element_datehour";
1596 $sql .=
" AND (".$datefieldname.
" >= '".$this->db->idate($dates).
"' OR ".$datefieldname.
" IS NULL)";
1599 $datefieldname =
"element_datehour";
1600 $sql .=
" AND (".$datefieldname.
" <= '".$this->db->idate(
$datee).
"' OR ".$datefieldname.
" IS NULL)";
1604 dol_syslog(get_class($this).
"::getSumOfAmount", LOG_DEBUG);
1605 $resql = $this->db->query($sql);
1607 $obj = $this->db->fetch_object($resql);
1609 $result[
'amount'] = $obj->amount;
1610 $result[
'nbseconds'] = $obj->nbseconds;
1611 $result[
'nblinesnull'] = $obj->nblinesnull;
1613 $this->db->free($resql);
1632 $timespent->fetch($id);
1634 dol_syslog(get_class($this).
"::fetchTimeSpent", LOG_DEBUG);
1636 if ($timespent->id > 0) {
1637 $this->timespent_id = $timespent->id;
1638 $this->
id = $timespent->fk_element;
1639 $this->timespent_date = $timespent->element_date;
1640 $this->timespent_datehour = $timespent->element_datehour;
1641 $this->timespent_withhour = $timespent->element_date_withhour;
1642 $this->timespent_duration = $timespent->element_duration;
1643 $this->timespent_fk_user = $timespent->fk_user;
1644 $this->timespent_fk_product = $timespent->fk_product;
1645 $this->timespent_thm = $timespent->thm;
1646 $this->timespent_note = $timespent->note;
1663 $arrayres = array();
1666 $sql .=
" s.rowid as socid,";
1667 $sql .=
" s.nom as thirdparty_name,";
1668 $sql .=
" s.email as thirdparty_email,";
1669 $sql .=
" ptt.rowid,";
1670 $sql .=
" ptt.fk_element as fk_task,";
1671 $sql .=
" ptt.element_date as task_date,";
1672 $sql .=
" ptt.element_datehour as task_datehour,";
1673 $sql .=
" ptt.element_date_withhour as task_date_withhour,";
1674 $sql .=
" ptt.element_duration as task_duration,";
1675 $sql .=
" ptt.fk_user,";
1676 $sql .=
" ptt.note,";
1677 $sql .=
" ptt.thm,";
1678 $sql .=
" pt.rowid as task_id,";
1679 $sql .=
" pt.ref as task_ref,";
1680 $sql .=
" pt.label as task_label,";
1681 $sql .=
" p.rowid as project_id,";
1682 $sql .=
" p.ref as project_ref,";
1683 $sql .=
" p.title as project_label,";
1684 $sql .=
" p.public as public";
1685 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as ptt, ".MAIN_DB_PREFIX.
"projet_task as pt, ".MAIN_DB_PREFIX.
"projet as p";
1686 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
1687 $sql .=
" WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid";
1688 $sql .=
" AND ptt.elementtype = 'task'";
1689 $sql .=
" AND ptt.fk_user = ".((int) $userobj->id);
1690 $sql .=
" AND pt.entity IN (".getEntity(
'project').
")";
1691 if ($morewherefilter) {
1692 $sql .= $morewherefilter;
1695 dol_syslog(get_class($this).
"::fetchAllTimeSpent", LOG_DEBUG);
1696 $resql = $this->db->query($sql);
1698 $num = $this->db->num_rows($resql);
1702 $obj = $this->db->fetch_object($resql);
1706 $newobj->socid = $obj->socid;
1707 $newobj->thirdparty_name = $obj->thirdparty_name;
1708 $newobj->thirdparty_email = $obj->thirdparty_email;
1710 $newobj->fk_project = $obj->project_id;
1711 $newobj->project_ref = $obj->project_ref;
1712 $newobj->project_label = $obj->project_label;
1713 $newobj->public = $obj->project_public;
1715 $newobj->fk_task = $obj->task_id;
1716 $newobj->task_ref = $obj->task_ref;
1717 $newobj->task_label = $obj->task_label;
1719 $newobj->timespent_id = $obj->rowid;
1720 $newobj->timespent_date = $this->db->jdate($obj->task_date);
1721 $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour);
1722 $newobj->timespent_withhour = $obj->task_date_withhour;
1723 $newobj->timespent_duration = $obj->task_duration;
1724 $newobj->timespent_fk_user = $obj->fk_user;
1725 $newobj->timespent_thm = $obj->thm;
1726 $newobj->timespent_note = $obj->note;
1728 $arrayres[] = $newobj;
1733 $this->db->free($resql);
1736 $this->error =
"Error ".$this->db->lasterror();
1752 global $conf, $langs;
1757 if ($this->timespent_date ==
'') {
1758 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date"));
1761 if (!($this->timespent_fk_user > 0)) {
1762 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"User"));
1767 if (empty($this->timespent_datehour)) {
1768 $this->timespent_datehour = $this->timespent_date;
1770 if (isset($this->timespent_note)) {
1771 $this->timespent_note = trim($this->timespent_note);
1775 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1778 if ($this->timespent_date < $restrictBefore) {
1779 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
1780 $this->errors[] = $this->error;
1788 $timespent->fetch($this->timespent_id);
1789 $timespent->element_date = $this->timespent_date;
1790 $timespent->element_datehour = $this->timespent_datehour;
1791 $timespent->element_date_withhour = $this->timespent_withhour;
1792 $timespent->element_duration = $this->timespent_duration;
1793 $timespent->fk_user = $this->timespent_fk_user;
1794 $timespent->fk_product = $this->timespent_fk_product;
1795 $timespent->note = $this->timespent_note;
1796 $timespent->invoice_id = $this->timespent_invoiceid;
1797 $timespent->invoice_line_id = $this->timespent_invoicelineid;
1799 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
1800 if ($timespent->update($user) > 0) {
1803 $result = $this->
call_trigger(
'TASK_TIMESPENT_MODIFY', $user);
1805 $this->db->rollback();
1815 $this->error = $this->db->lasterror();
1816 $this->db->rollback();
1820 if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) ||
getDolGlobalString(
'TIMESPENT_ALWAYS_UPDATE_THM'))) {
1821 if ($this->timespent_old_duration != $this->timespent_duration) {
1823 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"projet_task";
1824 $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) .
")";
1825 if (isset($this->progress)) {
1826 $sql .=
", progress = " . ((float) $this->progress);
1828 $sql .=
" WHERE rowid = " . ((int) $this->
id);
1830 dol_syslog(get_class($this) .
"::updateTimeSpent", LOG_DEBUG);
1831 if (!$this->db->query($sql)) {
1832 $this->error = $this->db->lasterror();
1833 $this->db->rollback();
1841 $resql_thm_user = $this->db->query(
"SELECT thm FROM " . MAIN_DB_PREFIX .
"user WHERE rowid = " . ((
int) $timespent->fk_user));
1842 if (!empty($resql_thm_user)) {
1843 $obj_thm_user = $this->db->fetch_object($resql_thm_user);
1844 $timespent->thm = $obj_thm_user->thm;
1846 $res_update = $timespent->update($user);
1849 dol_syslog(get_class($this).
"::updateTimeSpent", LOG_DEBUG);
1850 if ($res_update <= 0) {
1851 $this->error = $this->db->lasterror();
1857 $this->db->commit();
1871 global $conf, $langs;
1876 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1879 if ($this->timespent_date < $restrictBefore) {
1880 $this->error = $langs->trans(
'TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
1881 $this->errors[] = $this->error;
1890 $result = $this->
call_trigger(
'TASK_TIMESPENT_DELETE', $user);
1899 $timespent->fetch($this->timespent_id);
1901 $res_del = $timespent->delete($user);
1905 $this->errors[] =
"Error ".$this->db->lasterror();
1910 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task";
1911 $sql .=
" SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0);
1912 $sql .=
" WHERE rowid = ".((int) $this->
id);
1914 dol_syslog(get_class($this).
"::delTimeSpent", LOG_DEBUG);
1915 if ($this->db->query($sql)) {
1918 $this->error = $this->db->lasterror();
1925 foreach ($this->errors as $errmsg) {
1926 dol_syslog(get_class($this).
"::delTimeSpent ".$errmsg, LOG_ERR);
1927 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1929 $this->db->rollback();
1932 $this->db->commit();
1951 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)
1953 global $langs, $conf;
1962 $clone_task =
new Task($this->db);
1963 $origin_task =
new Task($this->db);
1965 $clone_task->context[
'createfromclone'] =
'createfromclone';
1970 $clone_task->fetch($fromid);
1971 $clone_task->fetch_optionals();
1974 $origin_task->fetch($fromid);
1977 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1979 require_once DOL_DOCUMENT_ROOT.
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON').
'.php';
1980 $modTask =
new $obj();
1981 $defaultref = $modTask->getNextValue(0, $clone_task);
1984 $ori_project_id = $clone_task->fk_project;
1986 $clone_task->id = 0;
1987 $clone_task->ref = $defaultref;
1988 $clone_task->fk_project = $project_id;
1989 $clone_task->fk_task_parent = $parent_task_id;
1990 $clone_task->date_c = $datec;
1991 $clone_task->planned_workload = $origin_task->planned_workload;
1992 $clone_task->rang = $origin_task->rang;
1993 $clone_task->priority = $origin_task->priority;
1996 if ($clone_change_dt) {
1997 $projectstatic =
new Project($this->db);
1998 $projectstatic->fetch($ori_project_id);
2001 $orign_project_dt_start = (!isset($projectstatic->date_start) || $projectstatic->date_start ==
'') ? $projectstatic->date_c : $projectstatic->date_start;
2004 if (!empty($clone_task->date_start)) {
2005 $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
2009 if (!empty($clone_task->date_end)) {
2010 $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
2015 $clone_task->progress = 0;
2019 $result = $clone_task->create($user);
2023 $this->error = $clone_task->error;
2029 $clone_task_id = $clone_task->id;
2030 $clone_task_ref = $clone_task->ref;
2034 $clone_task->note_private =
'';
2035 $clone_task->note_public =
'';
2038 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_public, ENT_QUOTES | ENT_HTML5),
'_public');
2040 $this->error .= $clone_task->error;
2042 $this->db->rollback();
2044 $this->db->commit();
2048 $res = $clone_task->update_note(
dol_html_entity_decode($clone_task->note_private, ENT_QUOTES | ENT_HTML5),
'_private');
2050 $this->error .= $clone_task->error;
2052 $this->db->rollback();
2054 $this->db->commit();
2060 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2063 $projectstatic =
new Project($this->db);
2064 $projectstatic->fetch($ori_project_id);
2065 $ori_project_ref = $projectstatic->ref;
2067 if ($ori_project_id != $project_id) {
2068 $projectstatic->fetch($project_id);
2069 $clone_project_ref = $projectstatic->ref;
2071 $clone_project_ref = $ori_project_ref;
2077 $filearray =
dol_dir_list($ori_task_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'', SORT_ASC, 1);
2078 foreach ($filearray as $key => $file) {
2079 if (!file_exists($clone_task_dir)) {
2081 $this->error .= $langs->trans(
'ErrorInternalErrorDetected').
':dol_mkdir';
2086 $rescopy =
dol_copy($ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name'], 0, 1);
2087 if (is_numeric($rescopy) && $rescopy < 0) {
2088 $this->error .= $langs->trans(
"ErrorFailToCopyFile", $ori_task_dir.
'/'.$file[
'name'], $clone_task_dir.
'/'.$file[
'name']);
2095 if ($clone_affectation) {
2096 $origin_task =
new Task($this->db);
2097 $origin_task->fetch($fromid);
2099 foreach (array(
'internal',
'external') as $source) {
2100 $tab = $origin_task->liste_contact(-1, $source);
2104 $clone_task->add_contact($tab[$i][
'id'], $tab[$i][
'code'], $tab[$i][
'source']);
2105 if ($clone_task->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2106 $langs->load(
"errors");
2107 $this->error .= $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
2110 if ($clone_task->error !=
'') {
2111 $this->error .= $clone_task->error;
2125 unset($clone_task->context[
'createfromclone']);
2128 $this->db->commit();
2129 return $clone_task_id;
2131 $this->db->rollback();
2132 dol_syslog(get_class($this).
"::createFromClone nbError: ".$error.
" error : ".$this->error, LOG_ERR);
2146 return $this->
LibStatut($this->fk_statut, $mode);
2163 $this->labelStatus[0] =
'Draft';
2164 $this->labelStatus[1] =
'ToDo';
2165 $this->labelStatus[2] =
'Running';
2166 $this->labelStatus[3] =
'Finish';
2167 $this->labelStatus[4] =
'Transfered';
2168 $this->labelStatusShort[0] =
'Draft';
2169 $this->labelStatusShort[1] =
'ToDo';
2170 $this->labelStatusShort[2] =
'Running';
2171 $this->labelStatusShort[3] =
'Completed';
2172 $this->labelStatusShort[4] =
'Transfered';
2175 return $langs->trans($this->labelStatus[$status]);
2176 } elseif ($mode == 1) {
2177 return $langs->trans($this->labelStatusShort[$status]);
2178 } elseif ($mode == 2) {
2180 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatusShort[$status]);
2181 } elseif ($status == 1) {
2182 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatusShort[$status]);
2183 } elseif ($status == 2) {
2184 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatusShort[$status]);
2185 } elseif ($status == 3) {
2186 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2187 } elseif ($status == 4) {
2188 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatusShort[$status]);
2189 } elseif ($status == 5) {
2190 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatusShort[$status]);
2192 } elseif ($mode == 3) {
2194 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0');
2195 } elseif ($status == 1) {
2196 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1');
2197 } elseif ($status == 2) {
2198 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3');
2199 } elseif ($status == 3) {
2200 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2201 } elseif ($status == 4) {
2202 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6');
2203 } elseif ($status == 5) {
2204 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5');
2206 } elseif ($mode == 4) {
2208 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut0').
' '.$langs->trans($this->labelStatus[$status]);
2209 } elseif ($status == 1) {
2210 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut1').
' '.$langs->trans($this->labelStatus[$status]);
2211 } elseif ($status == 2) {
2212 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut3').
' '.$langs->trans($this->labelStatus[$status]);
2213 } elseif ($status == 3) {
2214 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2215 } elseif ($status == 4) {
2216 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut6').
' '.$langs->trans($this->labelStatus[$status]);
2217 } elseif ($status == 5) {
2218 return img_picto($langs->trans($this->labelStatusShort[$status]),
'statut5').
' '.$langs->trans($this->labelStatus[$status]);
2220 } elseif ($mode == 5) {
2230 } elseif ($mode == 6) {
2254 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
2258 $outputlangs->load(
"projects");
2261 $modele =
'nodefault';
2263 if (!empty($this->model_pdf)) {
2264 $modele = $this->model_pdf;
2266 $modele = $conf->global->PROJECT_TASK_ADDON_PDF;
2270 $modelpath =
"core/modules/project/task/doc/";
2272 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
2286 global $conf, $langs;
2292 $projectstatic =
new Project($this->db);
2293 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
2296 $sql =
"SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
2297 $sql .=
" t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
2298 $sql .=
" t.dateo as date_start, t.datee as datee";
2299 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2302 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2303 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2304 $sql .=
" AND p.fk_statut = 1";
2305 $sql .=
" AND t.fk_projet = p.rowid";
2306 $sql .=
" AND (t.progress IS NULL OR t.progress < 100)";
2307 if (!$user->hasRight(
'projet',
'all',
'lire')) {
2308 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2316 $resql = $this->db->query($sql);
2318 $task_static =
new Task($this->db);
2321 $response->warning_delay = $conf->project->task->warning_delay / 60 / 60 / 24;
2322 $response->label = $langs->trans(
"OpenedTasks");
2323 if ($user->hasRight(
"projet",
"all",
"lire")) {
2324 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mainmenu=project';
2326 $response->url = DOL_URL_ROOT.
'/projet/tasks/list.php?mode=mine&mainmenu=project';
2331 while ($obj = $this->db->fetch_object($resql)) {
2332 $response->nbtodo++;
2334 $task_static->projectstatus = $obj->projectstatus;
2335 $task_static->progress = $obj->progress;
2336 $task_static->fk_statut = $obj->status;
2337 $task_static->date_end = $this->db->jdate($obj->datee);
2339 if ($task_static->hasDelay()) {
2340 $response->nbtodolate++;
2346 $this->error = $this->db->error();
2364 $socid = $user->socid;
2366 $projectstatic =
new Project($this->db);
2367 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid);
2370 $sql =
"SELECT count(p.rowid) as nb";
2371 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
2372 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
2373 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
2374 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = s.rowid";
2376 $sql .=
", ".MAIN_DB_PREFIX.
"projet_task as t";
2377 $sql .=
" WHERE p.entity IN (".getEntity(
'project', 0).
')';
2378 $sql .=
" AND t.fk_projet = p.rowid";
2379 if ($mine || !$user->hasRight(
'projet',
'all',
'lire')) {
2380 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
2385 $sql .=
" AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).
")";
2387 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
2388 $sql .=
" AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).
") OR (s.rowid IS NULL))";
2391 $resql = $this->db->query($sql);
2394 while ($obj = $this->db->fetch_object($resql)) {
2395 $this->nb[
"tasks"] = $obj->nb;
2397 $this->db->free($resql);
2401 $this->error = $this->db->error();
2415 if (!($this->progress >= 0 && $this->progress < 100)) {
2421 $datetouse = ($this->date_end > 0) ? $this->date_end : ((isset($this->datee) && $this->datee > 0) ? $this->datee : 0);
2423 return ($datetouse > 0 && ($datetouse < ($now - $conf->project->task->warning_delay)));
2435 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2437 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2438 $return .=
'<div class="info-box info-box-sm info-box-kanban">';
2439 $return .=
'<span class="info-box-icon bg-infobox-action">';
2442 $return .=
'</span>';
2443 $return .=
'<div class="info-box-content">';
2444 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
2445 if ($selected >= 0) {
2446 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2448 if (!empty($arraydata[
'projectlink'])) {
2451 $return .=
'<br><span class="info-box-status ">'.$arraydata[
'projectlink'].
'</span>';
2453 if (property_exists($this,
'budget_amount')) {
2456 if (property_exists($this,
'duration_effective')) {
2457 $return .=
'<br><br><div class="info-box-label progressinkanban">'.getTaskProgressView($this,
false,
true).
'</div>';
2459 $return .=
'</div>';
2460 $return .=
'</div>';
2461 $return .=
'</div>';
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.
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.
getSumOfAmount($fuser='', $dates='', $datee='')
Calculate quantity and value of time consumed using the thm (hourly amount value of work for user ent...
__construct($db)
Constructor.
fetchTimeSpentOnTask($morewherefilter='')
Fetch records of time spent of this task.
hasTimeSpent()
Return nb of time spent.
getNomUrl($withpicto=0, $option='', $mode='task', $addlabel=0, $sep=' - ', $notooltip=0, $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
getListContactId($source='internal')
Return list of id of contacts of task.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
delTimeSpent($user, $notrigger=0)
Delete time spent.
getTasksArray($usert=null, $userp=null, $projectid=0, $socid=0, $mode=0, $filteronproj='', $filteronprojstatus='-1', $morewherefilter='', $filteronprojuser=0, $filterontaskuser=0, $extrafields=array(), $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,...
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
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.
initAsSpecimen()
Initialise an instance with random values.
load_state_board()
Charge indicateurs this->nb de tableau de bord.
addTimeSpent($user, $notrigger=0)
Add time spent.
hasDelay()
Is the task delayed?
LibStatut($status, $mode=0)
Return status label for an object.
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_move_dir($srcdir, $destdir, $overwriteifexists=1, $indexdatabase=1, $renamedircontent=1)
Move a directory into another name.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_dir_list($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 informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)