FIX: projet time spent: also restrict to X months back for update and delete
This commit is contained in:
parent
6733d278d8
commit
7317aad41f
@ -1465,6 +1465,17 @@ class Task extends CommonObject
|
||||
if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date;
|
||||
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
|
||||
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||
|
||||
if ($this->timespent_date < $restrictBefore) {
|
||||
$this->error = $langs->trans('TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
|
||||
$this->errors[] = $this->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
|
||||
@ -1530,6 +1541,17 @@ class Task extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||
|
||||
if ($this->timespent_date < $restrictBefore) {
|
||||
$this->error = $langs->trans('TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
|
||||
$this->errors[] = $this->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user