diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index cabe14be219..f833504f065 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -430,9 +430,10 @@ class Cronjob extends CommonObject
* @param int $id Id object
* @param string $objectname Object name
* @param string $methodname Method name
+ * @param string $label Label
* @return int if KO: <0 || if OK: >0
*/
- public function fetch(int $id, string $objectname = '', string $methodname = '')
+ public function fetch(int $id, string $objectname = '', string $methodname = '', string $label = '')
{
$sql = "SELECT";
$sql .= " t.rowid,";
@@ -472,13 +473,15 @@ class Cronjob extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."cronjob as t";
if ($id > 0) {
$sql .= " WHERE t.rowid = ".((int) $id);
+ } elseif ($label) {
+ $sql .= " WHERE t.entity IN(0, ".getEntity('cron').")";
+ $sql .= " AND t.label = '".$this->db->escape($label)."'";
} else {
$sql .= " WHERE t.entity IN(0, ".getEntity('cron').")";
$sql .= " AND t.objectname = '".$this->db->escape($objectname)."'";
$sql .= " AND t.methodename = '".$this->db->escape($methodname)."'";
}
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->num_rows($resql)) {
@@ -488,6 +491,7 @@ class Cronjob extends CommonObject
$this->ref = $obj->rowid;
$this->entity = $obj->entity;
$this->tms = $this->db->jdate($obj->tms);
+ $this->date_modification = $this->db->jdate($obj->tms);
$this->datec = $this->db->jdate($obj->datec);
$this->label = $obj->label;
$this->jobtype = $obj->jobtype;
diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php
index b1fa1ec9967..c6b4a298468 100644
--- a/htdocs/datapolicy/admin/setup.php
+++ b/htdocs/datapolicy/admin/setup.php
@@ -29,6 +29,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT.'/datapolicy/lib/datapolicy.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
/**
* @var Conf $conf
@@ -256,8 +257,13 @@ print dol_get_fiche_head($head, 'settings', '', -1, '');
print ''.$langs->trans("datapolicySetupPage").'';
print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP', $langs->transnoentitiesnoconv("DATAPOLICYJob"), $langs->transnoentitiesnoconv("CronList")));
if (!isModEnabled('cron')) {
- print info_admin($langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentities("CronList")), 0, 0, 'warning');
+ print info_admin($langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("CronList")), 0, 0, 'warning');
} else {
+ $tmpjob = new Cronjob($db);
+ $tmpjob->fetch(0, '', '', 'DATAPOLICYJob');
+ if ($tmpjob->status != $tmpjob::STATUS_ENABLED) {
+ print info_admin($langs->trans("JobMustBeEnabledFirst", $langs->transnoentitiesnoconv("DATAPOLICYJob"), $langs->transnoentitiesnoconv("CronList")), 0, 0, 'warning');
+ }
}
print '
';
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 1151a285c5b..b8de0d813bb 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -415,7 +415,8 @@ ThemeDir=Skins directory
ConnectionTimeout=Connection timeout
ResponseTimeout=Response timeout
SmsTestMessage=Test message from __PHONEFROM__ to __PHONETO__
-ModuleMustBeEnabledFirst=Module %s must be enabled first if you need this feature.
+ModuleMustBeEnabledFirst=The module %s must be enabled first if you need this feature.
+JobMustBeEnabledFirst=The scheduled job %s is not enabled. It must be enabled first if you need this feature (see the setup of module %s).
SecurityToken=Key to secure URLs
NoSmsEngine=No SMS sender manager available. A SMS sender manager is not installed with the default distribution because they depend on an external vendor, but you can find some on %s
PDF=PDF