Online Consultant (#183)

This commit is contained in:
Yura 2020-08-21 14:15:47 +03:00 committed by GitHub
parent 6a221ab5f8
commit 6b2d6aeb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 162 additions and 1 deletions

View File

@ -105,6 +105,34 @@ class ControllerExtensionModuleRetailcrm extends Controller
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector'); $this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector');
} }
/**
* Install OnlineConsultant method
*
* @return void
*/
public function install_consultant()
{
$consultant = $this->getConsultantTitle();
$this->loadModels();
$this->load->model('setting/setting');
$this->{'model_' . $this->modelExtension}->install('analytics', 'online_consultant');
$this->model_setting_setting->editSetting($consultant, array($consultant . '_status' => 1));
}
/**
* Uninstall OnlineConsultant method
*
* @return void
*/
public function uninstall_consultant()
{
$consultant = $this->getConsultantTitle();
$this->loadModels();
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting($consultant, array($consultant . '_status' => 0));
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'online_consultant');
}
/** /**
* Setup page * Setup page
* *
@ -124,6 +152,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css'); $this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
$collector = $this->getCollectorTitle(); $collector = $this->getCollectorTitle();
$consultant = $this->getConsultantTitle();
$history_setting = $this->model_setting_setting->getSetting('retailcrm_history'); $history_setting = $this->model_setting_setting->getSetting('retailcrm_history');
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) { if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
@ -144,6 +173,12 @@ class ControllerExtensionModuleRetailcrm extends Controller
$this->uninstall_collector(); $this->uninstall_collector();
} }
if ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 1) {
$this->install_consultant();
} elseif ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 0) {
$this->uninstall_consultant();
}
if (parse_url($this->request->post[$this->moduleTitle . '_url'])) { if (parse_url($this->request->post[$this->moduleTitle . '_url'])) {
$crm_url = parse_url($this->request->post[$this->moduleTitle . '_url'], PHP_URL_HOST); $crm_url = parse_url($this->request->post[$this->moduleTitle . '_url'], PHP_URL_HOST);
$this->request->post[$this->moduleTitle . '_url'] = 'https://' . $crm_url; $this->request->post[$this->moduleTitle . '_url'] = 'https://' . $crm_url;
@ -265,6 +300,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
'general_tab_text', 'general_tab_text',
'references_tab_text', 'references_tab_text',
'collector_tab_text', 'collector_tab_text',
'consultant_tab_text',
'logs_tab_text', 'logs_tab_text',
'text_yes', 'text_yes',
'text_no', 'text_no',
@ -300,7 +336,9 @@ class ControllerExtensionModuleRetailcrm extends Controller
'text_status_changes', 'text_status_changes',
'text_lenght', 'text_lenght',
'text_lenght_label', 'text_lenght_label',
'corporate_enabled_label' 'corporate_enabled_label',
'entry_code',
'entry_status'
); );
$_data = &$data; $_data = &$data;
@ -737,6 +775,22 @@ class ControllerExtensionModuleRetailcrm extends Controller
return $title; return $title;
} }
/**
* Get consultant module name
*
* @return string
*/
private function getConsultantTitle()
{
if (version_compare(VERSION, '3.0', '<')) {
$title = 'online_consultant';
} else {
$title = 'analytics_online_consultant';
}
return $title;
}
/** /**
* Check file size * Check file size
* *

View File

@ -13,6 +13,7 @@ $_['retailcrm_dict_settings'] = 'Configuration of directories correspondence'
$_['retailcrm_countries_settings'] = 'Setting of trade zones'; $_['retailcrm_countries_settings'] = 'Setting of trade zones';
$_['retailcrm_upload_order'] = 'Uploading one order'; $_['retailcrm_upload_order'] = 'Uploading one order';
$_['daemon_collector'] = 'Daemon Collector'; $_['daemon_collector'] = 'Daemon Collector';
$_['consultant_tab_text'] = 'Online Consultant';
$_['general_tab_text'] = 'Main'; $_['general_tab_text'] = 'Main';
$_['references_tab_text'] = 'Directories'; $_['references_tab_text'] = 'Directories';
$_['collector_tab_text'] = 'Daemon Collector'; $_['collector_tab_text'] = 'Daemon Collector';
@ -86,5 +87,8 @@ $_['size'] = 'Size';
$_['text_yes'] = 'Yes'; $_['text_yes'] = 'Yes';
$_['text_no'] = 'No'; $_['text_no'] = 'No';
$_['entry_code'] = 'Online consultant code';
$_['entry_status'] = 'Use code for online consultant';
// Errors // Errors
$_['error_permission'] = 'You do not have rights for changing the module settings'; $_['error_permission'] = 'You do not have rights for changing the module settings';

View File

@ -13,6 +13,7 @@ $_['retailcrm_dict_settings'] = 'Ajustes de coincidencia de directorios';
$_['retailcrm_countries_settings'] = 'Configurar zonas comerciales'; $_['retailcrm_countries_settings'] = 'Configurar zonas comerciales';
$_['retailcrm_upload_order'] = 'Exportación de un pedido'; $_['retailcrm_upload_order'] = 'Exportación de un pedido';
$_['daemon_collector'] = 'Daemon Collector'; $_['daemon_collector'] = 'Daemon Collector';
$_['consultant_tab_text'] = 'Online Consultant';
$_['general_tab_text'] = 'Inicio'; $_['general_tab_text'] = 'Inicio';
$_['references_tab_text'] = 'Directorios'; $_['references_tab_text'] = 'Directorios';
$_['collector_tab_text'] = 'Daemon Collector'; $_['collector_tab_text'] = 'Daemon Collector';
@ -86,5 +87,8 @@ $_['size'] = 'Tamaño';
$_['text_yes'] = 'Sí'; $_['text_yes'] = 'Sí';
$_['text_no'] = 'No'; $_['text_no'] = 'No';
$_['entry_code'] = 'Código para online consultant';
$_['entry_status'] = 'Usar código para online consultant';
// Errors // Errors
$_['error_permission'] = 'No tiene suficientes permisos para cambiar la configuración del módulo'; $_['error_permission'] = 'No tiene suficientes permisos para cambiar la configuración del módulo';

View File

@ -16,6 +16,7 @@ $_['daemon_collector'] = 'Демон Collector';
$_['general_tab_text'] = 'Главная'; $_['general_tab_text'] = 'Главная';
$_['references_tab_text'] = 'Справочники'; $_['references_tab_text'] = 'Справочники';
$_['collector_tab_text'] = 'Daemon Collector'; $_['collector_tab_text'] = 'Daemon Collector';
$_['consultant_tab_text'] = 'Online Consultant';
$_['logs_tab_text'] = 'Логи'; $_['logs_tab_text'] = 'Логи';
$_['collector_custom_text'] = 'Настройка полей формы'; $_['collector_custom_text'] = 'Настройка полей формы';
$_['custom_fields_tab_text'] = 'Пользовательские поля'; $_['custom_fields_tab_text'] = 'Пользовательские поля';
@ -88,3 +89,8 @@ $_['text_yes'] = 'Да';
$_['text_no'] = 'Нет'; $_['text_no'] = 'Нет';
// Errors // Errors
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля'; $_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
//online consultant
$_['entry_code'] = 'Код для online consultant';
$_['entry_status'] = 'Использовать код для online consultant';

View File

@ -40,6 +40,7 @@
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?> <?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
<li><a href="#tab-references" data-toggle="tab"><?php echo $references_tab_text; ?></a></li> <li><a href="#tab-references" data-toggle="tab"><?php echo $references_tab_text; ?></a></li>
<li><a href="#tab-collector" data-toggle="tab"><?php echo $collector_tab_text; ?></a></li> <li><a href="#tab-collector" data-toggle="tab"><?php echo $collector_tab_text; ?></a></li>
<li><a href="#tab-consultant" data-toggle="tab"><?php echo $consultant_tab_text; ?></a></li>
<li><a href="#tab-custom_fields" data-toggle="tab"><?php echo $custom_fields_tab_text; ?></a></li> <li><a href="#tab-custom_fields" data-toggle="tab"><?php echo $custom_fields_tab_text; ?></a></li>
<li><a href="#tab-logs" data-toggle="tab"><?php echo $logs_tab_text; ?></a></li> <li><a href="#tab-logs" data-toggle="tab"><?php echo $logs_tab_text; ?></a></li>
<?php endif; ?> <?php endif; ?>
@ -456,6 +457,37 @@
<?php endforeach; ?> <?php endforeach; ?>
</fieldset> </fieldset>
</div> </div>
<div class="tab-pane" id="tab-consultant">
<fieldset>
<legend><?php echo $consultant_tab_text; ?></legend>
{* onlineConsultant *}
<div class="form-group">
<label class="col-sm-2 control-label" for="input-code"><?php echo $entry_code;?></label>
<div class="col-sm-10">
<textarea name="module_retailcrm_online_consultant_code" rows="5" placeholder="<?php echo $entry_code;?>" id="retailcrm_entry_code" class="form-control">
<?php if (isset($saved_settings['module_retailcrm_online_consultant_code'])): echo $saved_settings['module_retailcrm_online_consultant_code']; endif;?>
</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_online_consultant_active"><?php echo $entry_status; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="module_retailcrm_online_consultant_active" value="1" <?php if (isset($saved_settings['module_retailcrm_online_consultant_active']) &&
$saved_settings['module_retailcrm_online_consultant_active'] == 1) :
echo 'checked'; endif; ?> />
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="module_retailcrm_online_consultant_active" value="0" <?php if (!isset($saved_settings['module_retailcrm_online_consultant_active']) ||
$saved_settings['module_retailcrm_online_consultant_active'] == 0) :
echo 'checked'; endif; ?> />
<?php echo $text_no; ?>
</label>
</div>
</div>
</fieldset>
</div>
<div class="tab-pane" id="tab-custom_fields"> <div class="tab-pane" id="tab-custom_fields">
<fieldset> <fieldset>
<legend><?php echo $retailcrm_dict_custom_fields; ?></legend> <legend><?php echo $retailcrm_dict_custom_fields; ?></legend>
@ -655,3 +687,4 @@
} }
}); });
</script> </script>

View File

@ -39,6 +39,7 @@
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %} {% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li> <li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li> <li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
<li><a href="#tab-consultant" data-toggle="tab">{{ consultant_tab_text }}</a></li>
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li> <li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li> <li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
{% endif %} {% endif %}
@ -465,6 +466,38 @@
{% endfor %} {% endfor %}
</fieldset> </fieldset>
</div> </div>
<div class="tab-pane" id="tab-consultant">
<legend>{{ consultant_tab_text }}</legend>
<fieldset>
{# online cosultant #}
<div class="form-group">
<label class="col-sm-2 control-label" for="input-code">{{ entry_code }}</label>
<div class="col-sm-10">
<textarea name="module_retailcrm_online_consultant_code" rows="5" placeholder="{{ entry_code }}" id="retailcrm_entry_code" class="form-control">
{% if saved_settings.module_retailcrm_online_consultant_code is defined %}
{{ saved_settings.module_retailcrm_online_consultant_code }}{% endif %}
</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_online_consultant_active" class="col-md-4">{{ entry_status }}</label>
<div class="col-sm-10">
<label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_online_consultant_active" value="1" {% if saved_settings.module_retailcrm_online_consultant_active is defined and
saved_settings.module_retailcrm_online_consultant_active == 1 %} {{ 'checked' }}
{% endif %}>
{{ text_yes }}
</label>
<label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_online_consultant_active" value="0" {% if not saved_settings.module_retailcrm_online_consultant_active or
saved_settings.module_retailcrm_online_consultant_active == 0 %} {{ 'checked' }}
{% endif %}>
{{ text_no }}
</label>
</div>
</div>
</fieldset>
</div>
<div class="tab-pane" id="tab-custom_fields"> <div class="tab-pane" id="tab-custom_fields">
<fieldset> <fieldset>
<legend>{{ retailcrm_dict_custom_fields }}</legend> <legend>{{ retailcrm_dict_custom_fields }}</legend>
@ -665,3 +698,4 @@
} }
}); });
</script> </script>

View File

@ -0,0 +1,26 @@
<?php
/**
* Class ControllerExtensionAnalyticsOnlineConsultant
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class ControllerExtensionAnalyticsOnlineConsultant extends Controller {
/**
* @return string
*/
public function index() {
$this->load->model('setting/setting');
$this->load->library('retailcrm/retailcrm');
$moduleTitle = $this->retailcrm->getModuleTitle();
$settings = $this->model_setting_setting->getSetting($moduleTitle);
$setting = trim($settings['module_retailcrm_online_consultant_code']);
return html_entity_decode($setting, ENT_QUOTES, 'UTF-8');
}
}