...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_view_helper.php
- Класс: \CCrmViewHelper
- Вызов: CCrmViewHelper::RenderProgressControl
static function RenderProgressControl($arParams) { if(!is_array($arParams)) { return ''; } \Bitrix\Main\Page\Asset::getInstance()->addJs('/bitrix/js/crm/progress_control.js'); \Bitrix\Main\Page\Asset::getInstance()->addJs('/bitrix/js/crm/partial_entity_editor.js'); $entityTypeName = isset($arParams['ENTITY_TYPE_NAME']) ? $arParams['ENTITY_TYPE_NAME'] : ''; $leadTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Lead); $dealTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Deal); $invoiceTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Invoice); $quoteTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Quote); $orderTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Order); $orderShipmentTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::OrderShipment); $categoryID = isset($arParams['CATEGORY_ID']) ? $arParams['CATEGORY_ID'] : 0; $infos = isset($arParams['INFOS']) ? $arParams['INFOS'] : null; if(!is_array($infos) || empty($infos)) { if($entityTypeName === $leadTypeName) { $infos = self::PrepareLeadStatuses(); } elseif($entityTypeName === $dealTypeName) { $infos = self::PrepareDealStages($categoryID); } elseif($entityTypeName === $quoteTypeName) { $infos = self::PrepareQuoteStatuses(); } elseif($entityTypeName === $invoiceTypeName) { $infos = self::PrepareInvoiceStatuses(); } elseif($entityTypeName === $orderTypeName) { $infos = self::PrepareOrderStatuses(); } elseif($entityTypeName === $orderShipmentTypeName) { $infos = self::PrepareOrderShipmentStatuses(); } elseif (\CCrmOwnerType::isUseFactoryBasedApproach((int)$arParams['ENTITY_TYPE_ID'])) { $infos = self::PrepareItemsStatuses((int)$arParams['ENTITY_TYPE_ID'], (int)$arParams['CATEGORY_ID']); } } $enableCustomColors = true; if(!is_array($infos) || empty($infos)) { return ''; } $registerSettings = isset($arParams['REGISTER_SETTINGS']) && is_bool($arParams['REGISTER_SETTINGS']) ? $arParams['REGISTER_SETTINGS'] : false; $registrationScript = ''; if($registerSettings) { if($entityTypeName === $leadTypeName) { $registrationScript = self::RenderLeadStatusSettings(); } elseif($entityTypeName === $dealTypeName) { $registrationScript = self::RenderDealStageSettings(); } elseif($entityTypeName === $quoteTypeName) { $registrationScript = self::RenderQuoteStatusSettings(); } elseif($entityTypeName === $invoiceTypeName) { $registrationScript = self::RenderInvoiceStatusSettings(); } elseif($entityTypeName === $orderTypeName) { $registrationScript = self::RenderOrderStatusSettings(); } elseif($entityTypeName === $orderShipmentTypeName) { $registrationScript = self::RenderOrderShipmentStatusSettings(); } } $finalID = isset($arParams['FINAL_ID']) ? $arParams['FINAL_ID'] : ''; if($finalID === '') { if($entityTypeName === $leadTypeName) { $finalID = 'CONVERTED'; } elseif($entityTypeName === $dealTypeName) { $finalID = DealCategory::prepareStageID($categoryID, 'WON'); } elseif($entityTypeName === $quoteTypeName) { $finalID = 'APPROVED'; } elseif($entityTypeName === $invoiceTypeName) { $finalID = 'P'; } elseif($entityTypeName === $orderTypeName) { $finalID = \Bitrix\Crm\Order\OrderStatus::getFinalStatus(); } elseif($entityTypeName === $orderShipmentTypeName) { $finalID = \Bitrix\Crm\Order\DeliveryStatus::getFinalStatus(); } elseif ($infos) { foreach ($infos as $stageInfo) { if (\Bitrix\Crm\PhaseSemantics::isFinal($stageInfo['SEMANTICS'])) { $finalID = $stageInfo['STATUS_ID']; break; } } } } $finalUrl = isset($arParams['FINAL_URL']) ? $arParams['FINAL_URL'] : ''; if($finalUrl === '' && $entityTypeName === $leadTypeName) { $arParams['FINAL_URL'] = isset($arParams['LEAD_CONVERT_URL']) ? $arParams['LEAD_CONVERT_URL'] : ''; } $currentInfo = null; $currentID = isset($arParams['CURRENT_ID']) ? $arParams['CURRENT_ID'] : ''; if($currentID !== '' && isset($infos[$currentID])) { $currentInfo = $infos[$currentID]; } $currentSort = is_array($currentInfo) && isset($currentInfo['SORT']) ? intval($currentInfo['SORT']) : -1; $finalInfo = null; if($finalID !== '' && isset($infos[$finalID])) { $finalInfo = $infos[$finalID]; } $finalSort = is_array($finalInfo) && isset($finalInfo['SORT']) ? intval($finalInfo['SORT']) : -1; $isSuccessful = $currentSort === $finalSort; $isFailed = $currentSort > $finalSort; $defaultProcessColor = self::PROCESS_COLOR; $defaultSuccessColor = self::SUCCESS_COLOR; $defaultFailureColor = self::FAILURE_COLOR; $stepHtml = ''; $color = isset($currentInfo['COLOR']) ? $currentInfo['COLOR'] : ''; if($color === '') { $color = $defaultProcessColor; if($isSuccessful) { $color = $defaultSuccessColor; } elseif($isFailed) { $color = $defaultFailureColor; } } $finalColor = isset($finalInfo['COLOR']) ? $finalInfo['COLOR'] : ''; if($finalColor === '') { $finalColor = $isSuccessful ? $defaultSuccessColor : $defaultFailureColor; } foreach($infos as $info) { $ID = isset($info['STATUS_ID']) ? $info['STATUS_ID'] : ''; $sort = isset($info['SORT']) ? (int)$info['SORT'] : 0; if($sort > $finalSort) { break; } if($enableCustomColors) { $stepHtml .= ''; } $wrapperStyle = ''; $wrapperClass = ''; if($enableCustomColors) { if($isSuccessful || $isFailed) { $wrapperStyle = 'style="background:'.$finalColor.'"'; } } else { if($isSuccessful) { $wrapperClass = ' crm-list-stage-end-good'; } elseif($isFailed) { $wrapperClass =' crm-list-stage-end-bad'; } } $prefix = isset($arParams['PREFIX']) ? $arParams['PREFIX'] : ''; $entityID = isset($arParams['ENTITY_ID']) ? intval($arParams['ENTITY_ID']) : 0; $controlID = isset($arParams['CONTROL_ID']) ? $arParams['CONTROL_ID'] : ''; if($controlID === '') { $controlID = $entityTypeName !== '' && $entityID > 0 ? "{$prefix}{$entityTypeName}_{$entityID}" : uniqid($prefix); } $isReadOnly = isset($arParams['READ_ONLY']) ? (bool)$arParams['READ_ONLY'] : false; $legendContainerID = isset($arParams['LEGEND_CONTAINER_ID']) ? $arParams['LEGEND_CONTAINER_ID'] : ''; $displayLegend = $legendContainerID === '' && (!isset($arParams['DISPLAY_LEGEND']) || $arParams['DISPLAY_LEGEND']); $legendHtml = ''; if($displayLegend) { $legendHtml = ' '; } $conversionScheme = null; if(isset($arParams['CONVERSION_SCHEME']) && is_array($arParams['CONVERSION_SCHEME'])) { $conversionScheme = array(); if(isset($arParams['CONVERSION_SCHEME']['ORIGIN_URL'])) { $conversionScheme['originUrl'] = $arParams['CONVERSION_SCHEME']['ORIGIN_URL']; } if(isset($arParams['CONVERSION_SCHEME']['SCHEME_NAME'])) { $conversionScheme['schemeName'] = $arParams['CONVERSION_SCHEME']['SCHEME_NAME']; } if(isset($arParams['CONVERSION_SCHEME']['SCHEME_CAPTION'])) { $conversionScheme['schemeCaption'] = $arParams['CONVERSION_SCHEME']['SCHEME_CAPTION']; } if(isset($arParams['CONVERSION_SCHEME']['SCHEME_DESCRIPTION'])) { $conversionScheme['schemeDescription'] = $arParams['CONVERSION_SCHEME']['SCHEME_DESCRIPTION']; } } $conversionTypeID = isset($arParams['CONVERSION_TYPE_ID']) ? (int)$arParams['CONVERSION_TYPE_ID'] : LeadConversionType::GENERAL; $canConvert = !isset($arParams['CAN_CONVERT']) || $arParams['CAN_CONVERT']; return $registrationScript.' '.$legendHtml; }