Move logs to var, split it by days, add task to remove old logs

This commit is contained in:
max-baranikov 2021-05-28 14:32:43 +03:00 committed by GitHub
parent 1c86091b56
commit 6cdb1f48a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 494 additions and 79 deletions

View File

@ -374,8 +374,9 @@ class RetailcrmCli
'RetailcrmIcmlEvent',
'RetailcrmSyncEvent',
'RetailcrmInventoriesEvent',
'RetailcrmExportEvent',
'RetailcrmUpdateSinceIdEvent',
'RetailcrmExportEvent'
'RetailcrmClearLogsEvent'
);
}
}

View File

@ -724,6 +724,9 @@ class RetailcrmHistory
}
$orderToUpdate = new Order((int)$order['externalId']);
if(!Validate::isLoadedObject($orderToUpdate)) {
continue;
}
self::handleCustomerDataChange($orderToUpdate, $order);
/*

View File

@ -191,11 +191,6 @@ class RetailcrmJobManager
sprintf('Executed job %s, result: %s', $job, $result ? 'true' : 'false')
);
$lastRuns[$job] = new \DateTime('now');
$lastRunsDetails[$job] = [
'success' => true,
'lastRun' => new \DateTime('now'),
'error' => null,
];
break;
}
@ -241,6 +236,12 @@ class RetailcrmJobManager
}
if (isset($result) && $result) {
$lastRunsDetails[$job] = [
'success' => true,
'lastRun' => new \DateTime('now'),
'error' => null,
];
self::clearCurrentJob($job);
}
@ -325,7 +326,7 @@ class RetailcrmJobManager
* @return array<string, array>
* @throws \Exception
*/
private static function getLastRunDetails()
public static function getLastRunDetails()
{
$lastRuns = json_decode((string)Configuration::getGlobalValue(self::LAST_RUN_DETAIL_NAME), true);

View File

@ -0,0 +1,91 @@
<?php
/**
* MIT License
*
* Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Class RetailcrmLogger
* @author DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @license GPL
* @link https://retailcrm.ru
*/
class RetailcrmJsonResponse
{
private static function jsonResponse($response)
{
header('Content-Type: application/json');
$result = json_encode($response);
echo $result;
return $result;
}
public static function invalidResponse($msg, $status = 404)
{
http_response_code($status);
return self::jsonResponse([
'success' => false,
'errorMsg' => $msg
]);
}
public static function successfullResponse($data = null, $key = null)
{
$response = [
'success' => true,
];
if (!is_null($data)) {
if (is_array($key)) {
foreach ($key as $i => $value) {
if (isset($data[$i]))
$response[$value] = $data[$i];
}
} elseif (is_string($key)) {
$response[$key] = $data;
} else {
$response['response'] = $data;
}
}
return self::jsonResponse($response);
}
}

View File

@ -176,7 +176,12 @@ class RetailcrmLogger
return '';
}
return _PS_ROOT_DIR_ . '/retailcrm_' . self::getLogFilePrefix() . '.log';
return self::getLogDir() . '/retailcrm_' . self::getLogFilePrefix() . '_' . date('Y_m_d') . '.log';
}
public static function getLogDir()
{
return _PS_ROOT_DIR_ . '/var/logs';
}
/**
@ -196,4 +201,56 @@ class RetailcrmLogger
return 'web';
}
/**
* Removes module log files from var/logs which is older than 30 days
*/
public static function clearObsoleteLogs()
{
$logDir = self::getLogDir();
$handle = opendir($logDir);
while (($file = readdir($handle)) !== false) {
if (false !== self::checkFileName($file)) {
$path = "$logDir/$file";
if (filemtime($path) < strtotime('-30 days')) {
unlink($path);
}
}
}
}
public static function getLogFilesInfo()
{
$fileNames = [];
$logDir = self::getLogDir();
$handle = opendir($logDir);
while (false !== $file = readdir($handle)) {
if (false !== self::checkFileName($file)) {
$path = "$logDir/$file";
$fileNames[] = [
'name' => $file,
'path' => $path,
'size' => number_format(filesize($path), 0, '.', ' ') . ' bytes',
'modified' => date('Y-m-d H:i:s', filemtime($path)),
];
}
}
closedir($handle);
return $fileNames;
}
public static function checkFileName($file)
{
$logDir = self::getLogDir();
if (preg_match('/^retailcrm[a-zA-Z0-9-_]+.log$/', $file)) {
$path = "$logDir/$file";
if (is_file($path)) {
return $path;
}
}
return false;
}
}

View File

@ -410,16 +410,14 @@ class RetailcrmTools
}
/**
* Returns true if PrestaShop in debug mode or _RCRM_MODE_DEV_ const defined to true.
* Add define('_RCRM_MODE_DEV_', true); to enable extended logging (dev mode) ONLY for retailCRM module.
* Returns true if debug mode is checked in advance settings page
* In developer mode module will log every JobManager run and every request and response from retailCRM API.
*
* @return bool
*/
public static function isDebug()
{
return (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ == true)
|| (defined('_RCRM_MODE_DEV_') && _RCRM_MODE_DEV_ == true);
return '1' === Configuration::get(RetailCRM::ENABLE_DEBUG_MODE);
}
/**
@ -633,10 +631,11 @@ class RetailcrmTools
public static function startJobManager()
{
RetailcrmJobManager::startJobs(array(
'RetailcrmAbandonedCartsEvent' => new \DateInterval('PT1M'),
'RetailcrmClearLogsEvent' => new \DateInterval('P1D'),
'RetailcrmIcmlEvent' => new \DateInterval('PT4H'),
'RetailcrmInventoriesEvent' => new \DateInterval('PT15M'),
'RetailcrmSyncEvent' => new \DateInterval('PT7M'),
'RetailcrmInventoriesEvent' => new \DateInterval('PT15M')
'RetailcrmAbandonedCartsEvent' => new \DateInterval('PT1M')
));
}

View File

@ -0,0 +1,66 @@
<?php
/**
* MIT License
*
* Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
require_once(dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php');
class RetailcrmClearLogsEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface
{
/**
* @inheritDoc
*/
public function execute()
{
if ($this->isRunning()) {
return false;
}
$this->setRunning();
RetailcrmLogger::clearObsoleteLogs();
return true;
}
/**
* @inheritDoc
*/
public function getName()
{
return 'RetailcrmClearLogsEvent';
}
}

