1
0
mirror of synced 2025-02-21 01:13:13 +03:00

Add enable debug info

This commit is contained in:
Dima Uryvskiy 2021-07-14 10:49:42 +03:00 committed by GitHub
parent 83e900ba95
commit 58e0e8b22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 160 additions and 33 deletions

View File

@ -274,3 +274,5 @@ msgstr "Introduce el número de teléfono correcto"
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open."
msgstr "Presionando el botón «Exportar» puedes descargar a todos los pedidos y clientes de CMS a Simla.com. Este proceso puede llevar mucho tiempo y es necesario mantener abierta la pestaña hasta que termine el proceso."
msgid "Debug information"
msgstr "Información Debug"

View File

@ -283,4 +283,8 @@ msgstr "Введите корректный номер телефона"
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open."
msgstr "Вы можете экспортировать все заказы и клиентов из CMS в Simla.com, нажав кнопку «Выгрузить». Этот процесс может занять много времени, и до его завершения необходимо держать вкладку открытой."
msgid "Debug information"
msgstr "Отладочная информация"

View File

@ -0,0 +1,7 @@
.retail-cron-info {
padding: 5px 30px !important;
}
.retail-cron-info-title {
font-weight: bold;
}

1
src/assets/css/debug-info.min.css vendored Normal file
View File

@ -0,0 +1 @@
.retail-cron-info{padding:5px 30px!important}.retail-cron-info-title{font-weight:700}

View File

@ -0,0 +1,49 @@
jQuery(function () {
function RetailcrmCronInfo()
{
this.title = jQuery('h2[id="woocommerce_integration-retailcrm_16"]').get(0);
if (typeof this.title === 'undefined') {
return false;
}
this.history = 0;
this.icml = 0;
this.inventories = 0;
let _this = this;
jQuery.ajax({
url: window.location.origin + '/wp-admin/admin-ajax.php?action=cron_info',
method: "POST",
timeout: 0,
data: {ajax: 1},
dataType: "json"
})
.done(function (response) {
_this.history = response.history;
_this.icml = response.icml;
_this.inventories = response.inventories;
_this.displayInfoAboutCron();
})
}
RetailcrmCronInfo.prototype.displayInfoAboutCron = function () {
this.table = jQuery(this.title).next();
this.table.append('<tbody class="retail-debug-info"></tbody>');
this.infoTable = jQuery('tbody[class="retail-debug-info"]').get(0);
jQuery(this.infoTable).append("<tr><td class='retail-cron-info-title'>" + "Cron launches:" + "</td></tr>");
jQuery(this.infoTable).append("<tr><td class='retail-cron-info'>" + "History: " + this.history + "</td></tr>");
jQuery(this.infoTable).append("<tr><td class='retail-cron-info'>" + "Icml: " + this.icml + "</td></tr>");
jQuery(this.infoTable).append("<tr><td class='retail-cron-info'>" + "Inventories: " + this.inventories + "</td></tr>");
}
window.RetailcrmCronInfo = RetailcrmCronInfo;
if (!(typeof RetailcrmCronInfo === 'undefined')) {
new window.RetailcrmCronInfo();
}
});

View File

@ -36,37 +36,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
) {
add_action('init', array($this, 'init_settings_fields'), 99);
}
// Include js scripts
$this->includeJsScripts();
// Include css file
$this->includeCssFile();
}//end __construct()
/**
* In this method we include JS scripts.
*
* @return void
*/
private function includeJsScripts()
{
wp_register_script('retailcrm-export', plugins_url() . '/woo-retailcrm/assets/js/retailcrm-export.js');
wp_enqueue_script('retailcrm-export');
}
/**
* In this method we include CSS file
*
* @return void
*/
private function includeCssFile()
{
wp_register_style('retailcrm-orders-export', plugins_url() . '/woo-retailcrm/assets/css/progress-bar.min.css', false, '0.1');
wp_enqueue_style('retailcrm-orders-export');
}
@ -89,6 +58,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
<?php
}
public function ajax_selected_order()
{
$ajax_url = admin_url('admin-ajax.php');
@ -112,6 +82,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
<?php
}
/**
* Initialize integration settings form fields.
*/
@ -507,7 +478,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'type' => 'checkbox'
);
/*
/**
* Upload single order
*/
$this->form_field[] = array(
@ -561,6 +532,16 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'class' => 'checkbox',
'type' => 'checkbox'
);
/**
* Debug information
*/
$this->form_fields[] = array(
'title' => __('Debug information', 'retailcrm'),
'type' => 'heading',
'description' => '',
'id' => 'cron_info_options'
);
}
}
}

