diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 57f8633f..bd0940cf 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -1,17 +1,17 @@ INSTALL_PATH = $path; - include($path."/version.php"); + include($path . "/version.php"); $this->MODULE_VERSION = $arModuleVersion["VERSION"]; $this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"]; $this->MODULE_NAME = GetMessage('MODULE_NAME'); @@ -55,20 +52,18 @@ class intaro_intarocrm extends CModule * Functions DoInstall and DoUninstall are * All other functions are optional */ - - function DoInstall() - { + function DoInstall() { global $APPLICATION, $step, $arResult; if (!in_array('curl', get_loaded_extensions())) { $APPLICATION->ThrowException(GetMessage("INTAROCRM_CURL_ERR")); return false; } - + if (!date_default_timezone_get()) { if (!ini_get('date.timezone')) { $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR")); - return false; + return false; } } @@ -78,16 +73,88 @@ class intaro_intarocrm extends CModule $step = intval($_REQUEST['step']); + $arResult['orderProps'] = array( + array( + 'NAME' => GetMessage('FIO'), + 'ID' => 'fio' + ), + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('PHONE'), + 'ID' => 'phone' + ), + array( + 'NAME' => GetMessage('EMAIL'), + 'ID' => 'email' + ), + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('ADDRESS'), + 'ID' => 'text' + ), + // address + /* array( + 'NAME' => GetMessage('COUNTRY'), + 'ID' => 'country' + ), + array( + 'NAME' => GetMessage('REGION'), + 'ID' => 'region' + ), + array( + 'NAME' => GetMessage('CITY'), + 'ID' => 'city' + ), */ + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('STREET'), + 'ID' => 'street' + ), + array( + 'NAME' => GetMessage('BUILDING'), + 'ID' => 'building' + ), + array( + 'NAME' => GetMessage('FLAT'), + 'ID' => 'flat' + ), + array( + 'NAME' => GetMessage('INTERCOMECODE'), + 'ID' => 'intercomecode' + ), + array( + 'NAME' => GetMessage('FLOOR'), + 'ID' => 'floor' + ), + array( + 'NAME' => GetMessage('BLOCK'), + 'ID' => 'block' + ), + array( + 'NAME' => GetMessage('HOUSE'), + 'ID' => 'house' + ) + ); + if ($step <= 1) { - if(!CModule::IncludeModule("sale")) { + if (!CModule::IncludeModule("sale")) { $arResult['errCode'] = 'ERR_SALE'; } - if(!CModule::IncludeModule("iblock")) { + if (!CModule::IncludeModule("iblock")) { $arResult['errCode'] = 'ERR_IBLOCK'; } - if(!CModule::IncludeModule("catalog")) { + if (!CModule::IncludeModule("catalog")) { $arResult['errCode'] = 'ERR_CATALOG'; } @@ -97,23 +164,22 @@ class intaro_intarocrm extends CModule $arResult['arSites'][] = $ar; $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); } else if ($step == 2) { - - if(!CModule::IncludeModule("sale")) { + + if (!CModule::IncludeModule("sale")) { $arResult['errCode'] = 'ERR_SALE'; } - if(!CModule::IncludeModule("iblock")) { + if (!CModule::IncludeModule("iblock")) { $arResult['errCode'] = 'ERR_IBLOCK'; } - if(!CModule::IncludeModule("catalog")) { + if (!CModule::IncludeModule("catalog")) { $arResult['errCode'] = 'ERR_CATALOG'; } - + $arResult['arSites'] = array(); $rsSites = CSite::GetList($by, $sort, array()); while ($ar = $rsSites->Fetch()) @@ -121,48 +187,42 @@ class intaro_intarocrm extends CModule if (isset($arResult['errCode']) && $arResult['errCode']) { $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); return; } - - if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') - && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { - + + if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { + $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); - + //prepare crm lists $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList(); - + if ((int) $this->INTARO_CRM_API->getStatusCode() != 200) { $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(array("success" => false))); } - + $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList(); $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList(); $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList(); $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups - //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); - + //form order types ids arr $orderTypesArr = array(); @@ -175,16 +235,12 @@ class intaro_intarocrm extends CModule //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); //form delivery types ids arr @@ -198,13 +254,12 @@ class intaro_intarocrm extends CModule //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y" + ) ); //form payment types ids arr @@ -218,14 +273,13 @@ class intaro_intarocrm extends CModule //bitrix paymentStatusesList $dbPaymentStatusesList = CSaleStatus::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "LID" => "ru", //ru - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "LID" => "ru", //ru + "ACTIVE" => "Y" + ) ); //form payment statuses ids arr @@ -236,7 +290,7 @@ class intaro_intarocrm extends CModule $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']])); } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } - + $arResult['bitrixPaymentStatusesList'][] = array( 'ID' => 'Y', 'NAME' => GetMessage('CANCELED') @@ -252,140 +306,141 @@ class intaro_intarocrm extends CModule COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr)); - + // generate updated select inputs $input = array(); - - foreach($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) { + + foreach ($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) { $input['delivery-type-' . $bitrixDeliveryType['ID']] = - ''; $input['delivery-type-' . $bitrixDeliveryType['ID']] .= ''; - - foreach($arResult['deliveryTypesList'] as $deliveryType) { + + foreach ($arResult['deliveryTypesList'] as $deliveryType) { if ($deliveryTypesArr[$bitrixDeliveryType['ID']] == $deliveryType['code']) { $input['delivery-type-' . $bitrixDeliveryType['ID']] .= - ''; } - + $input['delivery-type-' . $bitrixDeliveryType['ID']] .= ''; } - - foreach($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) { + + foreach ($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) { $input['payment-type-' . $bitrixPaymentType['ID']] = - ''; $input['payment-type-' . $bitrixPaymentType['ID']] .= ''; - - foreach($arResult['paymentTypesList'] as $paymentType) { + + foreach ($arResult['paymentTypesList'] as $paymentType) { if ($paymentTypesArr[$bitrixPaymentType['ID']] == $paymentType['code']) { $input['payment-type-' . $bitrixPaymentType['ID']] .= - ''; } - + $input['payment-type-' . $bitrixPaymentType['ID']] .= ''; } - - foreach($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) { + + foreach ($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) { $input['payment-status-' . $bitrixPaymentStatus['ID']] = - ''; $input['payment-status-' . $bitrixPaymentStatus['ID']] .= ''; - - foreach($arResult['paymentGroupList'] as $orderStatusGroup){ - if(empty($orderStatusGroup['statuses'])) continue; - - $input['payment-status-' . $bitrixPaymentStatus['ID']].= - ''; - - foreach($orderStatusGroup['statuses'] as $payment) { + + foreach ($arResult['paymentGroupList'] as $orderStatusGroup) { + if (empty($orderStatusGroup['statuses'])) + continue; + + $input['payment-status-' . $bitrixPaymentStatus['ID']].= + ''; + + foreach ($orderStatusGroup['statuses'] as $payment) { if ($paymentStatusesArr[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) { $input['payment-status-' . $bitrixPaymentStatus['ID']] .= - ''; } - + $input['payment-status-' . $bitrixPaymentStatus['ID']] .= ''; } - + $input['payment-status-' . $bitrixPaymentStatus['ID']] .= ''; } - - foreach($arResult['bitrixPaymentList'] as $bitrixPayment) { + + foreach ($arResult['bitrixPaymentList'] as $bitrixPayment) { $input['payment-' . $bitrixPayment['ID']] = - ''; $input['payment-' . $bitrixPayment['ID']] .= ''; - - foreach($arResult['paymentStatusesList'] as $paymentStatus) { + + foreach ($arResult['paymentStatusesList'] as $paymentStatus) { if ($paymentArr[$bitrixPayment['ID']] == $paymentStatus['code']) { $input['payment-' . $bitrixPayment['ID']] .= - ''; } - + $input['payment-' . $bitrixPayment['ID']] .= ''; } - - foreach($arResult['bitrixOrderTypesList'] as $bitrixOrderType) { + + foreach ($arResult['bitrixOrderTypesList'] as $bitrixOrderType) { $input['order-type-' . $bitrixOrderType['ID']] = - ''; $input['order-type-' . $bitrixOrderType['ID']] .= ''; - - foreach($arResult['orderTypesList'] as $orderType) { + + foreach ($arResult['orderTypesList'] as $orderType) { if ($orderTypesArr[$bitrixOrderType['ID']] == $orderType['code']) { $input['order-type-' . $bitrixOrderType['ID']] .= - ''; + ''; } - - $input['order-type-' . $bitrixOrderType['ID']] .= ''; + + $input['order-type-' . $bitrixOrderType['ID']] .= ''; } - + $APPLICATION->RestartBuffer(); - header('Content-Type: application/x-javascript; charset='.LANG_CHARSET); - die(json_encode(array("success" => true, "result" => $input))); + header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); + die(json_encode(array("success" => true, "result" => $input))); } $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); - + // empty == select all $orderSites = array(); - foreach($_POST[$this->CRM_ORDER_SITES] as $site) { + foreach ($_POST[$this->CRM_ORDER_SITES] as $site) { $orderSites[] = htmlspecialchars(trim($site)); } @@ -393,11 +448,11 @@ class intaro_intarocrm extends CModule $api_host = parse_url($api_host); $api_host = $api_host['scheme'] . '://' . $api_host['host']; - if(!$api_host || !$api_key) { + if (!$api_host || !$api_key) { $arResult['errCode'] = 'ERR_FIELDS_API_HOST'; $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); return; } @@ -407,12 +462,12 @@ class intaro_intarocrm extends CModule $this->INTARO_CRM_API->paymentStatusesList(); //check connection & apiKey valid - if((int) $this->INTARO_CRM_API->getStatusCode() != 200) { + if ((int) $this->INTARO_CRM_API->getStatusCode() != 200) { $arResult['errCode'] = 'ERR_' . $this->INTARO_CRM_API->getStatusCode(); $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); return; @@ -429,19 +484,14 @@ class intaro_intarocrm extends CModule $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList(); $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups - //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { @@ -449,19 +499,15 @@ class intaro_intarocrm extends CModule $arResult['bitrixOrderTypesList'][] = $arOrderTypesList; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } - + //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { @@ -472,13 +518,12 @@ class intaro_intarocrm extends CModule //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y" + ) ); if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) { @@ -489,14 +534,13 @@ class intaro_intarocrm extends CModule //bitrix paymentStatusesList --statuses $dbPaymentStatusesList = CSaleStatus::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "LID" => "ru", //ru - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "LID" => "ru", //ru + "ACTIVE" => "Y" + ) ); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { @@ -506,50 +550,25 @@ class intaro_intarocrm extends CModule } $arResult['bitrixPaymentStatusesList'][] = array( - 'ID' => 'Y', + 'ID' => 'Y', 'NAME' => GetMessage('CANCELED') ); $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php' + GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php' ); - } else if ($step == 3) { - if(!CModule::IncludeModule("sale")) { + if (!CModule::IncludeModule("sale")) { //handler } - if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') - && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { - ICrmOrderActions::uploadOrders(); // each 50 - - $lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); - $countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array()); - $countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array()); - - if(!isset($_POST['finish'])) - $finish = 0; - else - $finish = (int) $_POST['finish']; - - $percent = round(100 - ($countLeft * 100 / $countAll), 1); - - if(!$countLeft) - $finish = 1; - - $APPLICATION->RestartBuffer(); - header('Content-Type: application/x-javascript; charset='.LANG_CHARSET); - die(json_encode(array("finish" => $finish, "percent" => $percent))); - } - if (isset($_POST['back']) && $_POST['back']) { $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); } - + // 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); @@ -557,16 +576,12 @@ class intaro_intarocrm extends CModule //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); //form order types ids arr @@ -579,21 +594,17 @@ class intaro_intarocrm extends CModule //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y", + ), false, false, array() ); - + //form delivery types ids arr $deliveryTypesArr = array(); - + if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') { if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { do { @@ -614,39 +625,37 @@ class intaro_intarocrm extends CModule $resultDeliveryTypeId = $arId[0]; else $resultDeliveryTypeId = $arDeliveryTypesList['ID']; - + $deliveryTypesArr[$arDeliveryTypesList['ID']] = $resultDeliveryTypeId; - + // send to crm $this->INTARO_CRM_API->deliveryTypeEdit(ICrmOrderActions::clearArr(array( - 'code' => $resultDeliveryTypeId, - 'name' => ICrmOrderActions::toJSON($arDeliveryTypesList['NAME']), - 'defaultCost' => $arDeliveryTypesList['PRICE'], - 'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']), - 'paymentTypes' => '' + '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) { + if ($this->INTARO_CRM_API->getStatusCode() != 200) { if ($this->INTARO_CRM_API->getStatusCode() != 201) { //handle err ICrmOrderActions::eventLog('install/index.php', 'IntaroCrm\RestApi::deliveryTypeEdit', $this->INTARO_CRM_API->getLastError()); } } - } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } } //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "ACTIVE" => "Y" + ) ); //form payment types ids arr @@ -659,14 +668,13 @@ class intaro_intarocrm extends CModule //bitrix paymentStatusesList $dbPaymentStatusesList = CSaleStatus::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "LID" => "ru", //ru - "ACTIVE" => "Y" - ) + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), array( + "LID" => "ru", //ru + "ACTIVE" => "Y" + ) ); //form payment statuses ids arr @@ -682,6 +690,12 @@ class intaro_intarocrm extends CModule $paymentArr = array(); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); + + //form orderProps + $dbProp = CSaleOrderProps::GetList(array(), array()); + while ($arProp = $dbProp->GetNext()) { + $arResult['arProp'][] = $arProp; + } COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr)); @@ -689,87 +703,139 @@ 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); - + $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php' ); } else if ($step == 4) { - if(!CModule::IncludeModule("iblock")) { - $arResult['errCode'] = 'ERR_IBLOCK'; - } - - if(!CModule::IncludeModule("catalog")) { - $arResult['errCode'] = 'ERR_CATALOG'; - } - $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' - ); - - } else if ($step == 5) { - - if(!CModule::IncludeModule("iblock")) { - $arResult['errCode'] = 'ERR_IBLOCK'; + if (!CModule::IncludeModule("sale")) { + //handler } - if(!CModule::IncludeModule("catalog")) { - $arResult['errCode'] = 'ERR_CATALOG'; - } - - if(isset($arResult['errCode']) && $arResult['errCode']) { - $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' - ); - return; + if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') + && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { + ICrmOrderActions::uploadOrders(); // each 50 + + $lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); + $countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array()); + $countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array()); + + if (!isset($_POST['finish'])) + $finish = 0; + else + $finish = (int) $_POST['finish']; + + $percent = round(100 - ($countLeft * 100 / $countAll), 1); + + if (!$countLeft) + $finish = 1; + + $APPLICATION->RestartBuffer(); + header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); + die(json_encode(array("finish" => $finish, "percent" => $percent))); } if (isset($_POST['back']) && $_POST['back']) { $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php' ); } - if(!isset($_POST['IBLOCK_EXPORT'])) + $propsCount = 0; + $orderPropsArr = array(); + foreach ($arResult['orderProps'] as $orderProp) { + if ((!(int) htmlspecialchars(trim($_POST['address-detail']))) && $propsCount > 5) + break; + $orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID']])); + $propsCount++; + } + + $arResult['test'] = $_POST; + + COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_PROPS, serialize($orderPropsArr)); + + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' + ); + + } else if ($step == 5) { + if (!CModule::IncludeModule("iblock")) { + $arResult['errCode'] = 'ERR_IBLOCK'; + } + + if (!CModule::IncludeModule("catalog")) { + $arResult['errCode'] = 'ERR_CATALOG'; + } + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' + ); + } else if ($step == 6) { + + if (!CModule::IncludeModule("iblock")) { + $arResult['errCode'] = 'ERR_IBLOCK'; + } + + if (!CModule::IncludeModule("catalog")) { + $arResult['errCode'] = 'ERR_CATALOG'; + } + + if (isset($arResult['errCode']) && $arResult['errCode']) { + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' + ); + return; + } + + if (isset($_POST['back']) && $_POST['back']) { + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php' + ); + } + + if (!isset($_POST['IBLOCK_EXPORT'])) $arResult['errCode'] = 'ERR_FIELDS_IBLOCK'; else $iblocks = $_POST['IBLOCK_EXPORT']; - - if(!isset($_POST['IBLOCK_PROPERTY_ARTICLE'])) + + if (!isset($_POST['IBLOCK_PROPERTY_ARTICLE'])) $arResult['errCode'] = 'ERR_FIELDS_ARTICLE'; else $articleProperties = $_POST['IBLOCK_PROPERTY_ARTICLE']; - - if(!isset($_POST['SETUP_FILE_NAME'])) + + if (!isset($_POST['SETUP_FILE_NAME'])) $arResult['errCode'] = 'ERR_FIELDS_FILE'; else $filename = $_POST['SETUP_FILE_NAME']; - + if (count($iblocks) < count($articleProperties)) $arResult['errCode'] = 'ERR_ARTICLE_IBLOCK'; - - - if(!isset($_POST['TYPE_LOADING'])) + + + if (!isset($_POST['TYPE_LOADING'])) $typeLoading = 0; else $typeLoading = $_POST['TYPE_LOADING']; - - if(!isset($_POST['SETUP_PROFILE_NAME']) ) + + if (!isset($_POST['SETUP_PROFILE_NAME'])) $profileName = ""; else $profileName = $_POST['SETUP_PROFILE_NAME']; - + if ($typeLoading != 'none' && $profileName == "") $arResult['errCode'] = 'ERR_FIELDS_PROFILE'; - - if($filename == "") + + if ($filename == "") $arResult['errCode'] = 'ERR_FIELDS_FILE'; - - if(isset($arResult['errCode']) && $arResult['errCode']) { - - + + if (isset($arResult['errCode']) && $arResult['errCode']) { + + $arOldValues = Array( 'IBLOCK_EXPORT' => $iblocks, 'IBLOCK_PROPERTY_ARTICLE' => $articleProperties, @@ -779,150 +845,133 @@ class intaro_intarocrm extends CModule global $oldValues; $oldValues = $arOldValues; $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' ); return; } - + RegisterModule($this->MODULE_ID); RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder"); $this->CopyFiles(); if (isset($_POST['LOAD_NOW'])) { - + $loader = new ICMLLoader(); $loader->iblocks = $iblocks; $loader->articleProperties = $articleProperties; $loader->filename = $filename; $loader->application = $APPLICATION; $loader->Load(); - - } - + } + if ($typeLoading == 'agent' || $typeLoading == 'cron') { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) { $dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT)); while ($arProfile = $dbProfile->Fetch()) { - if ($arProfile["DEFAULT_PROFILE"]!="Y") { - CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(".$arProfile['ID'].");", "catalog"); + if ($arProfile["DEFAULT_PROFILE"] != "Y") { + CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(" . $arProfile['ID'] . ");", "catalog"); CCatalogExport::Delete($arProfile['ID']); } } } $ar = $this->GetProfileSetupVars($iblocks, $articleProperties, $filename); $PROFILE_ID = CCatalogExport::Add(array( - "LAST_USE" => false, - "FILE_NAME" => $this->INTARO_CRM_EXPORT, - "NAME" => $profileName, - "DEFAULT_PROFILE" => "N", - "IN_MENU" => "N", - "IN_AGENT" => "N", - "IN_CRON" => "N", - "NEED_EDIT" => "N", - "SETUP_VARS" => $ar - )); + "LAST_USE" => false, + "FILE_NAME" => $this->INTARO_CRM_EXPORT, + "NAME" => $profileName, + "DEFAULT_PROFILE" => "N", + "IN_MENU" => "N", + "IN_AGENT" => "N", + "IN_CRON" => "N", + "NEED_EDIT" => "N", + "SETUP_VARS" => $ar + )); if (intval($PROFILE_ID) <= 0) { $arResult['errCode'] = 'ERR_IBLOCK'; return; } if ($typeLoading == 'agent') { - + $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $dateAgent->add($intAgent); CAgent::AddAgent( - "CCatalogExport::PreGenerateExport(" . $PROFILE_ID . ");", - "catalog", - "N", - 86400, - $dateAgent->format('d.m.Y H:i:s'), // date of first check + "CCatalogExport::PreGenerateExport(" . $PROFILE_ID . ");", "catalog", "N", 86400, $dateAgent->format('d.m.Y H:i:s'), // date of first check "Y", // агент активен $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 - ); - + ); + CCatalogExport::Update($PROFILE_ID, array( - "IN_AGENT" => "Y" - )); + "IN_AGENT" => "Y" + )); } else { $agent_period = 24; $agent_php_path = "/usr/local/php/bin/php"; - if (!file_exists($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php")) - { - CheckDirPath($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS); - $tmp_file_size = filesize($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS_DEF."cron_frame.php"); - $fp = fopen($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS_DEF."cron_frame.php", "rb"); + if (!file_exists($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php")) { + CheckDirPath($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS); + $tmp_file_size = filesize($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS_DEF . "cron_frame.php"); + $fp = fopen($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS_DEF . "cron_frame.php", "rb"); $tmp_data = fread($fp, $tmp_file_size); fclose($fp); $tmp_data = str_replace("#DOCUMENT_ROOT#", $_SERVER["DOCUMENT_ROOT"], $tmp_data); $tmp_data = str_replace("#PHP_PATH#", $agent_php_path, $tmp_data); - $fp = fopen($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php", "ab"); + $fp = fopen($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php", "ab"); fwrite($fp, $tmp_data); fclose($fp); } $cfg_data = ""; - if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg")) - { - $cfg_file_size = filesize($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg"); - $fp = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", "rb"); - $cfg_data = fread($fp, $cfg_file_size); - fclose($fp); + if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg")) { + $cfg_file_size = filesize($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg"); + $fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", "rb"); + $cfg_data = fread($fp, $cfg_file_size); + fclose($fp); } - CheckDirPath($_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."logs/"); - - if ($arProfile["IN_CRON"]=="Y") - { - // remove - $cfg_data = preg_replace("#^.*?".preg_quote(CATALOG_PATH2EXPORTS)."cron_frame.php +".$PROFILE_ID." *>.*?$#im", "", $cfg_data); - } - else - { - $strTime = "0 */".$agent_period." * * * "; - if (strlen($cfg_data)>0) + CheckDirPath($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "logs/"); + + if ($arProfile["IN_CRON"] == "Y") { + // remove + $cfg_data = preg_replace("#^.*?" . preg_quote(CATALOG_PATH2EXPORTS) . "cron_frame.php +" . $PROFILE_ID . " *>.*?$#im", "", $cfg_data); + } else { + $strTime = "0 */" . $agent_period . " * * * "; + if (strlen($cfg_data) > 0) $cfg_data .= "\n"; - - $cfg_data .= $strTime.$agent_php_path." -f ".$_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."cron_frame.php ".$PROFILE_ID." >".$_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS."logs/".$PROFILE_ID.".txt\n"; + + $cfg_data .= $strTime . $agent_php_path . " -f " . $_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php " . $PROFILE_ID . " >" . $_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "logs/" . $PROFILE_ID . ".txt\n"; } CCatalogExport::Update($PROFILE_ID, array( - "IN_CRON" => "Y" - )); - - CheckDirPath($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/"); + "IN_CRON" => "Y" + )); + + CheckDirPath($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/"); $cfg_data = preg_replace("#[\r\n]{2,}#im", "\n", $cfg_data); - $fp = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", "wb"); + $fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", "wb"); fwrite($fp, $cfg_data); fclose($fp); $arRetval = array(); - @exec("crontab ".$_SERVER["DOCUMENT_ROOT"]."/bitrix/crontab/crontab.cfg", $arRetval, $return_var); - - } + @exec("crontab " . $_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", $arRetval, $return_var); + } } - - // //agent - $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $dateAgent->add($intAgent); CAgent::AddAgent( - "ICrmOrderActions::uploadOrdersAgent();", - $this->MODULE_ID, - "N", - 600, // interval - 10 mins - $dateAgent->format('d.m.Y H:i:s'), // date of first check - "Y", // агент активен - $dateAgent->format('d.m.Y H:i:s'), // date of first start - 30 + "ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID, "N", 600, // interval - 10 mins + $dateAgent->format('d.m.Y H:i:s'), // date of first check + "Y", // агент активен + $dateAgent->format('d.m.Y H:i:s'), // date of first start + 30 ); $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); @@ -931,8 +980,8 @@ class intaro_intarocrm extends CModule $this->INTARO_CRM_API->statisticUpdate(); $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php' ); } } @@ -940,7 +989,7 @@ class intaro_intarocrm extends CModule function DoUninstall() { global $APPLICATION; - CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID); + CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION); @@ -949,38 +998,34 @@ class intaro_intarocrm extends CModule COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID); - + UnRegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder"); UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder"); - if(CModule::IncludeModule("catalog")) { + if (CModule::IncludeModule("catalog")) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) { $dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT)); while ($arProfile = $dbProfile->Fetch()) { - if ($arProfile["DEFAULT_PROFILE"]!="Y") { - CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(".$arProfile['ID'].");", "catalog"); + if ($arProfile["DEFAULT_PROFILE"] != "Y") { + CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(" . $arProfile['ID'] . ");", "catalog"); CCatalogExport::Delete($arProfile['ID']); } } } } - + $this->DeleteFiles(); UnRegisterModule($this->MODULE_ID); $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_UNINSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php' + GetMessage('MODULE_UNINSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php' ); - } function CopyFiles() { CopyDirFiles( - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', - true, true + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true ); } @@ -988,23 +1033,23 @@ class intaro_intarocrm extends CModule unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php'); unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php'); } - + function GetProfileSetupVars($iblocks, $articleProperties, $filename) { // Get string like IBLOCK_EXPORT[0]=3& // IBLOCK_EXPORT[1]=6& // IBLOCK_PROPERTY_ARTICLE[0]=ARTICLE& // IBLOCK_PROPERTY_ARTICLE[1]=ARTNUMBER& // SETUP_FILE_NAME=%2Fbitrix%2Fcatalog_export%2Ftestintarocrm.xml - //$arProfileFields = explode(",", $SETUP_FIELDS_LIST); $strVars = ""; - foreach ($iblocks as $key => $val) + foreach ($iblocks as $key => $val) $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; - foreach ($articleProperties as $key => $val) + foreach ($articleProperties as $key => $val) $strVars .= 'IBLOCK_PROPERTY_ARTICLE[' . $key . ']=' . $val . '&'; - + $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); - + return $strVars; } + } \ No newline at end of file diff --git a/intaro.intarocrm/install/step3.php b/intaro.intarocrm/install/step3.php index 5a5658fb..eea3f901 100755 --- a/intaro.intarocrm/install/step3.php +++ b/intaro.intarocrm/install/step3.php @@ -2,168 +2,30 @@ if (!check_bitrix_sessid()) return; IncludeModuleLangFile(__FILE__); + +$defaultOrderProps = array( + 'fio' => 'FIO', + 'index' => 'ZIP', + 'text' => 'ADDRESS', + 'phone' => 'PHONE', + 'email' => 'EMAIL' +); + ?> - - - +
@@ -171,33 +33,53 @@ IncludeModuleLangFile(__FILE__); -
- - - - - - -
-
-
-
-
-
-
0%
-
- 0% -
-
-
+ + + + + + + + + + + + + + + + 5) echo 'class="address-detail"'; if (($countProps > 5) && (count($defaultOrderProps) < 6)) echo 'style="display:none;"'; ?>> + + + + + +
+ + + + +
+ + + +

