1
0
mirror of synced 2024-11-22 13:26:10 +03:00
This commit is contained in:
Ilyas Salikhov 2013-08-26 10:33:51 +04:00
commit 535e665fc7
15 changed files with 1930 additions and 0 deletions

View File

@ -0,0 +1,307 @@
<?php
class ICMLLoader {
public $iblocks;
public $filename;
public $articleProperties;
public $application;
public $encoding = 'utf-8';
protected $fp;
protected $mainSection = 1000000;
public function Load()
{
global $USER;
if(!isset($USER))
$USER = new CUser;
if (count($this->iblocks) < count($this->articleProperties))
return false;
$categories = $this->GetCategories();
$offers = $this->GetOffers();
$this->PrepareFile();
$this->PreWriteCatalog();
$this->WriteCategories($categories);
$this->WriteOffers($offers);
$this->PostWriteCatalog();
$this->CloseFile();
return true;
}
protected function PrepareValue($text)
{
$newText = $this->application->ConvertCharset($text, LANG_CHARSET, $this->encoding);
$newText = strip_tags($newText);
$newText = str_replace("&", "&#x26;", $newText);
return $newText;
}
protected function PrepareFile()
{
$fullFilename = $_SERVER["DOCUMENT_ROOT"] . $this->filename;
CheckDirPath($fullFilename);
if (!$this->fp = @fopen($fullFilename, "w"))
return false;
else
return true;
}
protected function PreWriteCatalog()
{
@fwrite($this->fp, "<yml_catalog date=\"" . $this->PrepareValue(Date("Y-m-d H:i:s")) . "\">\n");
@fwrite($this->fp, "<shop>\n");
@fwrite($this->fp, "<name>". $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."</name>\n");
@fwrite($this->fp, "<company>".$this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."</company>\n");
}
protected function WriteCategories($categories)
{
@fwrite($this->fp, "<categories>\n");
foreach ($categories as $category) {
@fwrite($this->fp, $category . "\n");
}
@fwrite($this->fp, "</categories>\n");
}
protected function WriteOffers($offers)
{
@fwrite($this->fp, "<offers>\n");
foreach ($offers as $offer) {
@fwrite($this->fp, $offer . "\n");
}
@fwrite($this->fp, "</offers>\n");
}
protected function PostWriteCatalog()
{
@fwrite($this->fp, "</shop>\n");
@fwrite($this->fp, "</yml_catalog>\n");
}
protected function CloseFile()
{
@fclose($this->fp);
}
protected function GetCategories()
{
$categories = array();
foreach ($this->iblocks as $id)
{
$filter = Array(
"IBLOCK_ID" => $id,
"ACTIVE" => "Y",
"IBLOCK_ACTIVE" => "Y",
"GLOBAL_ACTIVE" => "Y"
);
$dbRes = CIBlockSection::GetList(array("left_margin" => "asc"), $filter);
while ($arRes = $dbRes->Fetch())
{
$categories[] = $this->BuildCategory($arRes);
}
if (count($categories) == 0)
{
$arRes = Array();
$arRes['ID'] = $this->mainSection + $id;
$arRes['IBLOCK_SECTION_ID'] = 0;
$arRes['NAME'] = "Основной раздел каталога";
$categories[] = $this->BuildCategory($arRes);
}
}
return $categories;
}
protected function BuildCategory($arCategory)
{
return "
<category id=\"" . $this->PrepareValue($arCategory["ID"]) . "\""
. ( intval($arCategory["IBLOCK_SECTION_ID"] ) > 0 ?
" parentId=\"" . $this->PrepareValue($arCategory["IBLOCK_SECTION_ID"]) . "\""
:"")
. ">"
. $this->PrepareValue($arCategory["NAME"])
. "</category>";
}
protected function GetOffers()
{
$offers = Array();
foreach ($this->iblocks as $key => $id)
{
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
$arSelect = Array (
"ID",
"LID",
"IBLOCK_ID",
"IBLOCK_SECTION_ID",
"ACTIVE",
"ACTIVE_FROM",
"ACTIVE_TO",
"NAME",
"DETAIL_PICTURE",
"DETAIL_TEXT",
"DETAIL_PICTURE",
"LANG_DIR",
"DETAIL_PAGE_URL"
);
if (isset($this->articleProperties[$id]))
$arSelect[] = "PROPERTY_" . $this->articleProperties[$id];
$filter = Array (
"IBLOCK_ID" => $id,
"ACTIVE_DATE" => "Y",
"ACTIVE" => "Y",
"INCLUDE_SUBSECTIONS" => "Y"
);
$dbResProducts = CIBlockElement::GetList(array(), $filter, false, false, $arSelect);
while ($product = $dbResProducts->GetNextElement()) {
$product = $product->GetFields();
$categoriesString = "";
$existOffer = false;
if (!empty($iblockOffer['IBLOCK_ID'])) {
$arFilterOffer = Array (
'IBLOCK_ID' => $iblockOffer['IBLOCK_ID'],
'PROPERTY_'.$iblockOffer['SKU_PROPERTY_ID'] => $product["ID"]
);
$arSelectOffer = Array (
'ID',
"NAME",
"DETAIL_TEXT",
"DETAIL_PAGE_URL",
"DETAIL_PICTURE"
);
if (isset($this->articleProperties[$id]))
$arSelectOffer[] = "PROPERTY_" . $this->articleProperties[$id];
$rsOffers = CIBlockElement::GetList(array(), $arFilterOffer, false, false, $arSelectOffer);
while ($arOffer = $rsOffers->GetNext()) {
$dbResCategories = CIBlockElement::GetElementGroups($arOffer['ID'], true);
while ($arResCategory = $dbResCategories->Fetch()) {
$categoriesString .= "<categoryId>" . $arResCategory["ID"] . "</categoryId>\n";
}
if ($categoriesString == '')
$categoriesString .= "<categoryId>" . ($this->mainSection + $id) . "</categoryId>\n";
$offer = CCatalogProduct::GetByID($arOffer['ID']);
$arOffer['QUANTITY'] = $offer["QUANTITY"];
$arOffer['PRODUCT_ID'] = $product["ID"];
$arOffer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
$arOffer['DETAIL_PICTURE'] = $product["DETAIL_PICTURE"];
$arOffer['PREVIEW_PICTURE'] = $product["PREVIEW_PICTURE"];
$arOffer['PRODUCT_NAME'] = $product["NAME"];
if (isset($this->articleProperties[$id]))
$arOffer['ARTICLE'] = $arOffer["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"];
$dbPrice = GetCatalogProductPrice($arOffer["ID"],1);
$arOffer['PRICE'] = $dbPrice['PRICE'];
$offers[] = $this->BuildOffer($arOffer, $categoriesString, $iblock);
$existOffer = true;
}
}
if (!$existOffer) {
$dbResCategories = CIBlockElement::GetElementGroups($product["ID"], true);
while ($arResCategory = $dbResCategories->Fetch()) {
$categoriesString .= "<categoryId>" . $arResCategory["ID"] . "</categoryId>\n";
}
if ($categoriesString == '')
$categoriesString .= "<categoryId>" . ($this->mainSection + $id) . "</categoryId>\n";
$offer = CCatalogProduct::GetByID($product['ID']);
$product['QUANTITY'] = $offer["QUANTITY"];
$product['PRODUCT_ID'] = $product["ID"];
$product['PRODUCT_NAME'] = $product["NAME"];
if (isset($this->articleProperties[$id]))
$product['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"];
$dbPrice = GetCatalogProductPrice($product["ID"],1);
$product['PRICE'] = $dbPrice['PRICE'];
$offers[] = $this->BuildOffer($product, $categoriesString, $iblock);
}
}
}
return $offers;
}
protected function BuildOffer($arOffer, $categoriesString, $iblock)
{
$offer = "";
$offer .= "<offer id=\"" .$this->PrepareValue($arOffer["ID"]) . "\" ".
"productId=\"" . $this->PrepareValue($arOffer["PRODUCT_ID"]) . "\" ".
"quantity=\"" . $this->PrepareValue(DoubleVal($arOffer['QUANTITY'])) . "\">\n";
$offer .= "<url>http://" . $this->PrepareValue($iblock['IBLOCK_DB']['SERVER_NAME']) . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "</url>\n";
$offer .= "<price>" . $this->PrepareValue($arOffer['PRICE']) . "</price>\n";
$offer .= $categoriesString;
$detailPicture = intval($arOffer["DETAIL_PICTURE"]);
$previewPicture = intval($arOffer["PREVIEW_PICTURE"]);
if ($detailPicture > 0 || $previewPicture > 0)
{
$picture = $detailPicture;
if ($picture <= 0) {
$picture = $previewPicture;
}
if ($arFile = CFile::GetFileArray($picture))
{
if(substr($arFile["SRC"], 0, 1) == "/")
$strFile = "http://" . $this->PrepareValue($iblock['IBLOCK_DB']['SERVER_NAME']) . implode("/", array_map("rawurlencode", explode("/", $arFile["SRC"])));
elseif(preg_match("/^(http|https):\\/\\/(.*?)\\/(.*)\$/", $arFile["SRC"], $match))
$strFile = "http://" . $this->PrepareValue($match[2]) . '/' . implode("/", array_map("rawurlencode", explode("/", $this->PrepareValue($match[3]))));
else
$strFile = $arFile["SRC"];
$offer .= "<picture>" . $this->PrepareValue($strFile) . "</picture>\n";
}
}
$offer .= "<name>" . $this->PrepareValue($arOffer["NAME"]) . "</name>\n";
$offer .= "<xmlId>" . $this->PrepareValue($arOffer["EXTERNAL_ID"]) . "</xmlId>\n";
$offer .= "<productName>" . $this->PrepareValue($arOffer["PRODUCT_NAME"]) . "</productName>\n";
if (isset($arOffer["ARTICLE"]))
$offer .= "<article>" . $this->PrepareValue($arOffer["ARTICLE"]) . "</article>\n";
$offer.= "</offer>\n";
return $offer;
}
}

View File

@ -0,0 +1,2 @@
* При настройке выгрузки каталога сделано необязательным указание артикула товара
* Доработан скрипт генерации ICML-файла в части работы со спецсимволами

View File

@ -0,0 +1,19 @@
<?php
set_time_limit(0);
global $APPLICATION;
if (!CModule::IncludeModule("iblock"))
return;
if (!CModule::IncludeModule("catalog"))
return;
if (!CModule::IncludeModule("intaro.intarocrm"))
return;
$loader = new ICMLLoader();
$loader->iblocks = $IBLOCK_EXPORT;
$loader->articleProperties = $IBLOCK_PROPERTY_ARTICLE;
$loader->filename = $SETUP_FILE_NAME;
$loader->application = $APPLICATION;
$loader->Load();

View File

@ -0,0 +1,294 @@
<?
if(!check_bitrix_sessid()) return;
__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.intarocrm/lang/", "/icml_export_setup.php"));
if (($ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1)
{
if (isset($arOldSetupVars['SETUP_FILE_NAME']))
$SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME'];
if (isset($arOldSetupVars['SETUP_PROFILE_NAME']))
$SETUP_PROFILE_NAME = $arOldSetupVars['SETUP_PROFILE_NAME'];
if (isset($arOldSetupVars['IBLOCK_EXPORT']))
$IBLOCK_EXPORT = $arOldSetupVars['IBLOCK_EXPORT'];
if (isset($arOldSetupVars['IBLOCK_PROPERTY_ARTICLE']))
$IBLOCK_PROPERTY_ARTICLE = $arOldSetupVars['IBLOCK_PROPERTY_ARTICLE'];
}
if ($STEP>1)
{
if (count($IBLOCK_EXPORT) < count($IBLOCK_PROPERTY_ARTICLE))
$arSetupErrors[] = GetMessage("ERROR_ARTICLE_NOT_SET");
if (strlen($SETUP_FILE_NAME)<=0)
{
$arSetupErrors[] = GetMessage("CET_ERROR_NO_FILENAME");
}
elseif ($APPLICATION->GetFileAccessPermission($SETUP_FILE_NAME) < "W")
{
$arSetupErrors[] = str_replace("#FILE#", $SETUP_FILE_NAME, GetMessage('CET_YAND_RUN_ERR_SETUP_FILE_ACCESS_DENIED'));
}
if (($ACTION=="EXPORT_SETUP" || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && strlen($SETUP_PROFILE_NAME)<=0)
{
$arSetupErrors[] = GetMessage("CET_ERROR_NO_PROFILE_NAME");
}
if (!empty($arSetupErrors))
{
$STEP = 1;
}
}
if (!empty($arSetupErrors))
echo ShowError(implode('<br />', $arSetupErrors));
if ($STEP==1)
{
?>
<form method="post" action="<?php echo $APPLICATION->GetCurPage(); ?>" >
<?if ($ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY')
{
?><input type="hidden" name="PROFILE_ID" value="<? echo intval($PROFILE_ID); ?>"><?
}
?>
<font class="text"><?=GetMessage("EXPORT_CATALOGS");?><br><br></font>
<?
if (!isset($IBLOCK_EXPORT) || !is_array($IBLOCK_EXPORT))
{
$IBLOCK_EXPORT = array();
}
$boolAll = false;
$intCountChecked = 0;
$intCountAvailIBlock = 0;
$arIBlockList = array();
$db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W'));
while ($res = $db_res->Fetch())
{
if ($arCatalog = CCatalog::GetByIDExt($res["ID"]))
{
if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P")
{
$arSiteList = array();
$rsSites = CIBlock::GetSite($res["ID"]);
while ($arSite = $rsSites->Fetch())
{
$arSiteList[] = $arSite["SITE_ID"];
}
$db_properties = CIBlock::GetProperties($res['ID'], Array());
$properties = Array();
while($prop = $db_properties->Fetch())
$properties[] = $prop;
if (count($IBLOCK_EXPORT) != 0)
$boolExport = (in_array($res['ID'], $IBLOCK_EXPORT));
else
$boolExport = true;
$arIBlockList[] = array(
'ID' => $res['ID'],
'NAME' => $res['NAME'],
'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'],
'IBLOCK_EXPORT' => $boolExport,
'PROPERTIES' => $properties,
'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null,
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
);
if ($boolExport)
$intCountChecked++;
$intCountAvailIBlock++;
}
}
}
if (count($IBLOCK_EXPORT) != 0) {
if ($intCountChecked == $intCountAvailIBlock)
$boolAll = true;
} else {
$intCountChecked = $intCountAvailIBlock;
$boolAll = true;
}
?>
<table class="adm-list-table" id="export_setup">
<thead>
<tr class="adm-list-table-header">
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?echo GetMessage("CATALOG");?></div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">
<?echo GetMessage("EXPORT2INTAROCML");?>&nbsp;
</div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?echo GetMessage("PROPERTY");?></div>
</td>
</tr>
</thead>
<tbody>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<?echo GetMessage("ALL_CATALOG");?>
</td>
<td class="adm-list-table-cell">
<input style="vertical-align: middle;" type="checkbox" name="icml_export_all" id="icml_export_all" value="Y" onclick="checkAll(this,<? echo $intCountAvailIBlock; ?>);"<? echo ($boolAll ? ' checked' : ''); ?>>
</td>
<td class="adm-list-table-cell">
&nbsp;
</td>
</tr>
<?
foreach ($arIBlockList as $key => $arIBlock)
{
?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell" style="padding-left: 5em">
<? echo htmlspecialcharsex("[".$arIBlock["IBLOCK_TYPE_ID"]."] ".$arIBlock["NAME"]." ".$arIBlock['SITE_LIST']); ?>
</td>
<td class="adm-list-table-cell">
<font class="tablebodytext">
<input
type="checkbox"
name="IBLOCK_EXPORT[<?=$arIBlock["ID"]?>]"
id="IBLOCK_EXPORT<?=$arIBlock["ID"]?>"
value="<?=$arIBlock["ID"]?>"
<? if ($arIBlock['IBLOCK_EXPORT']) echo " checked"; ?>
onclick="checkOne(this,<? echo $intCountAvailIBlock; ?>);"
>
</font>
</td>
<td class="adm-list-table-cell">
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_ARTICLE<?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_ARTICLE[<?=$arIBlock["ID"]?>]"
class="property-export">
<option value=""></option>
<?
foreach ($arIBlock['PROPERTIES'] as $prop)
{
?>
<option value="<?=$prop['CODE'] ?>"
<?
if ($arIBlock['OLD_PROPERTY_SELECT'] == $prop["CODE"]){
echo " selected";
} else {
if ($arIBlock['OLD_PROPERTY_SELECT'] != "") {
if ($prop["CODE"] == "ARTICLE" ||
$prop["CODE"] == "ART" ||
$prop["CODE"] == "ARTNUMBER" )
echo " selected";
}
}
?>
>
<?=$prop["NAME"];?>
</option>
<?
}
?>
</select>
</td>
</tr>
<?
}
?>
</tbody>
</table>
<input type="hidden" name="count_checked" id="count_checked" value="<? echo $intCountChecked; ?>">
<br>
<br>
<br>
<font class="text"><?=GetMessage("FILENAME");?><br><br></font>
<input type="text" name="SETUP_FILE_NAME"
value="<?=htmlspecialcharsbx(strlen($SETUP_FILE_NAME) > 0 ?
$SETUP_FILE_NAME :
(COption::GetOptionString(
'catalog',
'export_default_path',
'/bitrix/catalog_export/'))
.'intarocrm'/* .mt_rand(0, 999999) */.'.xml'
); ?>" size="50">
<br>
<br>
<br>
<?if ($ACTION=="EXPORT_SETUP" || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY'):?>
<font class="text"><?=GetMessage("PROFILE_NAME");?><br><br></font>
<input
type="text"
name="SETUP_PROFILE_NAME"
value="<?echo htmlspecialchars($SETUP_PROFILE_NAME)?>"
size="50">
<br>
<br>
<br>
<?endif;?>
<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
function checkAll(obj,cnt)
{
var boolCheck = obj.checked;
for (i = 0; i < cnt; i++)
{
BX('IBLOCK_EXPORT'+i).checked = boolCheck;
}
BX('count_checked').value = (boolCheck ? cnt : 0);
};
function checkOne(obj,cnt)
{
var boolCheck = obj.checked;
var intCurrent = parseInt(BX('count_checked').value);
intCurrent += (boolCheck ? 1 : -1);
BX('icml_export_all').checked = (intCurrent < cnt ? false : true);
BX('count_checked').value = intCurrent;
if (!boolCheck)
BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_PROPERTY_ARTICLE')).value = 'none';
};
</script>
<?//Следующие переменные должны быть обязательно установлены?>
<?=bitrix_sessid_post();?>
<input type="hidden" name="lang" value="<?echo LANGUAGE_ID ?>">
<input type="hidden" name="ACT_FILE" value="<?echo htmlspecialcharsbx($_REQUEST["ACT_FILE"]) ?>">
<input type="hidden" name="ACTION" value="<?echo htmlspecialcharsbx($ACTION) ?>">
<input type="hidden" name="STEP" value="<?echo intval($STEP) + 1 ?>">
<input type="hidden" name="SETUP_FIELDS_LIST" value="SETUP_FILE_NAME,IBLOCK_EXPORT,IBLOCK_PROPERTY_ARTICLE">
<input type="submit" value="<?echo ($ACTION=="EXPORT")?GetMessage("CET_EXPORT"):GetMessage("CET_SAVE")?>">
</form>
<?
}
elseif ($STEP==2)
{
$FINITE = true;
}
?>

View File

@ -0,0 +1,3 @@
<?
//<title>IntaroCRM</title>
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.intarocrm/export/export_run.php");

View File

@ -0,0 +1,3 @@
<?
//<title>IntaroCRM</title>
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.intarocrm/export/export_setup.php");

View File

@ -0,0 +1,940 @@
<?php
/**
* Module Install/Uninstall script
* Module name: intaro.intarocrm
* Class name: intaro_intarocrm
*/
global $MESS;
IncludeModuleLangFile(__FILE__);
if (class_exists('intaro_intarocrm'))
return;
class intaro_intarocrm extends CModule
{
var $MODULE_ID = 'intaro.intarocrm';
var $MODULE_VERSION;
var $MODULE_VERSION_DATE;
var $MODULE_NAME;
var $MODULE_DESCRIPTION;
var $MODULE_GROUP_RIGHTS = 'N';
var $PARTNER_NAME;
var $PARTNER_URI;
var $INTARO_CRM_API;
var $INTARO_CRM_EXPORT = 'intarocrm';
var $CRM_API_HOST_OPTION = 'api_host';
var $CRM_API_KEY_OPTION = 'api_key';
var $CRM_ORDER_TYPES_ARR = 'order_types_arr';
var $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
var $CRM_PAYMENT_TYPES = 'pay_types_arr';
var $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
var $CRM_ORDER_LAST_ID = 'order_last_id';
var $INSTALL_PATH;
function intaro_intarocrm()
{
$arModuleVersion = array();
$path = str_replace("\\", "/", __FILE__);
$path = substr($path, 0, strlen($path) - strlen("/index.php"));
$this->INSTALL_PATH = $path;
include($path."/version.php");
$this->MODULE_VERSION = $arModuleVersion["VERSION"];
$this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
$this->MODULE_NAME = GetMessage('MODULE_NAME');
$this->MODULE_DESCRIPTION = GetMessage('MODULE_DESCRIPTION');
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
}
/**
* Functions DoInstall and DoUninstall are
* All other functions are optional
*/
function DoInstall()
{
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/ICrmOrderActions.php');
include($this->INSTALL_PATH . '/../classes/general/ICMLLoader.php');
$step = intval($_REQUEST['step']);
if ($step <= 1) {
if(!CModule::IncludeModule("sale")) {
$arResult['errCode'] = 'ERR_SALE';
}
if(!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK';
}
if(!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG';
}
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
);
} else if ($step == 2) {
if(!CModule::IncludeModule("sale")) {
$arResult['errCode'] = 'ERR_SALE';
}
if(!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK';
}
if(!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG';
}
if(isset($arResult['errCode']) && $arResult['errCode']) {
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
);
return;
}
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
//prepare crm lists
$arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList();
if ((int) $this->INTARO_CRM_API->getStatusCode() != 200) {
$APPLICATION->RestartBuffer();
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
die(json_encode(array("success" => false)));
}
$arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
$arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList();
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses
$arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList();
$arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups
//bitrix orderTypesList -- personTypes
$dbOrderTypesList = CSalePersonType::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
//form order types ids arr
$orderTypesArr = array();
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
do {
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
$orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
}
//bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
//form delivery types ids arr
$deliveryTypesArr = array();
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
do {
$arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
}
//bitrix paymentTypesList
$dbPaymentTypesList = CSalePaySystem::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y"
)
);
//form payment types ids arr
$paymentTypesArr = array();
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
do {
$arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
$paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
}
//bitrix paymentStatusesList
$dbPaymentStatusesList = CSaleStatus::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"LID" => "ru", //ru
"ACTIVE" => "Y"
)
);
//form payment statuses ids arr
$paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y']));
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
do {
$arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList;
$paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
}
$arResult['bitrixPaymentStatusesList'][] = array(
'ID' => 'Y',
'NAME' => GetMessage('CANCELED')
);
//form payment ids arr
$paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$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_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
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, serialize($paymentArr));
// generate updated select inputs
$input = array();
foreach($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) {
$input['delivery-type-' . $bitrixDeliveryType['ID']] =
'<select name="delivery-type-' . $bitrixDeliveryType['ID'] . '" class="typeselect">';
$input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value=""></option>';
foreach($arResult['deliveryTypesList'] as $deliveryType) {
if ($deliveryTypesArr[$bitrixDeliveryType['ID']] == $deliveryType['code']) {
$input['delivery-type-' . $bitrixDeliveryType['ID']] .=
'<option value="' . $deliveryType['code'] . '" selected>';
} else {
$input['delivery-type-' . $bitrixDeliveryType['ID']] .=
'<option value="' . $deliveryType['code'] . '">';
}
$input['delivery-type-' . $bitrixDeliveryType['ID']] .=
$APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET);
$input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</option>';
}
$input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</select>';
}
foreach($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) {
$input['payment-type-' . $bitrixPaymentType['ID']] =
'<select name="payment-type-' . $bitrixPaymentType['ID'] . '" class="typeselect">';
$input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value=""></option>';
foreach($arResult['paymentTypesList'] as $paymentType) {
if ($paymentTypesArr[$bitrixPaymentType['ID']] == $paymentType['code']) {
$input['payment-type-' . $bitrixPaymentType['ID']] .=
'<option value="' . $paymentType['code'] . '" selected>';
} else {
$input['payment-type-' . $bitrixPaymentType['ID']] .=
'<option value="' . $paymentType['code'] . '">';
}
$input['payment-type-' . $bitrixPaymentType['ID']] .=
$APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET);
$input['payment-type-' . $bitrixPaymentType['ID']] .= '</option>';
}
$input['payment-type-' . $bitrixPaymentType['ID']] .= '</select>';
}
foreach($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) {
$input['payment-status-' . $bitrixPaymentStatus['ID']] =
'<select name="payment-status-' . $bitrixPaymentStatus['ID'] . '" class="typeselect">';
$input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value=""></option>';
foreach($arResult['paymentGroupList'] as $orderStatusGroup){
if(empty($orderStatusGroup['statuses'])) continue;
$input['payment-status-' . $bitrixPaymentStatus['ID']].=
'<optgroup label="' . $orderStatusGroup['name'] . '">';
foreach($orderStatusGroup['statuses'] as $payment) {
if ($paymentStatusesArr[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) {
$input['payment-status-' . $bitrixPaymentStatus['ID']] .=
'<option value="' . $arResult['paymentList'][$payment]['code'] . '" selected>';
} else {
$input['payment-status-' . $bitrixPaymentStatus['ID']] .=
'<option value="' . $arResult['paymentList'][$payment]['code'] . '">';
}
$input['payment-status-' . $bitrixPaymentStatus['ID']] .=
$APPLICATION->ConvertCharset($arResult['paymentList'][$payment]['name'], 'utf-8', SITE_CHARSET);
$input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</option>';
}
$input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</optgroup>';
}
$input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</select>';
}
foreach($arResult['bitrixPaymentList'] as $bitrixPayment) {
$input['payment-' . $bitrixPayment['ID']] =
'<select name="payment-' . $bitrixPayment['ID'] . '" class="typeselect">';
$input['payment-' . $bitrixPayment['ID']] .= '<option value=""></option>';
foreach($arResult['paymentStatusesList'] as $paymentStatus) {
if ($paymentArr[$bitrixPayment['ID']] == $paymentStatus['code']) {
$input['payment-' . $bitrixPayment['ID']] .=
'<option value="' . $paymentStatus['code'] . '" selected>';
} else {
$input['payment-' . $bitrixPayment['ID']] .=
'<option value="' . $paymentStatus['code']. '">';
}
$input['payment-' . $bitrixPayment['ID']] .=
$APPLICATION->ConvertCharset($paymentStatus['name'], 'utf-8', SITE_CHARSET);
$input['payment-' . $bitrixPayment['ID']] .= '</option>';
}
$input['payment-' . $bitrixPayment['ID']] .= '</select>';
}
foreach($arResult['bitrixOrderTypesList'] as $bitrixOrderType) {
$input['order-type-' . $bitrixOrderType['ID']] =
'<select name="order-type-' . $bitrixOrderType['ID'] . '" class="typeselect">';
$input['order-type-' . $bitrixOrderType['ID']] .= '<option value=""></option>';
foreach($arResult['orderTypesList'] as $orderType) {
if ($orderTypesArr[$bitrixOrderType['ID']] == $orderType['code']) {
$input['order-type-' . $bitrixOrderType['ID']] .=
'<option value="' . $orderType['code'] . '" selected>';
} else {
$input['order-type-' . $bitrixOrderType['ID']] .=
'<option value="' . $orderType['code']. '">';
}
$input['order-type-' . $bitrixOrderType['ID']] .=
$APPLICATION->ConvertCharset($orderType['name'], 'utf-8', SITE_CHARSET);
$input['order-type-' . $bitrixOrderType['ID']] .= '</option>';
}
$input['order-type-' . $bitrixOrderType['ID']] .= '</select>';
}
$APPLICATION->RestartBuffer();
header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
die(json_encode(array("success" => true, "result" => $input)));
}
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
// form correct url
$api_host = parse_url($api_host);
$api_host = $api_host['scheme'] . '://' . $api_host['host'];
if(!$api_host || !$api_key) {
$arResult['errCode'] = 'ERR_FIELDS_API_HOST';
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
);
return;
}
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
$this->INTARO_CRM_API->paymentStatusesList();
//check connection & apiKey valid
if((int) $this->INTARO_CRM_API->getStatusCode() != 200) {
$arResult['errCode'] = 'ERR_' . $this->INTARO_CRM_API->getStatusCode();
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
);
return;
}
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
//prepare crm lists
$arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList();
$arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
$arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList();
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses
$arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList();
$arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups
//bitrix orderTypesList -- personTypes
$dbOrderTypesList = CSalePersonType::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
do {
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
}
//bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
do {
$arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
}
//bitrix paymentTypesList
$dbPaymentTypesList = CSalePaySystem::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y"
)
);
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
do {
$arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
}
//bitrix paymentStatusesList --statuses
$dbPaymentStatusesList = CSaleStatus::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"LID" => "ru", //ru
"ACTIVE" => "Y"
)
);
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
do {
$arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList;
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
}
$arResult['bitrixPaymentStatusesList'][] = array(
'ID' => 'Y',
'NAME' => GetMessage('CANCELED')
);
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php'
);
} else if ($step == 3) {
if(!CModule::IncludeModule("sale")) {
//handler
}
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
ICrmOrderActions::uploadOrders(); // each 50
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
$countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array());
if(!isset($_POST['finish']))
$finish = 0;
else
$finish = (int) $_POST['finish'];
$percent = 100 - round(($countLeft * 100 / $countAll), 1);
if(!$countLeft)
$finish = 1;
$APPLICATION->RestartBuffer();
header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
die(json_encode(array("finish" => $finish, "percent" => $percent)));
}
if (isset($_POST['back']) && $_POST['back']) {
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'
);
}
//bitrix orderTypesList -- personTypes
$dbOrderTypesList = CSalePersonType::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
//form order types ids arr
$orderTypesArr = array();
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
do {
$orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
}
//bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
//form delivery types ids arr
$deliveryTypesArr = array();
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
do {
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
}
//bitrix paymentTypesList
$dbPaymentTypesList = CSalePaySystem::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y"
)
);
//form payment types ids arr
$paymentTypesArr = array();
if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
do {
$paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
} while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
}
//bitrix paymentStatusesList
$dbPaymentStatusesList = CSaleStatus::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"LID" => "ru", //ru
"ACTIVE" => "Y"
)
);
//form payment statuses ids arr
$paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y']));
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
do {
$paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
}
//form payment ids arr
$paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$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_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
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, serialize($paymentArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
);
} else if ($step == 4) {
if(!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK';
}
if(!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG';
}
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
);
} else if ($step == 5) {
if(!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK';
}
if(!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG';
}
if(isset($arResult['errCode']) && $arResult['errCode']) {
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
);
return;
}
if (isset($_POST['back']) && $_POST['back']) {
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
);
}
if(!isset($_POST['IBLOCK_EXPORT']))
$arResult['errCode'] = 'ERR_FIELDS_IBLOCK';
else
$iblocks = $_POST['IBLOCK_EXPORT'];
if(!isset($_POST['IBLOCK_PROPERTY_ARTICLE']))
$arResult['errCode'] = 'ERR_FIELDS_ARTICLE';
else
$articleProperties = $_POST['IBLOCK_PROPERTY_ARTICLE'];
if(!isset($_POST['SETUP_FILE_NAME']))
$arResult['errCode'] = 'ERR_FIELDS_FILE';
else
$filename = $_POST['SETUP_FILE_NAME'];
if (count($iblocks) < count($articleProperties))
$arResult['errCode'] = 'ERR_ARTICLE_IBLOCK';
if(!isset($_POST['TYPE_LOADING']))
$typeLoading = 0;
else
$typeLoading = $_POST['TYPE_LOADING'];
if(!isset($_POST['SETUP_PROFILE_NAME']) )
$profileName = "";
else
$profileName = $_POST['SETUP_PROFILE_NAME'];
if ($typeLoading != 'none' && $profileName == "")
$arResult['errCode'] = 'ERR_FIELDS_PROFILE';
if($filename == "")
$arResult['errCode'] = 'ERR_FIELDS_FILE';
if(isset($arResult['errCode']) && $arResult['errCode']) {
$arOldValues = Array(
'IBLOCK_EXPORT' => $iblocks,
'IBLOCK_PROPERTY_ARTICLE' => $articleProperties,
'SETUP_FILE_NAME' => $filename,
'SETUP_PROFILE_NAME' => $profileName
);
global $oldValues;
$oldValues = $arOldValues;
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php'
);
return;
}
RegisterModule($this->MODULE_ID);
RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
$this->CopyFiles();
if (isset($_POST['LOAD_NOW'])) {
$loader = new ICMLLoader();
$loader->iblocks = $iblocks;
$loader->articleProperties = $articleProperties;
$loader->filename = $filename;
$loader->application = $APPLICATION;
$loader->Load();
}
if ($typeLoading == 'agent' || $typeLoading == 'cron') {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) {
$dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT));
while ($arProfile = $dbProfile->Fetch()) {
if ($arProfile["DEFAULT_PROFILE"]!="Y") {
CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(".$arProfile['ID'].");", "catalog");
CCatalogExport::Delete($arProfile['ID']);
}
}
}
$ar = $this->GetProfileSetupVars($iblocks, $articleProperties, $filename);
$PROFILE_ID = CCatalogExport::Add(array(
"LAST_USE" => false,
"FILE_NAME" => $this->INTARO_CRM_EXPORT,
"NAME" => $profileName,
"DEFAULT_PROFILE" => "N",
"IN_MENU" => "N",
"IN_AGENT" => "N",
"IN_CRON" => "N",
"NEED_EDIT" => "N",
"SETUP_VARS" => $ar
));
if (intval($PROFILE_ID) <= 0) {
$arResult['errCode'] = 'ERR_IBLOCK';
return;
}
if ($typeLoading == 'agent') {
$dateAgent = new DateTime();
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
$dateAgent->add($intAgent);
CAgent::AddAgent(
"CCatalogExport::PreGenerateExport(" . $PROFILE_ID . ");",
"catalog",
"N",
86400,
$dateAgent->format('d.m.Y H:i:s'), // date of first check
"Y", // агент активен
$dateAgent->format('d.m.Y H:i:s'), // date of first start
30
);
CCatalogExport::Update($PROFILE_ID, array(
"IN_AGENT" => "Y"
));
} else {
$agent_period = 24;
$agent_php_path = "/usr/local/php/bin/php";
if (!file_exists($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php"))
{
CheckDirPath($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS);
$tmp_file_size = filesize($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS_DEF."cron_frame.php");
$fp = fopen($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS_DEF."cron_frame.php", "rb");
$tmp_data = fread($fp, $tmp_file_size);
fclose($fp);
$tmp_data = str_replace("#DOCUMENT_ROOT#", $_SERVER["DOCUMENT_ROOT"], $tmp_data);
$tmp_data = str_replace("#PHP_PATH#", $agent_php_path, $tmp_data);
$fp = fopen($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php", "ab");
fwrite($fp, $tmp_data);
fclose($fp);
}
$cfg_data = "";
if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg"))
{
$cfg_file_size = filesize($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg");
$fp = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", "rb");
$cfg_data = fread($fp, $cfg_file_size);
fclose($fp);
}
CheckDirPath($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."logs/");
if ($arProfile["IN_CRON"]=="Y")
{
// remove
$cfg_data = preg_replace("#^.*?".preg_quote(CATALOG_PATH2EXPORTS)."cron_frame.php +".$PROFILE_ID." *>.*?$#im", "", $cfg_data);
}
else
{
$strTime = "0 */".$agent_period." * * * ";
if (strlen($cfg_data)>0)
$cfg_data .= "\n";
$cfg_data .= $strTime.$agent_php_path." -f ".$_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php ".$PROFILE_ID." >".$_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."logs/".$PROFILE_ID.".txt\n";
}
CCatalogExport::Update($PROFILE_ID, array(
"IN_CRON" => "Y"
));
CheckDirPath($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/");
$cfg_data = preg_replace("#[\r\n]{2,}#im", "\n", $cfg_data);
$fp = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", "wb");
fwrite($fp, $cfg_data);
fclose($fp);
$arRetval = array();
@exec("crontab ".$_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", $arRetval, $return_var);
}
}
//
//agent
$dateAgent = new DateTime();
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
$dateAgent->add($intAgent);
CAgent::AddAgent(
"ICrmOrderActions::uploadOrdersAgent();",
$this->MODULE_ID,
"N",
600, // interval - 10 mins
$dateAgent->format('d.m.Y H:i:s'), // date of first check
"Y", // агент активен
$dateAgent->format('d.m.Y H:i:s'), // date of first start
30
);
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
$this->INTARO_CRM_API->statisticUpdate();
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php'
);
}
}
function DoUninstall() {
global $APPLICATION;
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_KEY_OPTION);
COption::RemoveOption($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_TYPES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
UnRegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder");
UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
if(CModule::IncludeModule("catalog")) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) {
$dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT));
while ($arProfile = $dbProfile->Fetch()) {
if ($arProfile["DEFAULT_PROFILE"]!="Y") {
CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(".$arProfile['ID'].");", "catalog");
CCatalogExport::Delete($arProfile['ID']);
}
}
}
}
$this->DeleteFiles();
UnRegisterModule($this->MODULE_ID);
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_UNINSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
);
}
function CopyFiles() {
CopyDirFiles(
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/',
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/',
true, true
);
}
function DeleteFiles() {
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php');
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php');
}
function GetProfileSetupVars($iblocks, $articleProperties, $filename) {
// Get string like IBLOCK_EXPORT[0]=3&
// IBLOCK_EXPORT[1]=6&
// IBLOCK_PROPERTY_ARTICLE[0]=ARTICLE&
// IBLOCK_PROPERTY_ARTICLE[1]=ARTNUMBER&
// SETUP_FILE_NAME=%2Fbitrix%2Fcatalog_export%2Ftestintarocrm.xml
//$arProfileFields = explode(",", $SETUP_FIELDS_LIST);
$strVars = "";
foreach ($iblocks as $key => $val)
$strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&';
foreach ($articleProperties as $key => $val)
$strVars .= 'IBLOCK_PROPERTY_ARTICLE[' . $key . ']=' . $val . '&';
$strVars .= 'SETUP_FILE_NAME=' . urlencode($filename);
return $strVars;
}
}

