refactoring export run and setup
This commit is contained in:
parent
a1258b9af2
commit
04ea0ea00e
@ -9,6 +9,7 @@ class ICMLLoader {
|
||||
public $encoding = 'utf-8';
|
||||
|
||||
protected $fp;
|
||||
protected $mainSection = 1000000;
|
||||
|
||||
public function Load()
|
||||
{
|
||||
@ -16,6 +17,9 @@ class ICMLLoader {
|
||||
if(!isset($USER))
|
||||
$USER = new CUser;
|
||||
|
||||
if (count($this->iblocks) != count($this->articleProperties))
|
||||
return false;
|
||||
|
||||
$categories = $this->GetCategories();
|
||||
|
||||
$offers = $this->GetOffers();
|
||||
@ -30,6 +34,7 @@ class ICMLLoader {
|
||||
$this->PostWriteCatalog();
|
||||
|
||||
$this->CloseFile();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@ -107,6 +112,14 @@ class ICMLLoader {
|
||||
{
|
||||
$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;
|
||||
|
||||
@ -149,7 +162,7 @@ class ICMLLoader {
|
||||
"DETAIL_PICTURE",
|
||||
"LANG_DIR",
|
||||
"DETAIL_PAGE_URL",
|
||||
"PROPERTY_" . $this->articleProperties[$key]
|
||||
"PROPERTY_" . $this->articleProperties[$id]
|
||||
);
|
||||
|
||||
$filter = Array (
|
||||
@ -179,7 +192,7 @@ class ICMLLoader {
|
||||
"DETAIL_TEXT",
|
||||
"DETAIL_PAGE_URL",
|
||||
"DETAIL_PICTURE",
|
||||
"PROPERTY_" . $this->articleProperties[$key]
|
||||
"PROPERTY_" . $this->articleProperties[$id]
|
||||
);
|
||||
|
||||
$rsOffers = CIBlockElement::GetList(array(), $arFilterOffer, false, false, $arSelectOffer);
|
||||
@ -189,6 +202,8 @@ class ICMLLoader {
|
||||
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"];
|
||||
|
||||
@ -197,7 +212,7 @@ class ICMLLoader {
|
||||
$arOffer['DETAIL_PICTURE'] = $product["DETAIL_PICTURE"];
|
||||
$arOffer['PREVIEW_PICTURE'] = $product["PREVIEW_PICTURE"];
|
||||
$arOffer['PRODUCT_NAME'] = $product["NAME"];
|
||||
$arOffer['ARTICLE'] = $arOffer["PROPERTY_" . $this->articleProperties[$key] . "_VALUE"];
|
||||
$arOffer['ARTICLE'] = $arOffer["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"];
|
||||
|
||||
$dbPrice = GetCatalogProductPrice($arOffer["ID"],1);
|
||||
$arOffer['PRICE'] = $dbPrice['PRICE'];
|
||||
@ -213,14 +228,15 @@ class ICMLLoader {
|
||||
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"];
|
||||
$product['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$key] . "_VALUE"];
|
||||
$product['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"];
|
||||
|
||||
$dbPrice = GetCatalogProductPrice($product["ID"],1);
|
||||
$product['PRICE'] = $dbPrice['PRICE'];
|
||||
|
19
intaro.intarocrm/export/export_run.php
Normal file
19
intaro.intarocrm/export/export_run.php
Normal 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();
|
286
intaro.intarocrm/export/export_setup.php
Normal file
286
intaro.intarocrm/export/export_setup.php
Normal file
@ -0,0 +1,286 @@
|
||||
<?
|
||||
|
||||
|
||||
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(); ?>" >
|
||||
<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");?>
|
||||
</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">
|
||||
|
||||
</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[<?=$key?>]"
|
||||
id="IBLOCK_EXPORT<?=$key?>"
|
||||
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">
|
||||
<?
|
||||
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>
|
||||
|
||||
|
||||
<?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;
|
||||
}
|
||||
|
||||
?>
|
@ -1,18 +1,3 @@
|
||||
<?
|
||||
//<title>IntaroCRM</title>
|
||||
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();
|
||||
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/intaro.intarocrm/export/load/export_run.php");
|
@ -1,255 +1,3 @@
|
||||
<?
|
||||
//<title>IntaroCRM</title>
|
||||
|
||||
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 ($STEP>1)
|
||||
{
|
||||
|
||||
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(); ?>" >
|
||||
<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;
|
||||
|
||||
|
||||
$boolExport = (in_array($res['ID'],$IBLOCK_EXPORT));
|
||||
$arIBlockList[] = array(
|
||||
'ID' => $res['ID'],
|
||||
'NAME' => $res['NAME'],
|
||||
'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'],
|
||||
'IBLOCK_EXPORT' => $boolExport,
|
||||
'PROPERTIES' => $properties,
|
||||
'SITE_LIST' => '('.implode(' ',$arSiteList).')',
|
||||
);
|
||||
|
||||
if ($boolExport)
|
||||
$intCountChecked++;
|
||||
$intCountAvailIBlock++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$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");?>
|
||||
</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">
|
||||
|
||||
</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
|
||||
checked
|
||||
type="checkbox"
|
||||
name="IBLOCK_EXPORT[<?=$key?>]"
|
||||
id="IBLOCK_EXPORT<?=$key?>"
|
||||
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;" name="IBLOCK_PROPERTY_ARTICLE[<?=$key?>]" class="property-export">
|
||||
<?
|
||||
foreach ($arIBlock['PROPERTIES'] as $prop)
|
||||
{
|
||||
?>
|
||||
<option value="<?=$prop['CODE'] ?>"
|
||||
<?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;
|
||||
};
|
||||
</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;
|
||||
}
|
||||
|
||||
?>
|
||||
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/intaro.intarocrm/export/load/export_setup.php");
|
@ -677,6 +677,9 @@ class intaro_intarocrm extends CModule
|
||||
else
|
||||
$filename = $_POST['SETUP_FILE_NAME'];
|
||||
|
||||
if (count($iblocks) != count($articleProperties))
|
||||
$arResult['errCode'] = 'ERR_ARTICLE_IBLOCK';
|
||||
|
||||
|
||||
if(!isset($_POST['TYPE_LOADING']))
|
||||
$typeLoading = 0;
|
||||
@ -691,7 +694,18 @@ class intaro_intarocrm extends CModule
|
||||
if ($typeLoading != 'none' && $profileName == "")
|
||||
$arResult['errCode'] = 'ERR_FIELDS_PROFILE';
|
||||
|
||||
|
||||
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'
|
||||
@ -839,7 +853,10 @@ class intaro_intarocrm extends CModule
|
||||
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'),
|
||||
|
@ -8,6 +8,13 @@ __IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.
|
||||
<?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>
|
||||
@ -40,14 +47,18 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
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).')',
|
||||
);
|
||||
|
||||
@ -57,8 +68,13 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($IBLOCK_EXPORT) != 0) {
|
||||
if ($intCountChecked == $intCountAvailIBlock)
|
||||
$boolAll = true;
|
||||
} else {
|
||||
$intCountChecked = $intCountAvailIBlock;
|
||||
$boolAll = true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -104,10 +120,9 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
<td class="adm-list-table-cell">
|
||||
<font class="tablebodytext">
|
||||
<input
|
||||
checked
|
||||
type="checkbox"
|
||||
name="IBLOCK_EXPORT[<?=$key?>]"
|
||||
id="IBLOCK_EXPORT<?=$key?>"
|
||||
name="IBLOCK_EXPORT[<?=$arIBlock["ID"]?>]"
|
||||
id="IBLOCK_EXPORT<?=$arIBlock["ID"]?>"
|
||||
value="<?=$arIBlock["ID"]?>"
|
||||
<? if ($arIBlock['IBLOCK_EXPORT']) echo " checked"; ?>
|
||||
onclick="checkOne(this,<? echo $intCountAvailIBlock; ?>);"
|
||||
@ -115,16 +130,28 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
</font>
|
||||
</td>
|
||||
<td class="adm-list-table-cell">
|
||||
<select style="width: 200px;" name="IBLOCK_PROPERTY_ARTICLE[<?=$key?>]" class="property-export">
|
||||
<select
|
||||
style="width: 200px;"
|
||||
id="IBLOCK_PROPERTY_ARTICLE<?=$arIBlock["ID"]?>"
|
||||
name="IBLOCK_PROPERTY_ARTICLE[<?=$arIBlock["ID"]?>]"
|
||||
class="property-export">
|
||||
<?
|
||||
foreach ($arIBlock['PROPERTIES'] as $prop)
|
||||
{
|
||||
?>
|
||||
<option value="<?=$prop['CODE'] ?>"
|
||||
<?if ($prop["CODE"] == "ARTICLE" ||
|
||||
<?
|
||||
if ($arIBlock['OLD_PROPERTY_SELECT'] == $prop["CODE"]){
|
||||
echo " selected";
|
||||
} else {
|
||||
if ($prop["CODE"] == "ARTICLE" ||
|
||||
$prop["CODE"] == "ART" ||
|
||||
$prop["CODE"] == "ARTNUMBER" )
|
||||
echo " selected";?>
|
||||
echo " selected";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
>
|
||||
<?=$prop["NAME"];?>
|
||||
</option>
|
||||
@ -176,7 +203,7 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
<input
|
||||
type="text"
|
||||
name="SETUP_PROFILE_NAME"
|
||||
value="<?=GetMessage("PROFILE_NAME_EXAMPLE");?>"
|
||||
value="<?= ($SETUP_PROFILE_NAME ? $SETUP_PROFILE_NAME: GetMessage("PROFILE_NAME_EXAMPLE"));?>"
|
||||
size="30">
|
||||
<br>
|
||||
<br>
|
||||
@ -201,6 +228,8 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
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)
|
||||
{
|
||||
@ -230,3 +259,4 @@ if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
@ -9,4 +9,9 @@ $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"] = "Не установлены поля артикулов";
|
||||
|
||||
?>
|
@ -11,3 +11,4 @@ $MESS ['ERR_IBLOCK'] = 'Отсутствует модуль iblock! Дальне
|
||||
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
|
||||
$MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.';
|
||||
$MESS ['INTAROCRM_CURL_ERR'] = 'Для работы модуля интеграции с IntaroCRM требуется PHP-расширение CURL.';
|
||||
$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы';
|
Loading…
Reference in New Issue
Block a user