FIX : we can't update task if closed project because of wrong test with PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE conf

This commit is contained in:
Gauthier PC portable 024 2021-04-06 16:59:00 +02:00
parent 10fb793fb1
commit 04cb8453f0

View File

@ -402,20 +402,23 @@ class Task extends CommonObject
if (!$error && !empty($conf->global->PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE)) {
// Close the parent project if it is open (validated) and its tasks are 100% completed
$project = new Project($this->db);
if ($project->fetch($this->fk_project) > 0 && $project->statut == Project::STATUS_VALIDATED) {
$project->getLinesArray(null); // this method does not return <= 0 if fails
$projectCompleted = array_reduce(
$project->lines,
function ($allTasksCompleted, $task) {
return $allTasksCompleted && $task->progress >= 100;
},
if ($project->fetch($this->fk_project) > 0) {
if($project->statut == Project::STATUS_VALIDATED) {
$project->getLinesArray(null); // this method does not return <= 0 if fails
$projectCompleted = array_reduce(
$project->lines,
function ($allTasksCompleted, $task) {
return $allTasksCompleted && $task->progress >= 100;
},
1
);
if ($projectCompleted) {
if ($project->setClose($user) <= 0) {
$error++;
);
if ($projectCompleted) {
if ($project->setClose($user) <= 0) {
$error++;
}
}
}
} else {
$error++;
}