View File

@ -68,6 +68,10 @@ class RetailcrmExportEvent extends RetailcrmAbstractEvent implements RetailcrmEv
RetailcrmExport::$api = $api;
RetailcrmExport::exportOrders();
RetailcrmExport::exportCustomers();
RetailcrmHistory::$api = $api;
RetailcrmHistory::updateSinceId('customers');
RetailcrmHistory::updateSinceId('orders');
}
return true;

View File

@ -79,6 +79,10 @@ class RetailcrmSettingsTemplate extends RetailcrmAbstractTemplate
$params['exportCustomersCount'] = RetailcrmExport::getCustomersCount(false);
$params['exportOrdersStepSize'] = RetailcrmExport::RETAILCRM_EXPORT_ORDERS_STEP_SIZE_WEB;
$params['exportCustomersStepSize'] = RetailcrmExport::RETAILCRM_EXPORT_CUSTOMERS_STEP_SIZE_WEB;
$params['lastRunDetails'] = RetailcrmJobManager::getLastRunDetails();
$params['currentJob'] = Configuration::get(RetailcrmJobManager::CURRENT_TASK);
$params['currentJobCli'] = Configuration::get(RetailcrmCli::CURRENT_TASK_CLI);
$params['retailcrmLogsInfo'] = RetailcrmLogger::getLogFilesInfo();
}
return $params;

View File

@ -65,10 +65,14 @@ class RetailCRM extends Module
const UPLOAD_ORDERS = 'RETAILCRM_UPLOAD_ORDERS_ID';
const EXPORT_ORDERS = 'RETAILCRM_EXPORT_ORDERS_STEP';
const EXPORT_CUSTOMERS = 'RETAILCRM_EXPORT_CUSTOMERS_STEP';
const UPDATE_SINCE_ID = 'RETAILCRM_UPDATE_SINCE_ID';
const DOWNLOAD_LOGS_NAME = 'RETAILCRM_DOWNLOAD_LOGS_NAME';
const DOWNLOAD_LOGS = 'RETAILCRM_DOWNLOAD_LOGS';
const MODULE_LIST_CACHE_CHECKSUM = 'RETAILCRM_MODULE_LIST_CACHE_CHECKSUM';
const ENABLE_CORPORATE_CLIENTS = 'RETAILCRM_ENABLE_CORPORATE_CLIENTS';
const ENABLE_HISTORY_UPLOADS = 'RETAILCRM_ENABLE_HISTORY_UPLOADS';
const ENABLE_BALANCES_RECEIVING = 'RETAILCRM_ENABLE_BALANCES_RECEIVING';
const ENABLE_DEBUG_MODE = 'RETAILCRM_ENABLE_DEBUG_MODE';
const LATEST_API_VERSION = '5';
const CONSULTANT_SCRIPT = 'RETAILCRM_CONSULTANT_SCRIPT';
@ -78,7 +82,8 @@ class RetailCRM extends Module
'RetailcrmAbandonedCartsEvent' => 'Abandoned Carts',
'RetailcrmIcmlEvent' => 'Icml generation',
'RetailcrmSyncEvent' => 'History synchronization',
'RetailcrmInventoriesEvent' => 'Inventories uploads'
'RetailcrmInventoriesEvent' => 'Inventories uploads',
'RetailcrmClearLogsEvent' => 'Clearing logs'
];
/**
@ -226,6 +231,7 @@ class RetailCRM extends Module
Configuration::deleteByName(static::ENABLE_CORPORATE_CLIENTS) &&
Configuration::deleteByName(static::ENABLE_HISTORY_UPLOADS) &&
Configuration::deleteByName(static::ENABLE_BALANCES_RECEIVING) &&
Configuration::deleteByName(static::ENABLE_DEBUG_MODE) &&
Configuration::deleteByName('RETAILCRM_LAST_SYNC') &&
Configuration::deleteByName('RETAILCRM_LAST_ORDERS_SYNC') &&
Configuration::deleteByName('RETAILCRM_LAST_CUSTOMERS_SYNC') &&
@ -265,6 +271,9 @@ class RetailCRM extends Module
$ordersIds = (string)(Tools::getValue(static::UPLOAD_ORDERS));
$exportOrders = (int)(Tools::getValue(static::EXPORT_ORDERS));
$exportCustomers = (int)(Tools::getValue(static::EXPORT_CUSTOMERS));
$updateSinceId = (bool)(Tools::getValue(static::UPDATE_SINCE_ID));
$logNames = (string)(Tools::getValue(static::DOWNLOAD_LOGS_NAME));
$downloadLogs = (bool)(Tools::getValue(static::DOWNLOAD_LOGS));
if (!empty($ordersIds)) {
$output .= $this->uploadOrders(RetailcrmTools::partitionId($ordersIds));
@ -272,6 +281,10 @@ class RetailCRM extends Module
return $this->export($exportOrders);
} elseif (!empty($exportCustomers)) {
return $this->export($exportCustomers, 'customer');
} elseif ($updateSinceId) {
return $this->updateSinceId();
} elseif ($downloadLogs) {
return $this->downloadLogs($logNames);
} else {
$output .= $this->saveSettings();
}
@ -372,16 +385,18 @@ class RetailCRM extends Module
*/
public function export($step, $entity = 'order')
{
if (!Tools::getValue('ajax'))
return RetailcrmJsonResponse::invalidResponse('This method allow only in ajax mode');
$step--;
if ($step < 0)
return false;
return RetailcrmJsonResponse::invalidResponse('Invalid request data');
$api = RetailcrmTools::getApiClient();
if (empty($api)) {
RetailcrmLogger::writeCaller(__METHOD__, 'Set API key & URL first');
return false;
return RetailcrmJsonResponse::invalidResponse('Set API key & URL first');
}
RetailcrmExport::init();
@ -401,6 +416,65 @@ class RetailCRM extends Module
// todo maybe save current step to database
}
return RetailcrmJsonResponse::successfullResponse();
}
public function updateSinceId()
{
if (!Tools::getValue('ajax'))
return RetailcrmJsonResponse::invalidResponse('This method allow only in ajax mode');
$api = RetailcrmTools::getApiClient();
if (empty($api)) {
RetailcrmLogger::writeCaller(__METHOD__, 'Set API key & URL first');
return RetailcrmJsonResponse::invalidResponse('Set API key & URL first');
}
RetailcrmHistory::$api = $api;
RetailcrmHistory::updateSinceId('customers');
RetailcrmHistory::updateSinceId('orders');
return RetailcrmJsonResponse::successfullResponse();
}
public function downloadLogs($name = '')
{
if (!Tools::getValue('ajax'))
return false;
if (!empty($name)) {
if (false === ($filePath = RetailcrmLogger::checkFileName($name))) {
return false;
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($filePath) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
} else {
$zipname = _PS_DOWNLOAD_DIR_ . '/retailcrm_logs_' . date('Y-m-d H-i-s') . '.zip';
$zipFile = new ZipArchive();
$zipFile->open($zipname, ZIPARCHIVE::CREATE);
foreach (RetailcrmLogger::getLogFilesInfo() as $logFile) {
$zipFile->addFile($logFile['path'], $logFile['name']);
}
$zipFile->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . basename($zipname));
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
unlink($zipname);
}
return true;
}
@ -811,6 +885,7 @@ class RetailCRM extends Module
'enableCorporate' => (Tools::getValue(static::ENABLE_CORPORATE_CLIENTS) !== false),
'enableHistoryUploads' => (Tools::getValue(static::ENABLE_HISTORY_UPLOADS) !== false),
'enableBalancesReceiving' => (Tools::getValue(static::ENABLE_BALANCES_RECEIVING) !== false),
'debugMode' => (Tools::getValue(static::ENABLE_DEBUG_MODE) !== false),
'collectorActive' => (Tools::getValue(static::COLLECTOR_ACTIVE) !== false),
'collectorKey' => (string)(Tools::getValue(static::COLLECTOR_KEY)),
'clientId' => Configuration::get(static::CLIENT_ID),
@ -838,6 +913,7 @@ class RetailCRM extends Module
Configuration::updateValue(static::SYNC_CARTS_ACTIVE, $settings['synchronizeCartsActive']);
Configuration::updateValue(static::SYNC_CARTS_STATUS, $settings['synchronizedCartStatus']);
Configuration::updateValue(static::SYNC_CARTS_DELAY, $settings['synchronizedCartDelay']);
Configuration::updateValue(static::ENABLE_DEBUG_MODE, $settings['debugMode']);
$this->apiUrl = $settings['url'];
$this->apiKey = $settings['apiKey'];
@ -1093,7 +1169,6 @@ class RetailCRM extends Module
'deliveryDefault' => json_decode(Configuration::get(static::DELIVERY_DEFAULT), true),
'paymentDefault' => json_decode(Configuration::get(static::PAYMENT_DEFAULT), true),
'statusExport' => (string)(Configuration::get(static::STATUS_EXPORT)),
'lastRunDetails' => json_decode(Configuration::get(RetailcrmJobManager::LAST_RUN_DETAIL_NAME), true),
'collectorActive' => (Configuration::get(static::COLLECTOR_ACTIVE)),
'collectorKey' => (string)(Configuration::get(static::COLLECTOR_KEY)),
'clientId' => Configuration::get(static::CLIENT_ID),
@ -1104,6 +1179,7 @@ class RetailCRM extends Module
'enableCorporate' => (bool)(Configuration::get(static::ENABLE_CORPORATE_CLIENTS)),
'enableHistoryUploads' => (bool)(Configuration::get(static::ENABLE_HISTORY_UPLOADS)),
'enableBalancesReceiving' => (bool)(Configuration::get(static::ENABLE_BALANCES_RECEIVING)),
'debugMode' => (bool)(Configuration::get(static::ENABLE_DEBUG_MODE)),
);
}
@ -1134,6 +1210,7 @@ class RetailCRM extends Module
'enableCorporateName' => static::ENABLE_CORPORATE_CLIENTS,
'enableHistoryUploadsName' => static::ENABLE_HISTORY_UPLOADS,
'enableBalancesReceivingName' => static::ENABLE_BALANCES_RECEIVING,
'debugModeName' => static::ENABLE_DEBUG_MODE,
'jobsNames' => static::JOBS_NAMES
);
}