View File

@ -0,0 +1,263 @@
<?php
if(!check_bitrix_sessid()) return;
IncludeModuleLangFile(__FILE__);
__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.intarocrm/lang/", "/icml_export_setup.php"));
?>
<h3><?=GetMessage("EXPORT_CATALOGS_INFO");?></h3>
<?php
if(isset($arResult['errCode']) && $arResult['errCode'])
echo CAdminMessage::ShowMessage(GetMessage($arResult['errCode']));
global $oldValues;
if (!empty($oldValues)) {
$IBLOCK_EXPORT = $oldValues['IBLOCK_EXPORT'];
$IBLOCK_PROPERTY_ARTICLE = $oldValues['IBLOCK_PROPERTY_ARTICLE'];
$SETUP_FILE_NAME = $oldValues['SETUP_FILE_NAME'];
$SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME'];
}
?>
<form method="post" action="<?php echo $APPLICATION->GetCurPage(); ?>" >
<font class="text"><?=GetMessage("EXPORT_CATALOGS");?><br><br></font>
<?
if (!isset($IBLOCK_EXPORT) || !is_array($IBLOCK_EXPORT))
{
$IBLOCK_EXPORT = array();
}
$boolAll = false;
$intCountChecked = 0;
$intCountAvailIBlock = 0;
$arIBlockList = array();
$db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W'));
while ($res = $db_res->Fetch())
{
if ($arCatalog = CCatalog::GetByIDExt($res["ID"]))
{
if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P")
{
$arSiteList = array();
$rsSites = CIBlock::GetSite($res["ID"]);
while ($arSite = $rsSites->Fetch())
{
$arSiteList[] = $arSite["SITE_ID"];
}
$db_properties = CIBlock::GetProperties($res['ID'], Array());
$properties = Array();
while($prop = $db_properties->Fetch())
$properties[] = $prop;
if (count($IBLOCK_EXPORT) != 0)
$boolExport = (in_array($res['ID'], $IBLOCK_EXPORT));
else
$boolExport = true;
$arIBlockList[] = array(
'ID' => $res['ID'],
'NAME' => $res['NAME'],
'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'],
'IBLOCK_EXPORT' => $boolExport,
'PROPERTIES' => $properties,
'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null,
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
);
if ($boolExport)
$intCountChecked++;
$intCountAvailIBlock++;
}
}
}
if (count($IBLOCK_EXPORT) != 0) {
if ($intCountChecked == $intCountAvailIBlock)
$boolAll = true;
} else {
$intCountChecked = $intCountAvailIBlock;
$boolAll = true;
}
?>
<table class="adm-list-table" id="export_setup">
<thead>
<tr class="adm-list-table-header">
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?echo GetMessage("CATALOG");?></div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner">
<?echo GetMessage("EXPORT2INTAROCML");?>&nbsp;
</div>
</td>
<td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?echo GetMessage("PROPERTY");?></div>
</td>
</tr>
</thead>
<tbody>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<?echo GetMessage("ALL_CATALOG");?>
</td>
<td class="adm-list-table-cell">
<input style="vertical-align: middle;" type="checkbox" name="icml_export_all" id="icml_export_all" value="Y" onclick="checkAll(this,<? echo $intCountAvailIBlock; ?>);"<? echo ($boolAll ? ' checked' : ''); ?>>
</td>
<td class="adm-list-table-cell">
&nbsp;
</td>
</tr>
<?
foreach ($arIBlockList as $key => $arIBlock)
{
?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell" style="padding-left: 5em">
<? echo htmlspecialcharsex("[".$arIBlock["IBLOCK_TYPE_ID"]."] ".$arIBlock["NAME"]." ".$arIBlock['SITE_LIST']); ?>
</td>
<td class="adm-list-table-cell">
<font class="tablebodytext">
<input
type="checkbox"
name="IBLOCK_EXPORT[<?=$arIBlock["ID"]?>]"
id="IBLOCK_EXPORT<?=$arIBlock["ID"]?>"
value="<?=$arIBlock["ID"]?>"
<? if ($arIBlock['IBLOCK_EXPORT']) echo " checked"; ?>
onclick="checkOne(this,<? echo $intCountAvailIBlock; ?>);"
>
</font>
</td>
<td class="adm-list-table-cell">
<select
style="width: 200px;"
id="IBLOCK_PROPERTY_ARTICLE<?=$arIBlock["ID"]?>"
name="IBLOCK_PROPERTY_ARTICLE[<?=$arIBlock["ID"]?>]"
class="property-export">
<option value=""></option>
<?
foreach ($arIBlock['PROPERTIES'] as $prop)
{
?>
<option value="<?=$prop['CODE'] ?>"
<?
if ($arIBlock['OLD_PROPERTY_SELECT'] == $prop["CODE"]){
echo " selected";
} else {
if ($prop["CODE"] == "ARTICLE" ||
$prop["CODE"] == "ART" ||
$prop["CODE"] == "ARTNUMBER" )
echo " selected";
}
?>
>
<?=$prop["NAME"];?>
</option>
<?
}
?>
</select>
</td>
</tr>
<?
}
?>
</tbody>
</table>
<input type="hidden" name="count_checked" id="count_checked" value="<? echo $intCountChecked; ?>">
<br>
<br>
<br>
<font class="text"><?=GetMessage("FILENAME");?><br><br></font>
<input type="text" name="SETUP_FILE_NAME"
value="<?=htmlspecialcharsbx(strlen($SETUP_FILE_NAME) > 0 ?
$SETUP_FILE_NAME :
(COption::GetOptionString(
'catalog',
'export_default_path',
'/bitrix/catalog_export/'))
.'intarocrm'/* .mt_rand(0, 999999) */.'.xml'
); ?>" size="50">
<br>
<br>
<br>
<font class="text"><?=GetMessage("LOAD_PERIOD");?><br><br></font>
<input type="radio" name="TYPE_LOADING" value="none" onclick="checkProfile(this);"><?=GetMessage("NOT_LOADING");?><Br>
<input type="radio" name="TYPE_LOADING" value="cron" onclick="checkProfile(this);"><?=GetMessage("CRON_LOADING");?><Br>
<input type="radio" name="TYPE_LOADING" value="agent" checked onclick="checkProfile(this);"><?=GetMessage("AGENT_LOADING");?><Br>
<br>
<br>
<font class="text"><?=GetMessage("LOAD_NOW");?>&nbsp;</font>
<input id="load-now" type="checkbox" name="LOAD_NOW" value="now" checked >
<br>
<br>
<br>
<div id="profile-field" >
<font class="text"><?=GetMessage("PROFILE_NAME");?>&nbsp;</font>
<input
type="text"
name="SETUP_PROFILE_NAME"
value="<?= ($SETUP_PROFILE_NAME ? $SETUP_PROFILE_NAME: GetMessage("PROFILE_NAME_EXAMPLE"));?>"
size="30">
<br>
<br>
<br>
</div>
<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
function checkAll(obj,cnt)
{
var boolCheck = obj.checked;
for (i = 0; i < cnt; i++)
{
BX('IBLOCK_EXPORT'+i).checked = boolCheck;
}
BX('count_checked').value = (boolCheck ? cnt : 0);
};
function checkOne(obj,cnt)
{
var boolCheck = obj.checked;
var intCurrent = parseInt(BX('count_checked').value);
intCurrent += (boolCheck ? 1 : -1);
BX('icml_export_all').checked = (intCurrent < cnt ? false : true);
BX('count_checked').value = intCurrent;
if (!boolCheck)
BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_PROPERTY_ARTICLE')).value = 'none';
};
function checkProfile(obj)
{
if (obj.value !== 'none')
$('#profile-field').show();
else
$('#profile-field').hide();
};
</script>
<?//Следующие переменные должны быть обязательно установлены?>
<?=bitrix_sessid_post();?>
<input type="hidden" name="lang" value="<?php echo LANG; ?>">
<input type="hidden" name="id" value="intaro.intarocrm">
<input type="hidden" name="install" value="Y">
<input type="hidden" name="step" value="5">
<input type="hidden" name="continue" value="4">
<div style="padding: 1px 13px 2px; height:28px;">
<div align="right" style="float:right; width:50%; position:relative;">
<input type="submit" name="inst" value="<?php echo GetMessage("MOD_NEXT_STEP"); ?>" class="adm-btn-save">
</div>
<div align="left" style="float:right; width:50%; position:relative;">
<input type="submit" name="back" value="<?php echo GetMessage("MOD_PREV_STEP"); ?>" class="adm-btn-save">
</div>
</div>
</form>

