示例#1
0
 function InstallDB()
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     $clearInstall = false;
     if (!$DB->Query("SELECT 'x' FROM b_sale_basket", true)) {
         $clearInstall = 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("sender", "OnTriggerList", "sale", "\\Bitrix\\Sale\\Sender\\EventHandler", "onTriggerList");
     RegisterModuleDependences("sender", "OnPresetMailingList", "sale", "\\Bitrix\\Sale\\Sender\\EventHandler", "onPresetMailingList");
     RegisterModuleDependences("sender", "OnPresetTemplateList", "sale", "\\Bitrix\\Sale\\Sender\\EventHandler", "onPresetTemplateList");
     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");
     // conversion
     RegisterModuleDependences('conversion', 'OnGetCounterTypes', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onGetCounterTypes');
     RegisterModuleDependences('conversion', 'OnGetRateTypes', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onGetRateTypes');
     RegisterModuleDependences('conversion', 'OnGenerateInitialData', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onGenerateInitialData');
     RegisterModuleDependences('sale', 'OnBeforeBasketAdd', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBeforeBasketAdd');
     RegisterModuleDependences('sale', 'OnBasketAdd', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBasketAdd');
     RegisterModuleDependences('sale', 'OnBeforeBasketUpdate', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBeforeBasketUpdate');
     RegisterModuleDependences('sale', 'OnBasketUpdate', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBasketUpdate');
     RegisterModuleDependences('sale', 'OnBeforeBasketDelete', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBeforeBasketDelete');
     RegisterModuleDependences('sale', 'OnBasketDelete', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onBasketDelete');
     RegisterModuleDependences('sale', 'OnOrderAdd', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onOrderAdd');
     RegisterModuleDependences('sale', 'OnSalePayOrder', 'sale', '\\Bitrix\\Sale\\Internals\\ConversionHandlers', 'onSalePayOrder');
     RegisterModuleDependences("perfmon", "OnGetTableSchema", "sale", "sale", "OnGetTableSchema");
     COption::SetOptionString("sale", "viewed_capability", "N");
     COption::SetOptionString("sale", "viewed_count", 10);
     COption::SetOptionString("sale", "viewed_time", 5);
     COption::SetOptionString("main", "~sale_converted_15", 'Y');
     COption::SetOptionString("sale", "expiration_processing_events", 'N');
     COption::SetOptionString("sale", "p2p_status_list", serialize(array("N", "P", "F", "F_CANCELED", "F_DELIVERY", "F_PAY", "F_OUT")));
     if ($clearInstall) {
         \Bitrix\Main\Config\Option::set('sale', 'basket_discount_converted', 'Y', '');
     }
     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", 86400, "", "Y");
     COption::SetOptionString("sale", "product_reserve_clear_period", "3");
     \Bitrix\Main\Config\Option::set('sale', 'sale_locationpro_import_performed', 'Y');
     // install tasks + operations for statuses
     $operations = array();
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_view'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_cancel'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_mark'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_delivery'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_deduction'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_payment'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_to'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_update'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_delete'));
     $operations[] = Bitrix\Main\OperationTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_from'));
     Bitrix\Main\TaskTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_none', 'SYS' => 'Y', 'LETTER' => 'D'));
     $result = Bitrix\Main\TaskTable::add(array('MODULE_ID' => 'sale', 'BINDING' => 'status', 'NAME' => 'sale_status_all', 'SYS' => 'Y', 'LETTER' => 'X'));
     if ($result->isSuccess()) {
         $taskId = $result->getId();
         foreach ($operations as $result) {
             if ($result->isSuccess()) {
                 Bitrix\Main\TaskOperationTable::add(array('TASK_ID' => $taskId, 'OPERATION_ID' => $result->getId()));
             }
         }
     }
     if (Bitrix\Main\Loader::IncludeModule('sale')) {
         // install statuses
         $orderInitialStatus = Bitrix\Sale\OrderStatus::getInitialStatus();
         $orderFinalStatus = Bitrix\Sale\OrderStatus::getFinalStatus();
         $deliveryInitialStatus = Bitrix\Sale\DeliveryStatus::getInitialStatus();
         $deliveryFinalStatus = Bitrix\Sale\DeliveryStatus::getFinalStatus();
         $statusLanguages = array();
         $result = Bitrix\Main\Localization\LanguageTable::getList(array('select' => array('LID'), 'filter' => array('=ACTIVE' => 'Y')));
         while ($row = $result->Fetch()) {
             $languageId = $row['LID'];
             Bitrix\Main\Localization\Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/status.php', $languageId);
             foreach (array($orderInitialStatus, $orderFinalStatus, $deliveryInitialStatus, $deliveryFinalStatus) as $statusId) {
                 if ($statusName = Bitrix\Main\Localization\Loc::getMessage("SALE_STATUS_{$statusId}")) {
                     $statusLanguages[$statusId][] = array('LID' => $languageId, 'NAME' => $statusName, 'DESCRIPTION' => Bitrix\Main\Localization\Loc::getMessage("SALE_STATUS_{$statusId}_DESCR"));
                 }
             }
         }
         Bitrix\Sale\OrderStatus::install(array('ID' => $orderInitialStatus, 'SORT' => 100, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$orderInitialStatus]));
         Bitrix\Sale\OrderStatus::install(array('ID' => $orderFinalStatus, 'SORT' => 200, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$orderFinalStatus]));
         Bitrix\Sale\DeliveryStatus::install(array('ID' => $deliveryInitialStatus, 'SORT' => 300, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$deliveryInitialStatus]));
         Bitrix\Sale\DeliveryStatus::install(array('ID' => $deliveryFinalStatus, 'SORT' => 400, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$deliveryFinalStatus]));
         // 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;
 }
示例#2
0
 try {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/compatible/compatible.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/internals/status_grouptask.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/general/status.php';
     CSaleStatusAdapter::migrate();
 } catch (Exception $e) {
     \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "CSaleStatusAdapter::migrate", "DESCRIPTION" => $e->getMessage()));
 }
 try {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/status.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/internals/status.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/internals/status_lang.php';
     $deliveryInitialStatus = Bitrix\Sale\DeliveryStatus::getInitialStatus();
     $deliveryFinalStatus = Bitrix\Sale\DeliveryStatus::getFinalStatus();
     $statusLanguages = array();
     $result = Bitrix\Main\Localization\LanguageTable::getList(array('select' => array('LID'), 'filter' => array('=ACTIVE' => 'Y')));
     while ($row = $result->Fetch()) {
         $languageId = $row['LID'];
         Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lib/status.php', $languageId);
         foreach (array($deliveryInitialStatus, $deliveryFinalStatus) as $statusId) {
             if ($statusName = Loc::getMessage("SALE_STATUS_{$statusId}")) {
                 $statusLanguages[$statusId][] = array('LID' => $languageId, 'NAME' => $statusName, 'DESCRIPTION' => Loc::getMessage("SALE_STATUS_{$statusId}_DESCR"));
             }
         }
     }
     Bitrix\Sale\DeliveryStatus::install(array('ID' => $deliveryInitialStatus, 'SORT' => 300, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$deliveryInitialStatus]));
     Bitrix\Sale\DeliveryStatus::install(array('ID' => $deliveryFinalStatus, 'SORT' => 400, 'NOTIFY' => 'Y', 'LANG' => $statusLanguages[$deliveryFinalStatus]));
 } catch (Exception $e) {
     \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "Status::install", "DESCRIPTION" => $e->getMessage()));
 }
 try {