Enable and reset web jobs within the settings page

This commit is contained in:
max-baranikov 2021-08-03 18:39:40 +03:00 committed by GitHub
parent e2616f81b4
commit bf5c98218c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 389 additions and 146 deletions

View File

@ -118,11 +118,11 @@ class RetailcrmCli
} elseif (isset($options['reset-all'])) {
$this->resetAll();
} elseif (isset($options['query-web-jobs'])) {
$this->queryWebJobs();
$this->queryWebJobs($shopId);
} elseif (isset($options['run-jobs'])) {
RetailcrmTools::startJobManager();
} elseif (isset($options['set-web-jobs'])) {
$this->setWebJobs(self::getBool($options['set-web-jobs']));
$this->setWebJobs(self::getBool($options['set-web-jobs']), $shopId);
} elseif (empty($jobName)) {
$this->help();
} else {
@ -245,21 +245,36 @@ class RetailcrmCli
* Sets new web jobs state
*
* @param bool $state
* @param $shopId
*/
private function setWebJobs($state)
private function setWebJobs($state, $shopId = null)
{
if ($shopId === null) {
RetailcrmLogger::output('You must specify shop id');
return;
}
RetailcrmTools::setShopContext($shopId);
$this->loadConfiguration();
Configuration::updateGlobalValue(RetailCRM::ENABLE_WEB_JOBS, $state ? '1' : '0');
Configuration::updateValue(RetailCRM::ENABLE_WEB_JOBS, $state ? '1' : '0');
RetailcrmLogger::output('Updated web jobs state.');
$this->queryWebJobs();
$this->queryWebJobs($shopId);
}
/**
* Prints web jobs status
*
* @param $shopId
*/
private function queryWebJobs()
private function queryWebJobs($shopId = null)
{
if ($shopId === null) {
RetailcrmLogger::output('You must specify shop id');
return;
}
RetailcrmTools::setShopContext($shopId);
$this->loadConfiguration();
RetailcrmLogger::output(sprintf(

View File

@ -486,7 +486,7 @@ class RetailcrmTools
public static function isWebJobsEnabled()
{
return '0' !== Configuration::getGlobalValue(RetailCRM::ENABLE_WEB_JOBS);
return '0' !== Configuration::get(RetailCRM::ENABLE_WEB_JOBS);
}
/**

View File

@ -81,6 +81,7 @@ class RetailCRM extends Module
const CONSULTANT_SCRIPT = 'RETAILCRM_CONSULTANT_SCRIPT';
const CONSULTANT_RCCT = 'RETAILCRM_CONSULTANT_RCCT';
const ENABLE_WEB_JOBS = 'RETAILCRM_ENABLE_WEB_JOBS';
const RESET_JOBS = 'RETAILCRM_RESET_JOBS';
const JOBS_NAMES = [
'RetailcrmAbandonedCartsEvent' => 'Abandoned Carts',
'RetailcrmIcmlEvent' => 'Icml generation',
@ -246,6 +247,7 @@ class RetailCRM extends Module
Configuration::deleteByName(static::ENABLE_ORDER_NUMBER_SENDING) &&
Configuration::deleteByName(static::ENABLE_ORDER_NUMBER_RECEIVING) &&
Configuration::deleteByName(static::ENABLE_DEBUG_MODE) &&
Configuration::deleteByName(static::ENABLE_WEB_JOBS) &&
Configuration::deleteByName('RETAILCRM_LAST_SYNC') &&
Configuration::deleteByName('RETAILCRM_LAST_ORDERS_SYNC') &&
Configuration::deleteByName('RETAILCRM_LAST_CUSTOMERS_SYNC') &&
@ -289,8 +291,8 @@ class RetailCRM extends Module
$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));
$resetJobs = (bool)(Tools::getValue(static::RESET_JOBS));
if (!empty($ordersIds)) {
$output .= $this->uploadOrders(RetailcrmTools::partitionId($ordersIds));
@ -303,7 +305,9 @@ class RetailCRM extends Module
} elseif ($updateSinceId) {
return $this->updateSinceId();
} elseif ($downloadLogs) {
return $this->downloadLogs($logNames);
return $this->downloadLogs();
} elseif ($resetJobs) {
return $this->resetJobs();
} else {
$output .= $this->saveSettings();
}
@ -517,12 +521,13 @@ class RetailCRM extends Module
return RetailcrmJsonResponse::successfullResponse();
}
public function downloadLogs($name = '')
public function downloadLogs()
{
if (!Tools::getValue('ajax')) {
return false;
}
$name = (string)(Tools::getValue(static::DOWNLOAD_LOGS_NAME));
if (!empty($name)) {
if (false === ($filePath = RetailcrmLogger::checkFileName($name))) {
return false;
@ -558,6 +563,30 @@ class RetailCRM extends Module
return true;
}
/**
* Resets JobManager and cli internal lock
*/
public function resetJobs()
{
$errors = array();
try {
if (!RetailcrmJobManager::reset()) {
$errors[] = 'Job manager internal state was NOT cleared.';
}
if (!RetailcrmCli::clearCurrentJob(null)) {
$errors[] = 'CLI job was NOT cleared';
}
if (!empty($errors)) {
return RetailcrmJsonResponse::invalidResponse(implode(' ', $errors));
}
return RetailcrmJsonResponse::successfullResponse();
} catch (\Exception $exception) {
return RetailcrmJsonResponse::invalidResponse($exception->getMessage());
}
}
public function hookActionCustomerAccountAdd($params)
{
if ($this->api) {
@ -962,25 +991,26 @@ class RetailCRM extends Module
$settings = array(
'url' => rtrim($url, '/'),
'apiKey' => $apiKey,
'address' => (string)(Tools::getValue(static::API_URL)),
'address' => (string) (Tools::getValue(static::API_URL)),
'delivery' => json_encode(Tools::getValue(static::DELIVERY)),
'status' => json_encode(Tools::getValue(static::STATUS)),
'payment' => json_encode(Tools::getValue(static::PAYMENT)),
'deliveryDefault' => json_encode(Tools::getValue(static::DELIVERY_DEFAULT)),
'paymentDefault' => json_encode(Tools::getValue(static::PAYMENT_DEFAULT)),
'statusExport' => (string)(Tools::getValue(static::STATUS_EXPORT)),
'statusExport' => (string) (Tools::getValue(static::STATUS_EXPORT)),
'enableCorporate' => (Tools::getValue(static::ENABLE_CORPORATE_CLIENTS) !== false),
'enableHistoryUploads' => (Tools::getValue(static::ENABLE_HISTORY_UPLOADS) !== false),
'enableBalancesReceiving' => (Tools::getValue(static::ENABLE_BALANCES_RECEIVING) !== false),
'enableOrderNumberSending' => (Tools::getValue(static::ENABLE_ORDER_NUMBER_SENDING) !== false),
'enableOrderNumberReceiving' => (Tools::getValue(static::ENABLE_ORDER_NUMBER_RECEIVING) !== false),
'debugMode' => (Tools::getValue(static::ENABLE_DEBUG_MODE) !== false),
'webJobs' => (Tools::getValue(static::ENABLE_WEB_JOBS) !== false ? '1' : '0'),
'collectorActive' => (Tools::getValue(static::COLLECTOR_ACTIVE) !== false),
'collectorKey' => (string)(Tools::getValue(static::COLLECTOR_KEY)),
'collectorKey' => (string) (Tools::getValue(static::COLLECTOR_KEY)),
'clientId' => Configuration::get(static::CLIENT_ID),
'synchronizeCartsActive' => (Tools::getValue(static::SYNC_CARTS_ACTIVE) !== false),
'synchronizedCartStatus' => (string)(Tools::getValue(static::SYNC_CARTS_STATUS)),
'synchronizedCartDelay' => (string)(Tools::getValue(static::SYNC_CARTS_DELAY))
'synchronizedCartStatus' => (string) (Tools::getValue(static::SYNC_CARTS_STATUS)),
'synchronizedCartDelay' => (string) (Tools::getValue(static::SYNC_CARTS_DELAY))
);
$output .= $this->validateForm($settings, $output);
@ -1005,6 +1035,7 @@ class RetailCRM extends Module
Configuration::updateValue(static::SYNC_CARTS_STATUS, $settings['synchronizedCartStatus']);
Configuration::updateValue(static::SYNC_CARTS_DELAY, $settings['synchronizedCartDelay']);
Configuration::updateValue(static::ENABLE_DEBUG_MODE, $settings['debugMode']);
Configuration::updateValue(static::ENABLE_WEB_JOBS, $settings['webJobs']);
$this->apiUrl = $settings['url'];
$this->apiKey = $settings['apiKey'];
@ -1384,7 +1415,8 @@ class RetailCRM extends Module
'enableBalancesReceiving' => (bool)(Configuration::get(static::ENABLE_BALANCES_RECEIVING)),
'enableOrderNumberSending' => (bool)(Configuration::get(static::ENABLE_ORDER_NUMBER_SENDING)),
'enableOrderNumberReceiving' => (bool)(Configuration::get(static::ENABLE_ORDER_NUMBER_RECEIVING)),
'debugMode' => (bool)(Configuration::get(static::ENABLE_DEBUG_MODE)),
'debugMode' => RetailcrmTools::isDebug(),
'webJobs' => RetailcrmTools::isWebJobsEnabled()
);
}
@ -1419,6 +1451,7 @@ class RetailCRM extends Module
'enableOrderNumberSendingName' => static::ENABLE_ORDER_NUMBER_SENDING,
'enableOrderNumberReceivingName' => static::ENABLE_ORDER_NUMBER_RECEIVING,
'debugModeName' => static::ENABLE_DEBUG_MODE,
'webJobsName' => static::ENABLE_WEB_JOBS,
'jobsNames' => static::JOBS_NAMES
);
}

View File

@ -611,11 +611,17 @@ body, html {
td, th {
color: #333;
font-size: 14px;
line-height: 60px;
padding: 4px 4px 4px 6px;
line-height: 40px;
padding: 4px 6px;
max-width: 300px;
vertical-align: middle;
}
&-wrapper {
width: 100%;
max-height: 500px;
overflow-y: scroll;
overflow-x: hidden;
}
&__row {
&-bold {
font-weight: bold;
@ -627,6 +633,9 @@ body, html {
&-center {
text-align: center;
}
&-right {
text-align: right;
}
&-sort {
&__btn, &__switch {
cursor: pointer;
@ -637,7 +646,7 @@ body, html {
&__btn {
float: left;
clear: both;
line-height: 15px;
line-height: 20px;
font-size: 20px;
padding-left: 10px;
padding-right: 10px;
@ -648,12 +657,10 @@ body, html {
}
}
&__asc {
padding-top: 15px;
padding-bottom: 0;
//padding-bottom: 0;
}
&__desc {
padding-top: 0;
padding-bottom: 15px;
//padding-top: 0;
}
& thead th:hover &__btn, & thead td:hover &__btn {
opacity: 1;
@ -748,4 +755,17 @@ body, html {
color: @blue;
}
}
&-btn-svg {
width: 15px;
cursor: pointer;
//transition: transform .3s ease-out;
&_wrapper {
cursor: pointer;
&:hover {
//transform: scale(1.1);
fill: @gray;
color: @gray;
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,77 @@
/**
* 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.
*/
$(function () {
function RetailcrmAdvancedSettings() {
this.resetButton = $('input[id="reset-jobs-submit"]').get(0);
this.form = $(this.resetButton).closest('form').get(0);
this.resetAction = this.resetAction.bind(this);
$(this.resetButton).click(this.resetAction);
}
RetailcrmAdvancedSettings.prototype.resetAction = function (event) {
event.preventDefault();
this.resetButton.disabled = true;
let data = {
submitretailcrm: 1,
ajax: 1,
RETAILCRM_RESET_JOBS: 1
};
let _this = this;
$.ajax({
url: this.form.action,
method: this.form.method,
timeout: 0,
data: data,
dataType: 'json',
})
.done(function (response) {
alert('Reset completed successfully')
_this.resetButton.disabled = false;
})
.fail(function (error) {
alert('Error: ' + error.responseJSON.errorMsg);
_this.resetButton.disabled = false;
})
}
window.RetailcrmAdvancedSettings = RetailcrmAdvancedSettings;
});

View File

@ -0,0 +1,38 @@
/**
* 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.
*/
$(function(){function t(){this.resetButton=$('input[id="reset-jobs-submit"]').get(0),this.form=$(this.resetButton).closest("form").get(0),this.resetAction=this.resetAction.bind(this),$(this.resetButton).click(this.resetAction)}t.prototype.resetAction=function(t){t.preventDefault(),this.resetButton.disabled=!0;let e=this;$.ajax({url:this.form.action,method:this.form.method,timeout:0,data:{submitretailcrm:1,ajax:1,RETAILCRM_RESET_JOBS:1},dataType:"json"}).done(function(t){alert("Reset completed successfully"),e.resetButton.disabled=!1}).fail(function(t){alert("Error: "+t.responseJSON.errorMsg),e.resetButton.disabled=!1})},window.RetailcrmAdvancedSettings=t});
//# sourceMappingURL=retailcrm-advanced.min.js.map

View File

@ -35,7 +35,8 @@
* to avoid any conflicts with others containers.
*/
$(function () {
function RetailcrmExportForm() {
function RetailcrmExportForm()
{
this.form = $('input[name=RETAILCRM_EXPORT_ORDERS_COUNT]').closest('form').get(0);
if (typeof this.form === 'undefined') {
@ -96,8 +97,8 @@ $(function () {
data: data
})
.done(function (response) {
if(_this.isDone) {
return _this.exportDone();
if (_this.isDone) {
return _this.exportDone();
}
_this.updateProgressBar();
@ -116,12 +117,14 @@ $(function () {
RetailcrmExportForm.prototype.updateProgressBar = function () {
let processedOrders = this.ordersStep * this.ordersStepSize;
if (processedOrders > this.ordersCount)
if (processedOrders > this.ordersCount) {
processedOrders = this.ordersCount;
}
let processedCustomers = this.customersStep * this.customersStepSize;
if (processedCustomers > this.customersCount)
if (processedCustomers > this.customersCount) {
processedCustomers = this.customersCount;
}
const processed = processedOrders + processedCustomers;
const total = this.ordersCount + this.customersCount;

View File

@ -43,6 +43,7 @@ $(function(){
this.player.init();
this.tabs.init();
this.eventForm.init(this.settingsTabs.init());
this.advancedSettings.init();
this.popup.init();
this.toggleBox();
this.trimConsultant();
@ -240,6 +241,13 @@ $(function(){
}
},
},
advancedSettings: {
init: function () {
if (!(typeof RetailcrmAdvancedSettings === 'undefined')) {
new RetailcrmAdvancedSettings();
}
}
},
tabs: {
init: function () {
$('.retail-tabs__btn').on('click', this.swithTab);

View File

@ -34,5 +34,5 @@
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
$(function(){var i={init:function(){this.selects.init(),this.tableSort.init(),this.player.init(),this.tabs.init(),this.eventForm.init(this.settingsTabs.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 a=$(e).val();a&&a.length&&(n[t]=$('option[value="'+$(e).val()+'"]',$(e)).index())});let s=Object.values(n);t.each((a,i)=>{$("option",i).each((t,e)=>{-1===$.inArray(t,s)||void 0!==n[a]&&n[a]==t?i.sumo.enableItem(t):i.sumo.disableItem(t)})})}},tableSort:{init:function(){var n=this;$(".retail-table-sort").each((t,i)=>{$(i).find(".retail-table-sort__switch").each((t,e)=>{const a=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(i,a)})}),$(i).find(".retail-table-sort__asc").each((t,e)=>{const a=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(i,a,"asc")})}),$(i).find(".retail-table-sort__desc").each((t,e)=>{const a=$(e).closest("th,td").index();$(e).click(t=>{t.preventDefault(),n.sort(i,a,"desc")})}),$(i).find(".retail-table-sort__initial").click()})},sort:function(t,e,a=void 0){let i,n,s,r,o,l,c,d=0;for(n=!0,c=a||"asc";n;){for(n=!1,i=t.rows,s=1;s<i.length-1;s++)if(l=!1,r=i[s].getElementsByTagName("TD")[e],o=i[s+1].getElementsByTagName("TD")[e],"asc"===c){if(r.innerHTML.toLowerCase()>o.innerHTML.toLowerCase()){l=!0;break}}else if("desc"===c&&r.innerHTML.toLowerCase()<o.innerHTML.toLowerCase()){l=!0;break}l?(i[s].parentNode.insertBefore(i[s+1],i[s]),n=!0,d++):void 0===a&&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(){i.selects.update()}},a={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:a,rcrm_tab_advanced:a,rcrm_tab_catalog:a,rcrm_tab_orders_upload:a}),t.initializeTabs(),t}}},eventForm:{init:function(t){"undefined"!=typeof RetailcrmUploadForm&&new RetailcrmUploadForm(t),"undefined"!=typeof RetailcrmIcmlForm&&new RetailcrmIcmlForm(t),"undefined"!=typeof RetailcrmExportForm&&new RetailcrmExportForm}},tabs:{init:function(){$(".retail-tabs__btn").on("click",this.swithTab),this.advancedTab()},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")},advancedTab:function(){let t=document.getElementsByClassName("retail-title_content")[0];void 0!==t&&t.addEventListener("click",function(t){3===t.detail&&$('.retail-menu__btn[data-tab-trigger="rcrm_tab_advanced"]').click()})}},popup:{init:function(){var a=this;$("[data-popup]").on("click",function(t){var e=$(this).data("popup");a.open($(e))}),$(".retail-popup-wrap").on("click",function(t){$(t.target).hasClass("js-popup-close")&&(t=$(this).find(".retail-popup"),a.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")}};i.init()});
$(function(){var a={init:function(){this.selects.init(),this.tableSort.init(),this.player.init(),this.tabs.init(),this.eventForm.init(this.settingsTabs.init()),this.advancedSettings.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,r,o,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,r=a[s].getElementsByTagName("TD")[e],o=a[s+1].getElementsByTagName("TD")[e],"asc"===c){if(r.innerHTML.toLowerCase()>o.innerHTML.toLowerCase()){l=!0;break}}else if("desc"===c&&r.innerHTML.toLowerCase()<o.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_catalog:i,rcrm_tab_orders_upload:i}),t.initializeTabs(),t}}},eventForm:{init:function(t){"undefined"!=typeof RetailcrmUploadForm&&new RetailcrmUploadForm(t),"undefined"!=typeof RetailcrmIcmlForm&&new RetailcrmIcmlForm(t),"undefined"!=typeof RetailcrmExportForm&&new RetailcrmExportForm}},advancedSettings:{init:function(){"undefined"!=typeof RetailcrmAdvancedSettings&&new RetailcrmAdvancedSettings}},tabs:{init:function(){$(".retail-tabs__btn").on("click",this.swithTab),this.advancedTab()},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")},advancedTab:function(){let t=document.getElementsByClassName("retail-title_content")[0];void 0!==t&&t.addEventListener("click",function(t){3===t.detail&&$('.retail-menu__btn[data-tab-trigger="rcrm_tab_advanced"]').click()})}},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()});
//# sourceMappingURL=retailcrm.min.js.map

View File

@ -228,7 +228,7 @@
{/foreach}
<input type="hidden" name="{$runJobName|escape:'htmlall':'UTF-8'}" value="">
<div class="retail-form__row retail-form__row_submit"
style="text-align: center; height: 60px; margin-bottom: 20px; margin-top: 50px; clear:both;">
style="height: 60px; margin-bottom: 20px; margin-top: 50px; clear:both;">
<button id="update-icml-submit"
class="btn btn_invert btn_warning"
style="outline: none;{if !$showUpdateButton} display: none;{/if}">{l s='Update URL' mod='retailcrm'}</button>
@ -385,138 +385,186 @@
<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'}"
<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 class="retail-form__checkbox">
<input form="submitretailcrm-form" type="checkbox"
name="{$webJobsName|escape:'htmlall':'UTF-8'}"
value="{$webJobs|escape:'htmlall':'UTF-8'}"
{if $webJobs}checked="checked"{/if} id="webjobs-active">
<label for="webjobs-active"
class="retail-form__label">{l s='Web Jobs' mod='retailcrm'}</label>
</div>
</div>
<div class="retail-form__row">
<input form="submitretailcrm-form" type="submit" value="{l s='Save' mod='retailcrm'}" class="btn btn_invert btn_submit">
</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>
<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='Last Run' mod='retailcrm'}</span></th>
<th>
<span>{l s='Status' mod='retailcrm'}</span></th>
<th>
<span>{l s='Comment' mod='retailcrm'}</span></th>
</tr>
</thead>
<tbody>
{foreach from=$lastRunDetails key=key item=item}
<tr class="{if $key === $currentJob || $key === $currentJobCli} retail-table__row-bold{/if}">
<td>
{if isset($jobsNames[$key]) }
<span title="{$key|escape:'htmlall':'UTF-8'}">{l s=$jobsNames[$key] mod='retailcrm'}</span>
{else}
{$key|escape:'htmlall':'UTF-8'}
{/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'|escape:'htmlall':'UTF-8'}{/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>
<div class="retail-table-wrapper">
<table class="retail-table retail-table-sort">
<thead>
<tr>
<th>
<span>{l s='Job 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='Last Run' mod='retailcrm'}</span>
</th>
<th>
<span>{l s='Status' mod='retailcrm'}</span></th>
<th>
<span>{l s='Comment' mod='retailcrm'}</span></th>
</tr>
</thead>
<tbody>
{foreach from=$lastRunDetails key=key item=item}
<tr class="{if $key === $currentJob || $key === $currentJobCli} retail-table__row-bold{/if}">
<td>
{if isset($jobsNames[$key]) }
<span title="{$key|escape:'htmlall':'UTF-8'}">{l s=$jobsNames[$key] mod='retailcrm'}</span>
{else}
{$key|escape:'htmlall':'UTF-8'}
{/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'|escape:'htmlall':'UTF-8'}{/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}
{/if}
</td>
<td class="retail-collapsible">
{if isset($item['error']['message'])}
<input type="checkbox" class="retail-collapsible__input" id="error_{$key|escape:'htmlall':'UTF-8'}">
<label for="error_{$key|escape:'htmlall':'UTF-8'}"
class="retail-collapsible__title retail-error-msg">
<span class="retail-error-msg">{$item['error']['message']|escape:'htmlall':'UTF-8'}</span>
<p class="retail-collapsible__content">
<b>{l s='StackTrace' mod='retailcrm'}
:</b><br>{$item['error']['trace']|escape:'htmlall':'UTF-8'}
</p>
</label>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</td>
<td class="retail-collapsible">
{if isset($item['error']['message'])}
<input type="checkbox" class="retail-collapsible__input"
id="error_{$key|escape:'htmlall':'UTF-8'}">
<label for="error_{$key|escape:'htmlall':'UTF-8'}"
class="retail-collapsible__title retail-error-msg">
<span class="retail-error-msg">{$item['error']['message']|escape:'htmlall':'UTF-8'}</span>
<p class="retail-collapsible__content">
<b>{l s='StackTrace' mod='retailcrm'}
:</b><br>{$item['error']['trace']|escape:'htmlall':'UTF-8'}
</p>
</label>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
<div class="retail-form__row retail-form__row_submit">
<form class="rcrm-form-submit-trigger"
action="{$url_post|escape:'htmlall':'UTF-8'}&amp;configure=retailcrm&amp;ajax=1"
method="post">
<input type="submit" id="reset-jobs-submit" class="btn btn_submit"
value="{l s='Reset jobs' mod='retailcrm'}"/>
</form>
</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|escape:'htmlall':'UTF-8'}</td>
<td class="retail-table-center">{$logItem.modified|escape:'htmlall':'UTF-8'}</td>
<td class="retail-table-center">{$logItem.size|escape:'htmlall':'UTF-8'}</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>
<div class="retail-table-wrapper">
<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>
{/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>
</tbody>
</table>
</thead>
<tbody>
{foreach from=$retailcrmLogsInfo key=key item=logItem}
<tr class="retail-table__row-top">
<td>{$logItem.name|escape:'htmlall':'UTF-8'}</td>
<td class="retail-table-center">{$logItem.modified|escape:'htmlall':'UTF-8'}</td>
<td class="retail-table-center">{$logItem.size|escape:'htmlall':'UTF-8'}</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" id="download-log-{$key}" style="display: none;"/>
<label for="download-log-{$key}"
style="width: 100%; text-align: center;"
class="retail-btn-svg_wrapper"
title=" {l s='Download' mod='retailcrm'}"
>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 29.978 29.978"
xml:space="preserve"
class="retail-btn-svg"
>
<g>
<path d="M25.462,19.105v6.848H4.515v-6.848H0.489v8.861c0,1.111,0.9,2.012,2.016,2.012h24.967c1.115,0,2.016-0.9,2.016-2.012 v-8.861H25.462z"/>
<path d="M14.62,18.426l-5.764-6.965c0,0-0.877-0.828,0.074-0.828s3.248,0,3.248,0s0-0.557,0-1.416c0-2.449,0-6.906,0-8.723 c0,0-0.129-0.494,0.615-0.494c0.75,0,4.035,0,4.572,0c0.536,0,0.524,0.416,0.524,0.416c0,1.762,0,6.373,0,8.742 c0,0.768,0,1.266,0,1.266s1.842,0,2.998,0c1.154,0,0.285,0.867,0.285,0.867s-4.904,6.51-5.588,7.193 C15.092,18.979,14.62,18.426,14.62,18.426z"/>
</g>
</svg>
{l s='Download' mod='retailcrm'}
</label>
</form>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="retail-form__row retail-form__row_submit">
<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"/>
<button type="submit" id="download-log-all" class="btn btn_submit">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 29.978 29.978"
style="width: 20px; fill: #0068FF;" xml:space="preserve">
<g>
<path d="M25.462,19.105v6.848H4.515v-6.848H0.489v8.861c0,1.111,0.9,2.012,2.016,2.012h24.967c1.115,0,2.016-0.9,2.016-2.012 v-8.861H25.462z"/>
<path d="M14.62,18.426l-5.764-6.965c0,0-0.877-0.828,0.074-0.828s3.248,0,3.248,0s0-0.557,0-1.416c0-2.449,0-6.906,0-8.723 c0,0-0.129-0.494,0.615-0.494c0.75,0,4.035,0,4.572,0c0.536,0,0.524,0.416,0.524,0.416c0,1.762,0,6.373,0,8.742 c0,0.768,0,1.266,0,1.266s1.842,0,2.998,0c1.154,0,0.285,0.867,0.285,0.867s-4.904,6.51-5.588,7.193 C15.092,18.979,14.62,18.426,14.62,18.426z"/>
</g>
</svg>
{l s='Download All' mod='retailcrm'}
</button>
</form>
</div>
</div>
</div>
@ -533,4 +581,5 @@
<script src="{$assets|escape:'htmlall':'UTF-8'}/js/retailcrm-upload.min.js"></script>
<script src="{$assets|escape:'htmlall':'UTF-8'}/js/retailcrm-icml.min.js"></script>
<script src="{$assets|escape:'htmlall':'UTF-8'}/js/retailcrm-export.min.js"></script>
<script src="{$assets|escape:'htmlall':'UTF-8'}/js/retailcrm-advanced.min.js"></script>
<script src="{$assets|escape:'htmlall':'UTF-8'}/js/retailcrm.min.js"></script>