View File

@ -69,6 +69,16 @@ $_MODULE['<{retailcrm}prestashop>settings_54e85d70ea67acdcc86963b14d6223a8'] = '
$_MODULE['<{retailcrm}prestashop>settings_5ae96cfe7ea77a401db8e0d5dbab333c'] = 'Generación Icml';
$_MODULE['<{retailcrm}prestashop>settings_9abdd7d7fa90b7aa19e8ca8fb9f04ee4'] = 'Sincronización de historia';
$_MODULE['<{retailcrm}prestashop>settings_e1d641ca2884dbd4398e9252c0ab511e'] = 'Cargas de inventarios';
$_MODULE['<{retailcrm}prestashop>settings_540c49e6e05ff1d08a23d23f34f70d80'] = 'Borrado de registros';
$_MODULE['<{retailcrm}prestashop>settings_9b6545e4cea9b4ad4979d41bb9170e2b'] = 'Avanzado';
$_MODULE['<{retailcrm}prestashop>settings_ec3028a12402ab7f43962a6f3a667b6e'] = 'Modo de depuración';
$_MODULE['<{retailcrm}prestashop>settings_b2d37ae1cedf42ff874289b721860af2'] = 'Registros';
$_MODULE['<{retailcrm}prestashop>settings_34082694d21dbdcfc31e6e32d9fb2b9f'] = 'Nombre del archivo';
$_MODULE['<{retailcrm}prestashop>settings_a4b7f1864cfdb47cd05b54eb10337506'] = 'Fecha de modificación';
$_MODULE['<{retailcrm}prestashop>settings_6f6cb72d544962fa333e2e34ce64f719'] = 'Tamaño';
$_MODULE['<{retailcrm}prestashop>settings_06df33001c1d7187fdd81ea1f5b277aa'] = 'Comportamiento';
$_MODULE['<{retailcrm}prestashop>settings_801ab24683a4a8c433c6eb40c48bcd9d'] = 'Descargar';
$_MODULE['<{retailcrm}prestashop>settings_61b0ada67b7f40bf3d40dcc88ae4f3e6'] = 'Descargar todo';
$_MODULE['<{retailcrm}prestashop>index_f545947db05aa489f59babf06c319d06'] = 'RetailCRM es un servicio para tiendas online, el cual ayuda a dejar de perder pedidos y así mejorar las ganancias de tu comercio online en todas las etapas del embudo de ventas.';
$_MODULE['<{retailcrm}prestashop>index_96f5fae5347f2f1cf560e71a30420fec'] = 'Tengo una cuenta en RetailCRM';
$_MODULE['<{retailcrm}prestashop>index_e81c4e4f2b7b93b481e13a8553c2ae1b'] = 'o';

