merge
This commit is contained in:
commit
597696b692
@ -255,6 +255,7 @@ class ICrmOrderActions
|
|||||||
|
|
||||||
$resOrder = array();
|
$resOrder = array();
|
||||||
$resOrderDeliveryAddress = array();
|
$resOrderDeliveryAddress = array();
|
||||||
|
$contactNameArr = array();
|
||||||
|
|
||||||
$rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID']));
|
$rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID']));
|
||||||
while ($ar = $rsOrderProps->Fetch()) {
|
while ($ar = $rsOrderProps->Fetch()) {
|
||||||
@ -270,7 +271,7 @@ class ICrmOrderActions
|
|||||||
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
|
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'FIO': $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE']));
|
case 'FIO': $contactNameArr = self::explodeFIO($ar['VALUE']);
|
||||||
break;
|
break;
|
||||||
case 'PHONE': $resOrder['phone'] = $ar['VALUE'];
|
case 'PHONE': $resOrder['phone'] = $ar['VALUE'];
|
||||||
break;
|
break;
|
||||||
@ -309,10 +310,7 @@ class ICrmOrderActions
|
|||||||
$createdAt = new \DateTime($arFields['DATE_INSERT']);
|
$createdAt = new \DateTime($arFields['DATE_INSERT']);
|
||||||
$createdAt = $createdAt->format('Y-m-d H:i:s');
|
$createdAt = $createdAt->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$resOrder = self::clearArr(array(
|
$resOrder = array(
|
||||||
'lastName' => $resOrder['contactName'][0],
|
|
||||||
'firstName' => $resOrder['contactName'][1],
|
|
||||||
'patronymic' => $resOrder['contactName'][2],
|
|
||||||
'phone' => $resOrder['phone'],
|
'phone' => $resOrder['phone'],
|
||||||
'email' => $resOrder['email'],
|
'email' => $resOrder['email'],
|
||||||
'deliveryCost' => $arFields['PRICE_DELIVERY'],
|
'deliveryCost' => $arFields['PRICE_DELIVERY'],
|
||||||
@ -325,7 +323,7 @@ class ICrmOrderActions
|
|||||||
'orderType' => $arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']],
|
'orderType' => $arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']],
|
||||||
'deliveryType' => $arParams['optionsDelivTypes'][$resultDeliveryTypeId],
|
'deliveryType' => $arParams['optionsDelivTypes'][$resultDeliveryTypeId],
|
||||||
'status' => $arParams['optionsPayStatuses'][$arFields['STATUS_ID']],
|
'status' => $arParams['optionsPayStatuses'][$arFields['STATUS_ID']],
|
||||||
'statusComment' => $arFields['REASON_CANCELED'],
|
'statusComment' => $arFields['USER_DESCRIPTION'],
|
||||||
'createdAt' => $createdAt,
|
'createdAt' => $createdAt,
|
||||||
'deliveryAddress' => $resOrderDeliveryAddress,
|
'deliveryAddress' => $resOrderDeliveryAddress,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
@ -335,8 +333,19 @@ class ICrmOrderActions
|
|||||||
&& in_array($arFields['LID'], $arParams['optionsSites']))
|
&& in_array($arFields['LID'], $arParams['optionsSites']))
|
||||||
$resOrder['site'] = $arFields['LID'];
|
$resOrder['site'] = $arFields['LID'];
|
||||||
|
|
||||||
|
// parse fio
|
||||||
|
if(count($contactNameArr) == 1) {
|
||||||
|
$resOrder['firstName'] = $contactNameArr[0];
|
||||||
|
} else {
|
||||||
|
$resOrder['lastName'] = $contactNameArr[0];
|
||||||
|
$resOrder['firstName'] = $contactNameArr[1];
|
||||||
|
$resOrder['patronymic'] = $contactNameArr[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$resOrder = self::clearArr($resOrder);
|
||||||
|
|
||||||
if($send)
|
if($send)
|
||||||
$api->createOrder($resOrder);
|
return $api->orderEdit($resOrder);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'order' => $resOrder,
|
'order' => $resOrder,
|
||||||
@ -389,4 +398,21 @@ class ICrmOrderActions
|
|||||||
|
|
||||||
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function explodeFIO($str) {
|
||||||
|
if(!$str)
|
||||||
|
return array();
|
||||||
|
|
||||||
|
$array = explode(" ", self::toJSON($str), 3);
|
||||||
|
$newArray = array();
|
||||||
|
|
||||||
|
foreach($array as $ar) {
|
||||||
|
if(!$ar)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$newArray[] = $ar;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $newArray;
|
||||||
|
}
|
||||||
}
|
}
|
198
intaro.intarocrm/classes/general/events/ICrmOrderEvent.php
Normal file
198
intaro.intarocrm/classes/general/events/ICrmOrderEvent.php
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* OrderEvent
|
||||||
|
*/
|
||||||
|
class ICrmOrderEvent {
|
||||||
|
|
||||||
|
protected static $MODULE_ID = 'intaro.intarocrm';
|
||||||
|
protected static $CRM_API_HOST_OPTION = 'api_host';
|
||||||
|
protected static $CRM_API_KEY_OPTION = 'api_key';
|
||||||
|
protected static $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||||
|
protected static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||||
|
protected static $CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||||
|
protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||||
|
protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||||
|
protected static $CRM_ORDER_LAST_ID = 'order_last_id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onUpdateOrder
|
||||||
|
*
|
||||||
|
* @param mixed $ID - Order id
|
||||||
|
* @param mixed $arFields - Order arFields
|
||||||
|
*/
|
||||||
|
function onUpdateOrder($ID, $arFields = array()) {
|
||||||
|
self::writeDataOnOrderCreate($ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onSendOrderMail
|
||||||
|
* in: sale.order.ajax, sale.order.full
|
||||||
|
*
|
||||||
|
* @param mixed $ID - Order id
|
||||||
|
* @param mixed $eventName - Event type
|
||||||
|
* @param mixed $arFields - Order arFields for sending template
|
||||||
|
*/
|
||||||
|
function onSendOrderMail($ID, &$eventName, &$arFields) {
|
||||||
|
self::writeDataOnOrderCreate($ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writeDataOnOrderCreate via api
|
||||||
|
*
|
||||||
|
* @param integer $ID - Order Id
|
||||||
|
*/
|
||||||
|
function writeDataOnOrderCreate($ID) {
|
||||||
|
if (!CModule::IncludeModule('iblock')) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::writeDataOnOrderCreate', 'iblock', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("sale")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::writeDataOnOrderCreate', 'sale', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("catalog")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::writeDataOnOrderCreate', 'catalog', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||||
|
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||||
|
|
||||||
|
//saved cat params
|
||||||
|
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
|
||||||
|
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
|
||||||
|
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
|
||||||
|
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||||
|
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||||
|
|
||||||
|
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||||
|
|
||||||
|
$arParams = array(
|
||||||
|
'optionsOrderTypes' => $optionsOrderTypes,
|
||||||
|
'optionsDelivTypes' => $optionsDelivTypes,
|
||||||
|
'optionsPayTypes' => $optionsPayTypes,
|
||||||
|
'optionsPayStatuses' => $optionsPayStatuses,
|
||||||
|
'optionsPayment' => $optionsPayment
|
||||||
|
);
|
||||||
|
|
||||||
|
$arOrder = CSaleOrder::GetById($ID);
|
||||||
|
$result = ICrmOrderActions::orderCreate($arOrder, $api, $arParams, true);
|
||||||
|
|
||||||
|
if(!$result) {
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::writeDataOnOrderCreate', 'ICrmOrderActions::orderCreate', 'error during creating order');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $ID);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $ID -- orderId
|
||||||
|
* @param type $cancel -- Y / N - cancel order status
|
||||||
|
* @param type $reason -- cancel reason
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function onSaleCancelOrder($ID, $cancel, $reason) {
|
||||||
|
if(!$ID || !$cancel || ($cancel != 'Y'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule('iblock')) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSaleCancelOrder', 'iblock', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("sale")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSaleCancelOrder', 'sale', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("catalog")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSaleCancelOrder', 'catalog', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||||
|
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||||
|
|
||||||
|
//saved cat params
|
||||||
|
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||||
|
|
||||||
|
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||||
|
|
||||||
|
$order = array(
|
||||||
|
'externalId' => (int) $ID,
|
||||||
|
'status' => $optionsPayStatuses[$cancel],
|
||||||
|
'statusComment' => ICrmOrderActions::toJSON($reason)
|
||||||
|
);
|
||||||
|
|
||||||
|
$api->orderEdit($order);
|
||||||
|
|
||||||
|
// error pushing order
|
||||||
|
if ($api->getStatusCode() != 201)
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSaleCancelOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $ID -- orderId
|
||||||
|
* @param type $payed -- Y / N - pay order status
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function onSalePayOrder($ID, $payed) {
|
||||||
|
if(!$ID || !$payed || ($payed != 'Y'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule('iblock')) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'iblock', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("sale")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'sale', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CModule::IncludeModule("catalog")) {
|
||||||
|
//handle err
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'catalog', 'module not found');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||||
|
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||||
|
|
||||||
|
//saved cat params
|
||||||
|
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||||
|
|
||||||
|
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||||
|
|
||||||
|
$order = array(
|
||||||
|
'externalId' => (int) $ID,
|
||||||
|
'paymentStatus' => $optionsPayment[$payed]
|
||||||
|
);
|
||||||
|
|
||||||
|
$api->orderEdit($order);
|
||||||
|
|
||||||
|
// error pushing order
|
||||||
|
if ($api->getStatusCode() != 201)
|
||||||
|
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
295
intaro.intarocrm/export/export_setup.php
Normal file
295
intaro.intarocrm/export/export_setup.php
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
|
||||||
|
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");?>
|
||||||
|
</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[<?=$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -72,6 +72,13 @@ class intaro_intarocrm extends CModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!date_default_timezone_get()) {
|
||||||
|
if (!ini_get('date.timezone')) {
|
||||||
|
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_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');
|
||||||
include($this->INSTALL_PATH . '/../classes/general/ICMLLoader.php');
|
include($this->INSTALL_PATH . '/../classes/general/ICMLLoader.php');
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?
|
<?
|
||||||
$arModuleVersion = array(
|
$arModuleVersion = array(
|
||||||
"VERSION" => "0.4.0",
|
"VERSION" => "0.4.0",
|
||||||
"VERSION_DATE" => "2013-09-02 15:46:00",
|
"VERSION_DATE" => "2013-09-12 17:00:00",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -23,4 +23,9 @@ $MESS ['ERR_403'] = 'Неверный apiKey.';
|
|||||||
$MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.';
|
$MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.';
|
||||||
$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.';
|
$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.';
|
||||||
$MESS ['CANCELED'] = 'Флаг «Отменен»';
|
$MESS ['CANCELED'] = 'Флаг «Отменен»';
|
||||||
$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.';
|
$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.';
|
||||||
|
|
||||||
|
$MESS ['ICRM_OPTIONS_ORDER_DISCHARGE_TAB'] = 'Режим выгрузки заказов';
|
||||||
|
$MESS ['ORDER_DISCH'] = 'Режим выгрузки заказов';
|
||||||
|
$MESS ['DISCHARGE_AGENT'] = 'Выгрузка заказов с помощью агента';
|
||||||
|
$MESS ['DISCHARGE_EVENTS'] = 'Выгрузка заказов по событию';
|
||||||
|
@ -12,6 +12,7 @@ $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
|||||||
$CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
$CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||||
$CRM_ORDER_LAST_ID = 'order_last_id';
|
$CRM_ORDER_LAST_ID = 'order_last_id';
|
||||||
$CRM_ORDER_SITES = 'sites_ids';
|
$CRM_ORDER_SITES = 'sites_ids';
|
||||||
|
$CRM_ORDER_DISCHARGE = 'order_discharge';
|
||||||
|
|
||||||
if(!CModule::IncludeModule('intaro.intarocrm')
|
if(!CModule::IncludeModule('intaro.intarocrm')
|
||||||
|| !CModule::IncludeModule('sale'))
|
|| !CModule::IncludeModule('sale'))
|
||||||
@ -139,12 +140,43 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
$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']));
|
||||||
|
|
||||||
|
$previousDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
|
||||||
|
//order discharge mode
|
||||||
|
// 0 - agent
|
||||||
|
// 1 - event
|
||||||
|
$orderDischarge = 0;
|
||||||
|
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
|
||||||
|
|
||||||
|
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
|
||||||
|
// remove depenedencies
|
||||||
|
UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
|
||||||
|
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
|
||||||
|
// new agent
|
||||||
|
$dateAgent = new DateTime();
|
||||||
|
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
||||||
|
$dateAgent->add($intAgent);
|
||||||
|
CAgent::AddAgent(
|
||||||
|
"ICrmOrderActions::uploadOrdersAgent();", $mid, "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
|
||||||
|
);
|
||||||
|
} else if (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) {
|
||||||
|
// remove agent
|
||||||
|
CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $mid);
|
||||||
|
// event dependencies
|
||||||
|
RegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
|
||||||
|
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
|
||||||
|
}
|
||||||
|
|
||||||
COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
||||||
COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
||||||
COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
||||||
COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
||||||
COption::SetOptionString($mid, $CRM_PAYMENT, serialize($paymentArr));
|
COption::SetOptionString($mid, $CRM_PAYMENT, serialize($paymentArr));
|
||||||
COption::SetOptionString($mid, $CRM_ORDER_SITES, serialize($orderSites));
|
COption::SetOptionString($mid, $CRM_ORDER_SITES, serialize($orderSites));
|
||||||
|
COption::SetOptionString($mid, $CRM_ORDER_DISCHARGE, $orderDischarge);
|
||||||
|
|
||||||
$uri .= '&ok=Y';
|
$uri .= '&ok=Y';
|
||||||
LocalRedirect($uri);
|
LocalRedirect($uri);
|
||||||
@ -263,6 +295,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses
|
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||||
$optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0));
|
$optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0));
|
||||||
$optionsSites = unserialize(COption::GetOptionString($mid, $CRM_ORDER_SITES, 0));
|
$optionsSites = unserialize(COption::GetOptionString($mid, $CRM_ORDER_SITES, 0));
|
||||||
|
$optionsDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
|
||||||
|
|
||||||
$aTabs = array(
|
$aTabs = array(
|
||||||
array(
|
array(
|
||||||
@ -277,6 +310,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
"ICON" => '',
|
"ICON" => '',
|
||||||
"TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION')
|
"TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION')
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
"DIV" => "edit4",
|
||||||
|
"TAB" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_TAB'),
|
||||||
|
"ICON" => '',
|
||||||
|
"TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$tabControl = new CAdminTabControl("tabControl", $aTabs);
|
$tabControl = new CAdminTabControl("tabControl", $aTabs);
|
||||||
$tabControl->Begin();
|
$tabControl->Begin();
|
||||||
@ -298,7 +337,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
<td width="50%" class="adm-detail-content-cell-l"><?php echo GetMessage('ICRM_API_KEY'); ?></td>
|
<td width="50%" class="adm-detail-content-cell-l"><?php echo GetMessage('ICRM_API_KEY'); ?></td>
|
||||||
<td width="50%" class="adm-detail-content-cell-r"><input type="text" id="api_key" name="api_key" value="<?php echo $api_key; ?>"></td>
|
<td width="50%" class="adm-detail-content-cell-r"><input type="text" id="api_key" name="api_key" value="<?php echo $api_key; ?>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<!--<tr>
|
||||||
<td width="50%" class="adm-detail-content-cell-l"><?php echo GetMessage('ICRM_SITES'); ?></td>
|
<td width="50%" class="adm-detail-content-cell-l"><?php echo GetMessage('ICRM_SITES'); ?></td>
|
||||||
<td width="50%" class="adm-detail-content-cell-r">
|
<td width="50%" class="adm-detail-content-cell-r">
|
||||||
<select id="sites_ids" name="sites_ids[]" multiple="multiple" size="3">
|
<select id="sites_ids" name="sites_ids[]" multiple="multiple" size="3">
|
||||||
@ -307,7 +346,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>-->
|
||||||
<?php $tabControl->BeginNextTab(); ?>
|
<?php $tabControl->BeginNextTab(); ?>
|
||||||
<input type="hidden" name="tab" value="catalog">
|
<input type="hidden" name="tab" value="catalog">
|
||||||
<tr align="center">
|
<tr align="center">
|
||||||
@ -418,6 +457,18 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php $tabControl->BeginNextTab(); ?>
|
<?php $tabControl->BeginNextTab(); ?>
|
||||||
|
<input type="hidden" name="tab" value="catalog">
|
||||||
|
<tr class="heading">
|
||||||
|
<td colspan="2"><b><?php echo GetMessage('ORDER_DISCH'); ?></b></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="heading">
|
||||||
|
<td colspan="2">
|
||||||
|
<b>
|
||||||
|
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
|
||||||
|
<label><input class="addr" type="radio" name="order-discharge" value="1" <?php if($optionsDischarge == 1) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_EVENTS'); ?></label>
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<?php $tabControl->Buttons(); ?>
|
<?php $tabControl->Buttons(); ?>
|
||||||
<input type="hidden" name="Update" value="Y" />
|
<input type="hidden" name="Update" value="Y" />
|
||||||
<input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save" />
|
<input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save" />
|
||||||
|
Loading…
Reference in New Issue
Block a user