sending delivery types without pay systems
This commit is contained in:
parent
b1b2d685db
commit
ca6e71d55f
@ -524,6 +524,11 @@ class intaro_intarocrm extends CModule
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// api load
|
||||||
|
$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);
|
||||||
|
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
|
||||||
|
|
||||||
//bitrix orderTypesList -- personTypes
|
//bitrix orderTypesList -- personTypes
|
||||||
$dbOrderTypesList = CSalePersonType::GetList(
|
$dbOrderTypesList = CSalePersonType::GetList(
|
||||||
array(
|
array(
|
||||||
@ -562,11 +567,48 @@ class intaro_intarocrm extends CModule
|
|||||||
|
|
||||||
//form delivery types ids arr
|
//form delivery types ids arr
|
||||||
$deliveryTypesArr = array();
|
$deliveryTypesArr = array();
|
||||||
|
|
||||||
|
if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {
|
||||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||||
do {
|
do {
|
||||||
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
||||||
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// send to intaro crm and save
|
||||||
|
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||||
|
do {
|
||||||
|
// parse id
|
||||||
|
$arId = array();
|
||||||
|
$resultDeliveryTypeId = 0;
|
||||||
|
if (strpos($arDeliveryTypesList['ID'], ":") !== false)
|
||||||
|
$arId = explode(":", $arDeliveryTypesList['ID']);
|
||||||
|
|
||||||
|
if ($arId)
|
||||||
|
$resultDeliveryTypeId = $arId[0];
|
||||||
|
else
|
||||||
|
$resultDeliveryTypeId = $arDeliveryTypesList['ID'];
|
||||||
|
|
||||||
|
$deliveryTypesArr[$arDeliveryTypesList['ID']] = $resultDeliveryTypeId;
|
||||||
|
|
||||||
|
// send to crm
|
||||||
|
$this->INTARO_CRM_API->deliveryTypeEdit(array(
|
||||||
|
'code' => $resultDeliveryTypeId,
|
||||||
|
'name' => ICrmOrderActions::toJSON($arDeliveryTypesList['NAME']),
|
||||||
|
'defaultCost' => $arDeliveryTypesList['PRICE'],
|
||||||
|
'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']),
|
||||||
|
'paymentTypes' => ''
|
||||||
|
));
|
||||||
|
|
||||||
|
// error pushing customer
|
||||||
|
if (($this->INTARO_CRM_API->getStatusCode() != 200) || ($this->INTARO_CRM_API->getStatusCode() != 201)) {
|
||||||
|
//handle err
|
||||||
|
self::eventLog('install/index.php', 'IntaroCrm\RestApi::deliveryTypeEdit', $this->INTARO_CRM_API->getLastError());
|
||||||
|
}
|
||||||
|
|
||||||
|
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//bitrix paymentTypesList
|
//bitrix paymentTypesList
|
||||||
$dbPaymentTypesList = CSalePaySystem::GetList(
|
$dbPaymentTypesList = CSalePaySystem::GetList(
|
||||||
|
@ -93,6 +93,13 @@ $defaultPayment = array(
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('input[name="delivery-types-export"]').click(function() {
|
||||||
|
if($(this).val() === 'true')
|
||||||
|
$('tr.delivery-types').hide('slow');
|
||||||
|
else if($(this).val() === 'false')
|
||||||
|
$('tr.delivery-types').show('show');
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -124,8 +131,16 @@ $defaultPayment = array(
|
|||||||
<tr class="heading">
|
<tr class="heading">
|
||||||
<td colspan="2"><b><?php echo GetMessage('DELIVERY_TYPES_LIST'); ?></b></td>
|
<td colspan="2"><b><?php echo GetMessage('DELIVERY_TYPES_LIST'); ?></b></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="heading">
|
||||||
|
<td width="50%" class="adm-detail-content-cell-l">
|
||||||
|
<label><input type="radio" name="delivery-types-export" value="true" checked> <?php echo GetMessage('DELIV_TYPES_EXPORT'); ?></label>
|
||||||
|
</td>
|
||||||
|
<td width="50%" class="adm-detail-content-cell-r">
|
||||||
|
<label><input type="radio" name="delivery-types-export" value="false"> <?php echo GetMessage('DELIV_TYPES_EXPORT_F'); ?></label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<?php foreach($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType): ?>
|
<?php foreach($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType): ?>
|
||||||
<tr>
|
<tr class="delivery-types" style="display: none;">
|
||||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixDeliveryType['ID']; ?>">
|
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixDeliveryType['ID']; ?>">
|
||||||
<?php echo $bitrixDeliveryType['NAME']; ?>
|
<?php echo $bitrixDeliveryType['NAME']; ?>
|
||||||
</td>
|
</td>
|
||||||
@ -175,7 +190,7 @@ $defaultPayment = array(
|
|||||||
<select name="payment-status-<?php echo $bitrixPaymentStatus['ID']; ?>" class="typeselect">
|
<select name="payment-status-<?php echo $bitrixPaymentStatus['ID']; ?>" class="typeselect">
|
||||||
<option value="" selected=""></option>
|
<option value="" selected=""></option>
|
||||||
<?php foreach($arResult['paymentGroupList'] as $orderStatusGroup): if(!empty($orderStatusGroup['statuses'])) : ?>
|
<?php foreach($arResult['paymentGroupList'] as $orderStatusGroup): if(!empty($orderStatusGroup['statuses'])) : ?>
|
||||||
<optgroup label="<?php echo $orderStatusGroup['name']; ?>">
|
<optgroup label="<?php echo $APPLICATION->ConvertCharset($orderStatusGroup['name'], 'utf-8', SITE_CHARSET); ?>">
|
||||||
<?php foreach($orderStatusGroup['statuses'] as $payment): ?>
|
<?php foreach($orderStatusGroup['statuses'] as $payment): ?>
|
||||||
<option value="<?php echo $arResult['paymentList'][$payment]['code']; ?>"
|
<option value="<?php echo $arResult['paymentList'][$payment]['code']; ?>"
|
||||||
<?php if ($defaultPayStatuses[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) echo 'selected'; ?>>
|
<?php if ($defaultPayStatuses[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) echo 'selected'; ?>>
|
||||||
|
@ -16,3 +16,5 @@ $MESS ['URL_1'] = 'Администрирование';
|
|||||||
$MESS ['INFO_3'] = 'После этого подгрузите новые значения, нажав кнопку «Обновить справочники»';
|
$MESS ['INFO_3'] = 'После этого подгрузите новые значения, нажав кнопку «Обновить справочники»';
|
||||||
$MESS ['UPDATE_CATS'] = 'Обновить справочники';
|
$MESS ['UPDATE_CATS'] = 'Обновить справочники';
|
||||||
$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.';
|
$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.';
|
||||||
|
$MESS ['DELIV_TYPES_EXPORT'] = 'Выгрузить список доставок из 1С-Битрикс';
|
||||||
|
$MESS ['DELIV_TYPES_EXPORT_F'] = 'Настроить соответствие доставок 1С-Битрикс и IntaroCRM';
|
Loading…
Reference in New Issue
Block a user