From 0968c68cf91a3cf937ad43a54ea6533b6b49660a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Dec 2020 12:45:43 +0100 Subject: [PATCH] Enhance widget --- htdocs/core/boxes/box_scheduled_jobs.php | 16 ++++++++++------ htdocs/core/lib/functions.lib.php | 2 +- htdocs/cron/class/cronjob.class.php | 9 ++++++--- .../template/class/myobject.class.php | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 1739c6ab8e9..afe71f09043 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -79,12 +79,13 @@ class box_scheduled_jobs extends ModeleBoxes if ($user->rights->cron->read) { include_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; $cronstatic = new Cronjob($this->db); - $nomUrlArray; + $resultarray = array(); $result = 0; - $sql = "SELECT t.rowid, t.datelastrun, t.datenextrun"; - $sql .= ", t.label, t.status, t.lastresult"; + $sql = "SELECT t.rowid, t.datelastrun, t.datenextrun,"; + $sql .= " t.label, t.status, t.lastresult"; $sql .= " FROM " . MAIN_DB_PREFIX . "cronjob as t"; + $sql .= " WHERE status <> ".$cronstatic::STATUS_DISABLED; $sql .= $this->db->order("t.datelastrun", "DESC"); $result = $this->db->query($sql); @@ -98,6 +99,7 @@ class box_scheduled_jobs extends ModeleBoxes if ($line == 0 || $objp->datenextrun < $cronstatic->datenextrun) { $cronstatic->id = $objp->rowid; $cronstatic->ref = $objp->rowid; + $cronstatic->label = $langs->trans($objp->label); $cronstatic->status = $objp->status; $cronstatic->datenextrun = $objp->datenextrun; $cronstatic->datelastrun = $objp->datelastrun; @@ -107,7 +109,8 @@ class box_scheduled_jobs extends ModeleBoxes $langs->trans("LastExecutedScheduledJob"), $cronstatic->getNomUrl(1), $this->db->jdate($cronstatic->datelastrun), - $cronstatic->status + $cronstatic->status, + $cronstatic->getLibStatut(2) ); $line++; } @@ -120,7 +123,8 @@ class box_scheduled_jobs extends ModeleBoxes $langs->trans("NextScheduledJobExecute"), $cronstatic->getNomUrl(1), $this->db->jdate($cronstatic->datenextrun), - $cronstatic->status + $cronstatic->status, + $cronstatic->getLibStatut(2) ); $line = 0; while ($line < 2) { @@ -139,7 +143,7 @@ class box_scheduled_jobs extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right" ', - 'textnoformat' => empty($resultarray[$line][3]) ? $langs->trans("Disabled") : $langs->trans("Scheduled") + 'textnoformat' => $resultarray[$line][4] ); $line++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e5816a7ea71..8b9edcd89ba 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3206,7 +3206,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', - 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', + 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cron', 'cubes', 'delete', 'dolly', 'dollyrevert', 'donation', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index e58abf24223..9d084ec4f24 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -820,9 +820,12 @@ class Cronjob extends CommonObject $result = ''; - $label = ''.$langs->trans("CronJob").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label = img_picto('', 'object_'.$this->picto).' '.$langs->trans("CronTask").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + $label .= '
'.$langs->trans('Title').': '.$this->label; $url = DOL_URL_ROOT.'/cron/card.php?id='.$this->id; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a8bed45c46a..a15f0f67fe9 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -744,11 +744,11 @@ class MyObject extends CommonObject $result = ''; $label = img_picto('', $this->picto).' '.$langs->trans("MyObject").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; - if (isset($this->status)) { - $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); - } $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id;