Fix date for tasks created during project creation

This commit is contained in:
Laurent Destailleur 2021-09-24 02:10:42 +02:00
parent 8fb5286260
commit 4c80e0425b
2 changed files with 11 additions and 8 deletions

View File

@ -101,8 +101,11 @@ class InterfaceEventOrganization extends DolibarrTriggers
$defaultref = '';
}
$task->ref = $defaultref;
$task->date_start = $object->date_start;
$task->date_end = $object->date_end;
// TODO Can set offset for start date or endline from setup of task to create when creating event
$task->date_start = null;
$task->date_end = null;
$result = $task->create($user);
if ($result < 0) {
$this->errors=array_merge($this->errors, $task->errors);

View File

@ -173,16 +173,16 @@ class Task extends CommonObject
$sql .= ", planned_workload";
$sql .= ", progress";
$sql .= ") VALUES (";
$sql .= $conf->entity;
$sql .= ", ".$this->fk_project;
$sql .= ((int) $conf->entity);
$sql .= ", ".((int) $this->fk_project);
$sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null');
$sql .= ", ".$this->fk_task_parent;
$sql .= ", ".((int) $this->fk_task_parent);
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->escape($this->description)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".$user->id;
$sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= ", ".((int) $user->id);
$sql .= ", ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? $this->planned_workload : 'null');
$sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null');
$sql .= ")";