" class="adm-btn-save">
- " class="adm-btn-save"> + " class="adm-btn-save">
-
-
\ No newline at end of file + +
\ No newline at end of file diff --git a/intaro.intarocrm/install/step4.php b/intaro.intarocrm/install/step4.php index 246c11dd..e10d025b 100644 --- a/intaro.intarocrm/install/step4.php +++ b/intaro.intarocrm/install/step4.php @@ -1,263 +1,203 @@ -

- -
-

- + .instal-load-block { /* */ } + + .instal-load-label { + color: #000; + margin-bottom: 15px; + } + + .instal-progress-bar-outer { + height: 32px; + border:1px solid; + border-color:#9ba6a8 #b1bbbe #bbc5c9 #b1bbbe; + -webkit-box-shadow: 1px 1px 0 #fff, inset 0 2px 2px #c0cbce; + box-shadow: 1px 1px 0 #fff, inset 0 2px 2px #c0cbce; + background-color:#cdd8da; + background-image:-webkit-linear-gradient(top, #cdd8da, #c3ced1); + background-image:-moz-linear-gradient(top, #cdd8da, #c3ced1); + background-image:-ms-linear-gradient(top, #cdd8da, #c3ced1); + background-image:-o-linear-gradient(top, #cdd8da, #c3ced1); + background-image:linear-gradient(top, #ced9db, #c3ced1); + border-radius: 2px; + text-align: center; + color: #6a808e; + text-shadow: 0 1px rgba(255,255,255,0.85); + font-size: 18px; + line-height: 35px; + font-weight: bold; } - $boolAll = false; - $intCountChecked = 0; - $intCountAvailIBlock = 0; - $arIBlockList = array(); - $db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); - while ($res = $db_res->Fetch()) - { - if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) - { - if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") - { - $arSiteList = array(); - $rsSites = CIBlock::GetSite($res["ID"]); - while ($arSite = $rsSites->Fetch()) - { - $arSiteList[] = $arSite["SITE_ID"]; - } - $db_properties = CIBlock::GetProperties($res['ID'], Array()); + .instal-progress-bar-alignment { + height: 28px; + margin: 0; + position: relative; + } - $properties = Array(); - while($prop = $db_properties->Fetch()) - $properties[] = $prop; + .instal-progress-bar-inner { + height: 28px; + border-radius: 2px; + border-top: solid 1px #52b9df; + background-color:#2396ce; + background-image:-webkit-linear-gradient(top, #27a8d7, #2396ce, #1c79c0); + background-image:-moz-linear-gradient(top, #27a8d7, #2396ce, #1c79c0); + background-image:-ms-linear-gradient(top, #27a8d7, #2396ce, #1c79c0); + background-image:-o-linear-gradient(top, #27a8d7, #2396ce, #1c79c0); + background-image:linear-gradient(top, #27a8d7, #2396ce, #1c79c0); + position: absolute; + overflow: hidden; + top: 1px; + left:0; + } - if (count($IBLOCK_EXPORT) != 0) - $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); - else - $boolExport = true; + .instal-progress-bar-inner-text { + color: #fff; + text-shadow: 0 1px rgba(0,0,0,0.2); + font-size: 18px; + line-height: 32px; + font-weight: bold; + text-align: center; + position: absolute; + left: -2px; + top: -2px; + } + - $arIBlockList[] = array( - 'ID' => $res['ID'], - 'NAME' => $res['NAME'], - 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], - 'IBLOCK_EXPORT' => $boolExport, - 'PROPERTIES' => $properties, - 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, - 'SITE_LIST' => '('.implode(' ',$arSiteList).')', - ); - - if ($boolExport) - $intCountChecked++; - $intCountAvailIBlock++; - } + + - ?> - - - - - - - - - - - - - - - - - - $arIBlock) - { - ?> - - - - - - - -
-
-
-
-   -
-
-
-
- - - > - - -   -
- - - - ]" - id="IBLOCK_EXPORT" - value="" - - onclick="checkOne(this,);" - > - - - -
- -
-
-
- -

