예제 #1
0
    ShowError(GetMessage('CRM_LEAD_VIEW_NOT_FOUND', array('#ID#' => $arParams['ENTITY_ID'])));
    return;
}
$arResult['PERMISSIONS'] = array('EDIT' => CCrmLead::CheckUpdatePermission($entityID, $userPerms) && $arFields['STATUS_ID'] !== 'CONVERTED', 'DELETE' => CCrmLead::CheckDeletePermission($entityID, $userPerms));
$arResult['STATUS_LIST'] = CCrmStatus::GetStatusList('STATUS');
$arResult['SOURCE_LIST'] = CCrmStatus::GetStatusList('SOURCE');
$arResult['CURRENCY_LIST'] = CCrmCurrencyHelper::PrepareListItems();
CCrmMobileHelper::PrepareLeadItem($arFields, $arParams, array('STATUS_LIST' => $arResult['STATUS_LIST'], 'SOURCE_LIST' => $arResult['SOURCE_LIST']));
$arFields['FM'] = array();
$dbMultiFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'LEAD', 'ELEMENT_ID' => $entityID));
if ($dbMultiFields) {
    while ($multiFields = $dbMultiFields->Fetch()) {
        $arFields['FM'][$multiFields['TYPE_ID']][] = array('VALUE' => $multiFields['VALUE'], 'VALUE_TYPE' => $multiFields['VALUE_TYPE']);
    }
}
$arResult['CALLTO'] = CCrmMobileHelper::PrepareCalltoParams(array('COMMUNICATION_LIST_URL_TEMPLATE' => $arParams['COMMUNICATION_LIST_URL_TEMPLATE'], 'ENTITY_TYPE_ID' => CCrmOwnerType::Lead, 'ENTITY_ID' => $entityID, 'FM' => $arFields['FM']));
$arResult['MAILTO'] = CCrmMobileHelper::PrepareMailtoParams(array('COMMUNICATION_LIST_URL_TEMPLATE' => $arParams['COMMUNICATION_LIST_URL_TEMPLATE'], 'ENTITY_TYPE_ID' => CCrmOwnerType::Lead, 'ENTITY_ID' => $entityID, 'FM' => $arFields['FM']));
$arFields['PRODUCT_ROWS_QUANTITY'] = CAllCrmProductRow::GetRowQuantity(CCrmOwnerTypeAbbr::ResolveByTypeID(CCrmOwnerType::Lead), $entityID);
$arFields['PRODUCT_ROWS_URL'] = $arParams['PRODUCT_ROW_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::MakePathFromTemplate($arParams['PRODUCT_ROW_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Lead, 'entity_id' => $entityID)) : '';
$arFields['ACTITITY_QUANTITY'] = CAllCrmActivity::GetCount(array('BINDINGS' => array(array('OWNER_TYPE_ID' => CCrmOwnerType::Lead, 'OWNER_ID' => $entityID))));
$arFields['ACTIVITY_LIST_URL'] = $arParams['ACTIVITY_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::MakePathFromTemplate($arParams['ACTIVITY_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Lead, 'entity_id' => $entityID)) : '';
$arFields['EVENT_LIST_URL'] = $arParams['EVENT_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::MakePathFromTemplate($arParams['EVENT_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Lead, 'entity_id' => $entityID)) : '';
$arFields['EDIT_URL'] = $arParams['LEAD_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::MakePathFromTemplate($arParams['LEAD_EDIT_URL_TEMPLATE'], array('lead_id' => $entityID)) : '';
$arFields['CALL_EDIT_URL'] = $arParams['ACTIVITY_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_EDIT_URL_TEMPLATE'], array('owner_type' => CCrmOwnerType::LeadName, 'owner_id' => $entityID, 'type_id' => CCrmActivityType::Call)) : '';
$arFields['MEETING_EDIT_URL'] = $arParams['ACTIVITY_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_EDIT_URL_TEMPLATE'], array('owner_type' => CCrmOwnerType::LeadName, 'owner_id' => $entityID, 'type_id' => CCrmActivityType::Meeting)) : '';
$arFields['EMAIL_EDIT_URL'] = $arParams['ACTIVITY_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_EDIT_URL_TEMPLATE'], array('owner_type' => CCrmOwnerType::LeadName, 'owner_id' => $entityID, 'type_id' => CCrmActivityType::Email)) : '';
$arResult['LEAD_STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['LEAD_STATUS_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['LEAD_STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['LEAD_STATUS_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['ENTITY'] =& $arFields;
unset($arFields);
$this->IncludeComponentTemplate();
예제 #2
0
 public static function TryResolveUserFieldOwners(&$arUsefFieldData, &$arOwnerData, $arField = null)
 {
     $parsed = 0;
     $defaultTypeName = '';
     if (is_array($arField) && isset($arField['USER_TYPE_ID']) && $arField['USER_TYPE_ID'] === 'crm' && isset($arField['SETTINGS']) && is_array($arField['SETTINGS'])) {
         foreach ($arField['SETTINGS'] as $k => $v) {
             if ($v !== 'Y') {
                 continue;
             }
             if ($defaultTypeName === '') {
                 $defaultTypeName = $k;
                 continue;
             }
             // There is more than one type enabled
             $defaultTypeName = '';
             break;
         }
     }
     foreach ($arUsefFieldData as $value) {
         $value = strval($value);
         if ($value === '') {
             continue;
         }
         $ownerTypeName = '';
         $ownerID = 0;
         if (preg_match('/^([A-Z]+)_([0-9]+)$/', strtoupper(trim($value)), $match) === 1) {
             $ownerTypeName = CCrmOwnerTypeAbbr::ResolveName($match[1]);
             $ownerID = intval($match[2]);
         } elseif ($defaultTypeName !== '') {
             $ownerTypeName = $defaultTypeName;
             $ownerID = intval($value);
         }
         if ($ownerTypeName === '' || $ownerID <= 0) {
             continue;
         }
         $arOwnerData[] = array('OWNER_TYPE_NAME' => $ownerTypeName, 'OWNER_ID' => $ownerID);
         $parsed++;
     }
     return $parsed > 0;
 }
예제 #3
0
 protected static function PrepareCrmUserTypeValueView($value, $defaultTypeName = '')
 {
     $parts = explode('_', $value);
     if (count($parts) > 1) {
         return CCrmOwnerType::GetCaption(CCrmOwnerType::ResolveID(CCrmOwnerTypeAbbr::ResolveName($parts[0])), $parts[1]);
     } elseif ($defaultTypeName !== '') {
         return CCrmOwnerType::GetCaption(CCrmOwnerType::ResolveID($defaultTypeName), $value);
     }
     return $value;
 }
예제 #4
0
 public function Execute()
 {
     if (!CModule::IncludeModule("tasks")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $arFields = $this->Fields;
     $arFields["CREATED_BY"] = CBPHelper::ExtractUsers($this->Fields["CREATED_BY"], $documentId, true);
     $arFields["RESPONSIBLE_ID"] = CBPHelper::ExtractUsers($this->Fields["RESPONSIBLE_ID"], $documentId, true);
     $arFields["ACCOMPLICES"] = CBPHelper::ExtractUsers($this->Fields["ACCOMPLICES"], $documentId);
     $arFields["AUDITORS"] = CBPHelper::ExtractUsers($this->Fields["AUDITORS"], $documentId);
     if (isset($this->Fields['DESCRIPTION'])) {
         $arFields['DESCRIPTION'] = preg_replace('/\\[url=(.*)\\](.*)\\[\\/url\\]/i' . BX_UTF_PCRE_MODIFIER, '<a href="${1}">${2}</a>', $this->Fields['DESCRIPTION']);
     }
     if (!$arFields["SITE_ID"]) {
         $arFields["SITE_ID"] = SITE_ID;
     }
     if ($this->AUTO_LINK_TO_CRM_ENTITY && CModule::IncludeModule('crm')) {
         $rootActivity = $this->GetRootActivity();
         $documentId = $rootActivity->GetDocumentId();
         $documentType = $rootActivity->GetDocumentType();
         $letter = CCrmOwnerTypeAbbr::ResolveByTypeID(CCrmOwnerType::ResolveID($documentType[2]));
         $arFields['UF_CRM_TASK'] = array(str_replace($documentType[2], $letter, $documentId[2]));
     }
     $arUnsetFields = array();
     foreach ($arFields as $fieldName => $fieldValue) {
         if (substr($fieldName, -5) === '_text') {
             $arFields[substr($fieldName, 0, -5)] = $fieldValue;
             $arUnsetFields[] = $fieldName;
         }
     }
     foreach ($arUnsetFields as $fieldName) {
         unset($arFields[$fieldName]);
     }
     // Check fields for "white" list
     $arFieldsChecked = array();
     foreach (array_keys($arFields) as $fieldName) {
         if (in_array($fieldName, static::$arAllowedTasksFieldNames, true) || strlen($fieldName) > 3 && substr($fieldName, 0, 3) === 'UF_') {
             if ('UF_TASK_WEBDAV_FILES' == $fieldName && is_array($arFields[$fieldName])) {
                 foreach ($arFields[$fieldName] as $key => $fileId) {
                     if (!empty($fileId) && is_string($fileId) && substr($fileId, 0, 1) != 'n') {
                         if (CModule::IncludeModule("disk") && \Bitrix\Disk\Configuration::isSuccessfullyConverted()) {
                             $item = \Bitrix\Disk\Internals\FileTable::getList(array('select' => array('ID'), 'filter' => array('=XML_ID' => $fileId, 'TYPE' => \Bitrix\Disk\Internals\FileTable::TYPE_FILE)))->fetch();
                             if ($item) {
                                 $arFields[$fieldName][$key] = 'n' . $item['ID'];
                             }
                         }
                     }
                 }
                 unset($fileId);
             }
             $arFieldsChecked[$fieldName] = $arFields[$fieldName];
         }
     }
     $task = new CTasks();
     $result = $task->Add($arFieldsChecked, array('USER_ID' => 1));
     if (!$result) {
         $arErrors = $task->GetErrors();
         if (count($arErrors) > 0) {
             $errorDesc = array();
             if (is_array($arErrors) && !empty($arErrors)) {
                 foreach ($arErrors as $error) {
                     $errorDesc[] = $error['text'] . ' (' . $error['id'] . ')';
                 }
             }
             $this->WriteToTrackingService(GetMessage("BPSA_TRACK_ERROR") . (!empty($errorDesc) ? ' ' . implode(', ', $errorDesc) : ''));
         }
         return CBPActivityExecutionStatus::Closed;
     }
     $this->TaskId = $result;
     $this->WriteToTrackingService(str_replace("#VAL#", $result, GetMessage("BPSA_TRACK_OK")));
     if ($this->isInEventActivityMode || !$this->HoldToClose) {
         return CBPActivityExecutionStatus::Closed;
     }
     $this->Subscribe($this);
     $this->isInEventActivityMode = false;
     $this->WriteToTrackingService(GetMessage("BPSA_TRACK_SUBSCR"));
     return CBPActivityExecutionStatus::Executing;
 }
예제 #5
0
CUtil::JSPostUnescape();
$APPLICATION->RestartBuffer();
Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
// Recalcutation of product prices after currency change
$mode = isset($_POST['MODE']) ? $_POST['MODE'] : '';
if (!isset($mode[0])) {
    die;
}
$ownerType = isset($_POST['OWNER_TYPE']) ? $_POST['OWNER_TYPE'] : '';
if (!isset($ownerType[0])) {
    echo CUtil::PhpToJSObject(array('ERROR' => 'OWNER_TYPE_NOT_FOUND'));
    die;
}
$siteID = isset($_POST['SITE_ID']) && $_POST['SITE_ID'] !== '' ? $_POST['SITE_ID'] : SITE_ID;
$ownerID = isset($_POST['OWNER_ID']) ? intval($_POST['OWNER_ID']) : 0;
$ownerName = CCrmOwnerTypeAbbr::ResolveName($ownerType);
$perms = new CCrmPerms($USER->GetID());
if ($mode === 'SET_OPTION') {
    $arResponse = array('MODE' => 'SET_OPTION');
    $data = isset($_POST['DATA']) && is_array($_POST['DATA']) ? $_POST['DATA'] : array();
    if (count($data) == 0) {
        $arResponse['ERROR'] = 'SOURCE_DATA_NOT_FOUND';
    } else {
        $bSuccess = true;
        if (empty($ownerType) || $ownerID <= 0) {
            $bSuccess = false;
        }
        if ($bSuccess) {
            $settings = array();
            if (isset($data['SHOW_DISCOUNT'])) {
                $settings['ENABLE_DISCOUNT'] = $data['SHOW_DISCOUNT'] === 'Y';
예제 #6
0
 private static function RegisterEvents($ownerType, $ownerID, $arEvents, $checkPerms)
 {
     global $USER;
     $userID = isset($USER) && $USER instanceof CUser && 'CUser' === get_class($USER) ? $USER->GetId() : 0;
     $CCrmEvent = new CCrmEvent();
     foreach ($arEvents as $arEvent) {
         $arEvent['EVENT_TYPE'] = 1;
         $arEvent['ENTITY_TYPE'] = CCrmOwnerTypeAbbr::ResolveName($ownerType);
         $arEvent['ENTITY_ID'] = $ownerID;
         $arEvent['ENTITY_FIELD'] = 'PRODUCT_ROWS';
         if ($userID > 0) {
             $arEvent['USER_ID'] = $userID;
         }
         $CCrmEvent->Add($arEvent, $checkPerms);
     }
     return true;
 }
예제 #7
0
 case CTaskColumnList::COLUMN_STATUS:
     echo GetMessage('TASKS_LIST_ITEMS_STATUS_' . $task['REAL_STATUS']);
     break;
 case CTaskColumnList::COLUMN_PRIORITY:
     echo GetMessage('TASKS_LIST_ITEMS_PRIORITY_' . $task['PRIORITY']);
     break;
 case CTaskColumnList::COLUMN_UF_CRM:
     if (empty($task['UF_CRM_TASK'])) {
         break;
     }
     $collection = array();
     sort($task['UF_CRM_TASK']);
     foreach ($task['UF_CRM_TASK'] as $value) {
         $crmElement = explode('_', $value);
         $type = $crmElement[0];
         $typeId = CCrmOwnerType::ResolveID(CCrmOwnerTypeAbbr::ResolveName($type));
         $title = CCrmOwnerType::GetCaption($typeId, $crmElement[1]);
         $url = CCrmOwnerType::GetShowUrl($typeId, $crmElement[1]);
         if (!isset($collection[$type])) {
             $collection[$type] = array();
         }
         $collection[$type][] = '<a href="' . $url . '">' . $title . '</a>';
     }
     if ($collection) {
         echo '<div class="tasks-list-crm-div">';
         $prevType = null;
         foreach ($collection as $type => $items) {
             if ($type !== $prevType) {
                 if ($prevType !== null) {
                     echo ' &nbsp;&nbsp; ';
                 }