mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 10:53:14 +03:00
Added showing all WebJobs in the settings page, sorting jobs by last run date. Fixed showing default WebJobs status
This commit is contained in:
parent
b3e8525c8e
commit
dde8701d74
@ -412,7 +412,6 @@ class RetailcrmJobManager
|
||||
*/
|
||||
private static function setLastRunDetails($lastRuns = [])
|
||||
{
|
||||
RetailcrmLogger::writeDebug(__METHOD__ . ':before', json_encode($lastRuns));
|
||||
if (!is_array($lastRuns)) {
|
||||
$lastRuns = [];
|
||||
}
|
||||
@ -425,7 +424,7 @@ class RetailcrmJobManager
|
||||
}
|
||||
}
|
||||
|
||||
RetailcrmLogger::writeDebug(__METHOD__ . ':after', json_encode($lastRuns));
|
||||
RetailcrmLogger::writeDebug(__METHOD__, json_encode($lastRuns));
|
||||
Configuration::updateGlobalValue(self::LAST_RUN_DETAIL_NAME, (string) json_encode($lastRuns));
|
||||
}
|
||||
|
||||
@ -858,4 +857,22 @@ class RetailcrmJobManager
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of jobs which are allowed to be executed via admin panel
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getAllowedJobs()
|
||||
{
|
||||
return [
|
||||
'RetailcrmAbandonedCartsEvent',
|
||||
'RetailcrmIcmlEvent',
|
||||
'RetailcrmIcmlUpdateUrlEvent',
|
||||
'RetailcrmSyncEvent',
|
||||
'RetailcrmInventoriesEvent',
|
||||
'RetailcrmUpdateSinceIdEvent',
|
||||
'RetailcrmClearLogsEvent',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,23 @@ class RetailcrmSettingsHelper
|
||||
{
|
||||
$jobsInfo = [];
|
||||
|
||||
$allJobsList = RetailcrmJobManager::getAllowedJobs();
|
||||
$lastRunDetails = RetailcrmJobManager::getLastRunDetails();
|
||||
$currentJob = Configuration::get(RetailcrmJobManager::CURRENT_TASK);
|
||||
$currentJobCli = Configuration::get(RetailcrmCli::CURRENT_TASK_CLI);
|
||||
|
||||
foreach ($allJobsList as $job) {
|
||||
if (!isset($lastRunDetails[$job])) {
|
||||
$jobsInfo[] = [
|
||||
'name' => $job,
|
||||
'running' => $job === $currentJob || $job === $currentJobCli,
|
||||
'lastRun' => null,
|
||||
'success' => null,
|
||||
'error' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lastRunDetails as $job => $detail) {
|
||||
$lastRunDetails[$job]['name'] = $job;
|
||||
$lastRunDetails[$job]['running'] = $job === $currentJob || $job === $currentJobCli;
|
||||
@ -64,6 +77,17 @@ class RetailcrmSettingsHelper
|
||||
$jobsInfo[] = $lastRunDetails[$job]; // todo refactor
|
||||
}
|
||||
|
||||
$orderBy = 'lastRun';
|
||||
$orderDirection = SORT_DESC;
|
||||
|
||||
array_multisort(
|
||||
array_map(function ($item) use ($orderBy) {
|
||||
return $item[$orderBy];
|
||||
}, $jobsInfo),
|
||||
$orderDirection,
|
||||
$jobsInfo
|
||||
);
|
||||
|
||||
return $jobsInfo;
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,13 @@ class RetailcrmSettingsItem
|
||||
{
|
||||
private $paramKey;
|
||||
protected $configKey;
|
||||
private $default;
|
||||
|
||||
public function __construct($paramKey, $configKey)
|
||||
public function __construct($paramKey, $configKey, $default = '')
|
||||
{
|
||||
$this->paramKey = $paramKey;
|
||||
$this->configKey = $configKey;
|
||||
$this->default = $default;
|
||||
}
|
||||
|
||||
public function updateValue()
|
||||
@ -80,7 +82,7 @@ class RetailcrmSettingsItem
|
||||
|
||||
public function getValueStored()
|
||||
{
|
||||
return Configuration::get($this->configKey, null, null, null, '');
|
||||
return Configuration::get($this->configKey, null, null, null, $this->default);
|
||||
}
|
||||
|
||||
public function getValueWithStored()
|
||||
|
@ -61,7 +61,7 @@ class RetailcrmSettingsItems
|
||||
'enableCorporate' => new RetailcrmSettingsItemBool('enableCorporate', RetailCRM::ENABLE_CORPORATE_CLIENTS),
|
||||
'enableOrderNumberSending' => new RetailcrmSettingsItemBool('enableOrderNumberSending', RetailCRM::ENABLE_ORDER_NUMBER_SENDING),
|
||||
'enableOrderNumberReceiving' => new RetailcrmSettingsItemBool('enableOrderNumberReceiving', RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING),
|
||||
'webJobs' => new RetailcrmSettingsItemBool('webJobs', RetailCRM::ENABLE_WEB_JOBS),
|
||||
'webJobs' => new RetailcrmSettingsItemBool('webJobs', RetailCRM::ENABLE_WEB_JOBS, '1'),
|
||||
'debugMode' => new RetailcrmSettingsItemBool('debugMode', RetailCRM::ENABLE_DEBUG_MODE),
|
||||
|
||||
'deliveryDefault' => new RetailcrmSettingsItem('deliveryDefault', RetailCRM::DELIVERY_DEFAULT),
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user