1
0
mirror of synced 2025-02-07 18:49:23 +03:00

Merge pull request #17 from ghostrainman/master

v.2.0.3
This commit is contained in:
Alex Lushpai 2016-10-04 19:04:42 +04:00 committed by GitHub
commit 526c74631b
19 changed files with 576 additions and 565 deletions

View File

@ -1,3 +1,12 @@
## 2016-10-04 v.2.0.3
* fix состава отгрузки
## 2016-10-04 v.2.0.2
* Исправлены ошибки
## 2016-10-03 v.2.0.1
* Исправлены ошибки
## 2016-09-12 v.2.0.0 ## 2016-09-12 v.2.0.0
* API V4 * API V4
* Переход на ядро d7 * Переход на ядро d7

View File

@ -1,15 +1,15 @@
Bitrix module Bitrix module
============= =============
Bitrix module for interaction with [retailCRM](http://www.retailcrm.ru) through [REST API](http://retailcrm.ru/docs/Разработчики). Bitrix module for interaction with [retailCRM](http://www.retailcrm.ru) through [REST API](http://www.retailcrm.ru/docs/Developers/Index).
Module allows: Module allows:
* Exchange the orders with retailCRM * Exchange the orders with retailCRM
* Configure relations between dictionaries of retailCRM and Bitrix (statuses, payments, delivery types and etc) * Configure relations between dictionaries of retailCRM and Bitrix (statuses, payments, delivery types and etc)
* Generate [ICML](http://docs.retailcrm.ru/index.php?n=Разработчики.ФорматICML) (Intaro Markup Language) for catalog loading by retailCRM * Generate [ICML](http://www.retailcrm.ru/docs/Developers/ICML) (Intaro Markup Language) for catalog loading by retailCRM
Installation Installation
------------- -------------
You should install module through [Bitrix.Marketplace](http://marketplace.1c-bitrix.ru/solutions/intaro.intarocrm/). You should install module through [Bitrix.Marketplace](http://marketplace.1c-bitrix.ru/solutions/intaro.retailcrm/).

View File

@ -14,8 +14,7 @@ class Logger
{ {
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y'));
$ar = $rsSites->Fetch(); $ar = $rsSites->Fetch();
if (!is_dir($ar['ABS_DOC_ROOT'] . $this->logPath . '/')) if (!is_dir($ar['ABS_DOC_ROOT'] . $this->logPath . '/')) {
{
mkdir($ar['ABS_DOC_ROOT'] . $this->logPath . '/'); mkdir($ar['ABS_DOC_ROOT'] . $this->logPath . '/');
} }
$file = $ar['ABS_DOC_ROOT'] . $this->logPath . '/' . $file . '.log'; $file = $ar['ABS_DOC_ROOT'] . $this->logPath . '/' . $file . '.log';

View File

@ -7,7 +7,8 @@ class RCrmActions
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
public static function SitesList(){ public static function SitesList()
{
$arSites = array(); $arSites = array();
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
while ($ar = $rsSites->Fetch()) { while ($ar = $rsSites->Fetch()) {
@ -17,7 +18,8 @@ class RCrmActions
return $arSites; return $arSites;
} }
public static function OrderTypesList($arSites){ public static function OrderTypesList($arSites)
{
$orderTypesList = array(); $orderTypesList = array();
foreach ($arSites as $site) { foreach ($arSites as $site) {
$personTypes = \Bitrix\Sale\PersonType::load($site['LID']); $personTypes = \Bitrix\Sale\PersonType::load($site['LID']);
@ -34,7 +36,8 @@ class RCrmActions
return $orderTypesList; return $orderTypesList;
} }
public static function DeliveryList(){ public static function DeliveryList()
{
$bitrixDeliveryTypesList = array(); $bitrixDeliveryTypesList = array();
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(); $noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
@ -47,21 +50,22 @@ class RCrmActions
return $bitrixDeliveryTypesList; return $bitrixDeliveryTypesList;
} }
public static function PaymentList(){ public static function PaymentList()
{
$bitrixPaymentTypesList = array(); $bitrixPaymentTypesList = array();
$dbPaymentAll = \Bitrix\Sale\PaySystem\Manager::getList(array( $dbPaymentAll = \Bitrix\Sale\PaySystem\Manager::getList(array(
'select' => array('ID', 'NAME'), 'select' => array('ID', 'NAME'),
'filter' => array('ACTIVE' => 'Y') 'filter' => array('ACTIVE' => 'Y')
)); ));
while($payment = $dbPaymentAll->fetch()) while ($payment = $dbPaymentAll->fetch()) {
{
$bitrixPaymentTypesList[] = $payment; $bitrixPaymentTypesList[] = $payment;
} }
return $bitrixPaymentTypesList; return $bitrixPaymentTypesList;
} }
public static function StatusesList(){ public static function StatusesList()
{
$bitrixPaymentStatusesList = array(); $bitrixPaymentStatusesList = array();
$arStatusesAll = \Bitrix\Sale\OrderStatus::getAllStatusesNames(); $arStatusesAll = \Bitrix\Sale\OrderStatus::getAllStatusesNames();
foreach ($arStatusesAll as $key => $arStatus) { foreach ($arStatusesAll as $key => $arStatus) {
@ -71,7 +75,8 @@ class RCrmActions
return $bitrixPaymentStatusesList; return $bitrixPaymentStatusesList;
} }
public static function OrderPropsList(){ public static function OrderPropsList()
{
$bitrixPropsList = array(); $bitrixPropsList = array();
$arPropsAll = \Bitrix\Sale\Internals\OrderPropsTable::getList(array( $arPropsAll = \Bitrix\Sale\Internals\OrderPropsTable::getList(array(
'select' => array('*') 'select' => array('*')
@ -87,8 +92,8 @@ class RCrmActions
* w+ event in bitrix log * w+ event in bitrix log
*/ */
public static function eventLog($auditType, $itemId, $description) { public static function eventLog($auditType, $itemId, $description)
{
CEventLog::Add(array( CEventLog::Add(array(
"SEVERITY" => "SECURITY", "SEVERITY" => "SECURITY",
"AUDIT_TYPE_ID" => $auditType, "AUDIT_TYPE_ID" => $auditType,
@ -105,7 +110,8 @@ class RCrmActions
* @return self name * @return self name
*/ */
public static function uploadOrdersAgent() { public static function uploadOrdersAgent()
{
RetailCrmOrder::uploadOrders(); RetailCrmOrder::uploadOrders();
$failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0)); $failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0));
if (is_array($failedIds) && !empty($failedIds)) { if (is_array($failedIds) && !empty($failedIds)) {
@ -122,7 +128,8 @@ class RCrmActions
* @return self name * @return self name
*/ */
public static function orderAgent() { public static function orderAgent()
{
if (COption::GetOptionString('main', 'agents_use_crontab', 'N') != 'N') { if (COption::GetOptionString('main', 'agents_use_crontab', 'N') != 'N') {
define('NO_AGENT_CHECK', true); define('NO_AGENT_CHECK', true);
} }
@ -141,7 +148,8 @@ class RCrmActions
* @param array $arr * @param array $arr
* @return array * @return array
*/ */
public static function clearArr($arr) { public static function clearArr($arr)
{
if (is_array($arr) === false) { if (is_array($arr) === false) {
return $arr; return $arr;
} }
@ -163,7 +171,8 @@ class RCrmActions
* @param $str in SITE_CHARSET * @param $str in SITE_CHARSET
* @return $str in utf-8 * @return $str in utf-8
*/ */
public static function toJSON($str) { public static function toJSON($str)
{
global $APPLICATION; global $APPLICATION;
return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8'); return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8');
@ -175,13 +184,15 @@ class RCrmActions
* @param $str in utf-8 * @param $str in utf-8
* @return $str in SITE_CHARSET * @return $str in SITE_CHARSET
*/ */
public static function fromJSON($str) { public static function fromJSON($str)
{
global $APPLICATION; global $APPLICATION;
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
} }
public static function explodeFIO($fio) { public static function explodeFIO($fio)
{
$newFio = empty($fio) ? false : explode(" ", $fio, 3); $newFio = empty($fio) ? false : explode(" ", $fio, 3);
$result = array(); $result = array();
switch (count($newFio)) { switch (count($newFio)) {
@ -210,7 +221,8 @@ class RCrmActions
return $result; return $result;
} }
public static function apiMethod($api, $methodApi, $method, $params, $site = null) { public static function apiMethod($api, $methodApi, $method, $params, $site = null)
{
switch ($methodApi) { switch ($methodApi) {
case 'ordersGet': case 'ordersGet':
case 'ordersEdit': case 'ordersEdit':

View File

@ -32,24 +32,6 @@ class RestNormalizer
$this->server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $this->server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
} }
/**
* Installation file validation
* @param string $file The path to the file validation
* @return void
* @access public
* @final
*/
// final public function setValidation($file = false)
// {
// if ($file === false || is_null($file) || is_file($file) === false) {
// $file = $this->server . '/bitrix/modules/intaro.intarocrm/classes/general/config/retailcrm.json';
// }
// if (json_decode(file_get_contents($file)) === null || $this->parseConfig($file) === false) {
// ICrmOrderActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect file normalize.');
// return false;
// }
// }
/** /**
* Parsing the file validation * Parsing the file validation
* @param string $file The path to the file validation * @param string $file The path to the file validation
@ -117,7 +99,6 @@ class RestNormalizer
$formatted = array(); $formatted = array();
foreach ($data as $code => $value) { foreach ($data as $code => $value) {
if (isset($this->validation[ $code ]) && $this->validation[ $code ]['type'] == 'skip') { if (isset($this->validation[ $code ]) && $this->validation[ $code ]['type'] == 'skip') {
$formatted[ $code ] = $value; $formatted[ $code ] = $value;
} elseif (isset($this->validation[ $code ]) && is_array($value) === false) { } elseif (isset($this->validation[ $code ]) && is_array($value) === false) {

View File

@ -2,7 +2,8 @@
/** /**
* RCrmEvent * RCrmEvent
*/ */
class RetailCrmEvent { class RetailCrmEvent
{
protected static $MODULE_ID = 'intaro.retailcrm'; protected static $MODULE_ID = 'intaro.retailcrm';
protected static $CRM_API_HOST_OPTION = 'api_host'; protected static $CRM_API_HOST_OPTION = 'api_host';
protected static $CRM_API_KEY_OPTION = 'api_key'; protected static $CRM_API_KEY_OPTION = 'api_key';
@ -24,7 +25,8 @@ class RetailCrmEvent {
* *
* @param mixed $arFields - User arFields * @param mixed $arFields - User arFields
*/ */
function OnAfterUserUpdate($arFields) { function OnAfterUserUpdate($arFields)
{
if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) { if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) {
return; return;
} }
@ -63,10 +65,11 @@ class RetailCrmEvent {
* @param mixed $ID - Order id * @param mixed $ID - Order id
* @param mixed $arFields - Order arFields * @param mixed $arFields - Order arFields
*/ */
function OnOrderSave($ID, $arFields, $arOrder, $isNew) { // function OnOrderSave($ID, $arFields, $arOrder, $isNew)
$GLOBALS['RETAILCRM_EVENT_OLD'] = true; // {
return; // $GLOBALS['RETAILCRM_EVENT_OLD'] = true;
} // return;
// }
/** /**
* onUpdateOrder * onUpdateOrder
@ -74,7 +77,8 @@ class RetailCrmEvent {
* @param mixed $ID - Order id * @param mixed $ID - Order id
* @param mixed $arFields - Order arFields * @param mixed $arFields - Order arFields
*/ */
function onUpdateOrder($ID, $arFields) { function onUpdateOrder($ID, $arFields)
{
if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) { if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) {
$GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = false; $GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = false;
return; return;
@ -89,7 +93,8 @@ class RetailCrmEvent {
* *
* @param object $event - Order object * @param object $event - Order object
*/ */
function orderDelete($event){ function orderDelete($event)
{
$GLOBALS['RETAILCRM_ORDER_DELETE'] = true; $GLOBALS['RETAILCRM_ORDER_DELETE'] = true;
return; return;
} }
@ -100,7 +105,8 @@ class RetailCrmEvent {
* @param object $event - Order object * @param object $event - Order object
*/ */
function orderSave($event){ function orderSave($event)
{
if ($GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] !== false && $GLOBALS['RETAIL_CRM_HISTORY'] !== true && $GLOBALS['RETAILCRM_ORDER_DELETE'] !== true) { if ($GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] !== false && $GLOBALS['RETAIL_CRM_HISTORY'] !== true && $GLOBALS['RETAILCRM_ORDER_DELETE'] !== true) {
if (!CModule::IncludeModule('iblock')) { if (!CModule::IncludeModule('iblock')) {
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'iblock', 'module not found'); RCrmActions::eventLog('RetailCrmEvent::orderSave', 'iblock', 'module not found');
@ -120,11 +126,9 @@ class RetailCrmEvent {
//проверка на существование getParameter("ENTITY") //проверка на существование getParameter("ENTITY")
if (method_exists($event, 'getId')) { if (method_exists($event, 'getId')) {
$obOrder = $event; $obOrder = $event;
} } elseif (method_exists($event, 'getParameter')) {
elseif(method_exists($event, 'getParameter')){
$obOrder = $event->getParameter("ENTITY"); $obOrder = $event->getParameter("ENTITY");
} } else {
else{
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'events', 'event error'); RCrmActions::eventLog('RetailCrmEvent::orderSave', 'events', 'event error');
return true; return true;
} }
@ -168,8 +172,7 @@ class RetailCrmEvent {
$orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site); $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site);
if (isset($orderCrm['order'])) { if (isset($orderCrm['order'])) {
$methodApi = 'ordersEdit'; $methodApi = 'ordersEdit';
} } else {
else{
$methodApi = 'ordersCreate'; $methodApi = 'ordersCreate';
} }

View File

@ -25,7 +25,8 @@ class RetailCrmHistory
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
public static function customerHistory(){ public static function customerHistory()
{
if (!CModule::IncludeModule("iblock")) { if (!CModule::IncludeModule("iblock")) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'iblock', 'module not found'); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'iblock', 'module not found');
return false; return false;
@ -182,8 +183,7 @@ class RetailCrmHistory
if (isset($phone['number'])) { if (isset($phone['number'])) {
$arUser[$key] = $phone['number']; $arUser[$key] = $phone['number'];
$user[$key] = $phone['number']; $user[$key] = $phone['number'];
} } else {
else{
$arUser[$key] = ''; $arUser[$key] = '';
$user[$key] = ''; $user[$key] = '';
} }
@ -228,7 +228,8 @@ class RetailCrmHistory
} }
} }
public static function orderHistory() { public static function orderHistory()
{
global $USER; global $USER;
if (is_object($USER) == false) { if (is_object($USER) == false) {
$USER = new RetailUser; $USER = new RetailUser;
@ -377,7 +378,9 @@ class RetailCrmHistory
if ($order['customer']['phones'][1]) { if ($order['customer']['phones'][1]) {
$arFields['PERSONAL_MOBILE'] = $order['customer']['phones'][1]; $arFields['PERSONAL_MOBILE'] = $order['customer']['phones'][1];
} }
$registeredUserID = $newUser->Add($arFields); $registeredUserID = $newUser->Add($arFields);
if ($registeredUserID === false) { if ($registeredUserID === false) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'CUser::Register', 'Error register user'); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'CUser::Register', 'Error register user');
continue; continue;
@ -407,8 +410,7 @@ class RetailCrmHistory
if (isset($optionsSitesList)) { if (isset($optionsSitesList)) {
$site = array_search($order['site'], $optionsSitesList); $site = array_search($order['site'], $optionsSitesList);
} } else {
else{
$site = CSite::GetDefSite(); $site = CSite::GetDefSite();
} }
@ -434,8 +436,7 @@ class RetailCrmHistory
continue; continue;
} }
} } else {
else{
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Error order create'); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Error order create');
} }
$order['externalId'] = $externalId; $order['externalId'] = $externalId;
@ -452,7 +453,7 @@ class RetailCrmHistory
if ($optionsOrderNumbers == 'Y' && isset($order['number'])) { if ($optionsOrderNumbers == 'Y' && isset($order['number'])) {
$newOrder->setField('ACCOUNT_NUMBER', $order['number']); $newOrder->setField('ACCOUNT_NUMBER', $order['number']);
} }
//var_dump(array($order['externalId'], $newOrder->getField('PERSON_TYPE_ID'), $optionsOrderTypes, $order));
$personType = $newOrder->getField('PERSON_TYPE_ID'); $personType = $newOrder->getField('PERSON_TYPE_ID');
if ($optionsOrderTypes[$order['orderType']]) { if ($optionsOrderTypes[$order['orderType']]) {
if ($personType != $optionsOrderTypes[$order['orderType']] && $personType != 0) { if ($personType != $optionsOrderTypes[$order['orderType']] && $personType != 0) {
@ -460,8 +461,7 @@ class RetailCrmHistory
} }
$personType = $optionsOrderTypes[$order['orderType']]; $personType = $optionsOrderTypes[$order['orderType']];
$newOrder->setField('PERSON_TYPE_ID', $personType); $newOrder->setField('PERSON_TYPE_ID', $personType);
} } elseif ($personType == 0) {
elseif($personType == 0){
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'orderType not found', 'PERSON_TYPE_ID = 0'); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'orderType not found', 'PERSON_TYPE_ID = 0');
} }
@ -470,8 +470,7 @@ class RetailCrmHistory
$newOrder->setField('STATUS_ID', $optionsPayStatuses[$order['status']]); $newOrder->setField('STATUS_ID', $optionsPayStatuses[$order['status']]);
if (in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)) { if (in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)) {
$newOrder->setField('CANCELED', 'Y'); $newOrder->setField('CANCELED', 'Y');
} } else {
else{
$newOrder->setField('CANCELED', 'N'); $newOrder->setField('CANCELED', 'N');
} }
} }
@ -536,8 +535,7 @@ class RetailCrmHistory
) )
) )
); );
} } else {
else{
$order['fio'] = trim( $order['fio'] = trim(
implode( implode(
' ', ' ',
@ -558,16 +556,14 @@ class RetailCrmHistory
if (array_key_exists($key, $order)) { if (array_key_exists($key, $order)) {
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $order[$key]); self::setProp($somePropValue, $order[$key]);
} } elseif (array_key_exists($key, $order['delivery']['address'])) {
elseif(array_key_exists($key, $order['delivery']['address'])){
if ($propsKey[$key]['TYPE'] == 'LOCATION') { if ($propsKey[$key]['TYPE'] == 'LOCATION') {
$parameters['filter']['NAME'] = $order['delivery']['address'][$key]; $parameters['filter']['NAME'] = $order['delivery']['address'][$key];
$parameters['filter']['LANGUAGE_ID'] = 'ru'; $parameters['filter']['LANGUAGE_ID'] = 'ru';
$location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch(); $location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch();
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $location['CODE']); self::setProp($somePropValue, $location['CODE']);
} } else {
else{
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $order['delivery']['address'][$key]); self::setProp($somePropValue, $order['delivery']['address'][$key]);
} }
@ -579,7 +575,6 @@ class RetailCrmHistory
foreach ($optionsLegalDetails[$personType] as $key => $orderProp) { foreach ($optionsLegalDetails[$personType] as $key => $orderProp) {
if (array_key_exists($key, $order)) { if (array_key_exists($key, $order)) {
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $order[$key]); self::setProp($somePropValue, $order[$key]);
} }
} }
@ -616,8 +611,7 @@ class RetailCrmHistory
'NAME' => $elem['NAME'], 'NAME' => $elem['NAME'],
'DETAIL_PAGE_URL' => $elem['URL'] 'DETAIL_PAGE_URL' => $elem['URL']
)); ));
} } else {
else{
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'createItem', 'Error item add'); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'createItem', 'Error item add');
continue; continue;
} }
@ -668,8 +662,7 @@ class RetailCrmHistory
if (array_key_exists('cost', $order['delivery'])) { if (array_key_exists('cost', $order['delivery'])) {
$deliverySumm = $order['delivery']['cost']; $deliverySumm = $order['delivery']['cost'];
} } else {
else{
$deliverySumm = $newOrder->getDeliveryPrice(); $deliverySumm = $newOrder->getDeliveryPrice();
} }
@ -704,7 +697,7 @@ class RetailCrmHistory
} }
//delivery cost //delivery cost
if(array_key_exists('cost', $order['delivery'])){//сделать такую же для оплаты при изменении суммы if (array_key_exists('cost', $order['delivery'])) {
$shipment = Bitrix\Sale\Shipment::getList(array( $shipment = Bitrix\Sale\Shipment::getList(array(
'filter' => array('ORDER_ID' => $order['externalId'], 'SYSTEM' => 'N'), 'filter' => array('ORDER_ID' => $order['externalId'], 'SYSTEM' => 'N'),
'order' => array('ID') 'order' => array('ID')
@ -718,6 +711,8 @@ class RetailCrmHistory
Bitrix\Sale\OrderTable::update($order['externalId'], array('MARKED' => 'N', 'EMP_MARKED_ID' => '', 'REASON_MARKED' => '')); Bitrix\Sale\OrderTable::update($order['externalId'], array('MARKED' => 'N', 'EMP_MARKED_ID' => '', 'REASON_MARKED' => ''));
self::updateShipmentItem($order['externalId']);
if (function_exists('retailCrmAfterOrderSave')) { if (function_exists('retailCrmAfterOrderSave')) {
retailCrmAfterOrderSave($order); retailCrmAfterOrderSave($order);
} }
@ -739,13 +734,13 @@ class RetailCrmHistory
} }
public static function assemblyCustomer($customerHistory){ public static function assemblyCustomer($customerHistory)
{
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$fields = array(); $fields = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml'); $objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
foreach($objects->fields->field as $object) foreach ($objects->fields->field as $object) {
{
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object; $fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
} }
} }
@ -754,8 +749,7 @@ class RetailCrmHistory
$change['customer'] = self::removeEmpty($change['customer']); $change['customer'] = self::removeEmpty($change['customer']);
if ($customers[$change['customer']['id']]) { if ($customers[$change['customer']['id']]) {
$customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']); $customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']);
} } else {
else{
$customers[$change['customer']['id']] = $change['customer']; $customers[$change['customer']['id']] = $change['customer'];
} }
@ -772,15 +766,12 @@ class RetailCrmHistory
if (isset($change['newValue'])) { if (isset($change['newValue'])) {
$customers[$change['customer']['id']]['phones'][$key]['number'] = $change['newValue']; $customers[$change['customer']['id']]['phones'][$key]['number'] = $change['newValue'];
} }
} } else {
else{
if ($fields['customerAddress'][$change['field']]) { if ($fields['customerAddress'][$change['field']]) {
$customers[$change['customer']['id']]['address'][$fields['customerAddress'][$change['field']]] = $change['newValue']; $customers[$change['customer']['id']]['address'][$fields['customerAddress'][$change['field']]] = $change['newValue'];
} } elseif ($fields['customerContragent'][$change['field']]) {
elseif($fields['customerContragent'][$change['field']]){
$customers[$change['customer']['id']]['contragent'][$fields['customerContragent'][$change['field']]] = $change['newValue']; $customers[$change['customer']['id']]['contragent'][$fields['customerContragent'][$change['field']]] = $change['newValue'];
} } elseif ($fields['customer'][$change['field']]) {
elseif($fields['customer'][$change['field']]){
$customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']); $customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']);
} }
@ -793,15 +784,16 @@ class RetailCrmHistory
} }
} }
} }
return $customers; return $customers;
} }
public static function assemblyOrder($orderHistory){ public static function assemblyOrder($orderHistory)
{
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml'); $objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
foreach($objects->fields->field as $object) foreach ($objects->fields->field as $object) {
{
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object; $fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
} }
} }
@ -826,16 +818,14 @@ class RetailCrmHistory
if ($orders[$change['order']['id']]) { if ($orders[$change['order']['id']]) {
$orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']); $orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']);
} } else {
else{
$orders[$change['order']['id']] = $change['order']; $orders[$change['order']['id']] = $change['order'];
} }
if ($change['item']) { if ($change['item']) {
if ($orders[$change['order']['id']]['items'][$change['item']['id']]) { if ($orders[$change['order']['id']]['items'][$change['item']['id']]) {
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']); $orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
} } else {
else{
$orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item']; $orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item'];
} }
@ -849,27 +839,20 @@ class RetailCrmHistory
if (!$orders[$change['order']['id']]['items'][$change['item']['id']]['create'] && $fields['item'][$change['field']]) { if (!$orders[$change['order']['id']]['items'][$change['item']['id']]['create'] && $fields['item'][$change['field']]) {
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue']; $orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
} }
} } else {
else{
if ($fields['delivery'][$change['field']] == 'service') { if ($fields['delivery'][$change['field']] == 'service') {
$orders[$change['order']['id']]['delivery']['service']['code'] = self::newValue($change['newValue']); $orders[$change['order']['id']]['delivery']['service']['code'] = self::newValue($change['newValue']);
} } elseif ($fields['delivery'][$change['field']]) {
elseif($fields['delivery'][$change['field']]){
$orders[$change['order']['id']]['delivery'][$fields['delivery'][$change['field']]] = self::newValue($change['newValue']); $orders[$change['order']['id']]['delivery'][$fields['delivery'][$change['field']]] = self::newValue($change['newValue']);
} } elseif ($fields['orderAddress'][$change['field']]) {
elseif($fields['orderAddress'][$change['field']]){
$orders[$change['order']['id']]['delivery']['address'][$fields['orderAddress'][$change['field']]] = $change['newValue']; $orders[$change['order']['id']]['delivery']['address'][$fields['orderAddress'][$change['field']]] = $change['newValue'];
} } elseif ($fields['integrationDelivery'][$change['field']]) {
elseif($fields['integrationDelivery'][$change['field']]){
$orders[$change['order']['id']]['delivery']['service'][$fields['integrationDelivery'][$change['field']]] = self::newValue($change['newValue']); $orders[$change['order']['id']]['delivery']['service'][$fields['integrationDelivery'][$change['field']]] = self::newValue($change['newValue']);
} } elseif ($fields['customerContragent'][$change['field']]) {
elseif($fields['customerContragent'][$change['field']]){
$orders[$change['order']['id']][$fields['customerContragent'][$change['field']]] = self::newValue($change['newValue']); $orders[$change['order']['id']][$fields['customerContragent'][$change['field']]] = self::newValue($change['newValue']);
} } elseif (strripos($change['field'], 'custom_') !== false) {
elseif(strripos($change['field'], 'custom_') !== false){
$orders[$change['order']['id']]['customFields'][str_replace('custom_', '', $change['field'])] = self::newValue($change['newValue']); $orders[$change['order']['id']]['customFields'][str_replace('custom_', '', $change['field'])] = self::newValue($change['newValue']);
} } elseif ($fields['order'][$change['field']]){
elseif($fields['order'][$change['field']]){
$orders[$change['order']['id']][$fields['order'][$change['field']]] = self::newValue($change['newValue']); $orders[$change['order']['id']][$fields['order'][$change['field']]] = self::newValue($change['newValue']);
} }
@ -882,17 +865,18 @@ class RetailCrmHistory
} }
} }
} }
return $orders; return $orders;
} }
public static function shipmentUpdate($orderCrm, $optionsDelivTypes){ public static function shipmentUpdate($orderCrm, $optionsDelivTypes)
{
if (isset($orderCrm['delivery']['code'])) { if (isset($orderCrm['delivery']['code'])) {
$crmCode = $orderCrm['delivery']['code']; $crmCode = $orderCrm['delivery']['code'];
if (isset($orderCrm['delivery']['data']['deliveryType'])) { if (isset($orderCrm['delivery']['data']['deliveryType'])) {
$crmService = $orderCrm['delivery']['data']['deliveryType']; $crmService = $orderCrm['delivery']['data']['deliveryType'];
} } elseif (isset($orderCrm['delivery']['service'])) {
elseif (isset($orderCrm['delivery']['service'])) {
$crmService = $orderCrm['delivery']['service']; $crmService = $orderCrm['delivery']['service'];
} }
@ -908,8 +892,7 @@ class RetailCrmHistory
//будем менять доставку на этот id //будем менять доставку на этот id
if ($crmService && $arDeliveryCode[$dCode]) { if ($crmService && $arDeliveryCode[$dCode]) {
$nowDelivery = $arDeliveryCode[$dCode]; $nowDelivery = $arDeliveryCode[$dCode];
} } else {
else{
$nowDelivery = $optionsDelivTypes[$crmCode]; $nowDelivery = $optionsDelivTypes[$crmCode];
} }
@ -924,8 +907,7 @@ class RetailCrmHistory
\Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $nowDelivery, 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'])); \Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $nowDelivery, 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME']));
} }
} }
} } else {//создаем
else{//создаем
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery)); \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery));
$shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array( $shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'], 'ORDER_ID' => $orderCrm['externalId'],
@ -965,8 +947,7 @@ class RetailCrmHistory
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime() 'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
)); ));
} }
} } else {
else{
//ищем у заказа на сайте доставки и удаляем/заменяем на без доставки //ищем у заказа на сайте доставки и удаляем/заменяем на без доставки
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(); $noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId)); \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId));
@ -1021,7 +1002,68 @@ class RetailCrmHistory
return true; return true;
} }
public static function paySystemUpdate($order, $optionsPayment){ public static function updateShipmentItem($orderId)
{
$orderBasket = \Bitrix\Sale\Internals\BasketTable::getList(array(
'filter' => array('ORDER_ID' => $orderId),
'select' => array('ID', 'QUANTITY')
));
$basketItems = array();
while ($basketItem = $orderBasket->fetch()) {
$basketItems[] = $basketItem;
$bItems[] = $basketItem['ID'];
}
$obShipments = \Bitrix\Sale\Internals\ShipmentTable::getList(array(
'filter' => array('ORDER_ID' => $orderId),
'select' => array('ID')
));
$shipmentItems = array();
while ($arShipment = $obShipments->fetch()) {
$dlvBaslet = \Bitrix\Sale\Internals\ShipmentItemTable::getList(array(
'order' => array('ORDER_DELIVERY_ID'),
'filter' => array('ORDER_DELIVERY_ID' => $arShipment['ID'])
));
$shipmentItems[$arShipment['ID']] = array();
while ($item = $dlvBaslet->fetch()) {
$shipmentItems[$arShipment['ID']][] = $item;
}
}
foreach ($basketItems as $basketItem) {
foreach ($shipmentItems as $key => $arShipmentItems) {
$found = false;
foreach ($arShipmentItems as $elShipmentItem) {
if (!in_array($elShipmentItem['BASKET_ID'], $bItems)) {
//удаляем элемент
\Bitrix\Sale\Internals\ShipmentItemTable::delete($elShipmentItem['ID']);
}
if ($elShipmentItem['BASKET_ID'] == $basketItem['ID']) {
//нашли
$found = true;
//проверяем кол-во, если нужно, обновляем
if ($elShipmentItem['QUANTITY'] != $basketItem['QUANTITY']) {
\Bitrix\Sale\Internals\ShipmentItemTable::update($elShipmentItem['ID'], array('QUANTITY' => $basketItem['QUANTITY']));
}
}
}
if (!$found) {
//добавляем
\Bitrix\Sale\Internals\ShipmentItemTable::add(array(
'ORDER_DELIVERY_ID' => $key,
'BASKET_ID' => $basketItem['ID'],
'DATE_INSERT' => new \Bitrix\Main\Type\DateTime(),
'QUANTITY' => $basketItem['QUANTITY'],
'RESERVED_QUANTITY' => '0.00',
));
}
}
}
}
public static function paySystemUpdate($order, $optionsPayment)
{
if (isset($order['paymentType'])) { if (isset($order['paymentType'])) {
if ($optionsPayment[$order['paymentType']]) { if ($optionsPayment[$order['paymentType']]) {
$paymentList = RCrmActions::PaymentList(); $paymentList = RCrmActions::PaymentList();
@ -1038,11 +1080,9 @@ class RetailCrmHistory
'filter' => array('ORDER_ID' => $order['externalId']), 'filter' => array('ORDER_ID' => $order['externalId']),
'order' => array('ID') 'order' => array('ID')
))->fetch(); ))->fetch();
if($payment){ if ($payment) {//если уже существует, update
//если уже существует, update
\Bitrix\Sale\Internals\PaymentTable::update($payment['ID'], array('PAY_SYSTEM_ID' => $optionsPayment[$order['paymentType']], 'PAY_SYSTEM_NAME' => $arPaymentsName[$optionsPayment[$order['paymentType']]], 'SUM' => $order['summ'])); \Bitrix\Sale\Internals\PaymentTable::update($payment['ID'], array('PAY_SYSTEM_ID' => $optionsPayment[$order['paymentType']], 'PAY_SYSTEM_NAME' => $arPaymentsName[$optionsPayment[$order['paymentType']]], 'SUM' => $order['summ']));
} } else {
else{
\Bitrix\Sale\Internals\PaymentTable::add(array( \Bitrix\Sale\Internals\PaymentTable::add(array(
'ORDER_ID' => $order['externalId'], 'ORDER_ID' => $order['externalId'],
'PAID' => 'N', 'PAID' => 'N',
@ -1058,18 +1098,13 @@ class RetailCrmHistory
)); ));
} }
//запись в историю //запись в историю
} } else {//ошибка, нет такой активной платежной системы
else{
//ошибка, нет такой активной платежной системы
RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found'); RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found');
} }
} } else {//ошибка, возможно платежная система не сопоставлена
else{
//ошибка, возможно платежная система не сопоставлена
RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found in option');; RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found in option');;
} }
} } else {
else{
\Bitrix\Sale\OrderTable::update($order['externalId'], array('PAY_SYSTEM_ID' => '')); \Bitrix\Sale\OrderTable::update($order['externalId'], array('PAY_SYSTEM_ID' => ''));
$payment = \Bitrix\Sale\Payment::getList(array( $payment = \Bitrix\Sale\Payment::getList(array(
'filter' => array('ORDER_ID' => $order['externalId']), 'filter' => array('ORDER_ID' => $order['externalId']),
@ -1083,16 +1118,17 @@ class RetailCrmHistory
} }
} }
public static function newValue($value){ public static function newValue($value)
{
if (isset($value['code'])) { if (isset($value['code'])) {
return $value['code']; return $value['code'];
} } else {
else{
return $value; return $value;
} }
} }
public static function removeEmpty($inputArray){ public static function removeEmpty($inputArray)
{
$outputArray = array(); $outputArray = array();
if (!empty($inputArray)) { if (!empty($inputArray)) {
foreach ($inputArray as $key => $element) { foreach ($inputArray as $key => $element) {
@ -1108,30 +1144,28 @@ class RetailCrmHistory
return $outputArray; return $outputArray;
} }
public static function setProp($obj, $value, $prop){ public static function setProp($obj, $value, $prop)
{
if (!isset($obj)) { if (!isset($obj)) {
return false; return false;
} }
if ($prop && $value) { if ($prop && $value) {
$obj->setField($prop, $value); $obj->setField($prop, $value);
} } elseif ($value) {
elseif($value){
$obj->setValue($value); $obj->setValue($value);
} } else {
else{
$obj->delete(); $obj->delete();
} }
return true; return true;
} }
public static function getExistsItem($basket, $moduleId, $productId){ public static function getExistsItem($basket, $moduleId, $productId)
foreach ($basket as $basketItem)
{ {
foreach ($basket as $basketItem) {
$itemExists = ($basketItem->getField('PRODUCT_ID') == $productId && $basketItem->getField('MODULE') == $moduleId); $itemExists = ($basketItem->getField('PRODUCT_ID') == $productId && $basketItem->getField('MODULE') == $moduleId);
if ($itemExists) if ($itemExists) {
{
return $basketItem; return $basketItem;
} }
} }
@ -1139,13 +1173,15 @@ class RetailCrmHistory
return false; return false;
} }
public static function getInfoElement($offerId){ public static function getInfoElement($offerId)
{
$elementInfo = CIBlockElement::GetByID($offerId)->fetch(); $elementInfo = CIBlockElement::GetByID($offerId)->fetch();
$url = CAllIBlock::ReplaceDetailUrl($elementInfo['DETAIL_PAGE_URL'], $elementInfo, false, 'E'); $url = CAllIBlock::ReplaceDetailUrl($elementInfo['DETAIL_PAGE_URL'], $elementInfo, false, 'E');
$info = array( $info = array(
'NAME' => $elementInfo['NAME'], 'NAME' => $elementInfo['NAME'],
'URL' => $url, 'URL' => $url,
); );
return $info; return $info;
} }
} }

View File

@ -66,8 +66,7 @@ class RetailCrmICML
curl_close($curlHandler); curl_close($curlHandler);
if ($statusCode == 200) { if ($statusCode == 200) {
$this->protocol = 'https://'; $this->protocol = 'https://';
} } else {
else{
$this->protocol = 'http://'; $this->protocol = 'http://';
} }
@ -124,6 +123,7 @@ class RetailCrmICML
$newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding); $newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding);
$newText = strip_tags($newText); $newText = strip_tags($newText);
$newText = str_replace("&", "&", $newText); $newText = str_replace("&", "&", $newText);
return $newText; return $newText;
} }
@ -132,11 +132,12 @@ class RetailCrmICML
$fullFilename = $_SERVER["DOCUMENT_ROOT"] . $filename; $fullFilename = $_SERVER["DOCUMENT_ROOT"] . $filename;
CheckDirPath($fullFilename); CheckDirPath($fullFilename);
if ($fp = @fopen($fullFilename, "w")) if ($fp = @fopen($fullFilename, "w")){
return $fp; return $fp;
else } else {
return false; return false;
} }
}
protected function PreWriteCatalog() protected function PreWriteCatalog()
{ {
@ -175,9 +176,10 @@ class RetailCrmICML
protected function WriteLog($text) protected function WriteLog($text)
{ {
if ($this->isLogged) if ($this->isLogged) {
@fwrite($this->fpLog, Date("Y:m:d H:i:s") . ": " . $text . "\n"); @fwrite($this->fpLog, Date("Y:m:d H:i:s") . ": " . $text . "\n");
} }
}
protected function PostWriteCatalog() protected function PostWriteCatalog()
{ {
@ -194,8 +196,7 @@ class RetailCrmICML
protected function GetCategories() protected function GetCategories()
{ {
$categories = array(); $categories = array();
foreach ($this->iblocks as $id) foreach ($this->iblocks as $id) {
{
$filter = array("IBLOCK_ID" => $id); $filter = array("IBLOCK_ID" => $id);
$dbRes = CIBlockSection::GetList(array("left_margin" => "asc"), $filter); $dbRes = CIBlockSection::GetList(array("left_margin" => "asc"), $filter);
@ -214,6 +215,7 @@ class RetailCrmICML
$categories[$arRes['ID']] = $arRes; $categories[$arRes['ID']] = $arRes;
} }
} }
return $categories; return $categories;
} }
@ -240,8 +242,7 @@ class RetailCrmICML
1 1
); );
foreach ($this->iblocks as $key => $id) foreach ($this->iblocks as $key => $id) {
{
// Get Info by infoblocks // Get Info by infoblocks
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch(); $iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id); $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
@ -266,7 +267,7 @@ class RetailCrmICML
} }
} }
$arSelectOffer = Array ( $arSelectOffer = array(
'ID', 'ID',
'ACTIVE', 'ACTIVE',
"NAME", "NAME",
@ -288,7 +289,7 @@ class RetailCrmICML
"IBLOCK_ID" => $id "IBLOCK_ID" => $id
); );
$order = array("id"); $order = array("id");
$arNavStatParams = Array( $arNavStatParams = array(
"iNumPage" => 1, "iNumPage" => 1,
"nPageSize" => $this->pageSize, "nPageSize" => $this->pageSize,
); );
@ -298,8 +299,7 @@ class RetailCrmICML
// Get products on this page // Get products on this page
$elems = array(); $elems = array();
$dbResProductsIds = CIBlockElement::GetList($order, $filter, false, $arNavStatParams, array('ID')); $dbResProductsIds = CIBlockElement::GetList($order, $filter, false, $arNavStatParams, array('ID'));
while($obIds = $dbResProductsIds->Fetch()) while ($obIds = $dbResProductsIds->Fetch()) {
{
$elems[] = $obIds['ID']; $elems[] = $obIds['ID'];
} }
$arfilter = array( $arfilter = array(
@ -312,7 +312,6 @@ class RetailCrmICML
$pictures = array(); $pictures = array();
$products = array(); $products = array();
while ($product = $dbResProducts->GetNext()) { while ($product = $dbResProducts->GetNext()) {
// Compile products to array // Compile products to array
$products[$product['ID']] = $product; $products[$product['ID']] = $product;
$products[$product['ID']]['offers'] = array(); $products[$product['ID']]['offers'] = array();
@ -320,13 +319,11 @@ class RetailCrmICML
$detailPicture = intval($product["DETAIL_PICTURE"]); $detailPicture = intval($product["DETAIL_PICTURE"]);
$previewPicture = intval($product["PREVIEW_PICTURE"]); $previewPicture = intval($product["PREVIEW_PICTURE"]);
if ($detailPicture > 0 || $previewPicture > 0) if ($detailPicture > 0 || $previewPicture > 0) {
{
$picture = $detailPicture; $picture = $detailPicture;
if ($picture <= 0) { if ($picture <= 0) {
$picture = $previewPicture; $picture = $previewPicture;
} }
// Link pictureID and productID // Link pictureID and productID
$pictures[$picture] = $product['ID']; $pictures[$picture] = $product['ID'];
} }
@ -337,9 +334,8 @@ class RetailCrmICML
$pictureIDs = array_keys($pictures); $pictureIDs = array_keys($pictures);
// Get pathes of pictures // Get pathes of pictures
$dbFiles = CFile::GetList(Array(), Array("@ID" => implode(',', $pictureIDs))); $dbFiles = CFile::GetList(array(), array("@ID" => implode(',', $pictureIDs)));
while ($file = $dbFiles->GetNext()) { while ($file = $dbFiles->GetNext()) {
// Link picture to product // Link picture to product
$products[$pictures[$file['ID']]]['PICTURE'] = $this->protocol . $products[$pictures[$file['ID']]]['PICTURE'] = $this->protocol .
$this->serverName . $this->serverName .
@ -372,7 +368,6 @@ class RetailCrmICML
$stringOffers = ""; $stringOffers = "";
foreach ($products as $product) { foreach ($products as $product) {
// Get properties of product // Get properties of product
$resPropertiesProduct = Array(); $resPropertiesProduct = Array();
foreach ($this->propertiesProduct[$id] as $key => $propProduct) { foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
@ -381,11 +376,9 @@ class RetailCrmICML
if ($propProduct != "") { if ($propProduct != "") {
if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) { if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) {
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"]; $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"];
} } elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])) {
elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])){
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"]; $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
} } elseif (isset($product[$propProduct])) {
elseif (isset($product[$propProduct])){
$resPropertiesProduct[$key] = $product[$propProduct]; $resPropertiesProduct[$key] = $product[$propProduct];
} }
if (array_key_exists($key, $this->propertiesUnitProduct[$id])) { if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
@ -396,7 +389,7 @@ class RetailCrmICML
} }
// Get categories of product // Get categories of product
$categories = Array(); $categories = array();
$dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true); $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true);
while ($arResCategory = $dbResCategories->Fetch()) { while ($arResCategory = $dbResCategories->Fetch()) {
$categories[$arResCategory["ID"]] = array( $categories[$arResCategory["ID"]] = array(
@ -412,7 +405,6 @@ class RetailCrmICML
$existOffer = false; $existOffer = false;
if (!empty($iblockOffer['IBLOCK_ID'])) { if (!empty($iblockOffer['IBLOCK_ID'])) {
foreach ($product['offers'] as $offer) { foreach ($product['offers'] as $offer) {
$offer['PRODUCT_ID'] = $product["ID"]; $offer['PRODUCT_ID'] = $product["ID"];
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"]; $offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
@ -428,11 +420,9 @@ class RetailCrmICML
if ($propSKU != "") { if ($propSKU != "") {
if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) { if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) {
$offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"]; $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"];
} } elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])) {
elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])){
$offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"]; $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"];
} } elseif (isset($offer[$propSKU])) {
elseif (isset($offer[$propSKU])){
$offer['_PROP_' . $key] = $offer[$propSKU]; $offer['_PROP_' . $key] = $offer[$propSKU];
} }
if (array_key_exists($key, $this->propertiesUnitSKU[$id])) { if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
@ -453,7 +443,6 @@ class RetailCrmICML
} }
} }
if (!$existOffer) { if (!$existOffer) {
$product['PRODUCT_ID'] = $product["ID"]; $product['PRODUCT_ID'] = $product["ID"];
$product['PRODUCT_NAME'] = $product["NAME"]; $product['PRODUCT_NAME'] = $product["NAME"];
$product['PRODUCT_ACTIVE'] = $product["ACTIVE"]; $product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
@ -482,8 +471,7 @@ class RetailCrmICML
} }
$arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1; $arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1;
} } while ($dbResProductsIds->NavPageNomer < $dbResProductsIds->NavPageCount);
while ($dbResProductsIds->NavPageNomer < $dbResProductsIds->NavPageCount);
} }
} }
@ -501,7 +489,6 @@ class RetailCrmICML
$keys = array_keys($categories); $keys = array_keys($categories);
if (strpos($arOffer['DETAIL_PAGE_URL'], "#SECTION_PATH#") !== false) { if (strpos($arOffer['DETAIL_PAGE_URL'], "#SECTION_PATH#") !== false) {
if (count($categories) != 0) { if (count($categories) != 0) {
$category = $allCategories[$keys[0]]; $category = $allCategories[$keys[0]];
$path = $category['CODE']; $path = $category['CODE'];
@ -509,10 +496,11 @@ class RetailCrmICML
while (true) { while (true) {
$category = $allCategories[$category['IBLOCK_SECTION_ID']]; $category = $allCategories[$category['IBLOCK_SECTION_ID']];
$path = $category['CODE'] . '/' . $path; $path = $category['CODE'] . '/' . $path;
if(intval($category["IBLOCK_SECTION_ID"] ) == 0) if(intval($category["IBLOCK_SECTION_ID"]) == 0){
break; break;
} }
} }
}
} }
$arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']); $arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']);
@ -538,8 +526,7 @@ class RetailCrmICML
if ($propProduct != "" && $arOffer['_PROP_' . $key] != null) { if ($propProduct != "" && $arOffer['_PROP_' . $key] != null) {
if ($key === "manufacturer") { if ($key === "manufacturer") {
$offer .= "<vendor>" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</vendor>\n"; $offer .= "<vendor>" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</vendor>\n";
} } else {
else{
$offer .= '<param name="' . $key . '"' . (isset($arOffer['_PROP_' . $key . "_UNIT"]) ? ' unit="' . $arOffer['_PROP_' . $key . "_UNIT"] . '"' : "") . ">" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</param>\n"; $offer .= '<param name="' . $key . '"' . (isset($arOffer['_PROP_' . $key . "_UNIT"]) ? ' unit="' . $arOffer['_PROP_' . $key . "_UNIT"] . '"' : "") . ">" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</param>\n";
} }
} }
@ -548,14 +535,14 @@ class RetailCrmICML
if ($propProduct != "" && $arOffer['_PROP_' . $key] != null) { if ($propProduct != "" && $arOffer['_PROP_' . $key] != null) {
if ($key === "manufacturer") { if ($key === "manufacturer") {
$offer .= "<vendor>" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</vendor>\n"; $offer .= "<vendor>" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</vendor>\n";
} } else {
else{
$offer .= '<param name="' . $key . '"' . (isset($arOffer['_PROP_' . $key . "_UNIT"]) ? ' unit="' . $arOffer['_PROP_' . $key . "_UNIT"] . '"' : "") . ">" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</param>\n"; $offer .= '<param name="' . $key . '"' . (isset($arOffer['_PROP_' . $key . "_UNIT"]) ? ' unit="' . $arOffer['_PROP_' . $key . "_UNIT"] . '"' : "") . ">" . $this->PrepareValue($arOffer['_PROP_' . $key]) . "</param>\n";
} }
} }
} }
$offer.= "</offer>\n"; $offer.= "</offer>\n";
return $offer; return $offer;
} }
} }