View File

@ -69,6 +69,16 @@ $_MODULE['<{retailcrm}prestashop>settings_54e85d70ea67acdcc86963b14d6223a8'] = '
$_MODULE['<{retailcrm}prestashop>settings_5ae96cfe7ea77a401db8e0d5dbab333c'] = 'Генерация Icml';
$_MODULE['<{retailcrm}prestashop>settings_9abdd7d7fa90b7aa19e8ca8fb9f04ee4'] = 'Синхронизация истории';
$_MODULE['<{retailcrm}prestashop>settings_e1d641ca2884dbd4398e9252c0ab511e'] = 'Выгрузка остатков';
$_MODULE['<{retailcrm}prestashop>settings_540c49e6e05ff1d08a23d23f34f70d80'] = 'Очистка лог-файлов';
$_MODULE['<{retailcrm}prestashop>settings_9b6545e4cea9b4ad4979d41bb9170e2b'] = 'Дополнительно';
$_MODULE['<{retailcrm}prestashop>settings_ec3028a12402ab7f43962a6f3a667b6e'] = 'Режим отладки';
$_MODULE['<{retailcrm}prestashop>settings_b2d37ae1cedf42ff874289b721860af2'] = 'Лог-файлы';
$_MODULE['<{retailcrm}prestashop>settings_34082694d21dbdcfc31e6e32d9fb2b9f'] = 'Имя файла';
$_MODULE['<{retailcrm}prestashop>settings_a4b7f1864cfdb47cd05b54eb10337506'] = 'Дата изменения';
$_MODULE['<{retailcrm}prestashop>settings_6f6cb72d544962fa333e2e34ce64f719'] = 'Размер';
$_MODULE['<{retailcrm}prestashop>settings_06df33001c1d7187fdd81ea1f5b277aa'] = 'Действия';
$_MODULE['<{retailcrm}prestashop>settings_801ab24683a4a8c433c6eb40c48bcd9d'] = 'Скачать';
$_MODULE['<{retailcrm}prestashop>settings_61b0ada67b7f40bf3d40dcc88ae4f3e6'] = 'Скачать все';
$_MODULE['<{retailcrm}prestashop>index_f545947db05aa489f59babf06c319d06'] = 'RetailCRM — сервис для интернет магазинов, который поможет перестать терять заказы и увеличить доход на всех этапах воронки.';
$_MODULE['<{retailcrm}prestashop>index_96f5fae5347f2f1cf560e71a30420fec'] = 'У меня уже есть аккаунт RetailCRM';
$_MODULE['<{retailcrm}prestashop>index_e81c4e4f2b7b93b481e13a8553c2ae1b'] = 'или';

View File