- - -
-
-
- -

-
-
-
-
-
-   - -
-
-
- -
-   - " - size="30"> -
-
-
-
- - - - - - - - - + + + +
+ + + + + + +
+
+
+
+
+
+
0%
+
+ 0% +
+
+
+
" class="adm-btn-save">
-
- " class="adm-btn-save"> +
+ " class="adm-btn-save">
- - - +
+ \ No newline at end of file diff --git a/intaro.intarocrm/install/step5.php b/intaro.intarocrm/install/step5.php index 0f8fd95c..4b19cc2c 100644 --- a/intaro.intarocrm/install/step5.php +++ b/intaro.intarocrm/install/step5.php @@ -1,11 +1,263 @@ -
- - - - "> - +if(!check_bitrix_sessid()) return; +IncludeModuleLangFile(__FILE__); +__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro.intarocrm/lang/", "/icml_export_setup.php")); +?> +

+ + +

+ "ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); + while ($res = $db_res->Fetch()) + { + if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) + { + if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") + { + $arSiteList = array(); + $rsSites = CIBlock::GetSite($res["ID"]); + while ($arSite = $rsSites->Fetch()) + { + $arSiteList[] = $arSite["SITE_ID"]; + } + $db_properties = CIBlock::GetProperties($res['ID'], Array()); + + $properties = Array(); + while($prop = $db_properties->Fetch()) + $properties[] = $prop; + + if (count($IBLOCK_EXPORT) != 0) + $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); + else + $boolExport = true; + + $arIBlockList[] = array( + 'ID' => $res['ID'], + 'NAME' => $res['NAME'], + 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], + 'IBLOCK_EXPORT' => $boolExport, + 'PROPERTIES' => $properties, + 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, + 'SITE_LIST' => '('.implode(' ',$arSiteList).')', + ); + + if ($boolExport) + $intCountChecked++; + $intCountAvailIBlock++; + } + } + } + if (count($IBLOCK_EXPORT) != 0) { + if ($intCountChecked == $intCountAvailIBlock) + $boolAll = true; + } else { + $intCountChecked = $intCountAvailIBlock; + $boolAll = true; + } + + ?> + + + + + + + + + + + + + + + + + + $arIBlock) + { + ?> + + + + + + + +
+
+
+
+   +
+
+
+
+ + + > + + +   +
+ + + + ]" + id="IBLOCK_EXPORT" + value="" + + onclick="checkOne(this,);" + > + + + +
+ +
+
+
+ +