View File

@ -88,6 +88,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('retailcrm_icml', array($this, 'generate_icml'));
add_action('retailcrm_inventories', array($this, 'load_stocks'));
add_action('wp_ajax_do_upload', array($this, 'upload_to_crm'));
add_action('wp_ajax_cron_info', array($this, 'get_cron_info'), 99);
add_action('wp_ajax_content_upload', array($this, 'count_upload_data'), 99);
add_action('wp_ajax_generate_icml', array($this, 'generate_icml'));
add_action('wp_ajax_order_upload', array($this, 'order_upload'));
@ -103,6 +104,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('wp_enqueue_scripts', array($this, 'include_whatsapp_icon_style'), 101);
add_action('wp_print_footer_scripts', array($this, 'initialize_whatsapp'), 101);
add_action('wp_print_footer_scripts', array($this, 'send_analytics'), 99);
add_action('admin_enqueue_scripts', array($this, 'include_files_for_admin'), 101);
add_action('woocommerce_new_order', array($this, 'create_order'), 11, 1);
if (
@ -415,6 +417,54 @@ if (!class_exists('WC_Retailcrm_Base')) {
}
/**
* In this method we include files in admin WP
*
* @return void
*/
public function include_files_for_admin()
{
$this->include_css_files_for_admin();
$this->include_js_scripts_for_admin();
}
/**
* In this method we include CSS file
*
* @return void
*/
private function include_css_files_for_admin()
{
$path = plugins_url() . '/woo-retailcrm/assets/css/';
// Include style for export
wp_register_style('retailcrm-export-style', $path . 'progress-bar.min.css', false, '0.1');
wp_enqueue_style('retailcrm-export-style');
// Include style for debug info
wp_register_style('retailcrm-debug-info-style', $path . 'debug-info.min.css', false, '0.1');
wp_enqueue_style('retailcrm-debug-info-style');
}
/**
* In this method we include JS scripts.
*
* @return void
*/
private function include_js_scripts_for_admin()
{
$path = plugins_url() . '/woo-retailcrm/assets/js/';
wp_register_script('retailcrm-export', $path . 'retailcrm-export.js');
wp_enqueue_script('retailcrm-export', $path . 'retailcrm-export.js', '', '', true);
wp_register_script('retailcrm-cron-info', $path . 'retailcrm-cron-info.js');
wp_enqueue_script('retailcrm-cron-info', $path . 'retailcrm-export.js', '', '', true);
}
/**
* Include style for WhatsApp icon
*/
@ -445,7 +495,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
/**
* Rerurn count upload data
* Return count upload data
*/
public function count_upload_data()
{
@ -460,6 +510,38 @@ if (!class_exists('WC_Retailcrm_Base')) {
}
/**
* Return time work next cron
*/
public function get_cron_info() {
$icml = 'This option is disabled';
$history = 'This option is disabled';
$inventories = 'This option is disabled';
if (isset($this->settings['history']) && $this->settings['history'] == static::YES) {
$history = date("H:i:s d-m-Y", wp_next_scheduled('retailcrm_history'));
}
if (isset($this->settings['icml']) && $this->settings['icml'] == static::YES) {
$icml = date("H:i:s d-m-Y", wp_next_scheduled('retailcrm_icml'));
}
if (isset($this->settings['sync']) && $this->settings['sync'] == static::YES) {
$inventories = date("H:i:s d-m-Y ", wp_next_scheduled('retailcrm_inventories'));
}
echo json_encode(
array(
'history' => $history,
'icml' => $icml,
'inventories' => $inventories
)
);
wp_die();
}
/**
* Get retailcrm api client
*
@ -522,3 +604,4 @@ if (!class_exists('WC_Retailcrm_Base')) {
}
}
}

Binary file not shown.

Binary file not shown.