View File

@ -0,0 +1,11 @@
<?php
if(!check_bitrix_sessid()) return;
echo CAdminMessage::ShowNote(GetMessage("MOD_INST_OK"));
echo GetMessage("INTAROCRM_INFO"); ?>
<form action="<?php echo $APPLICATION->GetCurPage(); ?>">
<input type="hidden" name="lang" value="<?php echo LANG; ?>">
<input type="hidden" name="id" value="intaro.intarocrm">
<input type="hidden" name="install" value="Y">
<input type="submit" name="" value="<?php echo GetMessage("MOD_BACK"); ?>">
<form>

View File

@ -0,0 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "0.3.9",
"VERSION_DATE" => "2013-08-21 18:32:00",
);

View File

@ -0,0 +1,17 @@
<?
$MESS["ERROR_FILENAME_NOT_SET"] = "Не указан файл данных.";
$MESS["ERROR_PROFIE_NOT_SET"] = "Не указано имя профиля";
$MESS["EXPORT_CATALOGS"] = "Выберите каталоги для выгрузки в ICML:";
$MESS["CATALOG"] = "Каталог";
$MESS["EXPORT2INTAROCML"] = "Выгрузить в ICML";
$MESS["FILENAME"] = "Укажите имя файла данных:";
$MESS["PROPERTY"] = "Свойство, содержащее артикул товара";
$MESS["ALL_CATALOG"] = "Все каталоги";
$MESS["CET_EXPORT"] = "Экспортировать";
$MESS["CET_SAVE"] = "Сохранить";
$MESS["ERROR_IBLOCK_MODULE"] = "Модуль Инфоблоки не установлен";
$MESS["ERROR_IBLOCK_CATALOG"] = "Модуль Каталог не установлен";
$MESS["ERROR_IBLOCK_INTAROCRM"] = "Модуль IntaroCRM не установлен";
$MESS["ERROR_ARTICLE_NOT_SET"] = "Были установлены поля артикулов, но не установлены Информационные блоки";
$MESS["PROFILE_NAME"] = "Имя профиля";
?>