+ + +
+
+
+ +

+
+
+
+
+
+   + +
+
+
+ +
+   + " + size="30"> +
+
+
+
+ + + + + + + + + + + + + +
+
+ " class="adm-btn-save"> +
+
+ " class="adm-btn-save"> +
+
+
+ + diff --git a/intaro.intarocrm/install/step6.php b/intaro.intarocrm/install/step6.php new file mode 100644 index 00000000..0f8fd95c --- /dev/null +++ b/intaro.intarocrm/install/step6.php @@ -0,0 +1,11 @@ + + +
+ + + + "> + diff --git a/intaro.intarocrm/lang/ru/install/index.php b/intaro.intarocrm/lang/ru/install/index.php index 60196348..9d10c0ef 100755 --- a/intaro.intarocrm/lang/ru/install/index.php +++ b/intaro.intarocrm/lang/ru/install/index.php @@ -12,4 +12,23 @@ $MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальн $MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.'; $MESS ['INTAROCRM_CURL_ERR'] = 'Для работы модуля интеграции с IntaroCRM требуется PHP-расширение CURL.'; $MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы'; -$MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона в настройках php.'; \ No newline at end of file +$MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона в настройках php.'; + +$MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа IntaroCRM свойствам заказа 1С-Битрикс'; +$MESS ['FIO'] = 'ф.И.О.'; +$MESS ['ZIP'] = 'Индекс'; +$MESS ['ADDRESS'] = 'Адрес (строкой)'; +$MESS ['PHONE'] = 'Телефон'; +$MESS ['EMAIL'] = 'E-mail'; +$MESS ['COUNTRY'] = 'Страна'; +$MESS ['REGION'] = 'Область / Край'; +$MESS ['CITY'] = 'Город'; +$MESS ['STREET'] = 'Улица'; +$MESS ['BUILDING'] = 'Строение'; +$MESS ['FLAT'] = 'Квартира'; +$MESS ['INTERCOMCODE'] = 'Домофон'; +$MESS ['FLOOR'] = 'Этаж'; +$MESS ['BLOCK'] = 'Подъезд'; +$MESS ['HOUSE'] = 'Строение / корпус'; +$MESS ['ADDRESS_SHORT'] = 'Краткий адрес'; +$MESS ['ADDRESS_FULL'] = 'Детальный адрес'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step3.php b/intaro.intarocrm/lang/ru/install/step3.php index 4646e95c..1bdef3a1 100755 --- a/intaro.intarocrm/lang/ru/install/step3.php +++ b/intaro.intarocrm/lang/ru/install/step3.php @@ -10,3 +10,23 @@ $MESS ['START_1'] = 'Начать выгрузку'; $MESS ['START_2'] = 'Приостановить выгрузку'; $MESS ['START_3'] = 'Возобновить выгрузку'; $MESS ['MOD_NEXT_STEP'] = 'Следующий шаг'; +$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг'; + +$MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа IntaroCRM свойствам заказа 1С-Битрикс'; +$MESS ['FIO'] = 'ф.И.О.'; +$MESS ['ZIP'] = 'Индекс'; +$MESS ['ADDRESS'] = 'Адрес (строкой)'; +$MESS ['PHONE'] = 'Телефон'; +$MESS ['EMAIL'] = 'E-mail'; +$MESS ['COUNTRY'] = 'Страна'; +$MESS ['REGION'] = 'Область / Край'; +$MESS ['CITY'] = 'Город'; +$MESS ['STREET'] = 'Улица'; +$MESS ['BUILDING'] = 'Строение'; +$MESS ['FLAT'] = 'Квартира'; +$MESS ['INTERCOMCODE'] = 'Домофон'; +$MESS ['FLOOR'] = 'Этаж'; +$MESS ['BLOCK'] = 'Подъезд'; +$MESS ['HOUSE'] = 'Строение / корпус'; +$MESS ['ADDRESS_SHORT'] = 'Краткий адрес'; +$MESS ['ADDRESS_FULL'] = 'Детальный адрес'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step4.php b/intaro.intarocrm/lang/ru/install/step4.php old mode 100755 new mode 100644 index 2c2b095c..2dd25661 --- a/intaro.intarocrm/lang/ru/install/step4.php +++ b/intaro.intarocrm/lang/ru/install/step4.php @@ -1,24 +1,12 @@ Дальнейшие действия

