function OnPostForm() { $wizard =& $this->GetWizard(); if ($wizard->IsNextButtonClick()) { $arResult = $wizard->GetVars(true); COption::SetOptionString("sale", "order_email", $arResult["orderEmail"]); COption::SetOptionString("sale", "delete_after", $arResult["saveBasket"]); COption::SetOptionString("sale", "default_currency", $arResult["currencyID"]); $arFields["LID"] = $arResult["siteID"]; $arFields["CURRENCY"] = $arResult["currencyID"]; CSaleLang::Update($arResult["siteID"], array("LID" => $arResult["siteID"], "CURRENCY" => $arResult["currencyID"])); CSaleGroupAccessToSite::DeleteBySite($arResult["siteID"]); foreach ($arResult["groupID"] as $v) { CSaleGroupAccessToSite::Add(array("SITE_ID" => $arResult["siteID"], "GROUP_ID" => $v)); } if (!empty($arResult["1C_GROUP_PERMISSIONS"])) { COption::SetOptionString("catalog", "1C_GROUP_PERMISSIONS", implode(",", $arResult["1C_GROUP_PERMISSIONS"])); } COption::SetOptionString("catalog", "1C_ELEMENT_ACTION", $arResult["1C_ELEMENT_ACTION"]); COption::SetOptionString("catalog", "1C_SECTION_ACTION", $arResult["1C_SECTION_ACTION"]); COption::SetOptionString("catalog", "1C_INTERVAL", $arResult["1C_INTERVAL"]); COption::SetOptionString("catalog", "1C_FILE_SIZE_LIMIT", $arResult["1C_FILE_SIZE_LIMIT"]); COption::SetOptionString("catalog", "1C_SITE_LIST", $arResult["siteID"]); if (!empty($arResult["1C_GROUP_PERMISSIONS"])) { COption::SetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", implode(",", $arResult["1C_GROUP_PERMISSIONS"])); } COption::SetOptionString("sale", "1C_EXPORT_PAYED_ORDERS", $arResult["1C_EXPORT_PAYED_ORDERS"]); COption::SetOptionString("sale", "1C_EXPORT_ALLOW_DELIVERY_ORDERS", $arResult["1C_EXPORT_ALLOW_DELIVERY_ORDERS"]); COption::SetOptionString("sale", "1C_EXPORT_FINAL_ORDERS", $arResult["1C_EXPORT_FINAL_ORDERS"]); COption::SetOptionString("sale", "1C_FINAL_STATUS_ON_DELIVERY", $arResult["1C_FINAL_STATUS_ON_DELIVERY"]); COption::SetOptionString("sale", "1C_SALE_SITE_LIST", $arResult["siteID"]); foreach ($arResult["groupID"] as $v) { $perm = $GLOBALS["APPLICATION"]->GetGroupRight("sale", $v); if ($perm != "W") { $GLOBALS["APPLICATION"]->SetGroupRight("sale", $v, "U"); } } $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"]), false, false, array("ID", "LID", "SORT")); while ($arStatus = $dbStatus->Fetch()) { $arPerms = array(); foreach ($arResult["groupID"] as $v) { $arPerms[] = array("GROUP_ID" => $v, "PERM_VIEW" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELETE"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_UPDATE"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_PAYMENT"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELIVERY"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_CANCEL"] == "Y" ? "Y" : $arResult["perm"][$arStatus["ID"]][$v]["PERM_VIEW"], "PERM_CANCEL" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_CANCEL"], "PERM_MARK" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_MARK"], "PERM_DEDUCTION" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DEDUCTION"], "PERM_DELIVERY" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELIVERY"], "PERM_PAYMENT" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_PAYMENT"], "PERM_STATUS" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_STATUS"], "PERM_STATUS_FROM" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_STATUS_FROM"], "PERM_UPDATE" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_UPDATE"], "PERM_DELETE" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELETE"]); } CSaleStatus::Update($arStatus["ID"], array("PERMS" => $arPerms, "SORT" => $arStatus["SORT"])); } $paySystemID = array(); $paySystem = array(); foreach ($arResult["paySystem"] as $pType => $pSystem) { if (!empty($pSystem)) { foreach ($pSystem as $v) { $paySystem[$v][] = $pType; if (!in_array($v, $paySystemID)) { $paySystemID[] = $v; } } } } $dbPaySys = CSalePaySystem::GetList(array(), array("ACTIVE" => "Y"), false, false, array("ID", "ACTIVE")); while ($arPaySys = $dbPaySys->Fetch()) { if (!in_array($arPaySys["ID"], $paySystemID)) { CSalePaySystem::Update($arPaySys["ID"], array("ACTIVE" => "N")); } } foreach ($paySystem as $pID => $value) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID)); while ($arPaySysAction = $dbPaySysAction->Fetch()) { if (!in_array($arPaySysAction["PERSON_TYPE_ID"], $value)) { CSalePaySystemAction::Delete($arPaySysAction["ID"]); } } } function LocalGetPSActionParams($fileName) { $arPSCorrespondence = array(); if (file_exists($fileName) && is_file($fileName)) { include $fileName; } return $arPSCorrespondence; } foreach ($paySystem as $pID => $value) { foreach ($value as $personID) { $arFields = array(); $arPaySysAction = ""; $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID, "PERSON_TYPE_ID" => $personID)); if ($arPaySysAction = $dbPaySysAction->Fetch()) { $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; } else { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID)); if ($arPaySysActionTmp = $dbPaySysAction->Fetch()) { $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysActionTmp["ACTION_FILE"]; } } if (strlen($pathToAction) > 0) { $arPSCorrespondence = LocalGetPSActionParams($pathToAction . "/.description.php"); $arParams = array(); foreach ($arPSCorrespondence as $k => $v) { $typeTmp = $arResult[$pID . "_" . $k . "_" . $personID]; $valueTmp = $arResult["VALUE1_" . $pID . "_" . $k . "_" . $personID]; if (strlen($valueTmp) <= 0) { $valueTmp = $arResult["VALUE2_" . $pID . "_" . $k . "_" . $personID]; } $arParams[$k] = array("TYPE" => $typeTmp, "VALUE" => $valueTmp); } $arFields = array("NEW_WINDOW" => $arResult["paySystemPopup"][$pID][$personID], "PARAMS" => CSalePaySystemAction::SerializeParams($arParams)); if (IntVal($arPaySysAction["ID"]) > 0) { CSalePaySystemAction::Update($arPaySysAction["ID"], $arFields); } else { $arFields["PAY_SYSTEM_ID"] = $pID; $arFields["PERSON_TYPE_ID"] = $personID; $arFields["NAME"] = $arPaySysActionTmp["NAME"]; $arFields["ACTION_FILE"] = $arPaySysActionTmp["ACTION_FILE"]; $arFields["HAVE_PREPAY"] = "N"; $arFields["HAVE_RESULT"] = "N"; $arFields["HAVE_ACTION"] = "N"; $arFields["HAVE_PAYMENT"] = "N"; $arFields["HAVE_RESULT_RECEIVE"] = "N"; if (file_exists($pathToAction)) { if (is_dir($pathToAction)) { if (file_exists($pathToAction . "/pre_payment.php")) { $arFields["HAVE_PREPAY"] = "Y"; } if (file_exists($pathToAction . "/result.php")) { $arFields["HAVE_RESULT"] = "Y"; } if (file_exists($pathToAction . "/action.php")) { $arFields["HAVE_ACTION"] = "Y"; } if (file_exists($pathToAction . "/payment.php")) { $arFields["HAVE_PAYMENT"] = "Y"; } if (file_exists($pathToAction . "/result_rec.php")) { $arFields["HAVE_RESULT_RECEIVE"] = "Y"; } } else { $arFields["HAVE_PAYMENT"] = "Y"; } } CSalePaySystemAction::Add($arFields); } } } } COption::SetOptionInt("sale", "location", $arResult["location"], false, $arResult["siteID"]); if (empty($arResult["delivery"])) { $arResult["delivery"] = array(); } $dbDelivery = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arResult["siteID"], "ACTIVE" => "Y")); while ($arDelivery = $dbDelivery->Fetch()) { if (!in_array($arDelivery["SID"] . "_new", $arResult["delivery"])) { CSaleDeliveryHandler::Set($arDelivery["SID"], array("ACTIVE" => "N")); } } $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"], "ACTIVE" => "Y")); while ($arDelivery = $dbDelivery->Fetch()) { if (!in_array($arDelivery["ID"], $arResult["delivery"])) { CSaleDelivery::Update($arDelivery["ID"], array("ACTIVE" => "N")); } } if (strlen($arResult["login"]) > 0) { $arFields = array("LOGIN" => $arResult["login"], "PASSWORD" => $arResult["password"], "CONFIRM_PASSWORD" => $arResult["password_rep"], "EMAIL" => $arResult["email"]); $user = new CUser(); $ID = $user->Add($arFields); if (IntVal($ID) > 0) { $sGroups = COption::GetOptionString("main", "new_user_registration_def_group", ""); CUser::SetUserGroup($ID, array_merge(explode(",", $sGroups), $arResult["1C_GROUP_PERMISSIONS"])); } } } }
/** * @param $params * @override * @return array */ public function onPrepareComponentParams($params) { $params = parent::onPrepareComponentParams($params); if (!isset($params["CACHE_TIME"])) { $params["CACHE_TIME"] = 86400; } $params["DETAIL_URL"] = trim($params["DETAIL_URL"]); if (isset($params["BY"]) && is_array($params["BY"])) { if (count($params["BY"])) { $params["BY"] = array_values($params["BY"]); $params["BY"] = $params["BY"][0]; } else { $params["BY"] = "AMOUNT"; } } if (!isset($params["BY"]) || !strlen(trim($params["BY"]))) { $params["BY"] = "AMOUNT"; } if (isset($params["PERIOD"])) { if (is_array($params["PERIOD"])) { if (count($params["PERIOD"])) { $params["PERIOD"] = array_values($params["PERIOD"]); $params["PERIOD"] = $params["PERIOD"][0]; } else { $params["PERIOD"] = 0; } } else { $params["PERIOD"] = (int) $params["PERIOD"]; if ($params["PERIOD"] < 0) { $params["PERIOD"] = 0; } } } else { $params["PERIOD"] = 0; } if (!isset($params['FILTER']) || empty($params['FILTER']) || !is_array($params['FILTER'])) { $params['FILTER'] = array(); } if (Loader::includeModule("sale")) { $statuses = array("CANCELED", "ALLOW_DELIVERY", "PAYED", "DEDUCTED"); $saleStatusIterator = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => $this->getLanguageId()), false, false, array("ID")); while ($row = $saleStatusIterator->Fetch()) { $statuses[] = $row['ID']; } foreach ($params['FILTER'] as $key => $status) { if (!in_array($status, $statuses)) { unset($params['FILTER'][$key]); } } } return $params; }
/** * Returns status list * This method must be called by event OnCrmStatusGetList from crm.config.status/component.php * RegisterModuleDependences('crm', 'OnCrmStatusGetList', 'crm', 'CCrmStatusInvoice', 'getStatusList'); * @return array Status list */ public static function getStatusList($entityId = 'INVOICE_STATUS') { if (!CModule::IncludeModule('sale')) { return array(); } if ($entityId != 'INVOICE_STATUS') { return array(); } $arStatus = array(); self::ensureLanguageDefined(); $res = CSaleStatus::GetList(array('SORT' => 'ASC'), array('LID' => self::$languageID), false, false, array('ID', 'SORT', 'NAME')); while ($row = $res->Fetch()) { if ($row['ID'] === 'F') { continue; } $arStatus[$row['ID']] = array('ID' => ord($row['ID']), 'ENTITY_ID' => 'INVOICE_STATUS', 'STATUS_ID' => $row['ID'], 'NAME' => $row['NAME'], 'NAME_INIT' => '', 'SORT' => $row['SORT'], 'SYSTEM' => 'N'); if (in_array($row['ID'], array('N', 'P', 'F', 'D'))) { if ($row['ID'] === 'F') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_F'); } elseif ($row['ID'] === 'D') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_D'); } elseif ($row['ID'] === 'N') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_N'); } elseif ($row['ID'] === 'P') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_P'); } $arStatus[$row['ID']]['SYSTEM'] = 'Y'; } } return $arStatus; }
/** * Function returns reference data as shared cache between this component and sale.personal.order.list. * * @throws Exception * @return void */ protected function obtainDataReferences() { if ($this->startCache(array('spo-shared'))) { try { $cachedData = array(); ///////////////////// ///////////////////// // Person type $dbPType = CSalePersonType::GetList(array("SORT" => "ASC")); while ($arPType = $dbPType->Fetch()) { $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType; } // Save statuses for Filter form $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID)); while ($arStatus = $dbStatus->Fetch()) { $cachedData['STATUS'][$arStatus["ID"]] = $arStatus; } $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC")); while ($arPaySystem = $dbPaySystem->Fetch()) { $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem; } $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC")); while ($arDelivery = $dbDelivery->Fetch()) { $cachedData['DELIVERY'][$arDelivery["ID"]] = $arDelivery; } $dbDelivery = CSaleDeliveryHandler::GetList(array(), array(array("SITE_ID" => SITE_ID))); while ($arDeliveryHandler = $dbDelivery->Fetch()) { $cachedData['DELIVERY_HANDLERS'][$arDeliveryHandler["SID"]] = $arDeliveryHandler; } ///////////////////// ///////////////////// } catch (Exception $e) { $this->abortCache(); throw $e; } $this->endCache($cachedData); } else { $cachedData = $this->getCacheData(); } $this->dbResult = array_merge($this->dbResult, $this->adaptCachedReferences($cachedData)); }
function DeliverOrder($ID, $val, $recurringID = 0, $arAdditionalFields = array()) { global $DB, $USER; $ID = IntVal($ID); $val = $val != "Y" ? "N" : "Y"; $recurringID = IntVal($recurringID); $NO_CHANGE_STATUS = "N"; if (is_set($arAdditionalFields["NOT_CHANGE_STATUS"]) && $arAdditionalFields["NOT_CHANGE_STATUS"] == "Y") { $NO_CHANGE_STATUS = "Y"; unset($arAdditionalFields["NOT_CHANGE_STATUS"]); } if ($ID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_NO_ORDER_ID"), "NO_ORDER_ID"); return False; } $arOrder = CSaleOrder::GetByID($ID); if (!$arOrder) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_NO_ORDER")), "NO_ORDER"); return False; } if ($arOrder["ALLOW_DELIVERY"] == $val) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_DUB_DELIVERY")), "ALREADY_FLAG"); return False; } foreach (GetModuleEvents("sale", "OnSaleBeforeDeliveryOrder", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, $val, $recurringID, $arAdditionalFields)) === false) { return false; } } $arFields = array("ALLOW_DELIVERY" => $val, "=DATE_ALLOW_DELIVERY" => $DB->GetNowFunction(), "EMP_ALLOW_DELIVERY_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false); if (count($arAdditionalFields) > 0) { foreach ($arAdditionalFields as $addKey => $addValue) { if (!array_key_exists($addKey, $arFields)) { $arFields[$addKey] = $addValue; } } } $res = CSaleOrder::Update($ID, $arFields); unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); if ($recurringID <= 0) { if (IntVal($arOrder["RECURRING_ID"]) > 0) { $recurringID = IntVal($arOrder["RECURRING_ID"]); } } CSaleBasket::OrderDelivery($ID, $val == "Y" ? True : False, $recurringID); foreach (GetModuleEvents("sale", "OnSaleDeliveryOrder", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $val)); } if ($val == "Y") { CTimeZone::Disable(); $arOrder = CSaleOrder::GetByID($ID); CTimeZone::Enable(); if ($NO_CHANGE_STATUS != "Y") { $orderStatus = COption::GetOptionString("sale", "status_on_allow_delivery", ""); if (strlen($orderStatus) > 0 && $orderStatus != $arOrder["STATUS_ID"]) { $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID), false, false, array("ID", "SORT")); while ($arStatus = $dbStatus->GetNext()) { $arStatuses[$arStatus["ID"]] = $arStatus["SORT"]; } if ($arStatuses[$orderStatus] >= $arStatuses[$arOrder["STATUS_ID"]]) { CSaleOrder::StatusOrder($ID, $orderStatus); } } } $userEMail = ""; $dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"], "PROP_IS_EMAIL" => "Y")); if ($arOrderProp = $dbOrderProp->Fetch()) { $userEMail = $arOrderProp["VALUE"]; } if (strlen($userEMail) <= 0) { $dbUser = CUser::GetByID($arOrder["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $userEMail = $arUser["EMAIL"]; } } $eventName = "SALE_ORDER_DELIVERY"; $arFields = array("ORDER_ID" => $ID, "ORDER_DATE" => $arOrder["DATE_INSERT_FORMAT"], "EMAIL" => $userEMail, "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"])); $bSend = true; foreach (GetModuleEvents("sale", "OnOrderDeliverSendEmail", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, &$eventName, &$arFields)) === false) { $bSend = false; } } if ($bSend) { $event = new CEvent(); $event->Send($eventName, $arOrder["LID"], $arFields, "N"); } } //reservation if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "D") { if (!CSaleOrder::ReserveOrder($ID, $val)) { return false; } } //proceed to deduction if ($val == "Y") { $allowDeduction = COption::GetOptionString("sale", "allow_deduction_on_delivery", ""); if ($allowDeduction == "Y" && $arOrder["DEDUCTED"] == "N") { CSaleOrder::DeductOrder($ID, "Y"); } } return $res; }
if ($dbStatusList->GetNext()) { ?> <select name="STATUS_ID" id="STATUS_ID"> <? $arFilter = array("LID" => LANG); $arGroupByTmp = false; if ($saleModulePermissions < "W") { $arFilter["GROUP_ID"] = $GLOBALS["USER"]->GetUserGroupArray(); $arFilter["PERM_STATUS"] = "Y"; } $dbStatusListTmp = CSaleStatus::GetList( array("SORT" => "ASC"), $arFilter, $arGroupByTmp, false, array("ID", "NAME", "SORT") ); while($arStatusListTmp = $dbStatusListTmp->GetNext()) { ?><option value="<?echo $arStatusListTmp["ID"] ?>"<?if ($arStatusListTmp["ID"]==$str_STATUS_ID) echo " selected"?>><?echo $arStatusListTmp["NAME"] ?> [<?echo $arStatusListTmp["ID"] ?>]</option><? } ?> </select> <? } else { $arStatusLand = CSaleStatus::GetLangByID($str_STATUS_ID, LANGUAGE_ID); echo htmlspecialcharsEx("[".$str_STATUS_ID."] ".$arStatusLand["NAME"]);
$getxml = new ProductsXML(); $xml = $getxml->getXML(); header('Content-type: text/xml'); echo $xml;*/ $arResult = array("ERROR" => "Не верный запрос"); // обновление статусов заказа if ($_REQUEST["update"]) { if ($_REQUEST["orders"] && CModule::IncludeModule("catalog") && CModule::IncludeModule("sale")) { $arResult = ""; $arOrders = $_REQUEST["orders"]; foreach ($arOrders as $key => $order) { if (!CSaleOrder::StatusOrder($order["ID"], $order["STATUS"])) { $result = true; } else { $result = false; } $arResult[] = array("ID" => $order["ID"], "RESULT" => $result); } } // все типы статусов } elseif ($_REQUEST["getstatus"] && CModule::IncludeModule("catalog") && CModule::IncludeModule("sale")) { $arResult = ""; $arStatus = array(); $rsStatus = CSaleStatus::GetList(array("ID" => "ASC"), array("LID" => "ru")); while ($arStatus_tmp = $rsStatus->Fetch()) { $arResult[] = array("ID" => $arStatus_tmp["ID"], "NAME" => $arStatus_tmp["NAME"], "DESCRIPTION" => $arStatus_tmp["DESCRIPTION"]); } } echo json_encode($arResult); exit; }
?> </select> </td> </tr> <?php if (CModule::IncludeModule('sale')) { ?> <tr> <td><?php echo GetMessage("MODULE_SETTINGS_STATUS_TITLE"); ?> :</td> <td> <select name="export_status[]" multiple="" class="adm-select-multiple"> <?php $statuses = CSaleStatus::GetList(array(), array('LID' => LANGUAGE_ID)); ?> <?php while ($status = $statuses->Fetch()) { ?> <option value="<?php echo $status['ID']; ?> " <?php if (isset($settings["export_status"]) && is_array($settings["export_status"]) && in_array($status['ID'], $settings["export_status"])) { echo 'selected'; } ?> ><?php echo $status['NAME']; ?>
if (!CModule::IncludeModule('sale')) { ShowError(GetMessage("SMOP_SALE_NOT_INSTALLED")); return; } $saleModulePermissions = $APPLICATION->GetGroupRight("sale"); $arStatusList = false; $arFilter = array("LID" => LANG, "ID" => "N"); $arGroupByTmpSt = false; $arUserGroups = $USER->GetUserGroupArray(); $userId = intval($USER->GetID()); if ($saleModulePermissions < "W") { $arFilter["GROUP_ID"] = $arUserGroups; $arFilter["PERM_UPDATE"] = "Y"; $arGroupByTmpSt = array("ID", "NAME", "MAX" => "PERM_UPDATE"); } $dbStatusList = CSaleStatus::GetList(array(), $arFilter, $arGroupByTmpSt, false, array("ID", "NAME")); $arStatusList = $dbStatusList->Fetch(); if ($saleModulePermissions == "D" or $saleModulePermissions < "W" and $arStatusList["PERM_UPDATE"] != "Y") { ShowError(GetMessage("SMOP_ACCESS_DENIED")); return; } if (!CModule::IncludeModule('mobileapp')) { ShowError(GetMessage("SMOP_MA_NOT_INSTALLED")); return; } $arResult = array("CURRENT_PAGE" => $APPLICATION->GetCurPage(), "AJAX_URL" => $componentPath . "/ajax.php", "EVENTS" => array()); $arEvents = CSaleMobileOrderPush::getEvents(); $arSubscribedEvents = CSaleMobileOrderPush::getSubscriptions($userId); $bSubscribedEarlier = !empty($arSubscribedEvents) ? true : false; $subscribedAll = 'Y'; foreach ($arEvents as $eventId) {
function GetConfig() { global $APPLICATION; $dbProps = CSaleOrderProps::GetList(array("SORT" => "ASC"), array("ACTIVE" => 'Y'), false, false, array()); $props = array(); while ($prop = $dbProps->Fetch()) { $props[$prop['CODE']] = $prop['NAME']; } $dbResultList = CSaleStatus::GetList(array('SORT' => 'ASC'), array("LID" => LANGUAGE_ID), false, false, array("ID", "NAME")); $sendStatusValues = array(); while ($arResult = $dbResultList->Fetch()) { $sendStatusValues[$arResult['ID']] = $arResult['NAME']; } $paymentTypes = array(); $dbPtype = CSalePaySystem::GetList($arOrder = array("SORT" => "ASC", "PSA_NAME" => "ASC"), array("ACTIVE" => "Y")); while ($pType = $dbPtype->Fetch()) { $paymentTypes[$pType['ID']] = $pType['NAME'] . ' (' . $pType['LID'] . ')'; } $jsHack = '<script> BX.ready(function() { var el = BX("bxlhe_frame_hndl_dscr_all"); while(el = el.parentNode) { if(el.tagName == "TR") break; } BX.remove(el); el = document.getElementsByName("HANDLER[BASE_CURRENCY]")[0]; while(el = el.parentNode) { if(el.tagName == "TR") break; } BX.remove(el); }); </script>'; $arConfig = array("CONFIG_GROUPS" => array("general" => GetMessage('DDELIVERY_CONFIG_GROUPS_GENERAL'), "type" => GetMessage('DDELIVERY_CONFIG_GROUPS_TYPE'), "price" => GetMessage("DDELIVERY_CONFIG_GROUPS_PRICE")), "CONFIG" => array("API_KEY" => array("TYPE" => "STRING", "DEFAULT" => '', "TITLE" => GetMessage('DDELIVERY_CONFIG_API_KEY'), "GROUP" => "general", "POST_TEXT" => GetMessage('DDELIVERY_CONFIG_API_KEY_DESCRIPTION') . $jsHack), "TEST_MODE" => array("TYPE" => "DROPDOWN", "DEFAULT" => 1, "TITLE" => GetMessage('DDELIVERY_CONFIG_MODE'), "VALUES" => array(1 => GetMessage('DDELIVERY_CONFIG_MODE_STAGE'), 0 => GetMessage('DDELIVERY_CONFIG_MODE_CLIENT')), "POST_TEXT" => GetMessage('DDELIVERY_CONFIG_MODE_POST_TEXT'), "GROUP" => "general"), "DECLARED_PERCENT" => array("TYPE" => "INTEGER", "DEFAULT" => "100", "TITLE" => GetMessage('DDELIVERY_CONFIG_DECLARED_PERCENT_TITLE'), 'POST_TEXT' => GetMessage('DDELIVERY_CONFIG_DECLARED_PERCENT_POST_TEXT'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), "POST_PAYMENT" => array("TYPE" => "MULTISELECT", "DEFAULT" => "", "TITLE" => GetMessage('DDELIVERY_CONFIG_POST_PAYMENT_TITLE'), 'POST_TEXT' => '', 'VALUES' => $paymentTypes, "GROUP" => "general"), "TEMPLATE" => array("TYPE" => "DROPDOWN", "DEFAULT" => 'default', "TITLE" => GetMessage('DDELIVERY_CONFIG_TEMPLATE_TITLE'), "VALUES" => array('default' => GetMessage('DDELIVERY_CONFIG_TEMPLATE_DEFAULT'), 'blue' => GetMessage('DDELIVERY_CONFIG_TEMPLATE_BLUE')), "GROUP" => "general"), "SECTION_PROP" => array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CONFIG_SECTION_PROP_TITLE'), "GROUP" => "general"), "SEND_STATUS" => array("TYPE" => 'DROPDOWN', "DEFAULT" => "P", "TITLE" => GetMessage('DDELIVERY_CONFIG_SEND_STATUS_TITLE'), "POST_TEXT" => GetMessage('DDELIVERY_CONFIG_SEND_STATUS_POST_TEXT'), "GROUP" => "general"), "PROP_FIO" => array("TYPE" => "DROPDOWN", "DEFAULT" => "FIO", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_FIO'), "GROUP" => "general", 'POST_TEXT' => ''), "PROP_PHONE" => array("TYPE" => "DROPDOWN", "DEFAULT" => "PHONE", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_PHONE'), "GROUP" => "general"), "PROP_ADDRESS" => array("TYPE" => "DROPDOWN", "DEFAULT" => "ADDRESS", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_ADDRESS'), "GROUP" => "general"), "PROP_ZIP_CODE" => array("TYPE" => "DROPDOWN", "DEFAULT" => "ZIP", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_ZIP_CODE'), "GROUP" => "general", 'POST_TEXT' => ''), "PROP_CORP" => array("TYPE" => "DROPDOWN", "DEFAULT" => "CORP", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_CORP'), "GROUP" => "general", 'POST_TEXT' => ''), "PROP_FLAT" => array("TYPE" => "DROPDOWN", "DEFAULT" => "FLAT", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_FLAT'), "GROUP" => "general", 'POST_TEXT' => ''), "PROP_HOUSE" => array("TYPE" => "DROPDOWN", "DEFAULT" => "HOUSE", "TITLE" => GetMessage('DDELIVERY_CONFIG_PROP_HOUSE'), "GROUP" => "general", 'POST_TEXT' => ''))); // Создаем вкладки для инфоблоков $cCatalog = new CCatalog(); $res = $cCatalog->GetList(); while ($catalog = $res->Fetch()) { $key = 'IBLOCK_' . $catalog['OFFERS_IBLOCK_ID']; $arConfig['CONFIG'][$key . '_SECTION'] = array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CUSTOM_FIELDS', array('#IBLOCK_NAME#' => $catalog['NAME'])), "GROUP" => "general"); $articulDefault = null; $iblockProperty = array(0 => GetMessage('DDELIVERY_DEFAULT')); $res = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $catalog['OFFERS_IBLOCK_ID'])); while ($prop = $res->Fetch()) { $iblockProperty[$prop['ID']] = $prop['NAME']; if ($prop['CODE'] == 'ARTNUMBER') { $articulDefault = $prop['ID']; } } foreach (array('X', 'Y', 'Z', 'W') as $key2) { $arConfig['CONFIG'][$key . '_' . $key2] = array("TYPE" => "DROPDOWN", "TITLE" => GetMessage('DDELIVERY_' . $key2), "GROUP" => "general", "DEFAULT" => 0, "VALUES" => $iblockProperty); } $iblockProperty[0] = GetMessage('DDELIVERY_NONE'); $arConfig['CONFIG'][$key . '_ARTICUL'] = array("TYPE" => "DROPDOWN", "TITLE" => GetMessage('DDELIVERY_ARTICUL'), "GROUP" => "general", "DEFAULT" => $articulDefault, "VALUES" => $iblockProperty); } $arConfig['CONFIG'] += array("SECTION_DEFAULT" => array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_DEFAULT_SIZE'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), "DEFAULT_X" => array("TYPE" => "INTEGER", "DEFAULT" => "100", "TITLE" => GetMessage('DDELIVERY_CONFIG_DEFAULT_X'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), "DEFAULT_Z" => array("TYPE" => "INTEGER", "DEFAULT" => "100", "TITLE" => GetMessage('DDELIVERY_CONFIG_DEFAULT_Z'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), "DEFAULT_Y" => array("TYPE" => "INTEGER", "DEFAULT" => "100", "TITLE" => GetMessage('DDELIVERY_CONFIG_DEFAULT_Y'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), "DEFAULT_W" => array("TYPE" => "INTEGER", "DEFAULT" => "100", "TITLE" => GetMessage('DDELIVERY_CONFIG_DEFAULT_W'), "GROUP" => "general", 'CHECK_FORMAT' => 'NUMBER'), 'COMPANY_TITLE' => array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CONFIG_COMPANY_TITLE'), 'GROUP' => 'type'), 'SUPPORTED_TYPE' => array("TYPE" => "DROPDOWN", "TITLE" => GetMessage('DDELIVERY_CONFIG_SUPPORTED_TYPE'), "GROUP" => "type", "DEFAULT" => '0', "VALUES" => array(0 => GetMessage('DDELIVERY_CONFIG_SUPPORTED_TYPE_ALL'), 1 => GetMessage('DDELIVERY_CONFIG_SUPPORTED_TYPE_PVZ'), 2 => GetMessage('DDELIVERY_CONFIG_SUPPORTED_TYPE_COURIER')))); $companyList = self::companyList(); $arConfig['CONFIG']['COMPANY_TITLE_COURIER'] = array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CONFIG_COMPANY_TITLE_COURIER'), 'GROUP' => 'type'); foreach ($companyList[DDeliverySDK::TYPE_COURIER] as $key => $company) { $arConfig['CONFIG']["COMPANY_" . DDeliverySDK::TYPE_COURIER . '_' . $key] = array("TYPE" => "CHECKBOX", "DEFAULT" => 'Y', "TITLE" => $company, "GROUP" => "type"); } $arConfig['CONFIG']['COMPANY_TITLE_SELF'] = array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CONFIG_COMPANY_TITLE_SELF'), 'GROUP' => 'type'); foreach ($companyList[DDeliverySDK::TYPE_SELF] as $key => $company) { $arConfig['CONFIG']["COMPANY_" . DDeliverySDK::TYPE_SELF . '_' . $key] = array("TYPE" => "CHECKBOX", "DEFAULT" => 'Y', "TITLE" => $company, "GROUP" => "type"); } $arConfig['CONFIG']['PRICE_IF_SECTION'] = array('TYPE' => 'SECTION', 'TITLE' => GetMessage('DDELIVERY_CONFIG_PRICE_IF_SECTION'), 'GROUP' => 'price'); for ($i = 1; $i <= 3; $i++) { $arConfig['CONFIG'] += array('PRICE_IF_' . $i . '_CONTROL' => array('TYPE' => 'MULTI_CONTROL_STRING', 'MCS_ID' => 'BOX_general_' . $i, 'TITLE' => GetMessage('DDELIVERY_FROM'), 'GROUP' => 'price'), 'PRICE_IF_' . $i . '_MIN' => array('TYPE' => 'STRING', 'MCS_ID' => 'BOX_general_' . $i, 'POST_TEXT' => ' ' . GetMessage('DDELIVERY_TO') . ' ', 'SIZE' => 1, 'DEFAULT' => '', 'GROUP' => 'price', 'CHECK_FORMAT' => 'NUMBER'), 'PRICE_IF_' . $i . '_MAX' => array('TYPE' => 'STRING', 'MCS_ID' => 'BOX_general_' . $i, 'POST_TEXT' => ' ' . GetMessage('DDELIVERY_DELIVERY_PRICE') . ' ', 'SIZE' => 1, 'DEFAULT' => '', 'GROUP' => 'price', 'CHECK_FORMAT' => 'NUMBER'), 'PRICE_IF_' . $i . '_TYPE' => array('TYPE' => 'DROPDOWN', 'MCS_ID' => 'BOX_general_' . $i, 'POST_TEXT' => ' ', 'DEFAULT' => '', 'VALUES' => array(1 => GetMessage('DDELIVERY_PRICE_CLIENT_ALL'), 2 => GetMessage('DDELIVERY_PRICE_MARKET_ALL'), 3 => GetMessage('DDELIVERY_PRICE_MARKET_PRESENT'), 4 => GetMessage('DDELIVERY_PRICE_MARKET_RUB')), 'GROUP' => 'price'), 'PRICE_IF_' . $i . '_AOMUNT' => array('TYPE' => 'STRING', 'MCS_ID' => 'BOX_general_' . $i, 'SIZE' => 1, 'DEFAULT' => '', 'GROUP' => 'price', 'CHECK_FORMAT' => 'NUMBER')); } $arConfig['CONFIG'] += array('AROUND_CONTROL' => array('TYPE' => 'MULTI_CONTROL_STRING', 'MCS_ID' => 'AROUND', 'TITLE' => GetMessage('DDELIVERY_AROUND_CONTROL'), 'GROUP' => 'price'), 'AROUND' => array('TYPE' => 'DROPDOWN', 'MCS_ID' => 'AROUND', 'POST_TEXT' => ' ' . GetMessage('DDELIVERY_STEP') . ' ', 'DEFAULT' => 1, 'GROUP' => 'price', 'VALUES' => array(2 => GetMessage('DDELIVERY_DOWN'), 3 => GetMessage('DDELIVERY_UP'), 1 => GetMessage('DDELIVERY_ROUND'))), 'AROUND_STEP' => array('TYPE' => 'STRING', 'MCS_ID' => 'AROUND', 'POST_TEXT' => ' ' . GetMessage('DDELIVERY_RUR'), 'SIZE' => 1, 'DEFAULT' => '', 'GROUP' => 'price', 'CHECK_FORMAT' => 'NUMBER'), 'PAY_PICKUP' => array('TITLE' => GetMessage('DDELIVERY_PAY_PICKUP'), "TYPE" => "CHECKBOX", "DEFAULT" => 'N', "GROUP" => "price")); // var_dump($arConfig); //$arConfig = $APPLICATION->ConvertCharsetArray($arConfig, 'cp1251', SITE_CHARSET); $arConfig['CONFIG']['SEND_STATUS']['VALUES'] = $sendStatusValues; $arConfig['CONFIG']['PROP_FIO']['VALUES'] = $props; $arConfig['CONFIG']['PROP_PHONE']['VALUES'] = $props; $arConfig['CONFIG']['PROP_ADDRESS']['VALUES'] = $props; $props = array_merge(array(GetMessage('DDELIVERY_CONFIG_EMPTY')), $props); $arConfig['CONFIG']['PROP_ZIP_CODE']['VALUES'] = $props; $arConfig['CONFIG']['PROP_CORP']['VALUES'] = $props; $arConfig['CONFIG']['PROP_FLAT']['VALUES'] = $props; $arConfig['CONFIG']['PROP_HOUSE']['VALUES'] = $props; return $arConfig; }
public static function GetStatusList() { if (!CModule::IncludeModule('sale')) { return false; } $arStatus = array(); $res = CSaleStatus::GetList(array('SORT' => 'ASC'), array('LID' => LANGUAGE_ID), false, false, array('ID', 'SORT', 'NAME')); $id = 1; while ($row = $res->Fetch()) { // Special status, not used in CRM if ($row['ID'] === 'F') { continue; } $arStatus[$row['ID']] = array('ID' => $id, 'ENTITY' => 'INVOICE_STATUS', 'STATUS_ID' => $row['ID'], 'NAME' => $row['NAME'], 'NAME_INIT' => '', 'SORT' => $id * 10, 'SYSTEM' => 'N'); if (in_array($row['ID'], array('P', 'D'))) { if ($row['ID'] === 'P') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_P'); } elseif ($row['ID'] === 'D') { $arStatus[$row['ID']]['NAME_INIT'] = GetMessage('CRM_INVOICE_STATUS_D'); } $arStatus[$row['ID']]['SYSTEM'] = 'Y'; } $id++; } return $arStatus; }
/** * Read some data from database, using cache. Under some info we mean status list, delivery system list and so on. * This will be a shared cache between sale.personal.order.list and sale.personal.order.detail, so beware of collisions. * @throws Main\SystemException * @return void */ protected function obtainDataReferences() { if ($this->startCache(array('spo-shared'))) { try { $cachedData = array(); ///////////////////// ///////////////////// // Person type $cachedData['PERSON_TYPE'] = array(); $dbPType = CSalePersonType::GetList(array("SORT" => "ASC")); while ($arPType = $dbPType->Fetch()) { $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType; } // Save statuses for Filter form $cachedData['STATUS'] = array(); $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID), faslse, false, array('ID', 'NAME', 'DESCRIPTION')); while ($arStatus = $dbStatus->Fetch()) { $cachedData['STATUS'][$arStatus["ID"]] = $arStatus; } $cachedData['PAYSYS'] = array(); $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC")); while ($arPaySystem = $dbPaySystem->Fetch()) { $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem; } $cachedData['DELIVERY'] = array(); $dbDelivery = \Bitrix\Sale\Delivery\Services\Table::getList(array('select' => array('ID', 'NAME', 'PARENT_ID'))); $deliveryService = array(); while ($delivery = $dbDelivery->fetch()) { $deliveryService[$delivery['ID']] = $delivery; } foreach ($deliveryService as $delivery) { $cachedData['DELIVERY'][$delivery["ID"]] = array(); if ($delivery['PARENT_ID']) { $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = $deliveryService[$delivery['PARENT_ID']]['NAME'] . ':' . $delivery['NAME']; } else { $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = $delivery['NAME']; } } ///////////////////// ///////////////////// } catch (Exception $e) { $this->abortCache(); throw $e; } $this->endCache($cachedData); } else { $cachedData = $this->getCacheData(); } $this->dbResult = array_merge($this->dbResult, $cachedData); }
unset($defaultSite, $siteIterator); } if (strlen($shopLocalization) <= 0) { $shopLocalization = "ru"; } $defCurrency = "EUR"; if ($shopLocalization == "ru") { $defCurrency = "RUB"; } elseif ($shopLocalization == "en") { $defCurrency = "USD"; } COption::SetOptionString("sale", "default_currency", $defCurrency); // Create order statuses $statusesSort = array('N' => 100, 'A' => 120, 'D' => 140, 'P' => 130, 'S' => 110); $createStatusList = $statusesSort; $dbStatusList = CSaleStatus::GetList(array(), array('ID' => array_keys($statusesSort)), false, false, array('ID')); $arExistStatuses = array(); while ($arStatusList = $dbStatusList->Fetch()) { //$arExistStatuses[$arStatusList['ID']] = $arStatusList; $arExistStatuses[$arStatusList['ID']] = true; if ($arStatusList['ID'] == 'N') { continue; } unset($createStatusList[$arStatusList['ID']]); } unset($arStatusList, $dbStatusList); $arActiveLangs = array(); $languageIterator = Main\Localization\LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y'))); while ($language = $languageIterator->fetch()) { $arActiveLangs[] = $language['ID']; }
function InstallDB() { global $DB, $DBType, $APPLICATION; $this->errors = false; if (!$DB->Query("SELECT 'x' FROM b_sale_basket", true)) { $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/install/db/" . $DBType . "/install.sql"); } if ($this->errors !== false) { $APPLICATION->ThrowException(implode("", $this->errors)); return false; } RegisterModule("sale"); RegisterModuleDependences("main", "OnUserLogin", "sale", "CSaleUser", "OnUserLogin"); RegisterModuleDependences("main", "OnUserLogout", "sale", "CSaleUser", "OnUserLogout"); RegisterModuleDependences("main", "OnBeforeLangDelete", "sale", "CSalePersonType", "OnBeforeLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocation", "OnLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocationGroup", "OnLangDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleOrderUserProps", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserAccount", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleAuxiliary", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUser", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleRecurring", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserCards", "OnUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleOrder", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleAffiliate", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleUserAccount", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 100, "/modules/sale/affiliate.php"); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleOrder", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleLang", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnModuleUnInstall", "sale", "", "CurrencyModuleUnInstallSale"); RegisterModuleDependences("catalog", "OnSaleOrderSumm", "sale", "CSaleOrder", "__SaleOrderCount"); RegisterModuleDependences("mobileapp", "OnBeforeAdminMobileMenuBuild", "sale", "CSaleMobileOrderUtils", "buildSaleAdminMobileMenu"); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketGroup", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketFields", "GetControlDescr", 300); // RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketProps", "GetControlDescr", 400); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlOrderFields", "GetControlDescr", 1000); // RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketProductFields", "GetControlDescr", 1100); // RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketProductProps", "GetControlDescr", 1200); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlCommon", "GetControlDescr", 10000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlDelivery", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketGroup", "GetControlDescr", 300); // RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlGiftsGroup", "GetControlDescr", 400); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlSubGroup", "GetControlDescr", 1000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCondCtrlBasketFields", "GetControlDescr", 1100); // RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketProductFields", "GetControlDescr", 1200); // RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketProductProps", "GetControlDescr", 1300); //pulling for mobile orders RegisterModuleDependences("sale", "OnOrderDelete", "sale", "CSaleMobileOrderPull", "onOrderDelete", 100); RegisterModuleDependences("sale", "OnOrderAdd", "sale", "CSaleMobileOrderPull", "onOrderAdd", 100); RegisterModuleDependences("sale", "OnOrderUpdate", "sale", "CSaleMobileOrderPull", "onOrderUpdate", 100); CAgent::AddAgent("CSaleRecurring::AgentCheckRecurring();", "sale", "N", 7200, "", "Y"); CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y"); CAgent::AddAgent("CSaleViewedProduct::ClearViewed();", "sale", "N", 86400, "", "Y"); if (CModule::IncludeModule("sale")) { $dbStatusList = CSaleStatus::GetList(array(), array(), false, false, array()); if (!($arStatusList = $dbStatusList->Fetch())) { $arLandDataN = array(); $arLandDataF = array(); $dbLangs = CLanguage::GetList($b = "", $o = "", array("ACTIVE" => "Y")); while ($arLangs = $dbLangs->Fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/status.php", $arLangs["LID"]); $arLandDataN[] = array("LID" => $arLangs["LID"], "NAME" => GetMessage("SIM_ACCEPTED"), "DESCRIPTION" => GetMessage("SIM_ACCEPTED_DESCR")); $arLandDataF[] = array("LID" => $arLangs["LID"], "NAME" => GetMessage("SIM_FINISHED"), "DESCRIPTION" => GetMessage("SIM_FINISHED_DESCR")); } CSaleStatus::Add(array("ID" => "N", "SORT" => 100, "LANG" => $arLandDataN)); CSaleStatus::Add(array("ID" => "F", "SORT" => 200, "LANG" => $arLandDataF)); } } return true; }
$arSites[] = $site["LID"]; } if (count($arSites) > 0) { $template = str_replace("#SITE_CHARSET#", $lang["CHARSET"], $templateGeneral); $arHTMLEvents = array("SALE_NEW_ORDER", "SALE_ORDER_CANCEL", "SALE_ORDER_DELIVERY", "SALE_ORDER_PAID", "SALE_ORDER_REMIND_PAYMENT", "SALE_SUBSCRIBE_PRODUCT", "SALE_ORDER_TRACKING_NUMBER"); foreach ($arHTMLEvents as $eventName) { $emess = new CEventMessage(); $message = str_replace(array("#TITLE#", "#SUB_TITLE#", "#TEXT#", "#FOOTER_BR#", "#FOOTER_SHOP#"), array(GetMessage($eventName . "_HTML_TITLE"), GetMessage($eventName . "_HTML_SUB_TITLE"), str_replace("\n", "<br />\n", GetMessage($eventName . "_HTML_TEXT")), GetMessage("SMAIL_FOOTER_BR"), GetMessage("SMAIL_FOOTER_SHOP")), $template); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => $eventName, "LID" => $arSites, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage($eventName . "_SUBJECT"), "MESSAGE" => $message, "BODY_TYPE" => "html")); } $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_NEW_ORDER_RECURRING", "LID" => $arSites, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_NEW_ORDER_RECURRING_SUBJECT"), "MESSAGE" => GetMessage("SALE_NEW_ORDER_RECURRING_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_RECURRING_CANCEL", "LID" => $arSites, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_RECURRING_CANCEL_SUBJECT"), "MESSAGE" => GetMessage("SALE_RECURRING_CANCEL_MESSAGE"), "BODY_TYPE" => "text")); } $dbStatus = CSaleStatus::GetList(array($by => $order), array(), false, false, array("ID")); while ($arStatus = $dbStatus->Fetch()) { $ID = $arStatus["ID"]; $eventType = new CEventType(); $eventMessage = new CEventMessage(); IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/general/status.php", $lid); $arStatusLang = CSaleStatus::GetLangByID($ID, $lid); $template = str_replace("#SITE_CHARSET#", $lang["CHARSET"], $templateGeneral); $dbEventType = $eventType->GetList(array("EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "LID" => $lid)); if (!($arEventType = $dbEventType->Fetch())) { $str = ""; $str .= "#ORDER_ID# - " . GetMessage("SKGS_ORDER_ID") . "\n"; $str .= "#ORDER_DATE# - " . GetMessage("SKGS_ORDER_DATE") . "\n"; $str .= "#ORDER_STATUS# - " . GetMessage("SKGS_ORDER_STATUS") . "\n"; $str .= "#EMAIL# - " . GetMessage("SKGS_ORDER_EMAIL") . "\n"; $str .= "#ORDER_DESCRIPTION# - " . GetMessage("SKGS_STATUS_DESCR") . "\n";
// bitrix deliveryServicesList $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID'])); if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) { do { $arResult['bitrixDeliveryTypesList'][] = array('ID' => $arDeliveryServicesList['SID'], 'NAME' => $arDeliveryServicesList['NAME']); } while ($arDeliveryServicesList = $dbDeliveryServicesList->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", "ACTIVE" => "Y")); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $arResult['bitrixPaymentStatusesList'][$arPaymentStatusesList['ID']] = $arPaymentStatusesList; } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } $arResult['bitrixPaymentStatusesList'][] = array('ID' => 'YY', 'NAME' => GetMessage('CANCELED')); //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'; $dbProp = CSaleOrderProps::GetList(array(), array()); while ($arProp = $dbProp->GetNext()) { $arResult['arProp'][$arProp['PERSON_TYPE_ID']][] = $arProp; }
if (strlen($action["ACTION_FILE"]) > 0 && file_exists($_SERVER["DOCUMENT_ROOT"].$action["ACTION_FILE"]."/logo.gif")) { $action["LOGOTIP"] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].$action["ACTION_FILE"]."/logo.gif"); } CSalePaySystemAction::Add($action); } } } if (COption::GetOptionString("eshop", "wizard_installed", "N", WIZARD_SITE_ID) != "Y" || WIZARD_INSTALL_DEMO_DATA) { $bStatusP = false; $dbStatus = CSaleStatus::GetList(Array("SORT" => "ASC")); while($arStatus = $dbStatus->Fetch()) { $arFields = Array(); foreach($arLanguages as $langID) { WizardServices::IncludeServiceLang("step1.php", $langID); $arFields["LANG"][] = Array("LID" => $langID, "NAME" => GetMessage("WIZ_SALE_STATUS_".$arStatus["ID"]), "DESCRIPTION" => GetMessage("WIZ_SALE_STATUS_DESCRIPTION_".$arStatus["ID"])); } $arFields["ID"] = $arStatus["ID"]; CSaleStatus::Update($arStatus["ID"], $arFields); if($arStatus["ID"] == "P") $bStatusP = true; } if(!$bStatusP) {
/** * Functions DoInstall and DoUninstall are * All other functions are optional */ 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; } } include $this->INSTALL_PATH . '/../classes/general/RestApi.php'; include $this->INSTALL_PATH . '/../classes/general/Response/ApiResponse.php'; include $this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php'; include $this->INSTALL_PATH . '/../classes/general/ICMLLoader.php'; include $this->INSTALL_PATH . '/../classes/general/Exception/InvalidJsonException.php'; include $this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php'; include $this->INSTALL_PATH . '/../classes/general/RestNormalizer.php'; $step = intval($_REQUEST['step']); if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.intarocrm/classes/general/config/options.xml')) { $options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.intarocrm/classes/general/config/options.xml'); foreach ($options->contragents->contragent as $contragent) { $type["NAME"] = $APPLICATION->ConvertCharset((string) $contragent, 'utf-8', SITE_CHARSET); $type["ID"] = (string) $contragent["id"]; $arResult['contragentType'][] = $type; unset($type); } foreach ($options->fields->field as $field) { $type["NAME"] = $APPLICATION->ConvertCharset((string) $field, 'utf-8', SITE_CHARSET); $type["ID"] = (string) $field["id"]; if ($field["group"] == 'custom') { $arResult['customFields'][] = $type; } elseif (!$field["group"]) { $arResult['orderProps'][] = $type; } else { $groups = explode(",", (string) $field["group"]); foreach ($groups as $group) { $type["GROUP"][] = trim($group); } $arResult['legalDetails'][] = $type; } unset($type); } } if ($step == 11) { $arResult['arSites'] = array(); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); while ($ar = $rsSites->Fetch()) { $arResult['arSites'][] = $ar; } if (count($arResult['arSites']) < 2) { $step = 2; } } if ($step <= 1) { if (!CModule::IncludeModule("sale")) { $arResult['errCode'] = 'ERR_SALE'; } if (!CModule::IncludeModule("iblock")) { $arResult['errCode'] = 'ERR_IBLOCK'; } if (!CModule::IncludeModule("catalog")) { $arResult['errCode'] = 'ERR_CATALOG'; } $arResult['arSites'] = array(); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); while ($ar = $rsSites->Fetch()) { $arResult['arSites'][] = $ar; } $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'); } else { if ($step == 11) { //new page if (!CModule::IncludeModule("sale")) { $arResult['errCode'] = 'ERR_SALE'; } 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/step1.php'); return; } $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); // form correct url $api_host = parse_url($api_host); if ($api_host['scheme'] != 'https') { $api_host['scheme'] = 'https'; } $api_host = $api_host['scheme'] . '://' . $api_host['host']; 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'); return; } $this->INTARO_CRM_API = new RetailCrm\RestApi($api_host, $api_key); //api key ok and sites list try { $arResult['sitesList'] = $APPLICATION->ConvertCharsetArray($this->INTARO_CRM_API->sitesList()->sites, 'utf-8', SITE_CHARSET); } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::sitesList', $e->getCode() . ': ' . $e->getMessage()); $arResult['errCode'] = 'ERR_' . $e->getCode(); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'); return; } COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step11.php'); } else { if ($step == 2) { //доставки, оплаты, типы заказов if (!CModule::IncludeModule("sale")) { $arResult['errCode'] = 'ERR_SALE'; } 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/step1.php'); return; } $arResult['arSites'] = array(); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); while ($ar = $rsSites->Fetch()) { if (!$ar["SERVER_NAME"]) { $arResult['errCode'] = 'URL_NOT_FOUND'; $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'); return; } else { $arResult['arSites'][] = $ar; } } 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 \RetailCrm\RestApi($api_host, $api_key); //prepare crm lists try { $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList()->orderTypes; } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::orderTypesList::CurlException', $e->getCode() . ': ' . $e->getMessage()); $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(array("success" => false))); } try { $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList()->deliveryTypes; $arResult['deliveryServicesList'] = $this->INTARO_CRM_API->deliveryServicesList()->deliveryServices; $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList()->paymentTypes; $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses; // --statuses $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList()->statuses; $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList()->statusGroups; // -- statuses groups } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::*List::CurlException', $e->getCode() . ': ' . $e->getMessage()); } //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 { $arResult['bitrixOrderTypesList'][] = $arOrderTypesList; $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_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 { $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList; $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']])); } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } //bitrix deliveryServicesList $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID'])); //form delivery services ids arr if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) { do { //auto delivery types $deliveryTypesArr[$arDeliveryServicesList['SID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryServicesList['SID']])); } while ($arDeliveryServicesList = $dbDeliveryServicesList->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 { $arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList; $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", "ACTIVE" => "Y")); //form payment statuses ids arr $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $arResult['bitrixPaymentStatusesList'][$arPaymentStatusesList['ID']] = $arPaymentStatusesList; $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']])); } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } $arResult['bitrixPaymentStatusesList'][] = array('ID' => 'YY', 'NAME' => GetMessage('CANCELED')); //form payment ids arr $paymentArr = array(); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(ICrmOrderActions::clearArr($orderTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize(ICrmOrderActions::clearArr($deliveryTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize(ICrmOrderActions::clearArr($paymentTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize(ICrmOrderActions::clearArr($paymentStatusesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize(ICrmOrderActions::clearArr($paymentArr))); // generate updated select inputs $input = array(); foreach ($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) { $input['delivery-type-' . $bitrixDeliveryType['ID']] = '<select name="delivery-type-' . $bitrixDeliveryType['ID'] . '" class="typeselect">'; $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value=""></option>'; foreach ($arResult['deliveryTypesList'] as $deliveryType) { if ($deliveryTypesArr[$bitrixDeliveryType['ID']] == $deliveryType['code']) { $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value="' . $deliveryType['code'] . '" selected>'; } else { $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value="' . $deliveryType['code'] . '">'; } $input['delivery-type-' . $bitrixDeliveryType['ID']] .= $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET); $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</option>'; } $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</select>'; } foreach ($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) { $input['payment-type-' . $bitrixPaymentType['ID']] = '<select name="payment-type-' . $bitrixPaymentType['ID'] . '" class="typeselect">'; $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value=""></option>'; foreach ($arResult['paymentTypesList'] as $paymentType) { if ($paymentTypesArr[$bitrixPaymentType['ID']] == $paymentType['code']) { $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value="' . $paymentType['code'] . '" selected>'; } else { $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value="' . $paymentType['code'] . '">'; } $input['payment-type-' . $bitrixPaymentType['ID']] .= $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET); $input['payment-type-' . $bitrixPaymentType['ID']] .= '</option>'; } $input['payment-type-' . $bitrixPaymentType['ID']] .= '</select>'; } foreach ($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) { $input['payment-status-' . $bitrixPaymentStatus['ID']] = '<select name="payment-status-' . $bitrixPaymentStatus['ID'] . '" class="typeselect">'; $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value=""></option>'; foreach ($arResult['paymentGroupList'] as $orderStatusGroup) { if (empty($orderStatusGroup['statuses'])) { continue; } $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<optgroup label="' . $orderStatusGroup['name'] . '">'; foreach ($orderStatusGroup['statuses'] as $payment) { if (!isset($arResult['paymentList'][$payment])) { continue; } if ($paymentStatusesArr[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) { $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value="' . $arResult['paymentList'][$payment]['code'] . '" selected>'; } else { $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value="' . $arResult['paymentList'][$payment]['code'] . '">'; } $input['payment-status-' . $bitrixPaymentStatus['ID']] .= $APPLICATION->ConvertCharset($arResult['paymentList'][$payment]['name'], 'utf-8', SITE_CHARSET); $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</option>'; } $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</optgroup>'; } $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</select>'; } foreach ($arResult['bitrixPaymentList'] as $bitrixPayment) { $input['payment-' . $bitrixPayment['ID']] = '<select name="payment-' . $bitrixPayment['ID'] . '" class="typeselect">'; $input['payment-' . $bitrixPayment['ID']] .= '<option value=""></option>'; foreach ($arResult['paymentStatusesList'] as $paymentStatus) { if ($paymentArr[$bitrixPayment['ID']] == $paymentStatus['code']) { $input['payment-' . $bitrixPayment['ID']] .= '<option value="' . $paymentStatus['code'] . '" selected>'; } else { $input['payment-' . $bitrixPayment['ID']] .= '<option value="' . $paymentStatus['code'] . '">'; } $input['payment-' . $bitrixPayment['ID']] .= $APPLICATION->ConvertCharset($paymentStatus['name'], 'utf-8', SITE_CHARSET); $input['payment-' . $bitrixPayment['ID']] .= '</option>'; } $input['payment-' . $bitrixPayment['ID']] .= '</select>'; } foreach ($arResult['bitrixOrderTypesList'] as $bitrixOrderType) { $input['order-type-' . $bitrixOrderType['ID']] = '<select name="order-type-' . $bitrixOrderType['ID'] . '" class="typeselect">'; $input['order-type-' . $bitrixOrderType['ID']] .= '<option value=""></option>'; foreach ($arResult['orderTypesList'] as $orderType) { if ($orderTypesArr[$bitrixOrderType['ID']] == $orderType['code']) { $input['order-type-' . $bitrixOrderType['ID']] .= '<option value="' . $orderType['code'] . '" selected>'; } else { $input['order-type-' . $bitrixOrderType['ID']] .= '<option value="' . $orderType['code'] . '">'; } $input['order-type-' . $bitrixOrderType['ID']] .= $APPLICATION->ConvertCharset($orderType['name'], 'utf-8', SITE_CHARSET); $input['order-type-' . $bitrixOrderType['ID']] .= '</option>'; } $input['order-type-' . $bitrixOrderType['ID']] .= '</select>'; } $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(array("success" => true, "result" => $input))); } if (count($arResult['arSites']) > 1) { // 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); foreach ($arResult['arSites'] as $site) { if ($_POST['sites-id-' . $site['LID']] && !empty($_POST['sites-id-' . $site['LID']])) { $siteCode[$site['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $site['LID']])); } } if (count($arResult['arSites']) != count($siteCode)) { $arResult['errCode'] = 'ERR_FIELDS_API_HOST'; $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step11.php'); return; } $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode)); } else { //если 1 сайт $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); // form correct url $api_host = parse_url($api_host); if ($api_host['scheme'] != 'https') { $api_host['scheme'] = 'https'; } $api_host = $api_host['scheme'] . '://' . $api_host['host']; 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'); return; } $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key); try { $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses; } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::paymentStatusesList::CurlException', $e->getCode() . ': ' . $e->getMessage()); $arResult['errCode'] = 'ERR_' . $e->getCode(); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php'); return; } COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); } //prepare crm lists try { $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList()->orderTypes; $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList()->deliveryTypes; $arResult['deliveryServicesList'] = $this->INTARO_CRM_API->deliveryServicesList()->deliveryServices; $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList()->paymentTypes; $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses; // --statuses $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList()->statuses; $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList()->statusGroups; // -- statuses groups } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::*List::CurlException', $e->getCode() . ': ' . $e->getMessage()); } //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 deliveryServicesList $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID'])); if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) { do { $arResult['bitrixDeliveryTypesList'][] = array('ID' => $arDeliveryServicesList['SID'], 'NAME' => $arDeliveryServicesList['NAME']); } while ($arDeliveryServicesList = $dbDeliveryServicesList->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 --statuses $dbPaymentStatusesList = CSaleStatus::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => "ru", "ACTIVE" => "Y")); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $arResult['bitrixPaymentStatusesList'][$arPaymentStatusesList['ID']] = $arPaymentStatusesList; } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } $arResult['bitrixPaymentStatusesList'][] = array('ID' => 'YY', 'NAME' => GetMessage('CANCELED')); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php'); } else { if ($step == 3) { //сопостовление свойств заказа if (!CModule::IncludeModule("sale")) { //handler } if (isset($_POST['back']) && $_POST['back']) { $APPLICATION->IncludeAdminFile(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); $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $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(); $arResult['bitrixOrderTypesList'] = array(); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { do { $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']])); $arResult['bitrixOrderTypesList'][] = $arOrderTypesList; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array()); //bitrix deliveryServicesList $rsSites = CSite::GetList($by, $sort, array()); while ($ar = $rsSites->Fetch()) { $arResult['arSites'][] = $ar; } $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID'])); //form delivery types / services ids arr $deliveryTypesArr = array(); if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') { if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { do { $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']])); } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) { do { //auto delivery types $deliveryTypesArr[$arDeliveryServicesList['SID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryServicesList['SID']])); } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()); } } elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') { // send to intaro crm and save delivery types! 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 try { $this->INTARO_CRM_API->deliveryTypeEdit(ICrmOrderActions::clearArr(array('code' => $resultDeliveryTypeId, 'name' => ICrmOrderActions::toJSON($arDeliveryTypesList['NAME']), 'defaultCost' => $arDeliveryTypesList['PRICE'], 'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']), 'paymentTypes' => ''))); } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::deliveryTypeEdit::CurlException', $e->getCode() . ': ' . $e->getMessage()); } } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) { do { $deliveryTypesArr[$arDeliveryServicesList['SID']] = $arDeliveryServicesList['SID']; // send to crm try { $this->INTARO_CRM_API->deliveryTypeEdit(ICrmOrderActions::clearArr(array('code' => $arDeliveryServicesList['SID'], 'name' => ICrmOrderActions::toJSON($arDeliveryServicesList['NAME']), 'defaultCost' => 0, 'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']), 'paymentTypes' => ''))); } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::deliveryTypeEdit::CurlException', $e->getCode() . ': ' . $e->getMessage()); } foreach ($arDeliveryServicesList['PROFILES'] as $id => $profile) { // send to crm try { $this->INTARO_CRM_API->deliveryServiceEdit(ICrmOrderActions::clearArr(array('code' => $arDeliveryServicesList['SID'] . '-' . $id, 'name' => ICrmOrderActions::toJSON($profile['TITLE']), 'deliveryType' => $arDeliveryServicesList['SID']))); } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'IntaroCrm\\RestApi::deliveryServiceEdit::CurlException', $e->getCode() . ': ' . $e->getMessage()); } } } while ($arDeliveryServicesList = $dbDeliveryServicesList->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", "ACTIVE" => "Y")); //form payment statuses ids arr $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); 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'])); //form orderProps $dbProp = CSaleOrderProps::GetList(array(), array()); while ($arProp = $dbProp->GetNext()) { $arResult['arProp'][$arProp['PERSON_TYPE_ID']][] = $arProp; } COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(ICrmOrderActions::clearArr($orderTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize(ICrmOrderActions::clearArr($deliveryTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize(ICrmOrderActions::clearArr($paymentTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize(ICrmOrderActions::clearArr($paymentStatusesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize(ICrmOrderActions::clearArr($paymentArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array())); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'); } else { if ($step == 4) { //выгрузка старых заказов if (!CModule::IncludeModule("sale")) { //handler } if (isset($_POST['back']) && $_POST['back']) { $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php'); } 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/step2.php'); } //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array()); //form order types ids arr $orderTypesArr = array(); $orderTypesList = array(); if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { do { $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']])); $orderTypesList[] = $arOrderTypesList; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } $orderPropsArr = array(); foreach ($orderTypesList as $orderType) { $propsCount = 0; $_orderPropsArr = array(); foreach ($arResult['orderProps'] as $orderProp) { if (!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']])) && $propsCount > 4) { break; } $_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']])); $propsCount++; } $orderPropsArr[$orderType['ID']] = $_orderPropsArr; } //legal details props $legalDetailsArr = array(); foreach ($orderTypesList as $orderType) { $_legalDetailsArr = array(); foreach ($arResult['legalDetails'] as $legalDetails) { $_legalDetailsArr[$legalDetails['ID']] = htmlspecialchars(trim($_POST['legal-detail-' . $legalDetails['ID'] . '-' . $orderType['ID']])); } $legalDetailsArr[$orderType['ID']] = $_legalDetailsArr; } $customFieldsArr = array(); foreach ($orderTypesList as $orderType) { $_customFieldsArr = array(); foreach ($arResult['customFields'] as $custom) { $_customFieldsArr[$custom['ID']] = htmlspecialchars(trim($_POST['custom-fields-' . $custom['ID'] . '-' . $orderType['ID']])); } $customFieldsArr[$orderType['ID']] = $_customFieldsArr; } //contragents type list $contragentTypeArr = array(); //сделать проверки foreach ($orderTypesList as $orderType) { $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); } COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_PROPS, serialize(ICrmOrderActions::clearArr($orderPropsArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOM_FIELDS, serialize(ICrmOrderActions::clearArr($customFieldsArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_LEGAL_DETAILS, serialize(ICrmOrderActions::clearArr($legalDetailsArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CONTRAGENT_TYPE, serialize(ICrmOrderActions::clearArr($contragentTypeArr))); $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'; } $arResult['PRICE_TYPES'] = array(); $dbPriceType = CCatalogGroup::GetList(array("SORT" => "ASC"), array(), array(), array(), array("ID", "NAME", "BASE")); while ($arPriceType = $dbPriceType->Fetch()) { $arResult['PRICE_TYPES'][$arPriceType['ID']] = $arPriceType; } $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']; } $iblockProperties = array("article" => "article", "manufacturer" => "manufacturer", "color" => "color", "weight" => "weight", "size" => "size", "length" => "length", "width" => "width", "height" => "height"); $propertiesSKU = array(); $propertiesUnitSKU = array(); foreach ($iblockProperties as $prop) { foreach ($_POST['IBLOCK_PROPERTY_SKU' . '_' . $prop] as $iblock => $val) { $propertiesSKU[$iblock][$prop] = $val; } foreach ($_POST['IBLOCK_PROPERTY_UNIT_SKU' . '_' . $prop] as $iblock => $val) { $propertiesUnitSKU[$iblock][$prop] = $val; } } $propertiesProduct = array(); $propertiesUnitProduct = array(); foreach ($iblockProperties as $prop) { foreach ($_POST['IBLOCK_PROPERTY_PRODUCT' . '_' . $prop] as $iblock => $val) { $propertiesProduct[$iblock][$prop] = $val; } foreach ($_POST['IBLOCK_PROPERTY_UNIT_PRODUCT' . '_' . $prop] as $iblock => $val) { $propertiesUnitProduct[$iblock][$prop] = $val; } } if (!isset($_POST['SETUP_FILE_NAME'])) { $arResult['errCode'] = 'ERR_FIELDS_FILE'; } else { $filename = $_POST['SETUP_FILE_NAME']; } if (!isset($_POST['TYPE_LOADING'])) { $typeLoading = 0; } else { $typeLoading = $_POST['TYPE_LOADING']; } if (!isset($_POST['SETUP_PROFILE_NAME'])) { $profileName = ""; } else { $profileName = $_POST['SETUP_PROFILE_NAME']; } if ($typeLoading != 'none' && $profileName == "") { $arResult['errCode'] = 'ERR_FIELDS_PROFILE'; } if ($filename == "") { $arResult['errCode'] = 'ERR_FIELDS_FILE'; } if (isset($arResult['errCode']) && $arResult['errCode']) { $arOldValues = array('IBLOCK_EXPORT' => $iblocks, 'IBLOCK_PROPERTY_SKU' => $propertiesSKU, 'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU, 'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct, 'IBLOCK_PROPERTY_UNIT_PRODUCT' => $propertiesUnitProduct, 'SETUP_FILE_NAME' => $filename, 'SETUP_PROFILE_NAME' => $profileName); global $oldValues; $oldValues = $arOldValues; $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php'); return; } RegisterModule($this->MODULE_ID); RegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder"); RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder"); RegisterModuleDependences("sale", "OnBeforeOrderAccountNumberSet", $this->MODULE_ID, "ICrmOrderEvent", "onBeforeOrderAccountNumberSet"); RegisterModuleDependences("sale", "OnOrderNewSendEmail", $this->MODULE_ID, "ICrmOrderEvent", "onSendOrderMail"); RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "ICrmOrderEvent", "onUpdateOrder"); RegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "ICrmOrderEvent", "onBeforeOrderAdd"); RegisterModuleDependences("sale", "OnSaleBeforeReserveOrder", $this->MODULE_ID, "ICrmOrderEvent", "OnSaleBeforeReserveOrder"); RegisterModuleDependences("sale", "OnSaleReserveOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleReserveOrder"); COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types']))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_IBLOCKS, $iblocks); $this->CopyFiles(); if (isset($_POST['LOAD_NOW'])) { $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); while ($ar = $rsSites->Fetch()) { if ($ar['DEF'] == 'Y') { $SERVER_NAME = $ar['SERVER_NAME']; //разделить потом с учетом многосайтовости } } $loader = new ICMLLoader(); $loader->iblocks = $iblocks; $loader->propertiesUnitProduct = $propertiesUnitProduct; $loader->propertiesProduct = $propertiesProduct; $loader->propertiesUnitSKU = $propertiesUnitSKU; $loader->propertiesSKU = $propertiesSKU; $loader->filename = $filename; $loader->serverName = $SERVER_NAME; $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"); CCatalogExport::Delete($arProfile['ID']); } } } $ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesUnitProduct, $propertiesSKU, $propertiesUnitSKU, $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)); 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'), "Y", $dateAgent->format('d.m.Y H:i:s'), 30); CCatalogExport::Update($PROFILE_ID, array("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"); $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"); 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); } 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"; } CCatalogExport::Update($PROFILE_ID, array("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"); fwrite($fp, $cfg_data); fclose($fp); $arRetval = array(); @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::orderAgent();", $this->MODULE_ID, "N", 600, $dateAgent->format('d.m.Y H:i:s'), "Y", $dateAgent->format('d.m.Y H:i:s'), 30); $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 \RetailCrm\RestApi($api_host, $api_key); try { $this->INTARO_CRM_API->statisticUpdate(); } catch (\RetailCrm\Exception\CurlException $e) { ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::statisticUpdate::CurlException', $e->getCode() . ': ' . $e->getMessage()); } // in fin order COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s')); $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php'); } } } } } } } }
private static function makeMessage($eventId, $arParams) { global $DB; $strResult = GetMessage('SMOB_PUSH_MES_' . $eventId, array("#ACCOUNT_NUMBER#" => $arParams["ORDER"]["ACCOUNT_NUMBER"], "#DATE_INSERT#" => FormatDate($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")), strtotime($arParams["ORDER"]["DATE_INSERT"])), "#PRICE#" => $arParams["ORDER"]["PRICE"], "#CURRENCY#" => $arParams["ORDER"]["CURRENCY"])); if ($eventId == "ORDER_STATUS_CHANGED") { $arFilter = array("LID" => LANGUAGE_ID, "ID" => $arParams["ORDER"]["STATUS_ID"]); $dbStatusListTmp = CSaleStatus::GetList(array("SORT" => "ASC"), $arFilter, false, false, array("NAME")); if ($arStatus = $dbStatusListTmp->GetNext()) { $strResult = str_replace("#STATUS_NAME#", $arStatus["NAME"], $strResult); } } return $strResult; }
@set_time_limit(0); $DB->StartTransaction(); if (!CSaleStatus::Delete($ID)) { $DB->Rollback(); if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(GetMessage("ERROR_DEL_STATUS"), $ID); } } $DB->Commit(); break; } } } $dbResultList = CSaleStatus::GetList(array($by => $order), $arFilter, false, false, array('ID', 'SORT', 'TYPE', 'NOTIFY', 'LID', 'NAME', 'DESCRIPTION', $by)); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("STATUS_NAV"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => GetMessage("STATUS_ID"), "sort" => "ID", "default" => true), array("id" => "SORT", "content" => GetMessage("STATUS_SORT"), "sort" => "SORT", "default" => true), array("id" => "NAME", "content" => GetMessage("SALE_NAME"), "sort" => "", "default" => true), array("id" => "TYPE", "content" => GetMessage("SSAN_TYPE"), "sort" => "TYPE", "default" => true), array('id' => 'NOTIFY', 'content' => GetMessage('SSAN_NOTIFY'), 'sort' => 'NOTIFY', 'default' => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); while ($arCCard = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arCCard); $row->AddField("ID", "<a href=\"/bitrix/admin/sale_status_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_") . "\" title=\"" . GetMessage("SALE_EDIT_DESCR") . "\">" . $f_ID . "</a>"); $row->AddField("SORT", $f_SORT); $row->AddField("NAME", $f_NAME . "<br><small>" . $f_DESCRIPTION . "</small><br>"); $row->AddField("TYPE", $f_TYPE == 'O' ? GetMessage('SSEN_TYPE_O') : ($f_TYPE == 'D' ? GetMessage('SSEN_TYPE_D') : 'Invalid ' . $f_TYPE)); $row->AddField("NOTIFY", $f_NOTIFY == 'Y' ? '<a href="/bitrix/admin/message_admin.php?find_event_type=SALE_STATUS_CHANGED_' . $f_ID . '" target="_blank">' . GetMessage('SSAN_NOTIFY_Y') . '</a>' : GetMessage('SSAN_NOTIFY_N')); $arActions = array(); $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("SALE_EDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_status_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_") . ""), "DEFAULT" => true); if ($saleModulePermissions >= "W" && $f_ID != "N" && $f_ID != "F") {
$width = intval($_GET["width"]); $max_width = COption::GetOptionInt("sale", "GRAPH_WEIGHT", 600); if ($width <= 0 || $width > $max_width) { $width = $max_width; } $height = intval($_GET["height"]); $max_height = COption::GetOptionInt("sale", "GRAPH_HEIGHT", 600); if ($height <= 0 || $height > $max_height) { $height = $max_height; } if ($mode != "money") { $mode = "count"; } $arColor = array("08738C", "C6B59C", "0000FF", "FF0000", "FFFF00", "F7C684", "8CD694", "9CADCE", "B584BD", "C684BD", "FF94C6", "BDE794", "F7949C", "7BCE6B", "FF6342", "E2F86B", "A5DE63", "42BD6B", "52BDA5", "F79473", "5AC6DE", "94D6C6", "9C52AD", "BD52AD", "9C94C6", "FF63AD", "FF6384", "FE881D", "FF9C21", "FFAD7B", "EFFF29", "7BCE6B", "42BD6B", "52C6AD", "6B8CBD", "3963AD", "F7298C", "A51800", "9CA510", "528C21", "689EB9", "217B29", "6B8CC6", "D6496C", "C6A56B", "00B0A4", "AD844A", "9710B4", "946331", "AD3908", "734210", "008400", "3EC19A", "28D7D7", "6B63AD", "A4C13E", "7BCE31", "A5DE94", "94D6E7", "9C8C73", "FF8C4A", "A7588B", "03CF45", "F7B54A", "808040", "947BBD", "840084", "737373", "C48322", "809254", "1E8259", "63C6DE", "46128D", "8080C0"); $arStatus = array(); $dbStatusList = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID), false, false, array("ID", "NAME", "SORT")); while ($arStatusList = $dbStatusList->GetNext()) { $arStatus[$arStatusList["ID"]] = $arStatusList["NAME"]; } $arCurrency = array(); $dbCur = CCurrency::GetList($b = "sort", $order1 = "asc", LANGUAGE_ID); while ($arCur = $dbCur->GetNext()) { $arCurrency[$arCur["CURRENCY"]] = $arCur["FULL_NAME"]; } $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($arSites = $dbSite->GetNext()) { $arSite[$arSites["LID"]] = $arSites["NAME"]; } $arFind = array("find_canceled" => $find_canceled, "find_allow_delivery" => $find_allow_delivery, "find_payed" => $find_payed, "find_all" => $find_all, "filter_by" => $filter_by, "mode" => $mode); foreach ($arCurrency as $k1 => $v1) { if (${"find_all_" . $k1} == "Y") {
function InstallDB() { global $DB, $DBType, $APPLICATION; $this->errors = false; if(!$DB->Query("SELECT 'x' FROM b_sale_basket", true)) { $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/install/db/".$DBType."/install.sql"); } if($this->errors !== false) { $APPLICATION->ThrowException(implode("", $this->errors)); return false; } RegisterModule("sale"); RegisterModuleDependences("main", "OnUserLogin", "sale", "CSaleUser", "OnUserLogin"); RegisterModuleDependences("main", "OnUserLogout", "sale", "CSaleUser", "OnUserLogout"); RegisterModuleDependences("main", "OnBeforeLangDelete", "sale", "CSalePersonType", "OnBeforeLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocation", "OnLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocationGroup", "OnLangDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleOrderUserProps", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserAccount", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleAuxiliary", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUser", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleRecurring", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserCards", "OnUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleOrder", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleAffiliate", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleUserAccount", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 100, "/modules/sale/affiliate.php"); RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "sale", "CSaleYMHandler", 'OnEventLogGetAuditTypes'); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleOrder", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleLang", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnModuleUnInstall", "sale", "", "CurrencyModuleUnInstallSale"); RegisterModuleDependences("catalog", "OnSaleOrderSumm", "sale", "CSaleOrder", "__SaleOrderCount"); RegisterModuleDependences("mobileapp", "OnBeforeAdminMobileMenuBuild", "sale", "CSaleMobileOrderUtils", "buildSaleAdminMobileMenu"); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketGroup", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketFields", "GetControlDescr", 300); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlOrderFields", "GetControlDescr", 1000); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlCommon", "GetControlDescr", 10000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlDelivery", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketGroup", "GetControlDescr", 300); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlSubGroup", "GetControlDescr", 1000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCondCtrlBasketFields", "GetControlDescr", 1100); //pulling for mobile orders RegisterModuleDependences("sale", "OnOrderDelete", "sale", "CSaleMobileOrderPull", "onOrderDelete", 100); RegisterModuleDependences("sale", "OnOrderAdd", "sale", "CSaleMobileOrderPull", "onOrderAdd", 100); RegisterModuleDependences("sale", "OnOrderUpdate", "sale", "CSaleMobileOrderPull", "onOrderUpdate", 100); // sale product2product RegisterModuleDependences("sale", "OnBasketOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleOrderAdd", 100); RegisterModuleDependences("sale", "OnSaleStatusOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleStatusOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleDeliveryOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeliveryOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleDeductOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeductOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleCancelOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleCancelOrderHandler", 100); RegisterModuleDependences("sale", "OnSalePayOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSalePayOrderHandler", 100); CAgent::AddAgent("\\Bitrix\\Sale\\Product2ProductTable::deleteOldProducts(10);", "sale", "N", 10 * 24 * 3600, "", "Y"); COption::SetOptionString("sale", "viewed_capability", "N"); COption::SetOptionString("sale", "viewed_count", 10); COption::SetOptionString("sale", "viewed_time", 5); COption::SetOptionString("sale", "p2p_status_list", serialize(array( "N", "P", "F", "F_CANCELED", "F_DELIVERY", "F_PAY", "F_OUT" ))); CAgent::AddAgent("CSaleRecurring::AgentCheckRecurring();", "sale", "N", 7200, "", "Y"); CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y"); CAgent::AddAgent("CSaleViewedProduct::ClearViewed();", "sale", "N", 86400, "", "Y"); CAgent::AddAgent("CSaleOrder::ClearProductReservedQuantity();", "sale", "N", 259200, "", "Y"); COption::SetOptionString("sale", "product_reserve_clear_period", "3"); if (CModule::IncludeModule("sale")) { $dbStatusList = CSaleStatus::GetList(array(), array(), false, false, array()); if (!($arStatusList = $dbStatusList->Fetch())) { $arLandDataN = array(); $arLandDataF = array(); $dbLangs = CLanguage::GetList(($b = ""), ($o = ""), array("ACTIVE" => "Y")); while ($arLangs = $dbLangs->Fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/status.php", $arLangs["LID"]); $arLandDataN[] = array( "LID" => $arLangs["LID"], "NAME" => GetMessage("SIM_ACCEPTED"), "DESCRIPTION" => GetMessage("SIM_ACCEPTED_DESCR") ); $arLandDataF[] = array( "LID" => $arLangs["LID"], "NAME" => GetMessage("SIM_FINISHED"), "DESCRIPTION" => GetMessage("SIM_FINISHED_DESCR") ); } CSaleStatus::Add( array( "ID" => "N", "SORT" => 100, "LANG" => $arLandDataN ) ); CSaleStatus::Add( array( "ID" => "F", "SORT" => 200, "LANG" => $arLandDataF ) ); } CSaleYMHandler::install(); } return true; }
/** * Function returns reference data as shared cache between this component and sale.personal.order.list. * * @throws Exception * @return void */ protected function obtainDataReferences() { if ($this->startCache(array('spo-shared'))) { try { $cachedData = array(); ///////////////////// ///////////////////// // Person type $dbPType = CSalePersonType::GetList(array("SORT" => "ASC")); while ($arPType = $dbPType->Fetch()) { $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType; } // Save statuses for Filter form $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID)); while ($arStatus = $dbStatus->Fetch()) { $cachedData['STATUS'][$arStatus["ID"]] = $arStatus; } $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC")); while ($arPaySystem = $dbPaySystem->Fetch()) { $arPaySystem['NAME'] = htmlspecialcharsbx($arPaySystem['NAME']); $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem; } $cachedData['DELIVERY'] = array(); $shipmentIds = array(); foreach ($this->dbResult['SHIPMENT'] as $shipment) { $shipmentIds[] = $shipment['DELIVERY_ID']; } $dbDelivery = \Bitrix\Sale\Delivery\Services\Table::getList(array('select' => array('ID', 'NAME', 'PARENT_NAME' => 'PARENT.NAME', 'PARENT_CLASS_NAME' => 'PARENT.CLASS_NAME'), 'filter' => array('ID' => $shipmentIds))); $deliveryService = array(); while ($delivery = $dbDelivery->fetch()) { $deliveryService[$delivery['ID']] = $delivery; } foreach ($deliveryService as $delivery) { $cachedData['DELIVERY'][$delivery["ID"]] = array(); if ($delivery['PARENT_NAME']) { $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = htmlspecialcharsbx($delivery['PARENT_NAME'] . ':' . $delivery['NAME']); } else { $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = htmlspecialcharsbx($delivery['NAME']); } } ///////////////////// ///////////////////// } catch (Exception $e) { $this->abortCache(); throw $e; } $this->endCache($cachedData); } else { $cachedData = $this->getCacheData(); } $this->dbResult = array_merge($this->dbResult, $this->adaptCachedReferences($cachedData)); }
$emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_NEW_ORDER_RECURRING", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_NEW_ORDER_RECURRING_SUBJECT"), "MESSAGE" => GetMessage("SALE_NEW_ORDER_RECURRING_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_ORDER_CANCEL", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_ORDER_CANCEL_SUBJECT"), "MESSAGE" => GetMessage("SALE_ORDER_CANCEL_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_ORDER_DELIVERY", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_ORDER_DELIVERY_SUBJECT"), "MESSAGE" => GetMessage("SALE_ORDER_DELIVERY_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_ORDER_PAID", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_ORDER_PAID_SUBJECT"), "MESSAGE" => GetMessage("SALE_ORDER_PAID_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_RECURRING_CANCEL", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_RECURRING_CANCEL_SUBJECT"), "MESSAGE" => GetMessage("SALE_RECURRING_CANCEL_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_ORDER_REMIND_PAYMENT", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("SALE_ORDER_REMIND_PAYMENT_SUBJECT"), "MESSAGE" => GetMessage("SALE_ORDER_REMIND_PAYMENT_MESSAGE"), "BODY_TYPE" => "text")); $emess = new CEventMessage(); $emess->Add(array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_SUBSCRIBE_PRODUCT", "LID" => WIZARD_SITE_ID, "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "BCC" => "#BCC#", "SUBJECT" => GetMessage("UP_SUBJECT"), "MESSAGE" => GetMessage("UP_MESSAGE"), "BODY_TYPE" => "text")); if (CModule::IncludeModule("sale")) { $dbStatus = CSaleStatus::GetList(array($by => $order), array(), false, false, array("ID", "SORT", "LID", "NAME", "DESCRIPTION")); while ($arStatus = $dbStatus->Fetch()) { $ID = $arStatus["ID"]; $eventType = new CEventType(); $eventMessage = new CEventMessage(); IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/general/status.php", $lid); $arStatusLang = CSaleStatus::GetLangByID($ID, $lid); $dbEventType = $eventType->GetList(array("EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "LID" => $lid)); if (!($arEventType = $dbEventType->Fetch())) { $str = ""; $str .= "#ORDER_ID# - " . GetMessage("SKGS_ORDER_ID") . "\n"; $str .= "#ORDER_DATE# - " . GetMessage("SKGS_ORDER_DATE") . "\n"; $str .= "#ORDER_STATUS# - " . GetMessage("SKGS_ORDER_STATUS") . "\n"; $str .= "#EMAIL# - " . GetMessage("SKGS_ORDER_EMAIL") . "\n"; $str .= "#ORDER_DESCRIPTION# - " . GetMessage("SKGS_STATUS_DESCR") . "\n"; $str .= "#TEXT# - " . GetMessage("SKGS_STATUS_TEXT") . "\n";
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("sale")) { return; } $arUGroupsEx = array(); $dbUGroups = CGroup::GetList($by = "c_sort", $order = "asc"); while ($arUGroups = $dbUGroups->Fetch()) { $arUGroupsEx[$arUGroups["ID"]] = $arUGroups["NAME"]; } $rsSite = CSite::GetList($by = "sort", $order = "asc", $arFilter = array("ACTIVE" => "Y")); $arSites = array("" => GetMessage("CP_BCI1_ALL_SITES")); while ($arSite = $rsSite->GetNext()) { $arSites[$arSite["LID"]] = $arSite["NAME"]; } $arStatuses = array("" => GetMessage("CP_BCI1_NO")); $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID)); while ($arStatus = $dbStatus->GetNext()) { $arStatuses[$arStatus["ID"]] = "[" . $arStatus["ID"] . "] " . $arStatus["NAME"]; } $arComponentParameters = array("PARAMETERS" => array("SITE_LIST" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_SITE_LIST"), "TYPE" => "LIST", "MULTIPLE" => "N", "VALUES" => $arSites), "IMPORT_NEW_ORDERS" => array("PARENT" => "BASE", "NAME" => GetMessage("SALE_1C_IMPORT_NEW_ORDERS"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "1C_SITE_NEW_ORDERS" => array("PARENT" => "BASE", "NAME" => GetMessage("SALE_1C_SITE_NEW_ORDERS"), "TYPE" => "LIST", "MULTIPLE" => "N", "VALUES" => $arSites), "EXPORT_PAYED_ORDERS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_EXPORT_PAYED_ORDERS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "EXPORT_ALLOW_DELIVERY_ORDERS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_EXPORT_ALLOW_DELIVERY_ORDERS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "CHANGE_STATUS_FROM_1C" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_CHANGE_STATUS_FROM_1C"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "EXPORT_FINAL_ORDERS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_EXPORT_FINAL_ORDERS"), "TYPE" => "LIST", "DEFAULT" => "", "VALUES" => $arStatuses), "REPLACE_CURRENCY" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_REPLACE_CURRENCY"), "TYPE" => "TEXT", "DEFAULT" => GetMessage("CP_BCI1_REPLACE_CURRENCY_VALUE")), "GROUP_PERMISSIONS" => array("PARENT" => "BASE", "NAME" => GetMessage("CP_BCI1_GROUP_PERMISSIONS"), "TYPE" => "LIST", "VALUES" => $arUGroupsEx, "DEFAULT" => array(1), "MULTIPLE" => "Y"), "USE_ZIP" => array("PARENT" => "ADDITIONAL", "NAME" => GetMessage("CP_BCI1_USE_ZIP"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "INTERVAL" => array("PARENT" => "ADDITIONAL", "NAME" => GetMessage("SALE_1C_INTERVAL"), "TYPE" => "TEXT", "DEFAULT" => 30), "FILE_SIZE_LIMIT" => array("PARENT" => "ADDITIONAL", "NAME" => GetMessage("SALE_1C_FILE_SIZE_LIMIT"), "TYPE" => "TEXT", "DEFAULT" => 200 * 1024)));
public static function getStatusesNames($arStatusIds) { $arStatusNames = array(); $dbStat = CSaleStatus::GetList( array(), array("ID" =>$arStatusIds, "LID" => LANGUAGE_ID), false, false, array("ID", "NAME") ); while($arStat = $dbStat->Fetch()) $arStatusNames[$arStat["ID"]] = htmlspecialcharsbx($arStat["NAME"]); return $arStatusNames; }
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arYesNo = array("Y" => GetMessage("SPO_DESC_YES"), "N" => GetMessage("SPO_DESC_NO")); $arComponentParameters = array("PARAMETERS" => array("SEF_MODE" => array("list" => array("NAME" => GetMessage("SPO_LIST_DESC"), "DEFAULT" => "index.php", "VARIABLES" => array()), "detail" => array("NAME" => GetMessage("SPO_DETAIL_DESC"), "DEFAULT" => "order_detail.php?ID=#ID#", "VARIABLES" => array("ID")), "cancel" => array("NAME" => GetMessage("SPO_CANCEL_DESC"), "DEFAULT" => "order_cancel.php?ID=#ID#", "VARIABLES" => array("ID"))), "ORDERS_PER_PAGE" => array("NAME" => GetMessage("SPO_ORDERS_PER_PAGE"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "20", "PARENT" => "ADDITIONAL_SETTINGS"), "PATH_TO_PAYMENT" => array("NAME" => GetMessage("SPO_PATH_TO_PAYMENT"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "payment.php", "PARENT" => "ADDITIONAL_SETTINGS"), "PATH_TO_BASKET" => array("NAME" => GetMessage("SPO_PATH_TO_BASKET"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "basket.php", "COLS" => 25, "PARENT" => "ADDITIONAL_SETTINGS"), "SET_TITLE" => array(), "SAVE_IN_SESSION" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SPO_SAVE_IN_SESSION"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "NAV_TEMPLATE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("SPOL_NAV_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => ""), "CACHE_TIME" => array("DEFAULT" => 3600), "CACHE_GROUPS" => array("PARENT" => "CACHE_SETTINGS", "NAME" => GetMessage("SPO_CACHE_GROUPS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"))); if (CModule::IncludeModule("iblock")) { $arComponentParameters["PARAMETERS"]["ACTIVE_DATE_FORMAT"] = CIBlockParameters::GetDateFormat(GetMessage("SPO_ACTIVE_DATE_FORMAT"), "VISUAL"); $arComponentParameters["PARAMETERS"]["CUSTOM_SELECT_PROPS"] = array("NAME" => GetMessage("SPO_PARAM_CUSTOM_SELECT_PROPS"), "TYPE" => "STRING", "MULTIPLE" => "Y", "VALUES" => array(), "PARENT" => "ADDITIONAL_SETTINGS"); } if (CModule::IncludeModule("sale")) { $dbPerson = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC")); while ($arPerson = $dbPerson->GetNext()) { $arPers2Prop = array("" => GetMessage("SPO_SHOW_ALL")); $bProp = false; $dbProp = CSaleOrderProps::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("PERSON_TYPE_ID" => $arPerson["ID"])); while ($arProp = $dbProp->GetNext()) { $arPers2Prop[$arProp["ID"]] = $arProp["NAME"]; $bProp = true; } if ($bProp) { $arComponentParameters["PARAMETERS"]["PROP_" . $arPerson["ID"]] = array("NAME" => GetMessage("SPO_PROPS_NOT_SHOW") . " \"" . $arPerson["NAME"] . "\" (" . $arPerson["LID"] . ")", "TYPE" => "LIST", "MULTIPLE" => "Y", "VALUES" => $arPers2Prop, "DEFAULT" => "", "COLS" => 25, "ADDITIONAL_VALUES" => "N", "PARENT" => "BASE"); } } // "historic" statuses $dbStat = CSaleStatus::GetList(array('sort' => 'asc'), array('LID' => LANGUAGE_ID), false, false, array('ID', 'NAME')); $statList = array(); while ($item = $dbStat->Fetch()) { $statList[$item['ID']] = $item['NAME']; } $arComponentParameters['PARAMETERS']['HISTORIC_STATUSES'] = array("NAME" => GetMessage("SPO_HISTORIC_STATUSES"), "TYPE" => "LIST", "VALUES" => $statList, "MULTIPLE" => "Y", "DEFAULT" => "F", "PARENT" => "ADDITIONAL_SETTINGS"); }
@set_time_limit(0); $DB->StartTransaction(); if (!CSaleStatus::Delete($ID)) { $DB->Rollback(); if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(GetMessage("ERROR_DEL_STATUS"), $ID); } } $DB->Commit(); break; } } } $dbResultList = CSaleStatus::GetList(array($by => $order), $arFilter, false, false, array("ID", "SORT", "LID", "NAME", "DESCRIPTION", $by)); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("STATUS_NAV"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => GetMessage("STATUS_ID"), "sort" => "ID", "default" => true), array("id" => "SORT", "content" => GetMessage("STATUS_SORT"), "sort" => "SORT", "default" => true), array("id" => "NAME", "content" => GetMessage("SALE_NAME"), "sort" => "", "default" => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); while ($arCCard = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arCCard); $row->AddField("ID", "<a href=\"/bitrix/admin/sale_status_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_") . "\" title=\"" . GetMessage("SALE_EDIT_DESCR") . "\">" . $f_ID . "</a>"); $row->AddField("SORT", $f_SORT); $row->AddField("NAME", $f_NAME . "<br><small>" . $f_DESCRIPTION . "</small><br>"); $arActions = array(); $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("SALE_EDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_status_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_") . ""), "DEFAULT" => true); if ($saleModulePermissions >= "W" && $f_ID != "N" && $f_ID != "F") { $arActions[] = array("SEPARATOR" => true); $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("SALE_DELETE_DESCR"), "ACTION" => "if(confirm('" . GetMessage('STATUS_DEL_CONF') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete"));
function InstallDB() { global $DB, $DBType, $APPLICATION; $this->errors = false; if (!$DB->Query("SELECT 'x' FROM b_sale_basket", true)) { $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/install/db/" . $DBType . "/install.sql"); } if ($this->errors !== false) { $APPLICATION->ThrowException(implode("", $this->errors)); return false; } ModuleManager::registerModule('sale'); $eventManager = \Bitrix\Main\EventManager::getInstance(); $eventManager->registerEventHandlerCompatible('main', 'OnUserLogout', 'sale', '\\Bitrix\\Sale\\DiscountCouponsManager', 'logout'); RegisterModuleDependences("main", "OnUserLogin", "sale", "CSaleUser", "OnUserLogin"); RegisterModuleDependences("main", "OnUserLogout", "sale", "CSaleUser", "OnUserLogout"); RegisterModuleDependences("main", "OnBeforeLangDelete", "sale", "CSalePersonType", "OnBeforeLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocation", "OnLangDelete"); RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocationGroup", "OnLangDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleOrderUserProps", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserAccount", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleAuxiliary", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUser", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleRecurring", "OnUserDelete"); RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserCards", "OnUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleOrder", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleAffiliate", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleUserAccount", "OnBeforeUserDelete"); RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 100, "/modules/sale/affiliate.php"); RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "sale", "CSaleYMHandler", 'OnEventLogGetAuditTypes'); RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "sale", "CSalePaySystemAction", 'OnEventLogGetAuditTypes'); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleOrder", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleLang", "OnBeforeCurrencyDelete"); RegisterModuleDependences("currency", "OnModuleUnInstall", "sale", "", "CurrencyModuleUnInstallSale"); RegisterModuleDependences("catalog", "OnSaleOrderSumm", "sale", "CSaleOrder", "__SaleOrderCount"); RegisterModuleDependences("mobileapp", "OnBeforeAdminMobileMenuBuild", "sale", "CSaleMobileOrderUtils", "buildSaleAdminMobileMenu"); RegisterModuleDependences("sender", "OnConnectorList", "sale", "\\Bitrix\\Sale\\SenderEventHandler", "onConnectorListBuyer"); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketGroup", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketFields", "GetControlDescr", 300); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlOrderFields", "GetControlDescr", 1000); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlCommon", "GetControlDescr", 10000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlDelivery", "GetControlDescr", 200); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketGroup", "GetControlDescr", 300); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlSubGroup", "GetControlDescr", 1000); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCondCtrlBasketFields", "GetControlDescr", 1100); //pulling for mobile orders RegisterModuleDependences("sale", "OnOrderDelete", "sale", "CSaleMobileOrderPull", "onOrderDelete", 100); RegisterModuleDependences("sale", "OnOrderAdd", "sale", "CSaleMobileOrderPull", "onOrderAdd", 100); RegisterModuleDependences("sale", "OnOrderUpdate", "sale", "CSaleMobileOrderPull", "onOrderUpdate", 100); // sale product2product RegisterModuleDependences("sale", "OnBasketOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleOrderAdd", 100); RegisterModuleDependences("sale", "OnSaleStatusOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleStatusOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleDeliveryOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeliveryOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleDeductOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeductOrderHandler", 100); RegisterModuleDependences("sale", "OnSaleCancelOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleCancelOrderHandler", 100); RegisterModuleDependences("sale", "OnSalePayOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSalePayOrderHandler", 100); CAgent::AddAgent("\\Bitrix\\Sale\\Product2ProductTable::deleteOldProducts(10);", "sale", "N", 10 * 24 * 3600, "", "Y"); COption::SetOptionString("sale", "viewed_capability", "N"); COption::SetOptionString("sale", "viewed_count", 10); COption::SetOptionString("sale", "viewed_time", 5); COption::SetOptionString("sale", "p2p_status_list", serialize(array("N", "P", "F", "F_CANCELED", "F_DELIVERY", "F_PAY", "F_OUT"))); CAgent::AddAgent("CSaleRecurring::AgentCheckRecurring();", "sale", "N", 7200, "", "Y"); CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y"); CAgent::AddAgent("CSaleViewedProduct::ClearViewed();", "sale", "N", 86400, "", "Y"); CAgent::AddAgent("CSaleOrder::ClearProductReservedQuantity();", "sale", "N", 259200, "", "Y"); COption::SetOptionString("sale", "product_reserve_clear_period", "3"); if (CModule::IncludeModule("sale")) { $dbStatusList = CSaleStatus::GetList(array(), array(), false, false, array()); if (!($arStatusList = $dbStatusList->Fetch())) { $arLandDataN = array(); $arLandDataF = array(); $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y'))); while ($language = $languageIterator->fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/status.php", $language['ID']); $arLandDataN[] = array("LID" => $language['ID'], "NAME" => GetMessage("SIM_ACCEPTED"), "DESCRIPTION" => GetMessage("SIM_ACCEPTED_DESCR")); $arLandDataF[] = array("LID" => $language['ID'], "NAME" => GetMessage("SIM_FINISHED"), "DESCRIPTION" => GetMessage("SIM_FINISHED_DESCR")); } unset($language, $languageIterator); CSaleStatus::Add(array("ID" => "N", "SORT" => 100, "LANG" => $arLandDataN)); CSaleStatus::Add(array("ID" => "F", "SORT" => 200, "LANG" => $arLandDataF)); } // enabling location pro COption::SetOptionString("sale", "sale_locationpro_migrated", "Y"); COption::SetOptionString("sale", "sale_locationpro_enabled", "Y"); if (\Bitrix\Main\ModuleManager::isModuleInstalled('bitrix24')) { // this will create at least base types if we are at Bitrix24 include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/sale/lib/location/migration/migrate.php"; \Bitrix\Sale\Location\Migration\CUpdaterLocationPro::createBaseTypes(); } CSaleYMHandler::install(); } return true; }
$rsStatusLangs = CSaleStatus::GetList(array(), array('ID' => $ID), false, false, array('ID', 'LID', 'NAME', 'DESCRIPTION')); while ($arOneLang = $rsStatusLangs->Fetch()) { if (!isset($arStatusLangs[$arOneLang['LID']])) { continue; } $arStatusLangs[$arOneLang['LID']] = $arOneLang; } if (!empty($arStatusGroupIDs)) { $arStatusPerms = array_fill_keys($arStatusGroupIDs, $arPermFields); foreach ($arStatusGroupIDs as &$intOneGroupID) { $arStatusPerms[$intOneGroupID]['GROUP_ID'] = $intOneGroupID; } if (isset($intOneGroupID)) { unset($intOneGroupID); } $rsPerms = CSaleStatus::GetList(array(), array('ID' => $ID, 'GROUP_ID' => $arStatusGroupIDs), false, false, array('*')); while ($arOnePerm = $rsPerms->Fetch()) { $arOnePerm['GROUP_ID'] = intval($arOnePerm['GROUP_ID']); $strSelected = 'N'; foreach ($arOnePerm as $key => $value) { if ('GROUP_ID' == $key || 'PERM_VIEW' == $key) { continue; } if ('Y' == $value) { $strSelected = 'Y'; break; } } $arOnePerm['EXT'] = $strSelected; $arStatusPerms[$arOnePerm['GROUP_ID']] = $arOnePerm; }