v.2.2.0.2
This commit is contained in:
parent
c26f03960d
commit
9e720c1df0
4 changed files with 60 additions and 33 deletions
|
@ -4,6 +4,7 @@ class RCrmActions
|
|||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
public static $CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
public static $CRM_API_VERSION = 'api_version';
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
|
@ -175,7 +176,7 @@ class RCrmActions
|
|||
RetailCrmOrder::uploadOrders(50, true);
|
||||
}
|
||||
|
||||
return 'RCrmActions::uploadOrdersAgent();';
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,25 +311,35 @@ class RCrmActions
|
|||
}
|
||||
|
||||
private function proxy($api, $methodApi, $method, $params) {
|
||||
$log = new Logger();
|
||||
$version = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_VERSION, 0);
|
||||
try {
|
||||
$result = call_user_func_array(array($api, $methodApi), $params);
|
||||
|
||||
if ($result->getStatusCode() !== 200 && $result->getStatusCode() !== 201) {
|
||||
$arResult = (array)$result;
|
||||
$log = new Logger();
|
||||
if ($methodApi == 'customersUpload' || $methodApi == 'ordersUpload') {
|
||||
if ($methodApi == 'ordersGet' || $methodApi == 'customersGet') {
|
||||
$log->write(array(
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $arResult['errorMsg'],
|
||||
'errors' => !empty($arResult['errors']) ? $arResult['errors'] : '',
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
'errors' => !empty($result['errors']) ? $result['errors'] : '',
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
} elseif ($methodApi == 'customersUpload' || $methodApi == 'ordersUpload') {
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
'errors' => !empty($result['errors']) ? $result['errors'] : '',
|
||||
'params' => $params
|
||||
), 'uploadApiErrors');
|
||||
} else {
|
||||
self::eventLog(__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi, $arResult['errorMsg']);
|
||||
self::eventLog(__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi, !empty($result['errorMsg']) ? $result['errorMsg'] : '');
|
||||
$log->write(array(
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $arResult['errorMsg'],
|
||||
'errors' => !empty($arResult['errors']) ? $arResult['errors'] : '',
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
'errors' => !empty($result['errors']) ? $result['errors'] : '',
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
}
|
||||
|
@ -343,6 +354,13 @@ class RCrmActions
|
|||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::CurlException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
);
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $e->getMessage(),
|
||||
'errors' => $e->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
return false;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
|
@ -350,6 +368,13 @@ class RCrmActions
|
|||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::InvalidArgumentException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
);
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $e->getMessage(),
|
||||
'errors' => $e->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ class RetailCrmUa
|
|||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', '" . $uaId . "', 'auto');
|
||||
ga('create', '" . $uaKeys[SITE_ID]['ID'] . "', 'auto');
|
||||
function getRetailCrmCookie(name) {
|
||||
var matches = document.cookie.match(new RegExp(
|
||||
'(?:^|; )' + name + '=([^;]*)'
|
||||
));
|
||||
return matches ? decodeURIComponent(matches[1]) : '';
|
||||
}
|
||||
ga('set', 'dimension" . $uaIndex . "', getRetailCrmCookie('_ga'));
|
||||
ga('set', 'dimension" . $uaKeys[SITE_ID]['INDEX'] . "', getRetailCrmCookie('_ga'));
|
||||
ga('send', 'pageview');
|
||||
</script>";
|
||||
if (isset($_GET['ORDER_ID'])) {
|
||||
|
|
|
@ -361,6 +361,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
//prices
|
||||
$bitrixPricesArr = array();
|
||||
$bitrixIblocksPrices = array();
|
||||
$bitrixPriceShopsArr = array();
|
||||
if(htmlspecialchars(trim($_POST['prices-upload'])) == 'Y'){
|
||||
$pricesUpload = 'Y';
|
||||
|
||||
|
@ -398,13 +399,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
}
|
||||
|
||||
//demon
|
||||
$collectorKeys = array();
|
||||
if (htmlspecialchars(trim($_POST['collector'])) == 'Y') {
|
||||
$collector = 'Y';
|
||||
$collectorKeys = array();
|
||||
foreach ($arResult['arSites'] as $site) {
|
||||
$collectorKeys[$site['LID']] = trim($_POST['collector-id-' . $site['LID']]);
|
||||
}
|
||||
//$collectorKey = trim($_POST['collector-id']);
|
||||
RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCollector", "add");
|
||||
} else {
|
||||
$collector = 'N';
|
||||
|
@ -412,15 +412,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
}
|
||||
|
||||
//UA
|
||||
$uaKeys = array();
|
||||
if (htmlspecialchars(trim($_POST['ua-integration'])) == 'Y') {
|
||||
$ua = 'Y';
|
||||
$uaKeys = array();
|
||||
foreach ($arResult['arSites'] as $site) {
|
||||
$uaKeys[$site['LID']]['ID'] = trim($_POST['ua-id-' . $site['LID']]);
|
||||
$uaKeys[$site['LID']]['INDEX'] = trim($_POST['ua-index-' . $site['LID']]);
|
||||
}
|
||||
// $uaId = trim($_POST['ua-id']);
|
||||
// $uaIndex = trim($_POST['ua-index']);
|
||||
RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add");
|
||||
} else {
|
||||
$ua = 'N';
|
||||
|
@ -494,7 +492,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
|
||||
COption::SetOptionString($mid, $CRM_UA, $ua);
|
||||
COption::SetOptionString($mid, $CRM_UA_KEYS, serialize(RCrmActions::clearArr($uaKeys)));
|
||||
//COption::SetOptionString($mid, $CRM_UA_ID, $uaId);
|
||||
|
||||
$uri .= '&ok=Y';
|
||||
LocalRedirect($uri);
|
||||
|
@ -1049,8 +1046,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="1" <?php if($optionsDischarge == 1) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_EVENTS'); ?></label>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -1189,7 +1186,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="r-coll">
|
||||
<tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="option-head" colspan="2">
|
||||
<b><?php echo GetMessage('ICRM_SITES'); ?></b>
|
||||
</td>
|
||||
|
@ -1210,7 +1207,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['arSites'] as $sitesList): ?>
|
||||
<tr class="r-ua">
|
||||
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="option-head" colspan="2">
|
||||
<b><?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</b>
|
||||
</td>
|
||||
|
|
|
@ -2,16 +2,21 @@
|
|||
if (!CModule::IncludeModule("main")) return;
|
||||
|
||||
$mid = 'intaro.retailcrm';
|
||||
$CRM_INVENTORIES_UPLOAD = 'inventories_upload';
|
||||
$CRM_PRICES_UPLOAD = 'prices_upload';
|
||||
$CRM_COLLECTOR = 'collector';
|
||||
$CRM_UA = 'ua';
|
||||
$CRM_API_VERSION = 'api_version';
|
||||
if (CModule::IncludeModule($mid)) {
|
||||
$CRM_INVENTORIES_UPLOAD = 'inventories_upload';
|
||||
$CRM_PRICES_UPLOAD = 'prices_upload';
|
||||
$CRM_COLLECTOR = 'collector';
|
||||
$CRM_UA = 'ua';
|
||||
$CRM_API_VERSION = 'api_version';
|
||||
|
||||
COption::SetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 'N');
|
||||
COption::SetOptionString($mid, $CRM_PRICES_UPLOAD, 'N');
|
||||
COption::SetOptionString($mid, $CRM_COLLECTOR, 'N');
|
||||
COption::SetOptionString($mid, $CRM_UA, 'N');
|
||||
COption::SetOptionString($mid, $CRM_API_VERSION, 'v4');
|
||||
COption::SetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 'N');
|
||||
COption::SetOptionString($mid, $CRM_PRICES_UPLOAD, 'N');
|
||||
COption::SetOptionString($mid, $CRM_COLLECTOR, 'N');
|
||||
COption::SetOptionString($mid, $CRM_UA, 'N');
|
||||
COption::SetOptionString($mid, $CRM_API_VERSION, 'v4');
|
||||
|
||||
COption::RemoveOption($mid, 'catalog_base_iblocks');
|
||||
COption::RemoveOption($mid, 'catalog_base_iblocks');
|
||||
}
|
||||
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/classes/general/ApiClient.php');
|
||||
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/classes/general/order/RetailCrmOrder.php');
|
||||
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/classes/general/history/RetailCrmHistory.php');
|
||||
|
|
Loading…
Add table
Reference in a new issue