opt export DeliveryServices
This commit is contained in:
parent
091d13b163
commit
2de2077055
@ -359,9 +359,6 @@ class ICrmOrderActions
|
||||
$optionsSites = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_SITES, 0));
|
||||
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
||||
|
||||
//use email as login for new customers
|
||||
$loginEmail = true;
|
||||
|
||||
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||
|
||||
$dateStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, null);
|
||||
@ -375,8 +372,6 @@ class ICrmOrderActions
|
||||
|
||||
$dateStart = new \DateTime($dateStart);
|
||||
|
||||
echo json_encode($orderHistory);
|
||||
|
||||
// pushing existing orders
|
||||
foreach ($orderHistory as $order) {
|
||||
|
||||
@ -384,7 +379,6 @@ class ICrmOrderActions
|
||||
|
||||
// we dont need new orders without any customers (can check only for externalId)
|
||||
if(!isset($order['customer']['externalId']) && !$order['customer']['externalId']) {
|
||||
if($loginEmail) {
|
||||
if (!$order['customer']['email']) {
|
||||
$login = 'user_' . (microtime(true) * 100);
|
||||
$server_name = 0 < strlen(SITE_SERVER_NAME)?
|
||||
@ -395,7 +389,7 @@ class ICrmOrderActions
|
||||
// if email already used
|
||||
$dbUser = CUser::GetList(($by = 'ID'), ($sort = 'ASC'), array('=EMAIL' => $order['email']));
|
||||
if ($dbUser->SelectedRowsCount() == 0) {
|
||||
$loginEmail ? $login = $order['customer']['email'] : $login = 'user_' . (microtime(true) * 100);
|
||||
$login = $order['customer']['email'];
|
||||
$registerNewUser = true;
|
||||
} elseif ($dbUser->SelectedRowsCount() == 1) {
|
||||
$arUser = $dbUser->Fetch();
|
||||
@ -405,7 +399,6 @@ class ICrmOrderActions
|
||||
$registerNewUser = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($registerNewUser) {
|
||||
$useCaptcha = COption::GetOptionString('main', 'captcha_registration', 'N');
|
||||
if ($useCaptcha == 'Y')
|
||||
@ -434,7 +427,7 @@ class ICrmOrderActions
|
||||
self::eventLog('ICrmOrderActions::orderHistory', 'IntaroCrm\RestApi::customerFixExternalIds', $api->getLastError());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// new order
|
||||
$newOrderFields = array(
|
||||
@ -1120,7 +1113,7 @@ class ICrmOrderActions
|
||||
* working with nested arrs
|
||||
*
|
||||
* @param array $arr
|
||||
* @return boolean
|
||||
* @return array
|
||||
*/
|
||||
public static function clearArr($arr) {
|
||||
if(!$arr || !is_array($arr))
|
||||
|
@ -668,6 +668,7 @@ class intaro_intarocrm extends CModule {
|
||||
do {
|
||||
//auto delivery types
|
||||
$deliveryTypesArr[$arDeliveryServicesList['SID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryServicesList['SID']]));
|
||||
|
||||
} while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
|
||||
}
|
||||
} elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {
|
||||
|
@ -23,21 +23,6 @@ $MESS["PROPERTY_OFFER_HEADER_NAME"] = "Свойство торгового пр
|
||||
$MESS["PROPERTY_ARTICLE_HEADER_NAME"] = "Артикул";
|
||||
$MESS["PROPERTY_MANUFACTURER_HEADER_NAME"] = "Производитель";
|
||||
$MESS["PROPERTY_COLOR_HEADER_NAME"] = "Цвет";
|
||||
$MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Вес (габариты)";
|
||||
$MESS["PROPERTY_LENGTH_HEADER_NAME"] = "Длина (габариты)";
|
||||
$MESS["PROPERTY_WIDTH_HEADER_NAME"] = "Ширина (габариты)";
|
||||
$MESS["PROPERTY_HEIGHT_HEADER_NAME"] = "Высота (габариты)";
|
||||
$MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Вес";
|
||||
$MESS["PROPERTY_SIZE_HEADER_NAME"] = "Размер";
|
||||
$MESS["SELECT_FIELD_NAME"] = "Поле";
|
||||
$MESS["SELECT_PROPERTY_NAME"] = "Свойства";
|
||||
$MESS["SELECT_WEIGHT_PROPERTY_NAME"] = "Вec (грамм)";
|
||||
$MESS["SELECT_LENGTH_PROPERTY_NAME"] = "Длина (мм.)";
|
||||
$MESS["SELECT_WIDTH_PROPERTY_NAME"] = "Ширина (мм.)";
|
||||
$MESS["SELECT_HEIGHT_PROPERTY_NAME"] = "Высота (мм.)";
|
||||
$MESS["UNIT_MEASUREMENT_MM"] = "мм.";
|
||||
$MESS["UNIT_MEASUREMENT_CM"] = "см.";
|
||||
$MESS["UNIT_MEASUREMENT_M"] = "м.";
|
||||
$MESS["UNIT_MEASUREMENT_MG"] = "мг.";
|
||||
$MESS["UNIT_MEASUREMENT_G"] = "г.";
|
||||
$MESS["UNIT_MEASUREMENT_KG"] = "кг.";
|
||||
?>
|
@ -51,4 +51,3 @@ $MESS ['BLOCK'] = 'Подъезд';
|
||||
$MESS ['HOUSE'] = 'Строение / корпус';
|
||||
$MESS ['ADDRESS_SHORT'] = 'Краткий адрес';
|
||||
$MESS ['ADDRESS_FULL'] = 'Детальный адрес';
|
||||
|
||||
|
@ -92,6 +92,69 @@ $arResult['orderProps'] = array(
|
||||
)
|
||||
);
|
||||
|
||||
//ajax update deliveryServices
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
||||
$result = array();
|
||||
|
||||
$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0);
|
||||
|
||||
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||
|
||||
//check connection & apiKey valid
|
||||
if ((int) $api->getStatusCode() != 200) {
|
||||
$APPLICATION->RestartBuffer();
|
||||
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
|
||||
die(json_encode(array('success' => false, 'errMsg' => $api->getStatusCode())));
|
||||
}
|
||||
|
||||
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0));
|
||||
|
||||
// bitrix deliveryServicesList
|
||||
$dbDeliveryServicesList = CSaleDeliveryHandler::GetList(
|
||||
array(
|
||||
'SORT' => 'ASC',
|
||||
'NAME' => 'ASC'
|
||||
),
|
||||
array(
|
||||
'ACTIVE' => 'Y'
|
||||
)
|
||||
);
|
||||
|
||||
if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
|
||||
do {
|
||||
|
||||
if(!$optionsDelivTypes[$arDeliveryServicesList['SID']]) {
|
||||
self::eventLog('options.php', 'No delivery type relations established', $arDeliveryServicesList['SID'] . ':' . $id);
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($arDeliveryServicesList['PROFILES'] as $id => $profile) {
|
||||
|
||||
// send to crm
|
||||
$this->INTARO_CRM_API->deliveryServiceEdit(ICrmOrderActions::clearArr(array(
|
||||
'code' => $arDeliveryServicesList['SID'] . '-' . $id,
|
||||
'name' => ICrmOrderActions::toJSON($profile['TITLE']),
|
||||
'deliveryType' => $arDeliveryServicesList['SID']
|
||||
)));
|
||||
|
||||
// error pushing dt
|
||||
if ($this->INTARO_CRM_API->getStatusCode() != 200) {
|
||||
if ($this->INTARO_CRM_API->getStatusCode() != 201) {
|
||||
//handle err
|
||||
self::eventLog('options.php', 'IntaroCrm\RestApi::deliveryServiceEdit', $this->INTARO_CRM_API->getLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
|
||||
}
|
||||
|
||||
$APPLICATION->RestartBuffer();
|
||||
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
|
||||
die(json_encode(array('success' => true)));
|
||||
}
|
||||
|
||||
//update connection settings
|
||||
if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$api_host = htmlspecialchars(trim($_POST['api_host']));
|
||||
|
Loading…
Reference in New Issue
Block a user