1
0
mirror of synced 2024-11-25 14:56:09 +03:00

+optionsOrderProps

This commit is contained in:
Grisha Pomadchin 2013-08-01 18:10:51 +04:00
parent e4176b2856
commit cdef1b84c5
4 changed files with 95 additions and 10 deletions

View File

@ -11,6 +11,7 @@ class ICrmOrderActions
protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
protected static $CRM_ORDER_LAST_ID = 'order_last_id';
protected static $CRM_ORDER_PROPS = 'order_props';
/**
* Mass order uploading, without repeating; always returns true, but writes error log
@ -54,6 +55,7 @@ class ICrmOrderActions
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
$api = new IntaroCrm\RestApi($api_host, $api_key);
@ -62,7 +64,8 @@ class ICrmOrderActions
'optionsDelivTypes' => $optionsDelivTypes,
'optionsPayTypes' => $optionsPayTypes,
'optionsPayStatuses' => $optionsPayStatuses,
'optionsPayment' => $optionsPayment
'optionsPayment' => $optionsPayment,
'optionsOrderProps' => $optionsOrderProps
);
// pack mode enable / disable
@ -251,22 +254,31 @@ class ICrmOrderActions
$rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID']));
while ($ar = $rsOrderProps->Fetch()) {
switch ($ar['CODE']) {
case 'ZIP': $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']);
case $arParams['optionsOrderProps']['index']: $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']);
break;
case 'CITY': $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']);
case $arParams['optionsOrderProps']['city']: if ($arParams['optionsOrderProps']['index'] == 'LOCATION') {
if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) {
$resOrderDeliveryAddress['city'] = CSaleLocation::GetByID($ar['VALUE']);
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
}
} else
$resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']);
break;
case 'ADDRESS': $resOrderDeliveryAddress['text'] = self::toJSON($ar['VALUE']);
case 'CITY': if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city'])
$resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); // we check both locations & city for export
break;
case 'LOCATION': if(!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) {
case $arParams['optionsOrderProps']['text']: $resOrderDeliveryAddress['text'] = self::toJSON($ar['VALUE']);
break;
case 'LOCATION': if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) {
$resOrderDeliveryAddress['city'] = CSaleLocation::GetByID($ar['VALUE']);
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
}
break;
case 'FIO': $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE']));
case $arParams['optionsOrderProps']['fio']: $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE']));
break;
case 'PHONE': $resOrder['phone'] = $ar['VALUE'];
case $arParams['optionsOrderProps']['phone']: $resOrder['phone'] = $ar['VALUE'];
break;
case 'EMAIL': $resOrder['email'] = $ar['VALUE'];
case $arParams['optionsOrderProps']['email']: $resOrder['email'] = $ar['VALUE'];
break;
}
}

View File

@ -30,6 +30,7 @@ class intaro_intarocrm extends CModule
var $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
var $CRM_ORDER_LAST_ID = 'order_last_id';
var $CRM_ORDER_PROPS = 'order_props';
var $INSTALL_PATH;
@ -363,6 +364,16 @@ class intaro_intarocrm extends CModule
$paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
// orderProps assoc arr
$orderPropsArr = array(
'city' => 'CITY',
'fio' => 'FIO',
'index' => 'ZIP',
'text' => 'ADDRESS',
'phone' => 'PHONE',
'email' => 'EMAIL'
);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
@ -370,6 +381,7 @@ class intaro_intarocrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_PROPS, serialize($orderPropsArr));
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),

View File

@ -1,6 +1,7 @@
<?php
$MESS ['ICRM_OPTIONS_GENERAL_TAB'] = 'Общие настройки';
$MESS ['ICRM_OPTIONS_IMPORT_TAB'] = 'Настройки импората';
$MESS ['ICRM_OPTIONS_ORDER_PROPS_TAB'] = 'Cоответствия полей свойств заказа';
$MESS ['ICRM_CONN_SETTINGS'] = 'Настройка соединения';
$MESS ['ICRM_API_HOST'] = 'Адрес Intaro CRM:';
$MESS ['ICRM_API_KEY'] = 'Ключ авторизации:';
@ -21,4 +22,12 @@ $MESS ['ERR_404'] = 'Возможно не верно введен адрес CR
$MESS ['ERR_403'] = 'Неверный apiKey.';
$MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.';
$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.';
$MESS ['CANCELED'] = 'Флаг «Отменен»';
$MESS ['CANCELED'] = 'Флаг «Отменен»';
$MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа IntaroCRM свойствам заказа 1С-Битрикс';
$MESS ['FIO'] = 'ф.И.О.';
$MESS ['CITY'] = 'Город';
$MESS ['ZIP'] = 'Индекс';
$MESS ['ADDRESS'] = 'Адрес (строкой)';
$MESS ['PHONE'] = 'Телефон';
$MESS ['EMAIL'] = 'E-mail';

View File

@ -11,6 +11,7 @@ $CRM_PAYMENT_TYPES = 'pay_types_arr';
$CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
$CRM_PAYMENT = 'payment_arr'; //order payment Y/N
$CRM_ORDER_LAST_ID = 'order_last_id';
$CRM_ORDER_PROPS = 'order_props';
if(!CModule::IncludeModule('intaro.intarocrm')
|| !CModule::IncludeModule('sale'))
@ -23,6 +24,18 @@ if($_GET['errc']) echo CAdminMessage::ShowMessage(GetMessage($_GET['errc']));
if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('ICRM_OPTIONS_OK'));
$arResult = array();
$arResult['orderProps'][0]['NAME'] = GetMessage('FIO');
$arResult['orderProps'][0]['ID'] = 'fio';
$arResult['orderProps'][1]['NAME'] = GetMessage('CITY');
$arResult['orderProps'][1]['ID'] = 'city';
$arResult['orderProps'][2]['NAME'] = GetMessage('ZIP');
$arResult['orderProps'][2]['ID'] = 'index';
$arResult['orderProps'][3]['NAME'] = GetMessage('ADDRESS');
$arResult['orderProps'][3]['ID'] = 'text';
$arResult['orderProps'][4]['NAME'] = GetMessage('PHONE');
$arResult['orderProps'][4]['ID'] = 'phone';
$arResult['orderProps'][5]['NAME'] = GetMessage('EMAIL');
$arResult['orderProps'][5]['ID'] = 'email';
//update connection settings
if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
@ -132,11 +145,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
foreach($arResult['orderProps'] as $orderProp)
$orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID']]));
COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
COption::SetOptionString($mid, $CRM_PAYMENT, serialize($paymentArr));
COption::SetOptionString($mid, $CRM_ORDER_PROPS, serialize($orderPropsArr));
$uri .= '&ok=Y';
LocalRedirect($uri);
@ -237,19 +254,26 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
'NAME' => GetMessage('CANCELED')
);
$dbProp = CSaleOrderProps::GetList(array(), array());
//bitrix pyament Y/N
$arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y');
$arResult['bitrixPaymentList'][0]['ID'] = 'Y';
$arResult['bitrixPaymentList'][1]['NAME'] = GetMessage('PAYMENT_N');
$arResult['bitrixPaymentList'][1]['ID'] = 'N';
while ($arProp = $dbProp->GetNext()) {
$arResult['arProp'][] = $arProp;
}
//saved cat params
$optionsOrderTypes = unserialize(COption::GetOptionString($mid, $CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0));
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses
$optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0));
$optionsOrderProps = unserialize(COption::GetOptionString($mid, $CRM_ORDER_PROPS, 0));
$aTabs = array(
array(
"DIV" => "edit1",
@ -263,6 +287,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
"ICON" => '',
"TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION')
),
array(
"DIV" => "edit3",
"TAB" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_TAB'),
"ICON" => '',
"TITLE" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_CAPTION')
),
);
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$tabControl->Begin();
@ -390,6 +420,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</td>
</tr>
<?php endforeach; ?>
<?php $tabControl->BeginNextTab(); ?>
<input type="hidden" name="tab" value="catalog">
<tr class="heading">
<td colspan="2"><b><?php echo GetMessage('ORDER_PROPS'); ?></b></td>
</tr>
<?php foreach($arResult['orderProps'] as $orderProp): ?>
<tr>
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $orderProp['ID']; ?>">
<?php echo $orderProp['NAME']; ?>
</td>
<td width="50%" class="adm-detail-content-cell-r">
<select name="order-prop-<?php echo $orderProp['ID']; ?>" class="typeselect">
<option value=""></option>
<?php foreach ($arResult['arProp'] as $arProp): ?>
<option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsOrderProps[$orderProp['ID']] == $arProp['CODE']) echo 'selected'; ?>>
<?php echo $arProp['NAME']; ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<?php endforeach; ?>
<?php $tabControl->BeginNextTab(); ?>
<?php $tabControl->Buttons(); ?>
<input type="hidden" name="Update" value="Y" />