-

- Если вы произвели выгрузку заказов на шаге 3, то эти заказы уже доступны в вашей CRM и - через некоторое время по этим заказам будет подготовлены аналитические отчеты в Панели KPI. -

-

- Новые заказы будут отправляться агентом ICrmOrderActions::uploadOrdersAgent(); - в IntaroCRM каждые 10 минут (интервал можно изменить в разделе Агенты). -

-

- Если вы выбрали опцию «Выгрузить каталог сейчас» на шаге 4, то ваш каталог уже загружается в IntaroCRM. - Загрузка длится, как правило, не более 10 минут. Если вы не выбирали эту опцию, то генерацию файла с каталогом - можно произвести экспортом «IntaroCRM» в разделе Магазин > Настройки > Экспорт данных. - IntaroCRM проверяет и загружает данный файл с каталогом каждые 3 часа. -

-'; +$MESS ['STEP_NAME'] = 'Шаг 5'; +$MESS ['MOD_NEXT_STEP'] = 'Завершить установку'; +$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг'; +$MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки'; +$MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты'; +$MESS ['PAYMENT_STATUS_LIST'] = 'Статусы'; +$MESS ['ORDER_TYPES_LIST'] = 'Типы заказа'; +$MESS ['PAYMENT_LIST'] = 'Оплата'; +$MESS ['PAYMENT_Y'] = 'Оплачен'; +$MESS ['PAYMENT_N'] = 'Не оплачен'; +$MESS ['CANCELED'] = 'Флаг «Отменен»'; +$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; +$MESS ['LOAD_PERIOD'] = 'Выгружать каталог периодически'; +$MESS ['NOT_LOADING'] = 'Нет'; +$MESS ['CRON_LOADING'] = 'С помощью CRON каждые 24 часа'; +$MESS ['AGENT_LOADING'] = 'Агентом каждые 24 часа (по умолчанию)'; +$MESS ['LOAD_NOW'] = 'Выгрузить сейчас'; +$MESS ['PROFILE_NAME'] = 'Имя профиля:'; +$MESS ['PROFILE_NAME_EXAMPLE'] = 'Выгрузка каталога IntaroCRM'; +$MESS ['ERR_FIELDS_PROFILE'] = 'Неверно заполнено поле имени профиля'; +$MESS ['ERR_FIELDS_IBLOCK'] = 'Не выбрано ни одного информационного блока'; +$MESS ['ERR_FIELDS_ARTICLE'] = 'Не выбраны артикулы'; +$MESS ['ERR_FIELDS_FILE'] = 'Не указано имя файла'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step6.php b/intaro.intarocrm/lang/ru/install/step6.php new file mode 100755 index 00000000..354c4b4a --- /dev/null +++ b/intaro.intarocrm/lang/ru/install/step6.php @@ -0,0 +1,18 @@ +Дальнейшие действия

