GetCurPage() . '?mid=' . htmlspecialchars($mid) . '&lang=' . LANGUAGE_ID; $CRM_API_HOST_OPTION = 'api_host'; $CRM_API_KEY_OPTION = 'api_key'; $CRM_ORDER_TYPES_ARR = 'order_types_arr'; $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; $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')) return; $_GET['errc'] = htmlspecialchars(trim($_GET['errc'])); $_GET['ok'] = htmlspecialchars(trim($_GET['ok'])); 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('ZIP'); $arResult['orderProps'][1]['ID'] = 'index'; $arResult['orderProps'][2]['NAME'] = GetMessage('PHONE'); $arResult['orderProps'][2]['ID'] = 'phone'; $arResult['orderProps'][3]['NAME'] = GetMessage('EMAIL'); $arResult['orderProps'][3]['ID'] = 'email'; // address $arResult['orderProps'][4]['NAME'] = GetMessage('ADDRESS'); $arResult['orderProps'][4]['ID'] = 'text'; $arResult['orderProps'][5]['NAME'] = GetMessage('COUNTRY'); $arResult['orderProps'][5]['ID'] = 'country'; $arResult['orderProps'][6]['NAME'] = GetMessage('REGION'); $arResult['orderProps'][6]['ID'] = 'region'; $arResult['orderProps'][7]['NAME'] = GetMessage('CITY'); $arResult['orderProps'][7]['ID'] = 'city'; $arResult['orderProps'][8]['NAME'] = GetMessage('STREET'); $arResult['orderProps'][8]['ID'] = 'street'; $arResult['orderProps'][9]['NAME'] = GetMessage('BUILDING'); $arResult['orderProps'][9]['ID'] = 'building'; $arResult['orderProps'][10]['NAME'] = GetMessage('FLAT'); $arResult['orderProps'][10]['ID'] = 'flat'; $arResult['orderProps'][11]['NAME'] = GetMessage('INTERCOMCODE'); $arResult['orderProps'][11]['ID'] = 'intercomecode'; $arResult['orderProps'][12]['NAME'] = GetMessage('FLOOR'); $arResult['orderProps'][12]['ID'] = 'floor'; $arResult['orderProps'][13]['NAME'] = GetMessage('BLOCK'); $arResult['orderProps'][13]['ID'] = 'block'; $arResult['orderProps'][14]['NAME'] = GetMessage('HOUSE'); $arResult['orderProps'][14]['ID'] = 'house'; //update connection settings if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $api_host = htmlspecialchars(trim($_POST['api_host'])); $api_key = htmlspecialchars(trim($_POST['api_key'])); if($api_host && $api_key) { $api = new IntaroCrm\RestApi($api_host, $api_key); $api->paymentStatusesList(); //check connection & apiKey valid if((int) $api->getStatusCode() != 200) { $uri .= '&errc=ERR_' . $api->getStatusCode(); LocalRedirect($uri); } else { COption::SetOptionString($mid, 'api_host', $api_host); COption::SetOptionString($mid, 'api_key', $api_key); } } //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y", ), false, false, array() ); //form order types ids arr $orderTypesArr = array(); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { do { $orderTypesArr[$arOrderTypesList['ID']] = $_POST['order-type-' . $arOrderTypesList['ID']]; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y", ), false, false, array() ); //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()); } //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y" ) ); //form payment types ids arr $paymentTypesArr = array(); if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) { do { $paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']])); } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch()); } //bitrix paymentStatusesList $dbPaymentStatusesList = CSaleStatus::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "LID" => "ru", //ru "ACTIVE" => "Y" ) ); //form payment statuses ids arr $paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y'])); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']])); } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } //form payment ids arr $paymentArr = array(); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); $propsCount = 0; foreach($arResult['orderProps'] as $orderProp) { if((!(int) htmlspecialchars(trim($_POST['address-detail']))) && $propsCount > 4) break; $orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID']])); $propsCount++; } 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); } else { $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); //prepare crm lists $arResult['orderTypesList'] = $api->orderTypesList(); $arResult['deliveryTypesList'] = $api->deliveryTypesList(); $arResult['paymentTypesList'] = $api->paymentTypesList(); $arResult['paymentStatusesList'] = $api->paymentStatusesList(); // --statuses $arResult['paymentList'] = $api->orderStatusesList(); $arResult['paymentGroupList'] = $api->orderStatusGroupsList(); // -- statuses groups //check connection & apiKey valid if ((int) $api->getStatusCode() != 200) echo CAdminMessage::ShowMessage(GetMessage('ERR_' . $api->getStatusCode())); //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y", ), false, false, array() ); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { do { $arResult['bitrixOrderTypesList'][] = $arOrderTypesList; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y", ), false, false, array() ); if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { do { $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList; } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "ACTIVE" => "Y" ) ); if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) { do { $arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList; } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch()); } //bitrix paymentStatusesList $dbPaymentStatusesList = CSaleStatus::GetList( array( "SORT" => "ASC", "NAME" => "ASC" ), array( "LID" => "ru", //ru "ACTIVE" => "Y" ) ); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList; } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } $arResult['bitrixPaymentStatusesList'][] = array( 'ID' => '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", "TAB" => GetMessage('ICRM_OPTIONS_GENERAL_TAB'), "ICON" => "", "TITLE" => GetMessage('ICRM_OPTIONS_GENERAL_CAPTION') ), array( "DIV" => "edit2", "TAB" => GetMessage('ICRM_OPTIONS_CATALOG_TAB'), "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(); ?> AddHeadString(''); ?>
BeginNextTab(); ?> BeginNextTab(); ?> BeginNextTab(); ?> > 5) echo "checked"; ?>> 4) echo 'class="address-detail"'; if(($countProps > 4) && (count($optionsOrderProps) < 6)) echo 'style="display:none;"';?>> BeginNextTab(); ?> Buttons(); ?> End(); ?>