Added curl checking
This commit is contained in:
parent
e7d54bf4e8
commit
58340c9164
@ -10,7 +10,7 @@ IncludeModuleLangFile(__FILE__);
|
|||||||
if (class_exists('intaro_intarocrm'))
|
if (class_exists('intaro_intarocrm'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
class intaro_intarocrm extends CModule
|
class intaro_intarocrm extends CModule
|
||||||
{
|
{
|
||||||
var $MODULE_ID = 'intaro.intarocrm';
|
var $MODULE_ID = 'intaro.intarocrm';
|
||||||
var $MODULE_VERSION;
|
var $MODULE_VERSION;
|
||||||
@ -21,7 +21,7 @@ class intaro_intarocrm extends CModule
|
|||||||
var $PARTNER_NAME;
|
var $PARTNER_NAME;
|
||||||
var $PARTNER_URI;
|
var $PARTNER_URI;
|
||||||
var $INTARO_CRM_API;
|
var $INTARO_CRM_API;
|
||||||
|
|
||||||
var $CRM_API_HOST_OPTION = 'api_host';
|
var $CRM_API_HOST_OPTION = 'api_host';
|
||||||
var $CRM_API_KEY_OPTION = 'api_key';
|
var $CRM_API_KEY_OPTION = 'api_key';
|
||||||
var $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
var $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||||
@ -31,9 +31,9 @@ class intaro_intarocrm extends CModule
|
|||||||
var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||||
var $CRM_ORDER_LAST_ID = 'order_last_id';
|
var $CRM_ORDER_LAST_ID = 'order_last_id';
|
||||||
|
|
||||||
|
|
||||||
var $INSTALL_PATH;
|
var $INSTALL_PATH;
|
||||||
|
|
||||||
function intaro_intarocrm()
|
function intaro_intarocrm()
|
||||||
{
|
{
|
||||||
$arModuleVersion = array();
|
$arModuleVersion = array();
|
||||||
@ -48,51 +48,56 @@ class intaro_intarocrm extends CModule
|
|||||||
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
|
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
|
||||||
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
|
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions DoInstall and DoUninstall are
|
* Functions DoInstall and DoUninstall are
|
||||||
* All other functions are optional
|
* All other functions are optional
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function DoInstall()
|
function DoInstall()
|
||||||
{
|
{
|
||||||
global $APPLICATION, $step, $arResult;
|
global $APPLICATION, $step, $arResult;
|
||||||
|
|
||||||
|
if (!in_array('curl', get_loaded_extensions())) {
|
||||||
|
$APPLICATION->ThrowException( GetMessage("INTAROCRM_CURL_ERR") );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
include($this->INSTALL_PATH . '/../classes/general/RestApi.php');
|
include($this->INSTALL_PATH . '/../classes/general/RestApi.php');
|
||||||
include($this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php');
|
include($this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php');
|
||||||
|
|
||||||
$step = intval($_REQUEST['step']);
|
$step = intval($_REQUEST['step']);
|
||||||
|
|
||||||
if ($step <= 1) {
|
if ($step <= 1) {
|
||||||
if(!CModule::IncludeModule("sale")) {
|
if(!CModule::IncludeModule("sale")) {
|
||||||
$arResult['errCode'] = 'ERR_SALE';
|
$arResult['errCode'] = 'ERR_SALE';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CModule::IncludeModule("iblock")) {
|
if(!CModule::IncludeModule("iblock")) {
|
||||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CModule::IncludeModule("catalog")) {
|
if(!CModule::IncludeModule("catalog")) {
|
||||||
$arResult['errCode'] = 'ERR_CATALOG';
|
$arResult['errCode'] = 'ERR_CATALOG';
|
||||||
}
|
}
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
||||||
);
|
);
|
||||||
} else if ($step == 2) {
|
} else if ($step == 2) {
|
||||||
if(!CModule::IncludeModule("sale")) {
|
if(!CModule::IncludeModule("sale")) {
|
||||||
$arResult['errCode'] = 'ERR_SALE';
|
$arResult['errCode'] = 'ERR_SALE';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CModule::IncludeModule("iblock")) {
|
if(!CModule::IncludeModule("iblock")) {
|
||||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CModule::IncludeModule("catalog")) {
|
if(!CModule::IncludeModule("catalog")) {
|
||||||
$arResult['errCode'] = 'ERR_CATALOG';
|
$arResult['errCode'] = 'ERR_CATALOG';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($arResult['errCode']) && $arResult['errCode']) {
|
if(isset($arResult['errCode']) && $arResult['errCode']) {
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
@ -100,15 +105,15 @@ class intaro_intarocrm extends CModule
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
|
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
|
||||||
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
|
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
|
||||||
|
|
||||||
// form correct url
|
// form correct url
|
||||||
$api_host = parse_url($api_host);
|
$api_host = parse_url($api_host);
|
||||||
$api_host = $api_host['scheme'] . '://' . $api_host['host'];
|
$api_host = $api_host['scheme'] . '://' . $api_host['host'];
|
||||||
|
|
||||||
if(!$api_host || !$api_key) {
|
if(!$api_host || !$api_key) {
|
||||||
$arResult['errCode'] = 'ERR_FIELDS_API_HOST';
|
$arResult['errCode'] = 'ERR_FIELDS_API_HOST';
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
@ -116,26 +121,26 @@ class intaro_intarocrm extends CModule
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
|
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
|
||||||
|
|
||||||
$this->INTARO_CRM_API->paymentStatusesList();
|
$this->INTARO_CRM_API->paymentStatusesList();
|
||||||
|
|
||||||
//check connection & apiKey valid
|
//check connection & apiKey valid
|
||||||
if((int) $this->INTARO_CRM_API->getStatusCode() != 200) {
|
if((int) $this->INTARO_CRM_API->getStatusCode() != 200) {
|
||||||
$arResult['errCode'] = 'ERR_' . $this->INTARO_CRM_API->getStatusCode();
|
$arResult['errCode'] = 'ERR_' . $this->INTARO_CRM_API->getStatusCode();
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
|
||||||
|
|
||||||
//prepare crm lists
|
//prepare crm lists
|
||||||
$arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList();
|
$arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList();
|
||||||
$arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
|
$arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
|
||||||
@ -143,7 +148,7 @@ class intaro_intarocrm extends CModule
|
|||||||
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses
|
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses
|
||||||
$arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList();
|
$arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList();
|
||||||
$arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups
|
$arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups
|
||||||
|
|
||||||
//bitrix orderTypesList -- personTypes
|
//bitrix orderTypesList -- personTypes
|
||||||
$dbOrderTypesList = CSalePersonType::GetList(
|
$dbOrderTypesList = CSalePersonType::GetList(
|
||||||
array(
|
array(
|
||||||
@ -157,13 +162,13 @@ class intaro_intarocrm extends CModule
|
|||||||
false,
|
false,
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
|
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
|
||||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix deliveryTypesList
|
//bitrix deliveryTypesList
|
||||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||||
array(
|
array(
|
||||||
@ -177,78 +182,78 @@ class intaro_intarocrm extends CModule
|
|||||||
false,
|
false,
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
|
$arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
|
||||||
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix paymentTypesList
|
//bitrix paymentTypesList
|
||||||
$dbPaymentTypesList = CSalePaySystem::GetList(
|
$dbPaymentTypesList = CSalePaySystem::GetList(
|
||||||
array(
|
array(
|
||||||
"SORT" => "ASC",
|
"SORT" => "ASC",
|
||||||
"NAME" => "ASC"
|
"NAME" => "ASC"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
"ACTIVE" => "Y"
|
"ACTIVE" => "Y"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
|
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
|
$arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
|
||||||
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
|
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix paymentStatusesList --statuses
|
//bitrix paymentStatusesList --statuses
|
||||||
$dbPaymentStatusesList = CSaleStatus::GetList(
|
$dbPaymentStatusesList = CSaleStatus::GetList(
|
||||||
array(
|
array(
|
||||||
"SORT" => "ASC",
|
"SORT" => "ASC",
|
||||||
"NAME" => "ASC"
|
"NAME" => "ASC"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
"LID" => "ru", //ru
|
"LID" => "ru", //ru
|
||||||
"ACTIVE" => "Y"
|
"ACTIVE" => "Y"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
|
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList;
|
$arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList;
|
||||||
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
$arResult['bitrixPaymentStatusesList'][] = array(
|
$arResult['bitrixPaymentStatusesList'][] = array(
|
||||||
'ID' => 'Y',
|
'ID' => 'Y',
|
||||||
'NAME' => GetMessage('CANCELED')
|
'NAME' => GetMessage('CANCELED')
|
||||||
);
|
);
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if ($step == 3) {
|
} else if ($step == 3) {
|
||||||
if(!CModule::IncludeModule("sale")) {
|
if(!CModule::IncludeModule("sale")) {
|
||||||
//handler
|
//handler
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
||||||
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
||||||
ICrmOrderActions::uploadOrders(true); // each 50
|
ICrmOrderActions::uploadOrders(true); // each 50
|
||||||
|
|
||||||
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
||||||
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
|
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
|
||||||
$countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array());
|
$countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array());
|
||||||
|
|
||||||
if(!isset($_POST['finish']))
|
if(!isset($_POST['finish']))
|
||||||
$finish = 0;
|
$finish = 0;
|
||||||
else
|
else
|
||||||
$finish = (int) $_POST['finish'];
|
$finish = (int) $_POST['finish'];
|
||||||
|
|
||||||
$percent = 100 - round(($countLeft * 100 / $countAll), 1);
|
$percent = 100 - round(($countLeft * 100 / $countAll), 1);
|
||||||
|
|
||||||
if(!$countLeft) {
|
if(!$countLeft) {
|
||||||
$api_host = COption::GetOptionString($mid, $this->CRM_API_HOST_OPTION, 0);
|
$api_host = COption::GetOptionString($mid, $this->CRM_API_HOST_OPTION, 0);
|
||||||
$api_key = COption::GetOptionString($mid, $this->CRM_API_KEY_OPTION, 0);
|
$api_key = COption::GetOptionString($mid, $this->CRM_API_KEY_OPTION, 0);
|
||||||
@ -256,20 +261,20 @@ class intaro_intarocrm extends CModule
|
|||||||
$this->INTARO_CRM_API->statisticUpdate();
|
$this->INTARO_CRM_API->statisticUpdate();
|
||||||
$finish = 1;
|
$finish = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$APPLICATION->RestartBuffer();
|
$APPLICATION->RestartBuffer();
|
||||||
header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
|
header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
|
||||||
die(json_encode(array("finish" => $finish, "percent" => $percent)));
|
die(json_encode(array("finish" => $finish, "percent" => $percent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['back']) && $_POST['back']) {
|
if (isset($_POST['back']) && $_POST['back']) {
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix orderTypesList -- personTypes
|
//bitrix orderTypesList -- personTypes
|
||||||
$dbOrderTypesList = CSalePersonType::GetList(
|
$dbOrderTypesList = CSalePersonType::GetList(
|
||||||
array(
|
array(
|
||||||
@ -283,15 +288,15 @@ class intaro_intarocrm extends CModule
|
|||||||
false,
|
false,
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
//form order types ids arr
|
//form order types ids arr
|
||||||
$orderTypesArr = array();
|
$orderTypesArr = array();
|
||||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
|
$orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
|
||||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix deliveryTypesList
|
//bitrix deliveryTypesList
|
||||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||||
array(
|
array(
|
||||||
@ -305,75 +310,75 @@ class intaro_intarocrm extends CModule
|
|||||||
false,
|
false,
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
//form delivery types ids arr
|
//form delivery types ids arr
|
||||||
$deliveryTypesArr = array();
|
$deliveryTypesArr = array();
|
||||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
||||||
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix paymentTypesList
|
//bitrix paymentTypesList
|
||||||
$dbPaymentTypesList = CSalePaySystem::GetList(
|
$dbPaymentTypesList = CSalePaySystem::GetList(
|
||||||
array(
|
array(
|
||||||
"SORT" => "ASC",
|
"SORT" => "ASC",
|
||||||
"NAME" => "ASC"
|
"NAME" => "ASC"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
"ACTIVE" => "Y"
|
"ACTIVE" => "Y"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//form payment types ids arr
|
//form payment types ids arr
|
||||||
$paymentTypesArr = array();
|
$paymentTypesArr = array();
|
||||||
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
|
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
|
$paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
|
||||||
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
|
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//bitrix paymentStatusesList
|
//bitrix paymentStatusesList
|
||||||
$dbPaymentStatusesList = CSaleStatus::GetList(
|
$dbPaymentStatusesList = CSaleStatus::GetList(
|
||||||
array(
|
array(
|
||||||
"SORT" => "ASC",
|
"SORT" => "ASC",
|
||||||
"NAME" => "ASC"
|
"NAME" => "ASC"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
"LID" => "ru", //ru
|
"LID" => "ru", //ru
|
||||||
"ACTIVE" => "Y"
|
"ACTIVE" => "Y"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//form payment statuses ids arr
|
//form payment statuses ids arr
|
||||||
$paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y']));
|
$paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y']));
|
||||||
|
|
||||||
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
|
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
|
$paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
|
||||||
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
//form payment ids arr
|
//form payment ids arr
|
||||||
$paymentArr = array();
|
$paymentArr = array();
|
||||||
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
|
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
|
||||||
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
|
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
|
||||||
|
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr));
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr));
|
||||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
|
||||||
);
|
);
|
||||||
} else if ($step == 4) {
|
} else if ($step == 4) {
|
||||||
|
|
||||||
RegisterModule($this->MODULE_ID);
|
RegisterModule($this->MODULE_ID);
|
||||||
|
|
||||||
//agent
|
//agent
|
||||||
$dateAgent = new DateTime();
|
$dateAgent = new DateTime();
|
||||||
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
||||||
@ -389,21 +394,21 @@ class intaro_intarocrm extends CModule
|
|||||||
$dateAgent->format('d.m.Y H:i:s'), // date of first start
|
$dateAgent->format('d.m.Y H:i:s'), // date of first start
|
||||||
30
|
30
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->CopyFiles();
|
$this->CopyFiles();
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_INSTALL_TITLE'),
|
GetMessage('MODULE_INSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DoUninstall() {
|
function DoUninstall() {
|
||||||
global $APPLICATION;
|
global $APPLICATION;
|
||||||
|
|
||||||
CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID);
|
CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID);
|
||||||
|
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR);
|
||||||
@ -411,16 +416,16 @@ class intaro_intarocrm extends CModule
|
|||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
|
||||||
|
|
||||||
$this->DeleteFiles();
|
$this->DeleteFiles();
|
||||||
|
|
||||||
UnRegisterModule($this->MODULE_ID);
|
UnRegisterModule($this->MODULE_ID);
|
||||||
|
|
||||||
$APPLICATION->IncludeAdminFile(
|
$APPLICATION->IncludeAdminFile(
|
||||||
GetMessage('MODULE_UNINSTALL_TITLE'),
|
GetMessage('MODULE_UNINSTALL_TITLE'),
|
||||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
|
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CopyFiles() {
|
function CopyFiles() {
|
||||||
|
@ -9,3 +9,5 @@ $MESS ['CANCELED'] = 'Флаг «Отменен»';
|
|||||||
$MESS ['ERR_SALE'] = 'Отсутствует модуль sale! Дальнейшая установка невозможна.';
|
$MESS ['ERR_SALE'] = 'Отсутствует модуль sale! Дальнейшая установка невозможна.';
|
||||||
$MESS ['ERR_IBLOCK'] = 'Отсутствует модуль iblock! Дальнейшая установка невозможна.';
|
$MESS ['ERR_IBLOCK'] = 'Отсутствует модуль iblock! Дальнейшая установка невозможна.';
|
||||||
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
|
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
|
||||||
|
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
|
||||||
|
$MESS ['INTAROCRM_CURL_ERR'] = 'Для работы модуля интеграции с IntaroCRM требуется PHP-расширение CURL.';
|
||||||
|
Loading…
Reference in New Issue
Block a user