NEW Can set a monthly frequency (or multiple) in cron tasks.
This commit is contained in:
parent
46b5f80db9
commit
ae31b595e5
@ -473,6 +473,16 @@ if (($action == "create") || ($action == "edit")) {
|
||||
}
|
||||
$input .= "<label for=\"frequency_semaine\">".$langs->trans('Weeks')."</label>";
|
||||
print $input;
|
||||
|
||||
$input = " <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
|
||||
if ($object->unitfrequency == "2678400") {
|
||||
$input .= ' checked />';
|
||||
} else {
|
||||
$input .= ' />';
|
||||
}
|
||||
$input .= "<label for=\"frequency_month\">".$langs->trans('Monthly')."</label>";
|
||||
print $input;
|
||||
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print "</td>";
|
||||
@ -664,6 +674,9 @@ if (($action == "create") || ($action == "edit")) {
|
||||
if ($object->unitfrequency == "604800") {
|
||||
print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
|
||||
}
|
||||
if ($object->unitfrequency == "2678400") {
|
||||
print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Month');
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2007-2022 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
|
||||
|
||||
|
||||
/**
|
||||
@ -1408,21 +1409,30 @@ class Cronjob extends CommonObject
|
||||
|
||||
if (empty($this->datenextrun)) {
|
||||
if (empty($this->datestart)) {
|
||||
$this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
|
||||
if ($this->unitfrequency == 2678400) {
|
||||
$this->datenextrun = dol_time_plus_duree($now, $this->frequency, 'm');
|
||||
} else {
|
||||
$this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
|
||||
}
|
||||
} else {
|
||||
$this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency);
|
||||
if ($this->unitfrequency == 2678400) {
|
||||
$this->datenextrun = dol_time_plus_duree($this->datestart, $this->frequency, 'm');
|
||||
} else {
|
||||
$this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0) {
|
||||
// Loop until date is after future
|
||||
while ($this->datenextrun < $now) {
|
||||
$this->datenextrun += ($this->frequency * $this->unitfrequency);
|
||||
|
||||
// TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
if ($this->unitfrequency == 2678400) {
|
||||
$this->datenextrun = dol_time_plus_duree($this->datenextrun, $this->frequency, 'm');
|
||||
} else {
|
||||
$this->datenextrun += ($this->frequency * $this->unitfrequency);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency);
|
||||
dol_syslog(get_class($this)."::reprogram_jobs datenextrun is already in future, we do not change it");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user