sending delivery types without pay systems
This commit is contained in:
parent
b1b2d685db
commit
ca6e71d55f
@ -21,7 +21,7 @@ class intaro_intarocrm extends CModule
|
||||
var $PARTNER_NAME;
|
||||
var $PARTNER_URI;
|
||||
var $INTARO_CRM_API;
|
||||
var $INTARO_CRM_EXPORT = 'intarocrm';
|
||||
var $INTARO_CRM_EXPORT = 'intarocrm';
|
||||
|
||||
var $CRM_API_HOST_OPTION = 'api_host';
|
||||
var $CRM_API_KEY_OPTION = 'api_key';
|
||||
@ -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
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
@ -562,10 +567,47 @@ class intaro_intarocrm extends CModule
|
||||
|
||||
//form delivery types ids arr
|
||||
$deliveryTypesArr = array();
|
||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||
do {
|
||||
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
||||
} while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
|
||||
|
||||
if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {
|
||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||
do {
|
||||
$deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
|
||||
} 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
|
||||
|
@ -93,6 +93,13 @@ $defaultPayment = array(
|
||||
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>
|
||||
|
||||
@ -124,8 +131,16 @@ $defaultPayment = array(
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('DELIVERY_TYPES_LIST'); ?></b></td>
|
||||
</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): ?>
|
||||
<tr>
|
||||
<tr class="delivery-types" style="display: none;">
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixDeliveryType['ID']; ?>">
|
||||
<?php echo $bitrixDeliveryType['NAME']; ?>
|
||||
</td>
|
||||
@ -175,7 +190,7 @@ $defaultPayment = array(
|
||||
<select name="payment-status-<?php echo $bitrixPaymentStatus['ID']; ?>" class="typeselect">
|
||||
<option value="" selected=""></option>
|
||||
<?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): ?>
|
||||
<option value="<?php echo $arResult['paymentList'][$payment]['code']; ?>"
|
||||
<?php if ($defaultPayStatuses[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) echo 'selected'; ?>>
|
||||
|
@ -16,3 +16,5 @@ $MESS ['URL_1'] = 'Администрирование';
|
||||
$MESS ['INFO_3'] = 'После этого подгрузите новые значения, нажав кнопку «Обновить справочники»';
|
||||
$MESS ['UPDATE_CATS'] = 'Обновить справочники';
|
||||
$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.';
|
||||
$MESS ['DELIV_TYPES_EXPORT'] = 'Выгрузить список доставок из 1С-Битрикс';
|
||||
$MESS ['DELIV_TYPES_EXPORT_F'] = 'Настроить соответствие доставок 1С-Битрикс и IntaroCRM';
|
Loading…
Reference in New Issue
Block a user