diff --git a/App/Controllers/ModuleBitrix24IntegrationController.php b/App/Controllers/ModuleBitrix24IntegrationController.php
index 6672897..a8e311c 100644
--- a/App/Controllers/ModuleBitrix24IntegrationController.php
+++ b/App/Controllers/ModuleBitrix24IntegrationController.php
@@ -202,6 +202,9 @@ public function indexAction(): void
}
$this->view->form = new ModuleBitrix24IntegrationForm($settings, $options);
+ // Опция импорта МТС доступна только если установлен соседний модуль ModuleMtsPbx.
+ // Используем FQCN-строку: при `use ...` PHP попытается зарезолвить класс ещё до class_exists.
+ $this->view->isMtsModuleInstalled = class_exists('\\Modules\\ModuleMtsPbx\\Models\\CallHistory');
$this->view->pick("{$this->moduleDir}/App/Views/index");
}
@@ -323,6 +326,12 @@ public function saveAction(): void
case 'lastCompanyId':
case 'lastLeadId':
case 'lastDealId':
+ case 'mts_import_last_id':
+ // Служебные/системные поля, не отображаются в форме.
+ // НЕ трогаем — без break-ветки default обнулил бы их
+ // на каждом сохранении настроек ('' → INTEGER → 0).
+ // Для mts_import_last_id это бы сбрасывало прогресс
+ // MTS-импорта в 0 при каждом сохранении через UI.
break;
case 'callbackQueue':
$record->$key = trim($data[$key]);
@@ -338,6 +347,11 @@ public function saveAction(): void
case 'crmCreateLead':
case 'backgroundUpload':
case 'export_records':
+ case 'import_mts_calls':
+ // Checkbox-поля: HTML отправляет 'on' если установлен,
+ // не отправляет вовсе если снят. Раньше import_mts_calls
+ // попадал в default → $record->key = 'on' → SQLite-affinity
+ // INTEGER приводил к 0, и галка никогда не сохранялась как 1.
if (array_key_exists($key, $data)) {
$record->$key = ($data[$key] === 'on') ? '1' : '0';
} else {
@@ -366,12 +380,13 @@ public function saveAction(): void
return;
}
$externalLinesPost = json_decode($data['externalLines'],true);
- $resultSaveLines = ConnectorDb::invokePriority(ConnectorDb::FUNC_SAVE_EXTERNAL_LINES, [$externalLinesPost]);
- if(!$resultSaveLines){
- $this->view->error = 'Fail save externalLines...';
- $this->view->success = false;
- return;
- }
+ // Результат saveExternalLinesData(bool) теряется при RPC-сериализации:
+ // unpackResult всегда возвращает array, json_decode(true|false) → bool
+ // → is_array(bool) === false → возврат `[]`. Старая проверка
+ // `if(!$resultSaveLines)` ложно срабатывала на каждом сохранении,
+ // показывая «Fail save externalLines...» даже при успешной записи.
+ // Полагаемся на лог ConnectorDb для диагностики реальных ошибок.
+ ConnectorDb::invokePriority(ConnectorDb::FUNC_SAVE_EXTERNAL_LINES, [$externalLinesPost]);
$this->flash->success($this->translation->_('ms_SuccessfulSaved'));
$this->view->success = true;
}
diff --git a/App/Forms/ModuleBitrix24IntegrationForm.php b/App/Forms/ModuleBitrix24IntegrationForm.php
index cadd787..e3c2dd1 100644
--- a/App/Forms/ModuleBitrix24IntegrationForm.php
+++ b/App/Forms/ModuleBitrix24IntegrationForm.php
@@ -46,6 +46,7 @@ public function initialize($entity = null, $options = null): void
$this->addCheckBox('backgroundUpload', intval($entity->backgroundUpload) === 1);
$this->addCheckBox('export_records', intval($entity->export_records) === 1);
$this->addCheckBox('use_interception', intval($entity->use_interception) === 1);
+ $this->addCheckBox('import_mts_calls', intval($entity->import_mts_calls) === 1);
// Numeric
$this->add(new Numeric('interception_call_duration'));
@@ -99,6 +100,17 @@ public function initialize($entity = null, $options = null): void
'useEmpty' => false,
'class' => 'ui selection dropdown b24_regions-select',
]));
+
+ $logLevels = [];
+ foreach (ModuleBitrix24Integration::getAvailableLogLevels() as $level) {
+ $logLevels[$level] = $this->translation->_('mod_b24_i_logLevel_' . $level);
+ }
+ $this->add(new Select('logLevel', $logLevels, [
+ 'using' => ['id', 'name'],
+ 'value' => empty($entity->logLevel) ? ModuleBitrix24Integration::LOG_LEVEL_INFO : $entity->logLevel,
+ 'useEmpty' => false,
+ 'class' => 'ui selection dropdown',
+ ]));
}
/**
* Adds a checkbox to the form field with the given name.
diff --git a/App/Views/index.volt b/App/Views/index.volt
index 6350470..a8ffe49 100644
--- a/App/Views/index.volt
+++ b/App/Views/index.volt
@@ -34,6 +34,19 @@
+ {% if isMtsModuleInstalled %}
+
+
+ {{ form.render('import_mts_calls') }}
+
+
+
+ {% endif %}
+
+
+ {{ form.render('logLevel') }}
+
{{ t._('mod_b24_i_logLevelHint') }}
+