View File

@ -0,0 +1,14 @@
<?php
$MESS ['MODULE_NAME'] = 'IntaroCRM';
$MESS ['MODULE_DESCRIPTION'] = 'Модуль интеграции с IntaroCRM — аналитической CRM для электронной коммерции';
$MESS ['MODULE_PARTNER_NAME'] = 'Интаро Софт';
$MESS ['MODULE_PARTNER_URI'] = 'http://intaro.ru';
$MESS ['MODULE_INSTALL_TITLE'] = 'Установка модуля';
$MESS ['MODULE_UNINSTALL_TITLE'] = 'Удаление модуля';
$MESS ['CANCELED'] = 'Флаг «Отменен»';
$MESS ['ERR_SALE'] = 'Отсутствует модуль sale! Дальнейшая установка невозможна.';
$MESS ['ERR_IBLOCK'] = 'Отсутствует модуль iblock! Дальнейшая установка невозможна.';
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
$MESS ['INTAROCRM_CURL_ERR'] = 'Для работы модуля интеграции с IntaroCRM требуется PHP-расширение CURL.';
$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы';

View File

@ -0,0 +1,24 @@
<?php
$MESS ['STEP_NAME'] = 'Øàã 4';
$MESS ['MOD_NEXT_STEP'] = 'Çàâåðøèòü óñòàíîâêó';
$MESS ['MOD_PREV_STEP'] = 'Ïðåäûäóùèé øàã';
$MESS ['DELIVERY_TYPES_LIST'] = 'Ñïîñîáû äîñòàâêè';
$MESS ['PAYMENT_TYPES_LIST'] = 'Ñïîñîáû îïëàòû';
$MESS ['PAYMENT_STATUS_LIST'] = 'Ñòàòóñû';
$MESS ['ORDER_TYPES_LIST'] = 'Òèïû çàêàçà';
$MESS ['PAYMENT_LIST'] = 'Îïëàòà';
$MESS ['PAYMENT_Y'] = 'Îïëà÷åí';
$MESS ['PAYMENT_N'] = 'Íå îïëà÷åí';
$MESS ['CANCELED'] = 'Ôëàã «Îòìåíåí»';
$MESS ['INFO_1'] = ' Çàäàéòå ñîîòâåòñòâèå ìåæäó ñïðàâî÷íèêàìè 1C-Áèòðèêñ è ñïðàâî÷íèêàìè IntaroCRM.';
$MESS ['LOAD_PERIOD'] = 'Âûãðóæàòü êàòàëîã ïåðèîäè÷åñêè';
$MESS ['NOT_LOADING'] = 'Íåò';
$MESS ['CRON_LOADING'] = 'Ñ ïîìîùüþ CRON êàæäûå 24 ÷àñà';
$MESS ['AGENT_LOADING'] = 'Àãåíòîì êàæäûå 24 ÷àñà (ïî óìîë÷àíèþ)';
$MESS ['LOAD_NOW'] = 'Âûãðóçèòü ñåé÷àñ';
$MESS ['PROFILE_NAME'] = 'Èìÿ ïðîôèëÿ:';
$MESS ['PROFILE_NAME_EXAMPLE'] = 'Âûãðóçêà êàòàëîãà IntaroCRM';
$MESS ['ERR_FIELDS_PROFILE'] = 'Íåâåðíî çàïîëíåíî ïîëå èìåíè ïðîôèëÿ';
$MESS ['ERR_FIELDS_IBLOCK'] = 'Íå âûáðàíî íè îäíîãî èíôîðìàöèîííîãî áëîêà';
$MESS ['ERR_FIELDS_ARTICLE'] = 'Íå âûáðàíû àðòèêóëû';
$MESS ['ERR_FIELDS_FILE'] = 'Íå óêàçàíî èìÿ ôàéëà';

