From 61fc81732c02bffd5cd18063dcbf667acb9a7e14 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 11:29:43 +0100 Subject: [PATCH] fix: #19749 --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/class/task.class.php | 10 ++++++++++ htdocs/projet/tasks/task.php | 1 + 3 files changed, 12 insertions(+) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index c19f32a0396..9d3a83c7a61 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -284,3 +284,4 @@ PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with al SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them ProjectTasksWithoutTimeSpent=Project tasks without time spent FormForNewLeadDesc=Thanks to fill the following form to contact us. You can also send us an email directly to %s. +StartDateCannotBeAfterEndDate=End date cannot be before start date diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index dac2afa4834..d0b27caf326 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -165,6 +165,11 @@ class Task extends CommonObject $this->label = trim($this->label); $this->description = trim($this->description); + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values @@ -384,6 +389,11 @@ class Task extends CommonObject $this->budget_amount = trim($this->budget_amount); } + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8feb682f023..8e773f92788 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -117,6 +117,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; } } } else {