commit
526c74631b
@ -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
|
||||
* API V4
|
||||
* Переход на ядро d7
|
||||
|
@ -1,15 +1,15 @@
|
||||
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:
|
||||
|
||||
* Exchange the orders with retailCRM
|
||||
* 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
|
||||
-------------
|
||||
|
||||
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/).
|
||||
|
@ -14,8 +14,7 @@ class Logger
|
||||
{
|
||||
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y'));
|
||||
$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 . '/');
|
||||
}
|
||||
$file = $ar['ABS_DOC_ROOT'] . $this->logPath . '/' . $file . '.log';
|
||||
|
@ -7,7 +7,8 @@ class RCrmActions
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
public static function SitesList(){
|
||||
public static function SitesList()
|
||||
{
|
||||
$arSites = array();
|
||||
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
|
||||
while ($ar = $rsSites->Fetch()) {
|
||||
@ -17,7 +18,8 @@ class RCrmActions
|
||||
return $arSites;
|
||||
}
|
||||
|
||||
public static function OrderTypesList($arSites){
|
||||
public static function OrderTypesList($arSites)
|
||||
{
|
||||
$orderTypesList = array();
|
||||
foreach ($arSites as $site) {
|
||||
$personTypes = \Bitrix\Sale\PersonType::load($site['LID']);
|
||||
@ -34,7 +36,8 @@ class RCrmActions
|
||||
return $orderTypesList;
|
||||
}
|
||||
|
||||
public static function DeliveryList(){
|
||||
public static function DeliveryList()
|
||||
{
|
||||
$bitrixDeliveryTypesList = array();
|
||||
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
|
||||
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
|
||||
@ -47,21 +50,22 @@ class RCrmActions
|
||||
return $bitrixDeliveryTypesList;
|
||||
}
|
||||
|
||||
public static function PaymentList(){
|
||||
public static function PaymentList()
|
||||
{
|
||||
$bitrixPaymentTypesList = array();
|
||||
$dbPaymentAll = \Bitrix\Sale\PaySystem\Manager::getList(array(
|
||||
'select' => array('ID', 'NAME'),
|
||||
'filter' => array('ACTIVE' => 'Y')
|
||||
));
|
||||
while($payment = $dbPaymentAll->fetch())
|
||||
{
|
||||
while ($payment = $dbPaymentAll->fetch()) {
|
||||
$bitrixPaymentTypesList[] = $payment;
|
||||
}
|
||||
|
||||
return $bitrixPaymentTypesList;
|
||||
}
|
||||
|
||||
public static function StatusesList(){
|
||||
public static function StatusesList()
|
||||
{
|
||||
$bitrixPaymentStatusesList = array();
|
||||
$arStatusesAll = \Bitrix\Sale\OrderStatus::getAllStatusesNames();
|
||||
foreach ($arStatusesAll as $key => $arStatus) {
|
||||
@ -71,7 +75,8 @@ class RCrmActions
|
||||
return $bitrixPaymentStatusesList;
|
||||
}
|
||||
|
||||
public static function OrderPropsList(){
|
||||
public static function OrderPropsList()
|
||||
{
|
||||
$bitrixPropsList = array();
|
||||
$arPropsAll = \Bitrix\Sale\Internals\OrderPropsTable::getList(array(
|
||||
'select' => array('*')
|
||||
@ -87,8 +92,8 @@ class RCrmActions
|
||||
* w+ event in bitrix log
|
||||
*/
|
||||
|
||||
public static function eventLog($auditType, $itemId, $description) {
|
||||
|
||||
public static function eventLog($auditType, $itemId, $description)
|
||||
{
|
||||
CEventLog::Add(array(
|
||||
"SEVERITY" => "SECURITY",
|
||||
"AUDIT_TYPE_ID" => $auditType,
|
||||
@ -105,7 +110,8 @@ class RCrmActions
|
||||
* @return self name
|
||||
*/
|
||||
|
||||
public static function uploadOrdersAgent() {
|
||||
public static function uploadOrdersAgent()
|
||||
{
|
||||
RetailCrmOrder::uploadOrders();
|
||||
$failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0));
|
||||
if (is_array($failedIds) && !empty($failedIds)) {
|
||||
@ -122,7 +128,8 @@ class RCrmActions
|
||||
* @return self name
|
||||
*/
|
||||
|
||||
public static function orderAgent() {
|
||||
public static function orderAgent()
|
||||
{
|
||||
if (COption::GetOptionString('main', 'agents_use_crontab', 'N') != 'N') {
|
||||
define('NO_AGENT_CHECK', true);
|
||||
}
|
||||
@ -141,7 +148,8 @@ class RCrmActions
|
||||
* @param array $arr
|
||||
* @return array
|
||||
*/
|
||||
public static function clearArr($arr) {
|
||||
public static function clearArr($arr)
|
||||
{
|
||||
if (is_array($arr) === false) {
|
||||
return $arr;
|
||||
}
|
||||
@ -163,7 +171,8 @@ class RCrmActions
|
||||
* @param $str in SITE_CHARSET
|
||||
* @return $str in utf-8
|
||||
*/
|
||||
public static function toJSON($str) {
|
||||
public static function toJSON($str)
|
||||
{
|
||||
global $APPLICATION;
|
||||
|
||||
return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8');
|
||||
@ -175,13 +184,15 @@ class RCrmActions
|
||||
* @param $str in utf-8
|
||||
* @return $str in SITE_CHARSET
|
||||
*/
|
||||
public static function fromJSON($str) {
|
||||
public static function fromJSON($str)
|
||||
{
|
||||
global $APPLICATION;
|
||||
|
||||
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);
|
||||
$result = array();
|
||||
switch (count($newFio)) {
|
||||
@ -210,7 +221,8 @@ class RCrmActions
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function apiMethod($api, $methodApi, $method, $params, $site = null) {
|
||||
public static function apiMethod($api, $methodApi, $method, $params, $site = null)
|
||||
{
|
||||
switch ($methodApi) {
|
||||
case 'ordersGet':
|
||||
case 'ordersEdit':
|
||||
|
@ -32,24 +32,6 @@ class RestNormalizer
|
||||
$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
|
||||
* @param string $file The path to the file validation
|
||||
@ -117,7 +99,6 @@ class RestNormalizer
|
||||
$formatted = array();
|
||||
|
||||
foreach ($data as $code => $value) {
|
||||
|
||||
if (isset($this->validation[ $code ]) && $this->validation[ $code ]['type'] == 'skip') {
|
||||
$formatted[ $code ] = $value;
|
||||
} elseif (isset($this->validation[ $code ]) && is_array($value) === false) {
|
||||
|
@ -2,7 +2,8 @@
|
||||
/**
|
||||
* RCrmEvent
|
||||
*/
|
||||
class RetailCrmEvent {
|
||||
class RetailCrmEvent
|
||||
{
|
||||
protected static $MODULE_ID = 'intaro.retailcrm';
|
||||
protected static $CRM_API_HOST_OPTION = 'api_host';
|
||||
protected static $CRM_API_KEY_OPTION = 'api_key';
|
||||
@ -24,7 +25,8 @@ class RetailCrmEvent {
|
||||
*
|
||||
* @param mixed $arFields - User arFields
|
||||
*/
|
||||
function OnAfterUserUpdate($arFields) {
|
||||
function OnAfterUserUpdate($arFields)
|
||||
{
|
||||
if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) {
|
||||
return;
|
||||
}
|
||||
@ -63,10 +65,11 @@ class RetailCrmEvent {
|
||||
* @param mixed $ID - Order id
|
||||
* @param mixed $arFields - Order arFields
|
||||
*/
|
||||
function OnOrderSave($ID, $arFields, $arOrder, $isNew) {
|
||||
$GLOBALS['RETAILCRM_EVENT_OLD'] = true;
|
||||
return;
|
||||
}
|
||||
// function OnOrderSave($ID, $arFields, $arOrder, $isNew)
|
||||
// {
|
||||
// $GLOBALS['RETAILCRM_EVENT_OLD'] = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
/**
|
||||
* onUpdateOrder
|
||||
@ -74,7 +77,8 @@ class RetailCrmEvent {
|
||||
* @param mixed $ID - Order id
|
||||
* @param mixed $arFields - Order arFields
|
||||
*/
|
||||
function onUpdateOrder($ID, $arFields) {
|
||||
function onUpdateOrder($ID, $arFields)
|
||||
{
|
||||
if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) {
|
||||
$GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = false;
|
||||
return;
|
||||
@ -89,7 +93,8 @@ class RetailCrmEvent {
|
||||
*
|
||||
* @param object $event - Order object
|
||||
*/
|
||||
function orderDelete($event){
|
||||
function orderDelete($event)
|
||||
{
|
||||
$GLOBALS['RETAILCRM_ORDER_DELETE'] = true;
|
||||
return;
|
||||
}
|
||||
@ -100,7 +105,8 @@ class RetailCrmEvent {
|
||||
* @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 (!CModule::IncludeModule('iblock')) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'iblock', 'module not found');
|
||||
@ -120,11 +126,9 @@ class RetailCrmEvent {
|
||||
//проверка на существование getParameter("ENTITY")
|
||||
if (method_exists($event, 'getId')) {
|
||||
$obOrder = $event;
|
||||
}
|
||||
elseif(method_exists($event, 'getParameter')){
|
||||
} elseif (method_exists($event, 'getParameter')) {
|
||||
$obOrder = $event->getParameter("ENTITY");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'events', 'event error');
|
||||
return true;
|
||||
}
|
||||
@ -168,8 +172,7 @@ class RetailCrmEvent {
|
||||
$orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site);
|
||||
if (isset($orderCrm['order'])) {
|
||||
$methodApi = 'ordersEdit';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$methodApi = 'ordersCreate';
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,8 @@ class RetailCrmHistory
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
public static function customerHistory(){
|
||||
public static function customerHistory()
|
||||
{
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'iblock', 'module not found');
|
||||
return false;
|
||||
@ -182,8 +183,7 @@ class RetailCrmHistory
|
||||
if (isset($phone['number'])) {
|
||||
$arUser[$key] = $phone['number'];
|
||||
$user[$key] = $phone['number'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$arUser[$key] = '';
|
||||
$user[$key] = '';
|
||||
}
|
||||
@ -228,7 +228,8 @@ class RetailCrmHistory
|
||||
}
|
||||
}
|
||||
|
||||
public static function orderHistory() {
|
||||
public static function orderHistory()
|
||||
{
|
||||
global $USER;
|
||||
if (is_object($USER) == false) {
|
||||
$USER = new RetailUser;
|
||||
@ -377,7 +378,9 @@ class RetailCrmHistory
|
||||
if ($order['customer']['phones'][1]) {
|
||||
$arFields['PERSONAL_MOBILE'] = $order['customer']['phones'][1];
|
||||
}
|
||||
|
||||
$registeredUserID = $newUser->Add($arFields);
|
||||
|
||||
if ($registeredUserID === false) {
|
||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'CUser::Register', 'Error register user');
|
||||
continue;
|
||||
@ -407,8 +410,7 @@ class RetailCrmHistory
|
||||
|
||||
if (isset($optionsSitesList)) {
|
||||
$site = array_search($order['site'], $optionsSitesList);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$site = CSite::GetDefSite();
|
||||
}
|
||||
|
||||
@ -434,8 +436,7 @@ class RetailCrmHistory
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Error order create');
|
||||
}
|
||||
$order['externalId'] = $externalId;
|
||||
@ -452,7 +453,7 @@ class RetailCrmHistory
|
||||
if ($optionsOrderNumbers == 'Y' && isset($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');
|
||||
if ($optionsOrderTypes[$order['orderType']]) {
|
||||
if ($personType != $optionsOrderTypes[$order['orderType']] && $personType != 0) {
|
||||
@ -460,8 +461,7 @@ class RetailCrmHistory
|
||||
}
|
||||
$personType = $optionsOrderTypes[$order['orderType']];
|
||||
$newOrder->setField('PERSON_TYPE_ID', $personType);
|
||||
}
|
||||
elseif($personType == 0){
|
||||
} elseif ($personType == 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']]);
|
||||
if (in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)) {
|
||||
$newOrder->setField('CANCELED', 'Y');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$newOrder->setField('CANCELED', 'N');
|
||||
}
|
||||
}
|
||||
@ -536,8 +535,7 @@ class RetailCrmHistory
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$order['fio'] = trim(
|
||||
implode(
|
||||
' ',
|
||||
@ -558,16 +556,14 @@ class RetailCrmHistory
|
||||
if (array_key_exists($key, $order)) {
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
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') {
|
||||
$parameters['filter']['NAME'] = $order['delivery']['address'][$key];
|
||||
$parameters['filter']['LANGUAGE_ID'] = 'ru';
|
||||
$location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch();
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
self::setProp($somePropValue, $location['CODE']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
self::setProp($somePropValue, $order['delivery']['address'][$key]);
|
||||
}
|
||||
@ -579,7 +575,6 @@ class RetailCrmHistory
|
||||
foreach ($optionsLegalDetails[$personType] as $key => $orderProp) {
|
||||
if (array_key_exists($key, $order)) {
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
|
||||
self::setProp($somePropValue, $order[$key]);
|
||||
}
|
||||
}
|
||||
@ -616,8 +611,7 @@ class RetailCrmHistory
|
||||
'NAME' => $elem['NAME'],
|
||||
'DETAIL_PAGE_URL' => $elem['URL']
|
||||
));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'createItem', 'Error item add');
|
||||
continue;
|
||||
}
|
||||
@ -668,8 +662,7 @@ class RetailCrmHistory
|
||||
|
||||
if (array_key_exists('cost', $order['delivery'])) {
|
||||
$deliverySumm = $order['delivery']['cost'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$deliverySumm = $newOrder->getDeliveryPrice();
|
||||
}
|
||||
|
||||
@ -704,7 +697,7 @@ class RetailCrmHistory
|
||||
}
|
||||
|
||||
//delivery cost
|
||||
if(array_key_exists('cost', $order['delivery'])){//сделать такую же для оплаты при изменении суммы
|
||||
if (array_key_exists('cost', $order['delivery'])) {
|
||||
$shipment = Bitrix\Sale\Shipment::getList(array(
|
||||
'filter' => array('ORDER_ID' => $order['externalId'], 'SYSTEM' => 'N'),
|
||||
'order' => array('ID')
|
||||
@ -718,6 +711,8 @@ class RetailCrmHistory
|
||||
|
||||
Bitrix\Sale\OrderTable::update($order['externalId'], array('MARKED' => 'N', 'EMP_MARKED_ID' => '', 'REASON_MARKED' => ''));
|
||||
|
||||
self::updateShipmentItem($order['externalId']);
|
||||
|
||||
if (function_exists('retailCrmAfterOrderSave')) {
|
||||
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();
|
||||
$fields = array();
|
||||
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');
|
||||
foreach($objects->fields->field as $object)
|
||||
{
|
||||
foreach ($objects->fields->field as $object) {
|
||||
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
||||
}
|
||||
}
|
||||
@ -754,8 +749,7 @@ class RetailCrmHistory
|
||||
$change['customer'] = self::removeEmpty($change['customer']);
|
||||
if ($customers[$change['customer']['id']]) {
|
||||
$customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$customers[$change['customer']['id']] = $change['customer'];
|
||||
}
|
||||
|
||||
@ -772,15 +766,12 @@ class RetailCrmHistory
|
||||
if (isset($change['newValue'])) {
|
||||
$customers[$change['customer']['id']]['phones'][$key]['number'] = $change['newValue'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if ($fields['customerAddress'][$change['field']]) {
|
||||
$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'];
|
||||
}
|
||||
elseif($fields['customer'][$change['field']]){
|
||||
} elseif ($fields['customer'][$change['field']]) {
|
||||
$customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']);
|
||||
}
|
||||
|
||||
@ -793,15 +784,16 @@ class RetailCrmHistory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $customers;
|
||||
}
|
||||
|
||||
public static function assemblyOrder($orderHistory){
|
||||
public static function assemblyOrder($orderHistory)
|
||||
{
|
||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||
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');
|
||||
foreach($objects->fields->field as $object)
|
||||
{
|
||||
foreach ($objects->fields->field as $object) {
|
||||
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
||||
}
|
||||
}
|
||||
@ -826,16 +818,14 @@ class RetailCrmHistory
|
||||
|
||||
if ($orders[$change['order']['id']]) {
|
||||
$orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$orders[$change['order']['id']] = $change['order'];
|
||||
}
|
||||
|
||||
if ($change['item']) {
|
||||
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']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$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']]) {
|
||||
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if ($fields['delivery'][$change['field']] == 'service') {
|
||||
$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']);
|
||||
}
|
||||
elseif($fields['orderAddress'][$change['field']]){
|
||||
} elseif ($fields['orderAddress'][$change['field']]) {
|
||||
$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']);
|
||||
}
|
||||
elseif($fields['customerContragent'][$change['field']]){
|
||||
} elseif ($fields['customerContragent'][$change['field']]) {
|
||||
$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']);
|
||||
}
|
||||
elseif($fields['order'][$change['field']]){
|
||||
} elseif ($fields['order'][$change['field']]){
|
||||
$orders[$change['order']['id']][$fields['order'][$change['field']]] = self::newValue($change['newValue']);
|
||||
}
|
||||
|
||||
@ -882,17 +865,18 @@ class RetailCrmHistory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $orders;
|
||||
}
|
||||
|
||||
public static function shipmentUpdate($orderCrm, $optionsDelivTypes){
|
||||
public static function shipmentUpdate($orderCrm, $optionsDelivTypes)
|
||||
{
|
||||
if (isset($orderCrm['delivery']['code'])) {
|
||||
$crmCode = $orderCrm['delivery']['code'];
|
||||
|
||||
if (isset($orderCrm['delivery']['data']['deliveryType'])) {
|
||||
$crmService = $orderCrm['delivery']['data']['deliveryType'];
|
||||
}
|
||||
elseif (isset($orderCrm['delivery']['service'])) {
|
||||
} elseif (isset($orderCrm['delivery']['service'])) {
|
||||
$crmService = $orderCrm['delivery']['service'];
|
||||
}
|
||||
|
||||
@ -908,8 +892,7 @@ class RetailCrmHistory
|
||||
//будем менять доставку на этот id
|
||||
if ($crmService && $arDeliveryCode[$dCode]) {
|
||||
$nowDelivery = $arDeliveryCode[$dCode];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{//создаем
|
||||
} else {//создаем
|
||||
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery));
|
||||
$shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array(
|
||||
'ORDER_ID' => $orderCrm['externalId'],
|
||||
@ -965,8 +947,7 @@ class RetailCrmHistory
|
||||
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
|
||||
));
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
//ищем у заказа на сайте доставки и удаляем/заменяем на без доставки
|
||||
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
|
||||
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId));
|
||||
@ -1021,7 +1002,68 @@ class RetailCrmHistory
|
||||
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 ($optionsPayment[$order['paymentType']]) {
|
||||
$paymentList = RCrmActions::PaymentList();
|
||||
@ -1038,11 +1080,9 @@ class RetailCrmHistory
|
||||
'filter' => array('ORDER_ID' => $order['externalId']),
|
||||
'order' => array('ID')
|
||||
))->fetch();
|
||||
if($payment){
|
||||
//если уже существует, update
|
||||
if ($payment) {//если уже существует, 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']));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
\Bitrix\Sale\Internals\PaymentTable::add(array(
|
||||
'ORDER_ID' => $order['externalId'],
|
||||
'PAID' => 'N',
|
||||
@ -1058,18 +1098,13 @@ class RetailCrmHistory
|
||||
));
|
||||
}
|
||||
//запись в историю
|
||||
}
|
||||
else{
|
||||
//ошибка, нет такой активной платежной системы
|
||||
} else {//ошибка, нет такой активной платежной системы
|
||||
RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found');
|
||||
}
|
||||
}
|
||||
else{
|
||||
//ошибка, возможно платежная система не сопоставлена
|
||||
} else {//ошибка, возможно платежная система не сопоставлена
|
||||
RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found in option');;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
\Bitrix\Sale\OrderTable::update($order['externalId'], array('PAY_SYSTEM_ID' => ''));
|
||||
$payment = \Bitrix\Sale\Payment::getList(array(
|
||||
'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'])) {
|
||||
return $value['code'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeEmpty($inputArray){
|
||||
public static function removeEmpty($inputArray)
|
||||
{
|
||||
$outputArray = array();
|
||||
if (!empty($inputArray)) {
|
||||
foreach ($inputArray as $key => $element) {
|
||||
@ -1108,30 +1144,28 @@ class RetailCrmHistory
|
||||
return $outputArray;
|
||||
}
|
||||
|
||||
public static function setProp($obj, $value, $prop){
|
||||
public static function setProp($obj, $value, $prop)
|
||||
{
|
||||
if (!isset($obj)) {
|
||||
return false;
|
||||
}
|
||||
if ($prop && $value) {
|
||||
$obj->setField($prop, $value);
|
||||
}
|
||||
elseif($value){
|
||||
} elseif ($value) {
|
||||
$obj->setValue($value);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$obj->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getExistsItem($basket, $moduleId, $productId){
|
||||
foreach ($basket as $basketItem)
|
||||
public static function getExistsItem($basket, $moduleId, $productId)
|
||||
{
|
||||
foreach ($basket as $basketItem) {
|
||||
$itemExists = ($basketItem->getField('PRODUCT_ID') == $productId && $basketItem->getField('MODULE') == $moduleId);
|
||||
|
||||
if ($itemExists)
|
||||
{
|
||||
if ($itemExists) {
|
||||
return $basketItem;
|
||||
}
|
||||
}
|
||||
@ -1139,13 +1173,15 @@ class RetailCrmHistory
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getInfoElement($offerId){
|
||||
public static function getInfoElement($offerId)
|
||||
{
|
||||
$elementInfo = CIBlockElement::GetByID($offerId)->fetch();
|
||||
$url = CAllIBlock::ReplaceDetailUrl($elementInfo['DETAIL_PAGE_URL'], $elementInfo, false, 'E');
|
||||
$info = array(
|
||||
'NAME' => $elementInfo['NAME'],
|
||||
'URL' => $url,
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ class RetailCrmICML
|
||||
curl_close($curlHandler);
|
||||
if ($statusCode == 200) {
|
||||
$this->protocol = 'https://';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->protocol = 'http://';
|
||||
}
|
||||
|
||||
@ -124,6 +123,7 @@ class RetailCrmICML
|
||||
$newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding);
|
||||
$newText = strip_tags($newText);
|
||||
$newText = str_replace("&", "&", $newText);
|
||||
|
||||
return $newText;
|
||||
}
|
||||
|
||||
@ -132,11 +132,12 @@ class RetailCrmICML
|
||||
$fullFilename = $_SERVER["DOCUMENT_ROOT"] . $filename;
|
||||
CheckDirPath($fullFilename);
|
||||
|
||||
if ($fp = @fopen($fullFilename, "w"))
|
||||
if ($fp = @fopen($fullFilename, "w")){
|
||||
return $fp;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function PreWriteCatalog()
|
||||
{
|
||||
@ -175,9 +176,10 @@ class RetailCrmICML
|
||||
|
||||
protected function WriteLog($text)
|
||||
{
|
||||
if ($this->isLogged)
|
||||
if ($this->isLogged) {
|
||||
@fwrite($this->fpLog, Date("Y:m:d H:i:s") . ": " . $text . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
protected function PostWriteCatalog()
|
||||
{
|
||||
@ -194,8 +196,7 @@ class RetailCrmICML
|
||||
protected function GetCategories()
|
||||
{
|
||||
$categories = array();
|
||||
foreach ($this->iblocks as $id)
|
||||
{
|
||||
foreach ($this->iblocks as $id) {
|
||||
$filter = array("IBLOCK_ID" => $id);
|
||||
|
||||
$dbRes = CIBlockSection::GetList(array("left_margin" => "asc"), $filter);
|
||||
@ -214,6 +215,7 @@ class RetailCrmICML
|
||||
$categories[$arRes['ID']] = $arRes;
|
||||
}
|
||||
}
|
||||
|
||||
return $categories;
|
||||
|
||||
}
|
||||
@ -240,8 +242,7 @@ class RetailCrmICML
|
||||
1
|
||||
);
|
||||
|
||||
foreach ($this->iblocks as $key => $id)
|
||||
{
|
||||
foreach ($this->iblocks as $key => $id) {
|
||||
// Get Info by infoblocks
|
||||
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
|
||||
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
|
||||
@ -266,7 +267,7 @@ class RetailCrmICML
|
||||
}
|
||||
}
|
||||
|
||||
$arSelectOffer = Array (
|
||||
$arSelectOffer = array(
|
||||
'ID',
|
||||
'ACTIVE',
|
||||
"NAME",
|
||||
@ -288,7 +289,7 @@ class RetailCrmICML
|
||||
"IBLOCK_ID" => $id
|
||||
);
|
||||
$order = array("id");
|
||||
$arNavStatParams = Array(
|
||||
$arNavStatParams = array(
|
||||
"iNumPage" => 1,
|
||||
"nPageSize" => $this->pageSize,
|
||||
);
|
||||
@ -298,8 +299,7 @@ class RetailCrmICML
|
||||
// Get products on this page
|
||||
$elems = array();
|
||||
$dbResProductsIds = CIBlockElement::GetList($order, $filter, false, $arNavStatParams, array('ID'));
|
||||
while($obIds = $dbResProductsIds->Fetch())
|
||||
{
|
||||
while ($obIds = $dbResProductsIds->Fetch()) {
|
||||
$elems[] = $obIds['ID'];
|
||||
}
|
||||
$arfilter = array(
|
||||
@ -312,7 +312,6 @@ class RetailCrmICML
|
||||
$pictures = array();
|
||||
$products = array();
|
||||
while ($product = $dbResProducts->GetNext()) {
|
||||
|
||||
// Compile products to array
|
||||
$products[$product['ID']] = $product;
|
||||
$products[$product['ID']]['offers'] = array();
|
||||
@ -320,13 +319,11 @@ class RetailCrmICML
|
||||
$detailPicture = intval($product["DETAIL_PICTURE"]);
|
||||
$previewPicture = intval($product["PREVIEW_PICTURE"]);
|
||||
|
||||
if ($detailPicture > 0 || $previewPicture > 0)
|
||||
{
|
||||
if ($detailPicture > 0 || $previewPicture > 0) {
|
||||
$picture = $detailPicture;
|
||||
if ($picture <= 0) {
|
||||
$picture = $previewPicture;
|
||||
}
|
||||
|
||||
// Link pictureID and productID
|
||||
$pictures[$picture] = $product['ID'];
|
||||
}
|
||||
@ -337,9 +334,8 @@ class RetailCrmICML
|
||||
$pictureIDs = array_keys($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()) {
|
||||
|
||||
// Link picture to product
|
||||
$products[$pictures[$file['ID']]]['PICTURE'] = $this->protocol .
|
||||
$this->serverName .
|
||||
@ -372,7 +368,6 @@ class RetailCrmICML
|
||||
|
||||
$stringOffers = "";
|
||||
foreach ($products as $product) {
|
||||
|
||||
// Get properties of product
|
||||
$resPropertiesProduct = Array();
|
||||
foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
|
||||
@ -381,11 +376,9 @@ class RetailCrmICML
|
||||
if ($propProduct != "") {
|
||||
if (isset($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"];
|
||||
}
|
||||
elseif (isset($product[$propProduct])){
|
||||
} elseif (isset($product[$propProduct])) {
|
||||
$resPropertiesProduct[$key] = $product[$propProduct];
|
||||
}
|
||||
if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
|
||||
@ -396,7 +389,7 @@ class RetailCrmICML
|
||||
}
|
||||
|
||||
// Get categories of product
|
||||
$categories = Array();
|
||||
$categories = array();
|
||||
$dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true);
|
||||
while ($arResCategory = $dbResCategories->Fetch()) {
|
||||
$categories[$arResCategory["ID"]] = array(
|
||||
@ -412,7 +405,6 @@ class RetailCrmICML
|
||||
|
||||
$existOffer = false;
|
||||
if (!empty($iblockOffer['IBLOCK_ID'])) {
|
||||
|
||||
foreach ($product['offers'] as $offer) {
|
||||
$offer['PRODUCT_ID'] = $product["ID"];
|
||||
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
|
||||
@ -428,11 +420,9 @@ class RetailCrmICML
|
||||
if ($propSKU != "") {
|
||||
if (isset ($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"];
|
||||
}
|
||||
elseif (isset($offer[$propSKU])){
|
||||
} elseif (isset($offer[$propSKU])) {
|
||||
$offer['_PROP_' . $key] = $offer[$propSKU];
|
||||
}
|
||||
if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
|
||||
@ -453,7 +443,6 @@ class RetailCrmICML
|
||||
}
|
||||
}
|
||||
if (!$existOffer) {
|
||||
|
||||
$product['PRODUCT_ID'] = $product["ID"];
|
||||
$product['PRODUCT_NAME'] = $product["NAME"];
|
||||
$product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
|
||||
@ -482,8 +471,7 @@ class RetailCrmICML
|
||||
}
|
||||
|
||||
$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);
|
||||
if (strpos($arOffer['DETAIL_PAGE_URL'], "#SECTION_PATH#") !== false) {
|
||||
if (count($categories) != 0) {
|
||||
|
||||
$category = $allCategories[$keys[0]];
|
||||
$path = $category['CODE'];
|
||||
|
||||
@ -509,10 +496,11 @@ class RetailCrmICML
|
||||
while (true) {
|
||||
$category = $allCategories[$category['IBLOCK_SECTION_ID']];
|
||||
$path = $category['CODE'] . '/' . $path;
|
||||
if(intval($category["IBLOCK_SECTION_ID"] ) == 0)
|
||||
if(intval($category["IBLOCK_SECTION_ID"]) == 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$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 ($key === "manufacturer") {
|
||||
$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";
|
||||
}
|
||||
}
|
||||
@ -548,14 +535,14 @@ class RetailCrmICML
|
||||
if ($propProduct != "" && $arOffer['_PROP_' . $key] != null) {
|
||||
if ($key === "manufacturer") {
|
||||
$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.= "</offer>\n";
|
||||
|
||||
return $offer;
|
||||
}
|
||||
}
|
@ -34,7 +34,8 @@ class RetailCrmOrder
|
||||
* @return boolean
|
||||
* @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
|
||||
return false;
|
||||
}
|
||||
@ -159,7 +160,8 @@ class RetailCrmOrder
|
||||
* @param $failed -- flag to export failed orders
|
||||
* @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")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'iblock', 'module not found');
|
||||
return true;
|
||||
@ -282,7 +284,8 @@ class RetailCrmOrder
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function orderObjToArr($obOrder){
|
||||
public static function orderObjToArr($obOrder)
|
||||
{
|
||||
$arOrder = array(
|
||||
'ID' => $obOrder->getId(),
|
||||
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
|
||||
@ -310,8 +313,7 @@ class RetailCrmOrder
|
||||
if ($delivery['PARENT_ID']) {
|
||||
$servise = explode(':', $delivery['CODE']);
|
||||
$shipment = array('id' => $delivery['PARENT_ID'], 'service' => $servise[1]);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$shipment = array('id' => $delivery['ID']);
|
||||
}
|
||||
$arOrder['DELIVERYS'][] = $shipment;
|
||||
|
@ -2,7 +2,8 @@
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
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
|
||||
return false;
|
||||
}
|
||||
@ -80,8 +81,7 @@ class RetailCrmUser
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$site = null;
|
||||
$userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arFields['ID'], $site);
|
||||
if (isset($userCrm['customer'])) {
|
||||
|
@ -1,2 +1 @@
|
||||
- Переход на новое API Битрикса
|
||||
- Переход на API црм v4
|
||||
- fix состава отгрузки
|
@ -1,18 +1,20 @@
|
||||
<?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");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(0);
|
||||
|
||||
global $APPLICATION;
|
||||
if (!CModule::IncludeModule("iblock"))
|
||||
if (!CModule::IncludeModule("iblock")){
|
||||
return;
|
||||
if (!CModule::IncludeModule("catalog"))
|
||||
}
|
||||
if (!CModule::IncludeModule("catalog")){
|
||||
return;
|
||||
if (!CModule::IncludeModule("intaro.retailcrm"))
|
||||
}
|
||||
if (!CModule::IncludeModule("intaro.retailcrm")){
|
||||
return;
|
||||
}
|
||||
|
||||
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
|
||||
while ($ar = $rsSites->Fetch()) {
|
||||
@ -21,7 +23,7 @@ else{
|
||||
}
|
||||
}
|
||||
|
||||
$iblockProperties = Array(
|
||||
$iblockProperties = array(
|
||||
"article" => "article",
|
||||
"manufacturer" => "manufacturer",
|
||||
"color" =>"color",
|
||||
@ -34,7 +36,6 @@ else{
|
||||
$IBLOCK_PROPERTY_SKU = array();
|
||||
$IBLOCK_PROPERTY_UNIT_SKU = array();
|
||||
foreach ($iblockProperties as $prop) {
|
||||
|
||||
$skuUnitProps = ('IBLOCK_PROPERTY_UNIT_SKU' . "_" . $prop);
|
||||
$skuUnitProps = $$skuUnitProps;
|
||||
if (is_array($skuUnitProps)) {
|
||||
@ -54,7 +55,6 @@ else{
|
||||
$IBLOCK_PROPERTY_PRODUCT = array();
|
||||
$IBLOCK_PROPERTY_UNIT_PRODUCT = array();
|
||||
foreach ($iblockProperties as $prop) {
|
||||
|
||||
$productUnitProps = "IBLOCK_PROPERTY_UNIT_PRODUCT" . "_" . $prop;
|
||||
$productUnitProps = $$productUnitProps;
|
||||
if (is_array($productUnitProps)) {
|
||||
|
@ -1,9 +1,8 @@
|
||||
<?
|
||||
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");
|
||||
}
|
||||
else{
|
||||
$iblockProperties = Array(
|
||||
} else {
|
||||
$iblockProperties = array(
|
||||
"article" => "article",
|
||||
"manufacturer" => "manufacturer",
|
||||
"color" =>"color",
|
||||
@ -14,7 +13,9 @@ else{
|
||||
"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"));
|
||||
|
||||
@ -33,7 +34,6 @@ else{
|
||||
|
||||
if (($ACTION == 'EXPORT' || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1)
|
||||
{
|
||||
|
||||
if (isset($arOldSetupVars['SETUP_FILE_NAME']))
|
||||
$SETUP_FILE_NAME = $arOldSetupVars['SETUP_FILE_NAME'];
|
||||
if (isset($arOldSetupVars['LOAD_PURCHASE_PRICE']))
|
||||
|
@ -10,8 +10,8 @@ IncludeModuleLangFile(__FILE__);
|
||||
if (class_exists('intaro_retailcrm'))
|
||||
return;
|
||||
|
||||
class intaro_retailcrm extends CModule {
|
||||
|
||||
class intaro_retailcrm extends CModule
|
||||
{
|
||||
var $MODULE_ID = 'intaro.retailcrm';
|
||||
var $OLD_MODULE_ID = 'intaro.intarocrm';
|
||||
var $MODULE_VERSION;
|
||||
@ -49,7 +49,8 @@ class intaro_retailcrm extends CModule {
|
||||
var $CRM_CANSEL_ORDER = 'cansel_order';
|
||||
var $INSTALL_PATH;
|
||||
|
||||
function intaro_retailcrm() {
|
||||
function intaro_retailcrm()
|
||||
{
|
||||
$arModuleVersion = array();
|
||||
$path = str_replace("\\", "/", __FILE__);
|
||||
$path = substr($path, 0, strlen($path) - strlen("/index.php"));
|
||||
@ -67,7 +68,8 @@ class intaro_retailcrm extends CModule {
|
||||
* Functions DoInstall and DoUninstall are
|
||||
* All other functions are optional
|
||||
*/
|
||||
function DoInstall() {
|
||||
function DoInstall()
|
||||
{
|
||||
global $APPLICATION, $step, $arResult;
|
||||
|
||||
if (!in_array('curl', get_loaded_extensions())) {
|
||||
@ -78,12 +80,14 @@ class intaro_retailcrm extends CModule {
|
||||
$infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION;
|
||||
if (version_compare($infoSale, '16', '<=')) {
|
||||
$APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!date_default_timezone_get()) {
|
||||
if (!ini_get('date.timezone')) {
|
||||
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -107,15 +111,13 @@ class intaro_retailcrm extends CModule {
|
||||
if (file_exists($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["ID"] = (string)$contragent["id"];
|
||||
$arResult['contragentType'][] = $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["ID"] = (string)$field["id"];
|
||||
|
||||
@ -190,7 +192,9 @@ class intaro_retailcrm extends CModule {
|
||||
|
||||
// form correct url
|
||||
$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'];
|
||||
|
||||
if (!$api_host || !$api_key) {
|
||||
@ -232,15 +236,12 @@ class intaro_retailcrm extends CModule {
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php'
|
||||
);
|
||||
} else if ($step == 2) {//доставки, оплаты, типы заказов
|
||||
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
$arResult['errCode'] = 'ERR_SALE';
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
$arResult['errCode'] = 'ERR_CATALOG';
|
||||
}
|
||||
@ -249,6 +250,7 @@ class intaro_retailcrm extends CModule {
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -555,14 +557,15 @@ class intaro_retailcrm extends CModule {
|
||||
|
||||
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
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_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
|
||||
|
||||
// form correct url
|
||||
$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'];
|
||||
|
||||
if (!$api_host || !$api_key) {
|
||||
@ -644,7 +647,7 @@ class intaro_retailcrm extends CModule {
|
||||
);
|
||||
} elseif ($step == 3) {//сопостовление свойств заказа
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
//handler
|
||||
$arResult['errCode'] = 'ERR_SALE';
|
||||
}
|
||||
|
||||
if (isset($_POST['back']) && $_POST['back']) {
|
||||
@ -675,8 +678,7 @@ class intaro_retailcrm extends CModule {
|
||||
foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) {
|
||||
$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!
|
||||
foreach ($optionsDelivTypes as $deliveryType) {
|
||||
$load = true;
|
||||
@ -777,7 +779,7 @@ class intaro_retailcrm extends CModule {
|
||||
);
|
||||
} elseif ($step == 4) {//выгрузка старых заказов
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
//handler
|
||||
$arResult['errCode'] = 'ERR_SALE';
|
||||
}
|
||||
|
||||
if (isset($_POST['back']) && $_POST['back']) {
|
||||
@ -796,8 +798,7 @@ class intaro_retailcrm extends CModule {
|
||||
|
||||
if (!isset($_POST['finish'])) {
|
||||
$finish = 0;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$finish = (int) $_POST['finish'];
|
||||
}
|
||||
$percent = round(100 - ($countLeft * 100 / $countAll), 1);
|
||||
@ -829,8 +830,9 @@ class intaro_retailcrm extends CModule {
|
||||
$propsCount = 0;
|
||||
$_orderPropsArr = array();
|
||||
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;
|
||||
}
|
||||
$_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']]));
|
||||
$propsCount++;
|
||||
}
|
||||
@ -875,10 +877,10 @@ class intaro_retailcrm extends CModule {
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
$arResult['errCode'] = 'ERR_CATALOG';
|
||||
}
|
||||
|
||||
$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 = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
@ -905,14 +907,13 @@ class intaro_retailcrm extends CModule {
|
||||
if (isset($history['history'])) {
|
||||
$hIs = (int)$history['history'][0]['id'] - 1;
|
||||
$orderH = $hIs;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$orderH = self::historyLoad($api, 'ordersHistory');
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$orderH = self::historyLoad($api, 'ordersHistory');
|
||||
}
|
||||
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH);
|
||||
|
||||
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'
|
||||
);
|
||||
} elseif ($step == 6) {//регистрация модуля
|
||||
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
$arResult['errCode'] = 'ERR_CATALOG';
|
||||
}
|
||||
@ -949,6 +948,7 @@ class intaro_retailcrm extends CModule {
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
|
||||
);
|
||||
|
||||
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';
|
||||
else
|
||||
} else {
|
||||
$iblocks = $_POST['IBLOCK_EXPORT'];
|
||||
}
|
||||
|
||||
$iblockProperties = Array(
|
||||
$iblockProperties = array(
|
||||
"article" => "article",
|
||||
"manufacturer" => "manufacturer",
|
||||
"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';
|
||||
else
|
||||
} else {
|
||||
$filename = $_POST['SETUP_FILE_NAME'];
|
||||
}
|
||||
|
||||
if (!isset($_POST['TYPE_LOADING']))
|
||||
if (!isset($_POST['TYPE_LOADING'])) {
|
||||
$typeLoading = 0;
|
||||
else
|
||||
} else {
|
||||
$typeLoading = $_POST['TYPE_LOADING'];
|
||||
}
|
||||
|
||||
if (!isset($_POST['SETUP_PROFILE_NAME']))
|
||||
if (!isset($_POST['SETUP_PROFILE_NAME'])) {
|
||||
$profileName = "";
|
||||
else
|
||||
} else {
|
||||
$profileName = $_POST['SETUP_PROFILE_NAME'];
|
||||
}
|
||||
|
||||
if ($typeLoading != 'none' && $profileName == "")
|
||||
if ($typeLoading != 'none' && $profileName == "") {
|
||||
$arResult['errCode'] = 'ERR_FIELDS_PROFILE';
|
||||
}
|
||||
|
||||
if ($filename == "")
|
||||
if ($filename == "") {
|
||||
$arResult['errCode'] = 'ERR_FIELDS_FILE';
|
||||
}
|
||||
|
||||
if (isset($arResult['errCode']) && $arResult['errCode']) {
|
||||
|
||||
$arOldValues = Array(
|
||||
$arOldValues = array(
|
||||
'IBLOCK_EXPORT' => $iblocks,
|
||||
'IBLOCK_PROPERTY_SKU' => $propertiesSKU,
|
||||
'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU,
|
||||
@ -1033,21 +1038,14 @@ class intaro_retailcrm extends CModule {
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd");
|
||||
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("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave");
|
||||
RegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete");
|
||||
@ -1094,10 +1092,10 @@ class intaro_retailcrm extends CModule {
|
||||
));
|
||||
if (intval($PROFILE_ID) <= 0) {
|
||||
$arResult['errCode'] = 'ERR_IBLOCK';
|
||||
|
||||
return;
|
||||
}
|
||||
if ($typeLoading == 'agent') {
|
||||
|
||||
$dateAgent = new DateTime();
|
||||
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
||||
$dateAgent->add($intAgent);
|
||||
@ -1199,7 +1197,8 @@ class intaro_retailcrm extends CModule {
|
||||
}
|
||||
}
|
||||
|
||||
function DoUninstall() {
|
||||
function DoUninstall()
|
||||
{
|
||||
global $APPLICATION;
|
||||
|
||||
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_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", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd");
|
||||
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("sale", "OnSaleOrderEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "orderSave");
|
||||
UnRegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $this->MODULE_ID, "RetailCrmEvent", "orderDelete");
|
||||
@ -1263,13 +1254,15 @@ class intaro_retailcrm extends CModule {
|
||||
);
|
||||
}
|
||||
|
||||
function CopyFiles() {
|
||||
function CopyFiles()
|
||||
{
|
||||
CopyDirFiles(
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true
|
||||
);
|
||||
}
|
||||
|
||||
function DeleteFiles() {
|
||||
function DeleteFiles()
|
||||
{
|
||||
$rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y'));
|
||||
$defaultSite = array();
|
||||
while ($ar = $rsSites->Fetch()) {
|
||||
@ -1305,7 +1298,8 @@ class intaro_retailcrm extends CModule {
|
||||
return $strVars;
|
||||
}
|
||||
|
||||
function historyLoad($api, $method){
|
||||
function historyLoad($api, $method)
|
||||
{
|
||||
$page = null;
|
||||
$i = 0;
|
||||
while (true) {
|
||||
@ -1332,8 +1326,7 @@ class intaro_retailcrm extends CModule {
|
||||
|
||||
if (isset($history['history'])) {
|
||||
$end = array_pop($history['history']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$end['id'] = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -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">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?
|
||||
$arModuleVersion = array(
|
||||
"VERSION" => "2.0.0",
|
||||
"VERSION_DATE" => "2016-09-12 12:00:00"
|
||||
"VERSION" => "2.0.3",
|
||||
"VERSION_DATE" => "2016-10-04 18:00:00"
|
||||
);
|
||||
|
||||
|
@ -36,15 +36,13 @@ $arResult = array();
|
||||
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');
|
||||
|
||||
foreach($options->contragents->contragent as $contragent)
|
||||
{
|
||||
foreach($options->contragents->contragent as $contragent) {
|
||||
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
|
||||
$type["ID"] = (string)$contragent["id"];
|
||||
$arResult['contragentType'][] = $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["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);
|
||||
} else {
|
||||
$orders = array();
|
||||
|
||||
for($i = 1; $i <= $countStep; $i++){
|
||||
$orders[] = $i + $step * $countStep;
|
||||
}
|
||||
@ -250,7 +247,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
// 1 - event
|
||||
$orderDischarge = 0;
|
||||
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
|
||||
///////////тут дописать\\\\\\\\\\\\\\\
|
||||
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
|
||||
// remove depenedencies
|
||||
UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
|
||||
@ -324,7 +320,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
} else {
|
||||
$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0);
|
||||
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
|
||||
//prepare crm lists
|
||||
@ -360,10 +355,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
|
||||
//bitrix statusesList
|
||||
$arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList();
|
||||
/*$arResult['bitrixPaymentStatusesList'][] = array(
|
||||
'ID' => 'YY',
|
||||
'NAME' => GetMessage('CANCELED')
|
||||
);*/
|
||||
|
||||
//bitrix pyament Y/N
|
||||
$arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y');
|
||||
|
Loading…
x
Reference in New Issue
Block a user