@ -488,6 +488,9 @@ body, html {
&_big {
font-size: 18px;
}
&_hidden {
display: none;
}
}
}
&-full-height {

File diff suppressed because one or more lines are too long

View File

@ -42,6 +42,7 @@ $(function () {
return false;
}
this.isDone = false;
this.ordersCount = parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_COUNT"]').val());
this.customersCount = parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_CUSTOMERS_COUNT"]').val());
this.ordersStepSize = parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_STEP_SIZE"]').val());
@ -69,22 +70,20 @@ $(function () {
};
RetailcrmExportForm.prototype.exportAction = function () {
let data = {};
let data = {
submitretailcrm: 1,
ajax: 1
};
if (this.ordersStep * this.ordersStepSize < this.ordersCount) {
this.ordersStep++;
data = {
submitretailcrm: 1,
RETAILCRM_EXPORT_ORDERS_STEP: this.ordersStep
}
data.RETAILCRM_EXPORT_ORDERS_STEP = this.ordersStep;
} else {
if (this.customersStep * this.customersStepSize < this.customersCount) {
this.customersStep++;
data = {
submitretailcrm: 1,
RETAILCRM_EXPORT_CUSTOMERS_STEP: this.customersStep
}
data.RETAILCRM_EXPORT_CUSTOMERS_STEP = this.customersStep;
} else {
return this.exportDone();
data.RETAILCRM_UPDATE_SINCE_ID = 1;
this.isDone = true;
}
}
@ -97,6 +96,10 @@ $(function () {
data: data
})
.done(function (response) {
if(_this.isDone) {
return _this.exportDone();
}
_this.updateProgressBar();
_this.exportAction();
})
@ -126,7 +129,7 @@ $(function () {
$(this.progressBar).find('.retail-progress__loader').text(percents + '%');
$(this.progressBar).find('.retail-progress__loader').css('width', percents + '%');
$(this.progressBar).find('.retail-progress__loader').attr('alt', processed + '/' + total);
$(this.progressBar).find('.retail-progress__loader').attr('title', processed + '/' + total);
};
RetailcrmExportForm.prototype.confirmLeave = function (event) {

View File

@ -34,4 +34,4 @@
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
$(function(){function t(){if(this.form=$("input[name=RETAILCRM_EXPORT_ORDERS_COUNT]").closest("form").get(0),void 0===this.form)return!1;this.ordersCount=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_COUNT"]').val()),this.customersCount=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_CUSTOMERS_COUNT"]').val()),this.ordersStepSize=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_STEP_SIZE"]').val()),this.customersStepSize=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_CUSTOMERS_STEP_SIZE"]').val()),this.ordersStep=0,this.customersStep=0,this.submitButton=$(this.form).find('button[id="export-orders-submit"]').get(0),this.progressBar=$(this.form).find('div[id="export-orders-progress"]').get(0),this.submitAction=this.submitAction.bind(this),this.exportAction=this.exportAction.bind(this),this.exportDone=this.exportDone.bind(this),this.initializeProgressBar=this.initializeProgressBar.bind(this),this.updateProgressBar=this.updateProgressBar.bind(this),$(this.submitButton).click(this.submitAction)}t.prototype.submitAction=function(t){t.preventDefault(),this.initializeProgressBar(),this.exportAction()},t.prototype.exportAction=function(){let t={};if(this.ordersStep*this.ordersStepSize<this.ordersCount)this.ordersStep++,t={submitretailcrm:1,RETAILCRM_EXPORT_ORDERS_STEP:this.ordersStep};else{if(!(this.customersStep*this.customersStepSize<this.customersCount))return this.exportDone();this.customersStep++,t={submitretailcrm:1,RETAILCRM_EXPORT_CUSTOMERS_STEP:this.customersStep}}let e=this;$.ajax({url:this.form.action,method:this.form.method,timeout:0,data:t}).done(function(t){e.updateProgressBar(),e.exportAction()})},t.prototype.initializeProgressBar=function(){$(this.submitButton).addClass("retail-hidden"),$(this.progressBar).removeClass("retail-hidden").append($("<div/>",{class:"retail-progress__loader",text:"0%"})),window.addEventListener("beforeunload",this.confirmLeave)},t.prototype.updateProgressBar=function(){let t=this.ordersStep*this.ordersStepSize;t>this.ordersCount&&(t=this.ordersCount);let e=this.customersStep*this.customersStepSize;e>this.customersCount&&(e=this.customersCount);var s=t+e,i=this.ordersCount+this.customersCount,r=Math.round(100*s/i);$(this.progressBar).find(".retail-progress__loader").text(r+"%"),$(this.progressBar).find(".retail-progress__loader").css("width",r+"%"),$(this.progressBar).find(".retail-progress__loader").attr("alt",s+"/"+i)},t.prototype.confirmLeave=function(t){t.preventDefault(),e.returnValue="Export process has been started"},t.prototype.exportDone=function(){window.removeEventListener("beforeunload",this.confirmLeave),alert("Export is done")},window.RetailcrmExportForm=t});
$(function(){function t(){if(this.form=$("input[name=RETAILCRM_EXPORT_ORDERS_COUNT]").closest("form").get(0),void 0===this.form)return!1;this.isDone=!1,this.ordersCount=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_COUNT"]').val()),this.customersCount=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_CUSTOMERS_COUNT"]').val()),this.ordersStepSize=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_ORDERS_STEP_SIZE"]').val()),this.customersStepSize=parseInt($(this.form).find('input[name="RETAILCRM_EXPORT_CUSTOMERS_STEP_SIZE"]').val()),this.ordersStep=0,this.customersStep=0,this.submitButton=$(this.form).find('button[id="export-orders-submit"]').get(0),this.progressBar=$(this.form).find('div[id="export-orders-progress"]').get(0),this.submitAction=this.submitAction.bind(this),this.exportAction=this.exportAction.bind(this),this.exportDone=this.exportDone.bind(this),this.initializeProgressBar=this.initializeProgressBar.bind(this),this.updateProgressBar=this.updateProgressBar.bind(this),$(this.submitButton).click(this.submitAction)}t.prototype.submitAction=function(t){t.preventDefault(),this.initializeProgressBar(),this.exportAction()},t.prototype.exportAction=function(){let t={submitretailcrm:1,ajax:1};this.ordersStep*this.ordersStepSize<this.ordersCount?(this.ordersStep++,t.RETAILCRM_EXPORT_ORDERS_STEP=this.ordersStep):this.customersStep*this.customersStepSize<this.customersCount?(this.customersStep++,t.RETAILCRM_EXPORT_CUSTOMERS_STEP=this.customersStep):(t.RETAILCRM_UPDATE_SINCE_ID=1,this.isDone=!0);let s=this;$.ajax({url:this.form.action,method:this.form.method,timeout:0,data:t}).done(function(t){return s.isDone?s.exportDone():(s.updateProgressBar(),void s.exportAction())})},t.prototype.initializeProgressBar=function(){$(this.submitButton).addClass("retail-hidden"),$(this.progressBar).removeClass("retail-hidden").append($("<div/>",{class:"retail-progress__loader",text:"0%"})),window.addEventListener("beforeunload",this.confirmLeave)},t.prototype.updateProgressBar=function(){let t=this.ordersStep*this.ordersStepSize;t>this.ordersCount&&(t=this.ordersCount);let s=this.customersStep*this.customersStepSize;s>this.customersCount&&(s=this.customersCount);var e=t+s,i=this.ordersCount+this.customersCount,r=Math.round(100*e/i);$(this.progressBar).find(".retail-progress__loader").text(r+"%"),$(this.progressBar).find(".retail-progress__loader").css("width",r+"%"),$(this.progressBar).find(".retail-progress__loader").attr("title",e+"/"+i)},t.prototype.confirmLeave=function(t){t.preventDefault(),e.returnValue="Export process has been started"},t.prototype.exportDone=function(){window.removeEventListener("beforeunload",this.confirmLeave),alert("Export is done")},window.RetailcrmExportForm=t});

View File

@ -219,7 +219,7 @@ $(function(){
'rcrm_tab_order_statuses': selectsUpdate,
'rcrm_tab_payment_types': selectsUpdate,
'rcrm_tab_consultant': mainSubmitHide,
'rcrm_tab_job_manager': mainSubmitHide,
'rcrm_tab_advanced': mainSubmitHide,
'rcrm_tab_orders_upload': mainSubmitHide
});
tabs.initializeTabs();

View File

@ -34,4 +34,4 @@
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
$(function(){var a={init:function(){this.selects.init(),this.tableSort.init(),this.player.init(),this.tabs.init(),this.uploadForm.init(this.settingsTabs.init()),this.exportForm.init(),this.popup.init(),this.toggleBox(),this.trimConsultant(),this.showSettings()},selects:{init:function(){var t=this;try{$(".jq-select").SumoSelect(),$("li.opt").each((t,e)=>{if(0===$(e).find("label").html().length){let t=$(e).closest("ul").closest("div").parent().find("select");$(e).find("label").html(t.attr("placeholder")),$(e).addClass("disabled")}}),t.update(),$(document).on("change",".jq-select",function(){t.update()})}catch(t){console.warn("Cannot initialize select: "+t.message)}},update:function(){var n={};let t=$(".retail-tab__enabled").find("select:not(#RETAILCRM_API_DELIVERY_DEFAULT, #RETAILCRM_API_PAYMENT_DEFAULT)");t.each((t,e)=>{var i=$(e).val();i&&i.length&&(n[t]=$('option[value="'+$(e).val()+'"]',$(e)).index())});let s=Object.values(n);t.each((i,a)=>{$("option",a).each((t,e)=>{-1===$.inArray(t,s)||void 0!==n[i]&&n[i]==t?a.sumo.enableItem(t):a.sumo.disableItem(t)})})}},tableSort:{init:function(){var n=this;$(".retail-table-sort").each((t,a)=>{$(a).find(".retail-table-sort__switch").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i)})}),$(a).find(".retail-table-sort__asc").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i,"asc")})}),$(a).find(".retail-table-sort__desc").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i,"desc")})}),$(a).find(".retail-table-sort__initial").click()})},sort:function(t,e,i=void 0){let a,n,s,o,r,l,c,d=0;for(n=!0,c=i||"asc";n;){for(n=!1,a=t.rows,s=1;s<a.length-1;s++)if(l=!1,o=a[s].getElementsByTagName("TD")[e],r=a[s+1].getElementsByTagName("TD")[e],"asc"===c){if(o.innerHTML.toLowerCase()>r.innerHTML.toLowerCase()){l=!0;break}}else if("desc"===c&&o.innerHTML.toLowerCase()<r.innerHTML.toLowerCase()){l=!0;break}l?(a[s].parentNode.insertBefore(a[s+1],a[s]),n=!0,d++):void 0===i&&0===d&&"asc"===c&&(c="desc",n=!0)}}},player:{init:function(){window.player={},window.onYouTubeIframeAPIReady=function(){window.player=new YT.Player("player",{height:"100%",width:"100%",videoId:window.RCRMPROMO})};var t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",document.body.appendChild(t)}},settingsTabs:{init:function(){if("undefined"!=typeof RCRMTabs){let t=new RCRMTabs('div[id^="rcrm_tab_"]',".retail-menu__btn","retail-tab__enabled","retail-tab__disabled","retail-menu__btn_active","retail-menu__btn_inactive","tab-trigger",".rcrm-form-submit-trigger");var e={afterActivate:function(){a.selects.update()}},i={beforeActivate:function(){$("#main-submit").hide()},afterDeactivate:function(){$("#main-submit").show()}};return t.tabsCallbacks({rcrm_tab_delivery_types:e,rcrm_tab_order_statuses:e,rcrm_tab_payment_types:e,rcrm_tab_consultant:i,rcrm_tab_job_manager:i,rcrm_tab_orders_upload:i}),t.initializeTabs(),t}}},uploadForm:{init:function(t){"undefined"!=typeof RetailcrmUploadForm&&new RetailcrmUploadForm(t)}},exportForm:{init:function(){"undefined"!=typeof RetailcrmExportForm&&new RetailcrmExportForm}},tabs:{init:function(){$(".retail-tabs__btn").on("click",this.swithTab)},swithTab:function(t){t.preventDefault();var e=$(this).attr("href");$(".retail-tabs__btn_active").removeClass("retail-tabs__btn_active"),$(".retail-tabs__item_active").removeClass("retail-tabs__item_active").fadeOut(150,function(){$(e).addClass("retail-tabs__item_active").fadeIn(150)}),$(this).addClass("retail-tabs__btn_active")}},popup:{init:function(){var i=this;$("[data-popup]").on("click",function(t){var e=$(this).data("popup");i.open($(e))}),$(".retail-popup-wrap").on("click",function(t){$(t.target).hasClass("js-popup-close")&&(t=$(this).find(".retail-popup"),i.close(t))})},open:function(t){t&&(t.closest(".retail-popup-wrap").fadeIn(200),t.addClass("open"),player.playVideo())},close:function(t){var e=t.closest(".retail-popup-wrap");t.removeClass("open"),e.fadeOut(200),player.stopVideo()}},toggleBox:function(){$(".toggle-btn").on("click",function(t){t.preventDefault();t=$(this).attr("href"),t=$(t);$(this).closest(".retail-btns").addClass("retail-btns_hide").slideUp(100),t.slideDown(100)})},trimConsultant:function(){let t=$("#rcrm_tab_consultant textarea");t.text(t.text().trim())},showSettings:function(){$(".retail.retail-wrap.hidden").removeClass("hidden")}};a.init()});
$(function(){var a={init:function(){this.selects.init(),this.tableSort.init(),this.player.init(),this.tabs.init(),this.uploadForm.init(this.settingsTabs.init()),this.exportForm.init(),this.popup.init(),this.toggleBox(),this.trimConsultant(),this.showSettings()},selects:{init:function(){var t=this;try{$(".jq-select").SumoSelect(),$("li.opt").each((t,e)=>{if(0===$(e).find("label").html().length){let t=$(e).closest("ul").closest("div").parent().find("select");$(e).find("label").html(t.attr("placeholder")),$(e).addClass("disabled")}}),t.update(),$(document).on("change",".jq-select",function(){t.update()})}catch(t){console.warn("Cannot initialize select: "+t.message)}},update:function(){var n={};let t=$(".retail-tab__enabled").find("select:not(#RETAILCRM_API_DELIVERY_DEFAULT, #RETAILCRM_API_PAYMENT_DEFAULT)");t.each((t,e)=>{var i=$(e).val();i&&i.length&&(n[t]=$('option[value="'+$(e).val()+'"]',$(e)).index())});let s=Object.values(n);t.each((i,a)=>{$("option",a).each((t,e)=>{-1===$.inArray(t,s)||void 0!==n[i]&&n[i]==t?a.sumo.enableItem(t):a.sumo.disableItem(t)})})}},tableSort:{init:function(){var n=this;$(".retail-table-sort").each((t,a)=>{$(a).find(".retail-table-sort__switch").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i)})}),$(a).find(".retail-table-sort__asc").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i,"asc")})}),$(a).find(".retail-table-sort__desc").each((t,e)=>{const i=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(a,i,"desc")})}),$(a).find(".retail-table-sort__initial").click()})},sort:function(t,e,i=void 0){let a,n,s,o,r,l,c,d=0;for(n=!0,c=i||"asc";n;){for(n=!1,a=t.rows,s=1;s<a.length-1;s++)if(l=!1,o=a[s].getElementsByTagName("TD")[e],r=a[s+1].getElementsByTagName("TD")[e],"asc"===c){if(o.innerHTML.toLowerCase()>r.innerHTML.toLowerCase()){l=!0;break}}else if("desc"===c&&o.innerHTML.toLowerCase()<r.innerHTML.toLowerCase()){l=!0;break}l?(a[s].parentNode.insertBefore(a[s+1],a[s]),n=!0,d++):void 0===i&&0===d&&"asc"===c&&(c="desc",n=!0)}}},player:{init:function(){window.player={},window.onYouTubeIframeAPIReady=function(){window.player=new YT.Player("player",{height:"100%",width:"100%",videoId:window.RCRMPROMO})};var t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",document.body.appendChild(t)}},settingsTabs:{init:function(){if("undefined"!=typeof RCRMTabs){let t=new RCRMTabs('div[id^="rcrm_tab_"]',".retail-menu__btn","retail-tab__enabled","retail-tab__disabled","retail-menu__btn_active","retail-menu__btn_inactive","tab-trigger",".rcrm-form-submit-trigger");var e={afterActivate:function(){a.selects.update()}},i={beforeActivate:function(){$("#main-submit").hide()},afterDeactivate:function(){$("#main-submit").show()}};return t.tabsCallbacks({rcrm_tab_delivery_types:e,rcrm_tab_order_statuses:e,rcrm_tab_payment_types:e,rcrm_tab_consultant:i,rcrm_tab_advanced:i,rcrm_tab_orders_upload:i}),t.initializeTabs(),t}}},uploadForm:{init:function(t){"undefined"!=typeof RetailcrmUploadForm&&new RetailcrmUploadForm(t)}},exportForm:{init:function(){"undefined"!=typeof RetailcrmExportForm&&new RetailcrmExportForm}},tabs:{init:function(){$(".retail-tabs__btn").on("click",this.swithTab)},swithTab:function(t){t.preventDefault();var e=$(this).attr("href");$(".retail-tabs__btn_active").removeClass("retail-tabs__btn_active"),$(".retail-tabs__item_active").removeClass("retail-tabs__item_active").fadeOut(150,function(){$(e).addClass("retail-tabs__item_active").fadeIn(150)}),$(this).addClass("retail-tabs__btn_active")}},popup:{init:function(){var i=this;$("[data-popup]").on("click",function(t){var e=$(this).data("popup");i.open($(e))}),$(".retail-popup-wrap").on("click",function(t){$(t.target).hasClass("js-popup-close")&&(t=$(this).find(".retail-popup"),i.close(t))})},open:function(t){t&&(t.closest(".retail-popup-wrap").fadeIn(200),t.addClass("open"),player.playVideo())},close:function(t){var e=t.closest(".retail-popup-wrap");t.removeClass("open"),e.fadeOut(200),player.stopVideo()}},toggleBox:function(){$(".toggle-btn").on("click",function(t){t.preventDefault();t=$(this).attr("href"),t=$(t);$(this).closest(".retail-btns").addClass("retail-btns_hide").slideUp(100),t.slideDown(100)})},trimConsultant:function(){let t=$("#rcrm_tab_consultant textarea");t.text(t.text().trim())},showSettings:function(){$(".retail.retail-wrap.hidden").removeClass("hidden")}};a.init()});

View File

@ -57,13 +57,13 @@
<a href="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" data-tab-trigger="rcrm_tab_carts_sync" class="retail-menu__btn retail-menu__btn_big retail-menu__btn_inactive"><span>{l s='Abandoned carts' mod='retailcrm'}<span/></a>
<a href="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" data-tab-trigger="rcrm_tab_daemon_collector" class="retail-menu__btn retail-menu__btn_big retail-menu__btn_inactive"><span>{l s='Daemon Collector' mod='retailcrm'}<span/></a>
<a href="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&item=consultant" data-tab-trigger="rcrm_tab_consultant" class="retail-menu__btn retail-menu__btn_big retail-menu__btn_inactive"><span>{l s='Online consultant' mod='retailcrm'}<span/></a>
<a href="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" data-tab-trigger="rcrm_tab_job_manager" class="retail-menu__btn retail-menu__btn_big retail-menu__btn_inactive"><span>{l s='Job Manager' mod='retailcrm'}<span/></a>
<a href="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" data-tab-trigger="rcrm_tab_advanced" class="retail-menu__btn retail-menu__btn_big retail-menu__btn_inactive retail-menu__btn_hidden"><span>{l s='Advanced' mod='retailcrm'}<span/></a>
</div>
</aside>
<article class="retail-column__content">
<h1 class="retail-title retail-title_content">RetailCRM</h1>
<div class="retail-form retail-form_main">
<form class="rcrm-form-submit-trigger" action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" method="post">
<form class="rcrm-form-submit-trigger" action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm" method="post" id="submitretailcrm-form">
<input type="hidden" name="submitretailcrm" value="1" />
<div id="rcrm_tab_connection">
<div class="retail-form__title">{l s='Connection Settings' mod='retailcrm'}</div>
@ -238,11 +238,15 @@
</div>
</form>
<div id="rcrm_tab_consultant">
<form class="rcrm-form-submit-trigger" action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&item=consultant" method="post">
<input type="hidden" name="submitretailcrm" value="1" />
<form class="rcrm-form-submit-trigger"
action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&item=consultant"
method="post">
<input type="hidden" name="submitretailcrm" value="1"/>
<div class="retail-form__title">{l s='Online consultant' mod='retailcrm'}</div>
<div class="retail-form__row">
<textarea name="{$consultantScriptName|escape:'htmlall':'UTF-8'}" class="retail-form__area retail-form__area_txt" id="retail-txt-area" placeholder="{l s='Code you need to insert on the web' mod='retailcrm'}">
<textarea name="{$consultantScriptName|escape:'htmlall':'UTF-8'}"
class="retail-form__area retail-form__area_txt" id="retail-txt-area"
placeholder="{l s='Code you need to insert on the web' mod='retailcrm'}">
{$consultantScript|escape:'htmlall':'UTF-8'}
</textarea>
</div>
@ -251,10 +255,27 @@
</div>
</form>
</div>
<div id="rcrm_tab_job_manager">
<div class="retail-form__title">{l s='Job Manager' mod='retailcrm'}</div>
<table class="retail-table retail-table-sort">
<thead>
<div id="rcrm_tab_advanced">
<div class="retail-form__title">{l s='Advanced' mod='retailcrm'}</div>
<div class="retail-form__row">
<div class="retail-form__checkbox">
<input form="submitretailcrm-form" type="checkbox" name="{$debugModeName|escape:'htmlall':'UTF-8'}"
value="{$debugMode|escape:'htmlall':'UTF-8'}"
{if $debugMode}checked="checked"{/if} id="debugmode-active">
<label for="debugmode-active"
class="retail-form__label">{l s='Debug mode' mod='retailcrm'}</label>
</div>
<div class="retail-form__row retail-form__row_submit">
<input form="submitretailcrm-form" type="submit" value="{l s='Save' mod='retailcrm'}" class="btn btn_invert btn_submit">
</div>
</div>
<div class="retail-form__row">
<label class="retail-form__label">{l s='Job Manager' mod='retailcrm'}</label>
<table class="retail-table retail-table-sort">
<thead>
<tr>
<th>
<span>{l s='Job name' mod='retailcrm'}</span></th>
@ -269,47 +290,112 @@
<th>
<span>{l s='Comment' mod='retailcrm'}</span></th>
</tr>
</thead>
<tbody>
{foreach from=$lastRunDetails key=key item=item}
<tr class="retail-table__row-top">
<td>
{if isset($jobsNames[$key]) }
<span title="{$key}">{l s=$jobsNames[$key] mod='retailcrm'}</span>
{else}
{$key}
{/if}
</td>
<td class="retail-table-center retail-table-no-wrap">{if isset($item['lastRun'])}{$item['lastRun']|date_format:'Y-m-d H:i:s'}{/if}</td>
<td class="retail-table-center">
{if isset($item['success'])}
{if $item['success'] === true}
<span style="color: #2e8b57;">
&#10004;
</span>
</thead>
<tbody>
{foreach from=$lastRunDetails key=key item=item}
<tr class="retail-table__row-top">
<td>
{if isset($jobsNames[$key]) }
<span title="{$key}">{l s=$jobsNames[$key] mod='retailcrm'}</span>
{else}
<span style="color: #dd2e44;">
&#10060;
</span>
{$key}
{/if}
{/if}
</td>
<td class="retail-collapsible">
{if isset($item['error']['message'])}
<input type="checkbox" class="retail-collapsible__input" id="error_{$key}">
<label for="error_{$key}" class="retail-collapsible__title retail-error-msg">
<span class="retail-error-msg">{$item['error']['message']}</span>
<p class="retail-collapsible__content">
<b>{l s='StackTrace' mod='retailcrm'}:</b><br>{$item['error']['trace']}
</p>
</label>
{/if}
</td>
<td class="retail-table-center retail-table-no-wrap">{if isset($item['lastRun'])}{$item['lastRun']|date_format:'Y-m-d H:i:s'}{/if}</td>
<td class="retail-table-center">
{if $key === $currentJob || $key === $currentJobCli}
<span>&#8987;</span>
{else}
{if isset($item['success'])}
{if $item['success'] === true}
<span style="color: #2e8b57;">&#10004;</span>
{else}
<span style="color: #dd2e44;">&#10060;</span>
{/if}
{/if}
{/if}
</td>
<td class="retail-collapsible">
{if isset($item['error']['message'])}
<input type="checkbox" class="retail-collapsible__input" id="error_{$key}">
<label for="error_{$key}"
class="retail-collapsible__title retail-error-msg">
<span class="retail-error-msg">{$item['error']['message']}</span>
<p class="retail-collapsible__content">
<b>{l s='StackTrace' mod='retailcrm'}
:</b><br>{$item['error']['trace']}
</p>
</label>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="retail-form__row">
<label class="retail-form__label">{l s='Logs' mod='retailcrm'}</label>
<table class="retail-table retail-table-sort">
<thead>
<tr>
<th><span>{l s='File name' mod='retailcrm'}</span></th>
<th>
<div class="retail-table-sort__btn-wrap">
<span class="retail-table-sort__asc retail-table-sort__btn">&#x25B2</span>
<span class="retail-table-sort__desc retail-table-sort__btn retail-table-sort__initial">&#x25BC</span>
</div>
<span class="retail-table-sort__switch">{l s='Modified date' mod='retailcrm'}</span>
</th>
<th>
<div class="retail-table-sort__btn-wrap">
<span class="retail-table-sort__asc retail-table-sort__btn">&#x25B2</span>
<span class="retail-table-sort__desc retail-table-sort__btn">&#x25BC</span>
</div>
<span class="retail-table-sort__switch">{l s='Size' mod='retailcrm'}</span>
</th>
<th><span>{l s='Actions' mod='retailcrm'}</span></th>
</tr>
</thead>
<tbody>
{foreach from=$retailcrmLogsInfo key=key item=logItem}
<tr class="retail-table__row-top">
<td>{$logItem.name}</td>
<td class="retail-table-center">{$logItem.modified}</td>
<td class="retail-table-center">{$logItem.size}</td>
<td class="retail-table-center">
<form class="rcrm-form-submit-trigger"
action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&amp;ajax=1"
method="post">
<input type="hidden" name="submitretailcrm" value="1"/>
<input type="hidden" name="RETAILCRM_DOWNLOAD_LOGS" value="1"/>
<input type="hidden" name="RETAILCRM_DOWNLOAD_LOGS_NAME"
value="{$logItem.name|escape:'htmlall':'UTF-8'}"/>
<input type="submit"
value="{l s='Download' mod='retailcrm'}"/>
</form>
</td>
</tr>
{/foreach}
<tr>
<td colspan="3"></td>
<td class="retail-table-center">
<form class="rcrm-form-submit-trigger"
action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&amp;ajax=1"
method="post">
<input type="hidden" name="submitretailcrm" value="1"/>
<input type="hidden" name="RETAILCRM_DOWNLOAD_LOGS" value="1"/>
<input type="submit" value="{l s='Download All' mod='retailcrm'}">
</form>
</td>
</tr>
{/foreach}
</tbody>
</table>
</tbody>
</table>
</div>
</div>
</div>
</article>
</div>