+

+ Если вы произвели выгрузку заказов на шаге 3, то эти заказы уже доступны в вашей CRM и + через некоторое время по этим заказам будет подготовлены аналитические отчеты в Панели KPI. +

+

+ Новые заказы будут отправляться агентом ICrmOrderActions::uploadOrdersAgent(); + в IntaroCRM каждые 10 минут (интервал можно изменить в разделе Агенты). +

+

+ Если вы выбрали опцию «Выгрузить каталог сейчас» на шаге 4, то ваш каталог уже загружается в IntaroCRM. + Загрузка длится, как правило, не более 10 минут. Если вы не выбирали эту опцию, то генерацию файла с каталогом + можно произвести экспортом «IntaroCRM» в разделе Магазин > Настройки > Экспорт данных. + IntaroCRM проверяет и загружает данный файл с каталогом каждые 3 часа. +

+'; diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index 8b4e4a69..df1c1fd5 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -26,37 +26,77 @@ if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('I $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'; +$arResult['orderProps'] = array( + array( + 'NAME' => GetMessage('FIO'), + 'ID' => 'fio' + ), + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('PHONE'), + 'ID' => 'phone' + ), + array( + 'NAME' => GetMessage('EMAIL'), + 'ID' => 'email' + ), + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('ADDRESS'), + 'ID' => 'text' + ), + // address + /* array( + 'NAME' => GetMessage('COUNTRY'), + 'ID' => 'country' + ), + array( + 'NAME' => GetMessage('REGION'), + 'ID' => 'region' + ), + array( + 'NAME' => GetMessage('CITY'), + 'ID' => 'city' + ),*/ + array( + 'NAME' => GetMessage('ZIP'), + 'ID' => 'index' + ), + array( + 'NAME' => GetMessage('STREET'), + 'ID' => 'street' + ), + array( + 'NAME' => GetMessage('BUILDING'), + 'ID' => 'building' + ), + array( + 'NAME' => GetMessage('FLAT'), + 'ID' => 'flat' + ), + array( + 'NAME' => GetMessage('INTERCOMECODE'), + 'ID' => 'intercomecode' + ), + array( + 'NAME' => GetMessage('FLOOR'), + 'ID' => 'floor' + ), + array( + 'NAME' => GetMessage('BLOCK'), + 'ID' => 'block' + ), + array( + 'NAME' => GetMessage('HOUSE'), + 'ID' => 'house' + ) +); //update connection settings if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { @@ -175,7 +215,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $propsCount = 0; $orderPropsArr = array(); foreach($arResult['orderProps'] as $orderProp) { - if((!(int) htmlspecialchars(trim($_POST['address-detail']))) && $propsCount > 4) + if((!(int) htmlspecialchars(trim($_POST['address-detail']))) && $propsCount > 5) break; $orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID']])); $propsCount++; @@ -501,7 +541,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { - 4) echo 'class="address-detail"'; if(($countProps > 4) && (count($optionsOrderProps) < 6)) echo 'style="display:none;"';?>> + 5) echo 'class="address-detail"'; if(($countProps > 5) && (count($optionsOrderProps) < 6)) echo 'style="display:none;"';?>>