Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
bf783cb068
@ -269,3 +269,5 @@ OneLinePerPeriod=One line per period
|
||||
RefTaskParent=Ref. Parent Task
|
||||
ProfitIsCalculatedWith=Profit is calculated using
|
||||
AddPersonToTask=Add also to tasks
|
||||
PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress)
|
||||
PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects.
|
||||
|
||||
@ -268,3 +268,5 @@ OneLinePerTask=Une ligne par tâche
|
||||
OneLinePerPeriod=Une ligne par période
|
||||
RefTaskParent=Réf. Tâche parent
|
||||
ProfitIsCalculatedWith=Le bénéfice est calculé sur la base de
|
||||
PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classer le projet à clôturé lorsque toutes les tâches de ce projet sont à 100 %% de progression
|
||||
PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Non rétroactif : l’activation de cette option ne clôturera pas les projets dont les tâches sont déjà à 100 %%. Cette option ne classe que les projets ouverts.
|
||||
|
||||
@ -244,6 +244,12 @@ elseif ($action == 'setdoc')
|
||||
}
|
||||
}
|
||||
|
||||
// Set boolean (on/off) constants
|
||||
elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
|
||||
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -840,6 +846,16 @@ print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany'));
|
||||
print '<input type="submit" class="button" name="PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
|
||||
$key = 'PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE';
|
||||
echo '<tr class="oddeven">',
|
||||
'<td class="left">',
|
||||
$form->textwithpicto($langs->transnoentities($key), $langs->transnoentities($key . '_help')),
|
||||
'</td>',
|
||||
'<td class="right" colspan="2">',
|
||||
ajax_constantonoff($key),
|
||||
'</td>',
|
||||
'</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
@ -383,13 +383,35 @@ class Task extends CommonObject
|
||||
|
||||
// Update extrafield
|
||||
if (!$error) {
|
||||
if (!$error)
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && $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;
|
||||
},
|
||||
1
|
||||
);
|
||||
if ($projectCompleted) {
|
||||
if ($project->setClose($user) <= 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
if ($error) {
|
||||
$this->errors[] = $project->error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user