View File

@ -34,7 +34,8 @@ class RetailCrmOrder
* @return boolean * @return boolean
* @return array - array('order' = $order, 'customer' => $customer) * @return array - array('order' = $order, 'customer' => $customer)
*/ */
public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit') { public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit')
{
if (!$api || empty($arParams)) { // add cond to check $arParams if (!$api || empty($arParams)) { // add cond to check $arParams
return false; return false;
} }
@ -159,7 +160,8 @@ class RetailCrmOrder
* @param $failed -- flag to export failed orders * @param $failed -- flag to export failed orders
* @return boolean * @return boolean
*/ */
public static function uploadOrders($pSize = 50, $failed = false, $orderList = false) { public static function uploadOrders($pSize = 50, $failed = false, $orderList = false)
{
if (!CModule::IncludeModule("iblock")) { if (!CModule::IncludeModule("iblock")) {
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'iblock', 'module not found'); RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'iblock', 'module not found');
return true; return true;
@ -282,7 +284,8 @@ class RetailCrmOrder
return true; return true;
} }
public static function orderObjToArr($obOrder){ public static function orderObjToArr($obOrder)
{
$arOrder = array( $arOrder = array(
'ID' => $obOrder->getId(), 'ID' => $obOrder->getId(),
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'), 'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
@ -310,8 +313,7 @@ class RetailCrmOrder
if ($delivery['PARENT_ID']) { if ($delivery['PARENT_ID']) {
$servise = explode(':', $delivery['CODE']); $servise = explode(':', $delivery['CODE']);
$shipment = array('id' => $delivery['PARENT_ID'], 'service' => $servise[1]); $shipment = array('id' => $delivery['PARENT_ID'], 'service' => $servise[1]);
} } else {
else{
$shipment = array('id' => $delivery['ID']); $shipment = array('id' => $delivery['ID']);
} }
$arOrder['DELIVERYS'][] = $shipment; $arOrder['DELIVERYS'][] = $shipment;

View File

@ -2,7 +2,8 @@
IncludeModuleLangFile(__FILE__); IncludeModuleLangFile(__FILE__);
class RetailCrmUser class RetailCrmUser
{ {
public static function customerSend($arFields, $api, $contragentType, $send = false, $site = null){//только на создание public static function customerSend($arFields, $api, $contragentType, $send = false, $site = null)
{
if (!$api || empty($contragentType)) { // add cond to check $arParams if (!$api || empty($contragentType)) { // add cond to check $arParams
return false; return false;
} }
@ -80,8 +81,7 @@ class RetailCrmUser
break; break;
} }
} }
} } else {
else{
$site = null; $site = null;
$userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arFields['ID'], $site); $userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arFields['ID'], $site);
if (isset($userCrm['customer'])) { if (isset($userCrm['customer'])) {

View File

@ -1,2 +1 @@
- Переход на новое API Битрикса - fix состава отгрузки
- Переход на API црм v4

View File

@ -1,18 +1,20 @@
<?php <?php
if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_run.php")){ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_run.php")){
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_run.php"); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_run.php");
} } else {
else{
ignore_user_abort(true); ignore_user_abort(true);
set_time_limit(0); set_time_limit(0);
global $APPLICATION; global $APPLICATION;
if (!CModule::IncludeModule("iblock")) if (!CModule::IncludeModule("iblock")){
return; return;
if (!CModule::IncludeModule("catalog")) }
if (!CModule::IncludeModule("catalog")){
return; return;
if (!CModule::IncludeModule("intaro.retailcrm")) }
if (!CModule::IncludeModule("intaro.retailcrm")){
return; return;
}
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
while ($ar = $rsSites->Fetch()) { while ($ar = $rsSites->Fetch()) {
@ -21,7 +23,7 @@ else{
} }
} }
$iblockProperties = Array( $iblockProperties = array(
"article" => "article", "article" => "article",
"manufacturer" => "manufacturer", "manufacturer" => "manufacturer",
"color" =>"color", "color" =>"color",
@ -34,7 +36,6 @@ else{
$IBLOCK_PROPERTY_SKU = array(); $IBLOCK_PROPERTY_SKU = array();
$IBLOCK_PROPERTY_UNIT_SKU = array(); $IBLOCK_PROPERTY_UNIT_SKU = array();
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
$skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop); $skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop);
$skuUnitProps = $$skuUnitProps; $skuUnitProps = $$skuUnitProps;
if (is_array($skuUnitProps)) { if (is_array($skuUnitProps)) {
@ -54,7 +55,6 @@ else{
$IBLOCK_PROPERTY_PRODUCT = array(); $IBLOCK_PROPERTY_PRODUCT = array();
$IBLOCK_PROPERTY_UNIT_PRODUCT = array(); $IBLOCK_PROPERTY_UNIT_PRODUCT = array();
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
$productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop; $productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop;
$productUnitProps = $$productUnitProps; $productUnitProps = $$productUnitProps;
if (is_array($productUnitProps)) { if (is_array($productUnitProps)) {

View File

@ -1,9 +1,8 @@
<? <?
if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_setup.php")){ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_setup.php")){
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_setup.php"); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/export_setup.php");
} } else {
else{ $iblockProperties = array(
$iblockProperties = Array(
"article" => "article", "article" => "article",
"manufacturer" => "manufacturer", "manufacturer" => "manufacturer",
"color" =>"color", "color" =>"color",
@ -14,7 +13,9 @@ else{
"height" => "height", "height" => "height",
); );
if(!check_bitrix_sessid()) return; if(!check_bitrix_sessid()) {
return;
}
__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intaro.retailcrm/lang/", "/icml_export_setup.php")); __IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intaro.retailcrm/lang/", "/icml_export_setup.php"));
@ -33,7 +34,6 @@ else{
if (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1) if (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1)
{ {
if (isset($arOldSetupVars['SETUP_FILE_NAME'])) if (isset($arOldSetupVars['SETUP_FILE_NAME']))
$SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME']; $SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME'];
if (isset($arOldSetupVars['LOAD_PURCHASE_PRICE'])) if (isset($arOldSetupVars['LOAD_PURCHASE_PRICE']))

View File

@ -10,8 +10,8 @@ IncludeModuleLangFile(__FILE__);
if (class_exists('intaro_retailcrm')) if (class_exists('intaro_retailcrm'))
return; return;
class intaro_retailcrm extends CModule { class intaro_retailcrm extends CModule
{
var $MODULE_ID = 'intaro.retailcrm'; var $MODULE_ID = 'intaro.retailcrm';
var $OLD_MODULE_ID = 'intaro.intarocrm'; var $OLD_MODULE_ID = 'intaro.intarocrm';
var $MODULE_VERSION; var $MODULE_VERSION;
@ -49,7 +49,8 @@ class intaro_retailcrm extends CModule {
var $CRM_CANSEL_ORDER = 'cansel_order'; var $CRM_CANSEL_ORDER = 'cansel_order';
var $INSTALL_PATH; var $INSTALL_PATH;
function intaro_retailcrm() { function intaro_retailcrm()
{
$arModuleVersion = array(); $arModuleVersion = array();
$path = str_replace("\\", "/", __FILE__); $path = str_replace("\\", "/", __FILE__);
$path = substr($path, 0, strlen($path) - strlen("/index.php")); $path = substr($path, 0, strlen($path) - strlen("/index.php"));
@ -67,7 +68,8 @@ class intaro_retailcrm extends CModule {
* Functions DoInstall and DoUninstall are * Functions DoInstall and DoUninstall are
* All other functions are optional * All other functions are optional
*/ */
function DoInstall() { function DoInstall()
{
global $APPLICATION, $step, $arResult; global $APPLICATION, $step, $arResult;
if (!in_array('curl', get_loaded_extensions())) { if (!in_array('curl', get_loaded_extensions())) {
@ -78,12 +80,14 @@ class intaro_retailcrm extends CModule {
$infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION; $infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION;
if (version_compare($infoSale, '16', '<=')) { if (version_compare($infoSale, '16', '<=')) {
$APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR")); $APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR"));
return false; return false;
} }
if (!date_default_timezone_get()) { if (!date_default_timezone_get()) {
if (!ini_get('date.timezone')) { if (!ini_get('date.timezone')) {
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR")); $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
return false; return false;
} }
} }
@ -107,15 +111,13 @@ class intaro_retailcrm extends CModule {
if (file_exists($this->INSTALL_PATH . '/../classes/general/config/options.xml')) { if (file_exists($this->INSTALL_PATH . '/../classes/general/config/options.xml')) {
$options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml'); $options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml');
foreach($options->contragents->contragent as $contragent) foreach ($options->contragents->contragent as $contragent) {
{
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
$type["ID"] = (string)$contragent["id"]; $type["ID"] = (string)$contragent["id"];
$arResult['contragentType'][] = $type; $arResult['contragentType'][] = $type;
unset ($type); unset ($type);
} }
foreach($options->fields->field as $field) foreach($options->fields->field as $field) {
{
$type["NAME"] = $APPLICATION->ConvertCharset((string)$field, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$field, 'utf-8', SITE_CHARSET);
$type["ID"] = (string)$field["id"]; $type["ID"] = (string)$field["id"];
@ -190,7 +192,9 @@ class intaro_retailcrm extends CModule {
// form correct url // form correct url
$api_host = parse_url($api_host); $api_host = parse_url($api_host);
if($api_host['scheme'] != 'https') $api_host['scheme'] = 'https'; if ($api_host['scheme'] != 'https') {
$api_host['scheme'] = 'https';
}
$api_host = $api_host['scheme'] . '://' . $api_host['host']; $api_host = $api_host['scheme'] . '://' . $api_host['host'];
if (!$api_host || !$api_key) { if (!$api_host || !$api_key) {
@ -232,15 +236,12 @@ class intaro_retailcrm extends CModule {
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php'
); );
} else if ($step == 2) {//доставки, оплаты, типы заказов } else if ($step == 2) {//доставки, оплаты, типы заказов
if (!CModule::IncludeModule("sale")) { if (!CModule::IncludeModule("sale")) {
$arResult['errCode'] = 'ERR_SALE'; $arResult['errCode'] = 'ERR_SALE';
} }
if (!CModule::IncludeModule("iblock")) { if (!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK'; $arResult['errCode'] = 'ERR_IBLOCK';
} }
if (!CModule::IncludeModule("catalog")) { if (!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG'; $arResult['errCode'] = 'ERR_CATALOG';
} }
@ -249,6 +250,7 @@ class intaro_retailcrm extends CModule {
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
@ -555,14 +557,15 @@ class intaro_retailcrm extends CModule {
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode)); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode));
} } else {//если 1 сайт
else{//если 1 сайт
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
// form correct url // form correct url
$api_host = parse_url($api_host); $api_host = parse_url($api_host);
if($api_host['scheme'] != 'https') $api_host['scheme'] = 'https'; if($api_host['scheme'] != 'https') {
$api_host['scheme'] = 'https';
}
$api_host = $api_host['scheme'] . '://' . $api_host['host']; $api_host = $api_host['scheme'] . '://' . $api_host['host'];
if (!$api_host || !$api_key) { if (!$api_host || !$api_key) {
@ -644,7 +647,7 @@ class intaro_retailcrm extends CModule {
); );
} elseif ($step == 3) {//сопостовление свойств заказа } elseif ($step == 3) {//сопостовление свойств заказа
if (!CModule::IncludeModule("sale")) { if (!CModule::IncludeModule("sale")) {
//handler $arResult['errCode'] = 'ERR_SALE';
} }
if (isset($_POST['back']) && $_POST['back']) { if (isset($_POST['back']) && $_POST['back']) {
@ -675,8 +678,7 @@ class intaro_retailcrm extends CModule {
foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) { foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) {
$deliveryTypesArr[$delivery['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $delivery['ID']])); $deliveryTypesArr[$delivery['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $delivery['ID']]));
} }
} } elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {//отправка доставок в црм
elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {//отправка доставок в црм
// send to intaro crm and save delivery types! // send to intaro crm and save delivery types!
foreach ($optionsDelivTypes as $deliveryType) { foreach ($optionsDelivTypes as $deliveryType) {
$load = true; $load = true;
@ -777,7 +779,7 @@ class intaro_retailcrm extends CModule {
); );
} elseif ($step == 4) {//выгрузка старых заказов } elseif ($step == 4) {//выгрузка старых заказов
if (!CModule::IncludeModule("sale")) { if (!CModule::IncludeModule("sale")) {
//handler $arResult['errCode'] = 'ERR_SALE';
} }
if (isset($_POST['back']) && $_POST['back']) { if (isset($_POST['back']) && $_POST['back']) {
@ -796,8 +798,7 @@ class intaro_retailcrm extends CModule {
if (!isset($_POST['finish'])) { if (!isset($_POST['finish'])) {
$finish = 0; $finish = 0;
} } else {
else{
$finish = (int) $_POST['finish']; $finish = (int) $_POST['finish'];
} }
$percent = round(100 - ($countLeft * 100 / $countAll), 1); $percent = round(100 - ($countLeft * 100 / $countAll), 1);
@ -829,8 +830,9 @@ class intaro_retailcrm extends CModule {
$propsCount = 0; $propsCount = 0;
$_orderPropsArr = array(); $_orderPropsArr = array();
foreach ($arResult['orderProps'] as $orderProp) { foreach ($arResult['orderProps'] as $orderProp) {
if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 4) if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 4){
break; break;
}
$_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']])); $_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']]));
$propsCount++; $propsCount++;
} }
@ -875,10 +877,10 @@ class intaro_retailcrm extends CModule {
if (!CModule::IncludeModule("iblock")) { if (!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK'; $arResult['errCode'] = 'ERR_IBLOCK';
} }
if (!CModule::IncludeModule("catalog")) { if (!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG'; $arResult['errCode'] = 'ERR_CATALOG';
} }
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $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); $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$api = new \RetailCrm\ApiClient($api_host, $api_key); $api = new \RetailCrm\ApiClient($api_host, $api_key);
@ -905,14 +907,13 @@ class intaro_retailcrm extends CModule {
if (isset($history['history'])) { if (isset($history['history'])) {
$hIs = (int)$history['history'][0]['id'] - 1; $hIs = (int)$history['history'][0]['id'] - 1;
$orderH = $hIs; $orderH = $hIs;
} } else {
else{
$orderH = self::historyLoad($api, 'ordersHistory'); $orderH = self::historyLoad($api, 'ordersHistory');
} }
} } else {
else{
$orderH = self::historyLoad($api, 'ordersHistory'); $orderH = self::historyLoad($api, 'ordersHistory');
} }
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH);
if ($orderLastId = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_LAST_ID, 0)) { if ($orderLastId = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_LAST_ID, 0)) {
@ -936,11 +937,9 @@ class intaro_retailcrm extends CModule {
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
); );
} elseif ($step == 6) {//регистрация модуля } elseif ($step == 6) {//регистрация модуля
if (!CModule::IncludeModule("iblock")) { if (!CModule::IncludeModule("iblock")) {
$arResult['errCode'] = 'ERR_IBLOCK'; $arResult['errCode'] = 'ERR_IBLOCK';
} }
if (!CModule::IncludeModule("catalog")) { if (!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG'; $arResult['errCode'] = 'ERR_CATALOG';
} }
@ -949,6 +948,7 @@ class intaro_retailcrm extends CModule {
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
); );
return; return;
} }
@ -958,12 +958,13 @@ class intaro_retailcrm extends CModule {
); );
} }
if (!isset($_POST['IBLOCK_EXPORT'])) if (!isset($_POST['IBLOCK_EXPORT'])) {
$arResult['errCode'] = 'ERR_FIELDS_IBLOCK'; $arResult['errCode'] = 'ERR_FIELDS_IBLOCK';
else } else {
$iblocks = $_POST['IBLOCK_EXPORT']; $iblocks = $_POST['IBLOCK_EXPORT'];
}
$iblockProperties = Array( $iblockProperties = array(
"article" => "article", "article" => "article",
"manufacturer" => "manufacturer", "manufacturer" => "manufacturer",
"color" => "color", "color" => "color",
@ -996,30 +997,34 @@ class intaro_retailcrm extends CModule {
} }
} }
if (!isset($_POST['SETUP_FILE_NAME'])) if (!isset($_POST['SETUP_FILE_NAME'])) {
$arResult['errCode'] = 'ERR_FIELDS_FILE'; $arResult['errCode'] = 'ERR_FIELDS_FILE';
else } else {
$filename = $_POST['SETUP_FILE_NAME']; $filename = $_POST['SETUP_FILE_NAME'];
}
if (!isset($_POST['TYPE_LOADING'])) if (!isset($_POST['TYPE_LOADING'])) {
$typeLoading = 0; $typeLoading = 0;
else } else {
$typeLoading = $_POST['TYPE_LOADING']; $typeLoading = $_POST['TYPE_LOADING'];
}
if (!isset($_POST['SETUP_PROFILE_NAME'])) if (!isset($_POST['SETUP_PROFILE_NAME'])) {
$profileName = ""; $profileName = "";
else } else {
$profileName = $_POST['SETUP_PROFILE_NAME']; $profileName = $_POST['SETUP_PROFILE_NAME'];
}
if ($typeLoading != 'none' && $profileName == "") if ($typeLoading != 'none' && $profileName == "") {
$arResult['errCode'] = 'ERR_FIELDS_PROFILE'; $arResult['errCode'] = 'ERR_FIELDS_PROFILE';
}
if ($filename == "") if ($filename == "") {
$arResult['errCode'] = 'ERR_FIELDS_FILE'; $arResult['errCode'] = 'ERR_FIELDS_FILE';
}
if (isset($arResult['errCode']) && $arResult['errCode']) { if (isset($arResult['errCode']) && $arResult['errCode']) {
$arOldValues = array(
$arOldValues = Array(
'IBLOCK_EXPORT' => $iblocks, 'IBLOCK_EXPORT' => $iblocks,
'IBLOCK_PROPERTY_SKU' => $propertiesSKU, 'IBLOCK_PROPERTY_SKU' => $propertiesSKU,
'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU, 'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU,
@ -1033,21 +1038,14 @@ class intaro_retailcrm extends CModule {
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
); );
return; return;
} }
RegisterModule($this->MODULE_ID); RegisterModule($this->MODULE_ID);
//RegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "RetailCrmEvent", "onSalePayOrder");
//RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "RetailCrmEvent", "onSaleCancelOrder");
//RegisterModuleDependences("sale", "OnBeforeOrderAccountNumberSet", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAccountNumberSet");
//RegisterModuleDependences("sale", "OnOrderNewSendEmail", $this->MODULE_ID, "RetailCrmEvent", "onSendOrderMail");
RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder"); RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder");
RegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd"); RegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd");
RegisterModuleDependences("sale", "OnOrderSave", $this->MODULE_ID, "RetailCrmEvent", "OnOrderSave"); RegisterModuleDependences("sale", "OnOrderSave", $this->MODULE_ID, "RetailCrmEvent", "OnOrderSave");
//RegisterModuleDependences("sale", "OnSaleBeforeReserveOrder", $this->MODULE_ID, "RetailCrmEvent", "OnSaleBeforeReserveOrder");
//RegisterModuleDependences("sale", "OnSaleReserveOrder", $this->MODULE_ID, "RetailCrmEvent", "onSaleReserveOrder");
//RegisterModuleDependences("main", "OnAfterUserRegister", $this->MODULE_ID, "ICrmOrderEvent", "OnAfterUserRegister");
//RegisterModuleDependences("main", "OnAfterUserAdd", $this->MODULE_ID, "ICrmOrderEvent", "OnAfterUserAdd");
RegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate"); RegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate");
RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave"); RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave");
RegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete"); RegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete");
@ -1094,10 +1092,10 @@ class intaro_retailcrm extends CModule {
)); ));
if (intval($PROFILE_ID) <= 0) { if (intval($PROFILE_ID) <= 0) {
$arResult['errCode'] = 'ERR_IBLOCK'; $arResult['errCode'] = 'ERR_IBLOCK';
return; return;
} }
if ($typeLoading == 'agent') { if ($typeLoading == 'agent') {
$dateAgent = new DateTime(); $dateAgent = new DateTime();
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
$dateAgent->add($intAgent); $dateAgent->add($intAgent);
@ -1199,7 +1197,8 @@ class intaro_retailcrm extends CModule {
} }
} }
function DoUninstall() { function DoUninstall()
{
global $APPLICATION; global $APPLICATION;
CAgent::RemoveAgent("RCrmActions::orderAgent();", $this->MODULE_ID); CAgent::RemoveAgent("RCrmActions::orderAgent();", $this->MODULE_ID);
@ -1226,17 +1225,9 @@ class intaro_retailcrm extends CModule {
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER); COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER);
//UnRegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "RetailCrmEvent", "onSalePayOrder");
//UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "RetailCrmEvent", "onSaleCancelOrder");
//UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $this->MODULE_ID, "RetailCrmEvent", "onSendOrderMail");
UnRegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder"); UnRegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder");
UnRegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd"); UnRegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd");
UnRegisterModuleDependences("sale", "OnOrderSave", $this->MODULE_ID, "RetailCrmEvent", "OnOrderSave"); UnRegisterModuleDependences("sale", "OnOrderSave", $this->MODULE_ID, "RetailCrmEvent", "OnOrderSave");
//UnRegisterModuleDependences("sale", "OnBeforeOrderAccountNumberSet", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAccountNumberSet");
//UnRegisterModuleDependences("sale", "OnSaleBeforeReserveOrder", $this->MODULE_ID, "RetailCrmEvent", "onSaleBeforeReserveOrder");
//UnRegisterModuleDependences("sale", "OnSaleReserveOrder", $this->MODULE_ID, "RetailCrmEvent", "onSaleReserveOrder");
//UnRegisterModuleDependences("main", "OnAfterUserRegister", $this->MODULE_ID, "ICrmOrderEvent", "OnAfterUserRegister");
//UnRegisterModuleDependences("main", "OnAfterUserAdd", $this->MODULE_ID, "ICrmOrderEvent", "OnAfterUserAdd");
UnRegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate"); UnRegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate");
UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave"); UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave");
UnRegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete"); UnRegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete");
@ -1263,13 +1254,15 @@ class intaro_retailcrm extends CModule {
); );
} }
function CopyFiles() { function CopyFiles()
{
CopyDirFiles( CopyDirFiles(
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true
); );
} }
function DeleteFiles() { function DeleteFiles()
{
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y'));
$defaultSite = array(); $defaultSite = array();
while ($ar = $rsSites->Fetch()) { while ($ar = $rsSites->Fetch()) {
@ -1305,7 +1298,8 @@ class intaro_retailcrm extends CModule {
return $strVars; return $strVars;
} }
function historyLoad($api, $method){ function historyLoad($api, $method)
{
$page = null; $page = null;
$i = 0; $i = 0;
while (true) { while (true) {
@ -1332,8 +1326,7 @@ class intaro_retailcrm extends CModule {
if (isset($history['history'])) { if (isset($history['history'])) {
$end = array_pop($history['history']); $end = array_pop($history['history']);
} } else {
else{
$end['id'] = 0; $end['id'] = 0;
break; break;
} }

View File

@ -24,7 +24,6 @@ else{
) )
); );
} }
echo"<pre>";var_export($arResult);echo"</pre>";
?> ?>
<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script> <script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1,6 +1,6 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "2.0.0", "VERSION" => "2.0.3",
"VERSION_DATE" => "2016-09-12 12:00:00" "VERSION_DATE" => "2016-10-04 18:00:00"
); );

View File

@ -36,15 +36,13 @@ $arResult = array();
if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml')) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml')) {
$options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml'); $options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml');
foreach($options->contragents->contragent as $contragent) foreach($options->contragents->contragent as $contragent) {
{
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
$type["ID"] = (string)$contragent["id"]; $type["ID"] = (string)$contragent["id"];
$arResult['contragentType'][] = $type; $arResult['contragentType'][] = $type;
unset ($type); unset ($type);
} }
foreach($options->fields->field as $field) foreach($options->fields->field as $field) {
{
$type["NAME"] = $APPLICATION->ConvertCharset((string)$field, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$field, 'utf-8', SITE_CHARSET);
$type["ID"] = (string)$field["id"]; $type["ID"] = (string)$field["id"];
@ -148,7 +146,6 @@ if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQ
$res = array("step" => $step, "percent" => $percent, 'stepOrders' => $stepOrders); $res = array("step" => $step, "percent" => $percent, 'stepOrders' => $stepOrders);
} else { } else {
$orders = array(); $orders = array();
for($i = 1; $i <= $countStep; $i++){ for($i = 1; $i <= $countStep; $i++){
$orders[] = $i + $step * $countStep; $orders[] = $i + $step * $countStep;
} }
@ -250,7 +247,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
// 1 - event // 1 - event
$orderDischarge = 0; $orderDischarge = 0;
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge'])); $orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
///////////тут дописать\\\\\\\\\\\\\\\
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) { if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
// remove depenedencies // remove depenedencies
UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail"); UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
@ -324,7 +320,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} else { } else {
$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0); $api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0); $api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0);
$api = new RetailCrm\ApiClient($api_host, $api_key); $api = new RetailCrm\ApiClient($api_host, $api_key);
//prepare crm lists //prepare crm lists
@ -360,10 +355,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
//bitrix statusesList //bitrix statusesList
$arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList(); $arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList();
/*$arResult['bitrixPaymentStatusesList'][] = array(
'ID' => 'YY',
'NAME' => GetMessage('CANCELED')
);*/
//bitrix pyament Y/N //bitrix pyament Y/N
$arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y'); $arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y');