View File

@ -0,0 +1,18 @@
<?php
$MESS ['INTAROCRM_INFO'] = '
<h2>Дальнейшие действия<h2>
<p>
Если вы произвели выгрузку заказов на шаге 3, то эти заказы уже доступны в вашей CRM и
через некоторое время по этим заказам будет подготовлены аналитические отчеты в Панели KPI.
</p>
<p>
Новые заказы будут отправляться агентом <span style="font-family: Courier New;">ICrmOrderActions::uploadOrdersAgent();</span>
в IntaroCRM каждые 10 минут (интервал можно изменить в разделе <a href="/bitrix/admin/agent_list.php">Агенты</a>).
</p>
<p>
Если вы выбрали опцию «Выгрузить каталог сейчас» на шаге 4, то ваш каталог уже загружается в IntaroCRM.
Загрузка длится, как правило, не более 10 минут. Если вы не выбирали эту опцию, то генерацию файла с каталогом
можно произвести экспортом «IntaroCRM» в разделе Магазин > Настройки > <a href="/bitrix/admin/cat_export_setup.php">Экспорт данных</a>.
IntaroCRM проверяет и загружает данный файл с каталогом каждые 3 часа.
</p>
';

View File

@ -0,0 +1,10 @@
<?
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php')) {
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php');
}
$updater->CopyFiles("install/export/intarocrm_run.php", "php_interface/include/catalog_export/intarocrm_run.php");
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php')) {
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php');
}
$updater->CopyFiles("install/export/intarocrm_setup.php", "php_interface/include/catalog_export/intarocrm_setup.php");