本文整理汇总了PHP中CCrmDeal::GetListEx方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmDeal::GetListEx方法的具体用法?PHP CCrmDeal::GetListEx怎么用?PHP CCrmDeal::GetListEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmDeal
的用法示例。
在下文中一共展示了CCrmDeal::GetListEx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSourceFields
public function getSourceFields()
{
if ($this->srcFields !== null) {
return $this->srcFields;
}
$dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $this->srcEntityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('*', 'UF_*'));
$result = $dbResult->Fetch();
return $this->srcFields = is_array($result) ? $result : array();
}
示例2: CrmCheckPath
$arResult['PATH_TO_DEAL_SHOW'] = $arParams['PATH_TO_DEAL_SHOW'] = CrmCheckPath('PATH_TO_DEAL_SHOW', $arParams['PATH_TO_DEAL_SHOW'], $APPLICATION->GetCurPage() . '?deal_id=#deal_id#&show');
$arParams['PATH_TO_DEAL_EDIT'] = CrmCheckPath('PATH_TO_DEAL_EDIT', $arParams['PATH_TO_DEAL_EDIT'], $APPLICATION->GetCurPage() . '?deal_id=#deal_id#&edit');
$arParams['PATH_TO_CONTACT_SHOW'] = CrmCheckPath('PATH_TO_CONTACT_SHOW', $arParams['PATH_TO_CONTACT_SHOW'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&show');
$arParams['PATH_TO_CONTACT_EDIT'] = CrmCheckPath('PATH_TO_CONTACT_EDIT', $arParams['PATH_TO_CONTACT_EDIT'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&edit');
$arParams['PATH_TO_COMPANY_SHOW'] = CrmCheckPath('PATH_TO_COMPANY_SHOW', $arParams['PATH_TO_COMPANY_SHOW'], $APPLICATION->GetCurPage() . '?company_id=#company_id#&show');
$arParams['PATH_TO_COMPANY_EDIT'] = CrmCheckPath('PATH_TO_COMPANY_EDIT', $arParams['PATH_TO_COMPANY_EDIT'], $APPLICATION->GetCurPage() . '?company_id=#company_id#&edit');
$arParams['PATH_TO_LEAD_SHOW'] = CrmCheckPath('PATH_TO_LEAD_SHOW', $arParams['PATH_TO_LEAD_SHOW'], $APPLICATION->GetCurPage() . '?lead_id=#lead_id#&show');
$arParams['PATH_TO_LEAD_EDIT'] = CrmCheckPath('PATH_TO_LEAD_EDIT', $arParams['PATH_TO_LEAD_EDIT'], $APPLICATION->GetCurPage() . '?lead_id=#lead_id#&edit');
$arParams['PATH_TO_LEAD_CONVERT'] = CrmCheckPath('PATH_TO_LEAD_CONVERT', $arParams['PATH_TO_LEAD_CONVERT'], $APPLICATION->GetCurPage() . '?lead_id=#lead_id#&convert');
$arParams['PATH_TO_USER_PROFILE'] = CrmCheckPath('PATH_TO_USER_PROFILE', $arParams['PATH_TO_USER_PROFILE'], '/company/personal/user/#user_id#/');
$arParams['PATH_TO_PRODUCT_EDIT'] = CrmCheckPath('PATH_TO_PRODUCT_EDIT', $arParams['PATH_TO_PRODUCT_EDIT'], $APPLICATION->GetCurPage() . '?product_id=#product_id#&edit');
$arParams['PATH_TO_PRODUCT_SHOW'] = CrmCheckPath('PATH_TO_PRODUCT_SHOW', $arParams['PATH_TO_PRODUCT_SHOW'], $APPLICATION->GetCurPage() . '?product_id=#product_id#&show');
$arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? CSite::GetNameFormat(false) : str_replace(array("#NOBR#", "#/NOBR#"), array("", ""), $arParams["NAME_TEMPLATE"]);
global $USER_FIELD_MANAGER;
$CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, CCrmDeal::$sUFEntityID);
$obFields = CCrmDeal::GetListEx(array(), array('ID' => $arParams['ELEMENT_ID']));
$arFields = $obFields->GetNext();
$arFields['CONTACT_FM'] = array();
if (isset($arFields['CONTACT_ID']) && intval($arFields['CONTACT_ID']) > 0) {
$dbResMultiFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $arFields['CONTACT_ID']));
while ($arMultiFields = $dbResMultiFields->Fetch()) {
$arFields['CONTACT_FM'][$arMultiFields['TYPE_ID']][$arMultiFields['ID']] = array('VALUE' => $arMultiFields['VALUE'], 'VALUE_TYPE' => $arMultiFields['VALUE_TYPE']);
}
}
$arFields['COMPANY_FM'] = array();
if (isset($arFields['COMPANY_ID']) && intval($arFields['COMPANY_ID']) > 0) {
$dbResMultiFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => $arFields['COMPANY_ID']));
while ($arMultiFields = $dbResMultiFields->Fetch()) {
$arFields['COMPANY_FM'][$arMultiFields['TYPE_ID']][$arMultiFields['ID']] = array('VALUE' => $arMultiFields['VALUE'], 'VALUE_TYPE' => $arMultiFields['VALUE_TYPE']);
}
}
示例3: __CrmMobileDealEditEndResonse
if (!CCrmDeal::CheckUpdatePermission($ID, $curUserPrems)) {
__CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ACCESS_DENIED')));
}
$stageID = isset($data['STAGE_ID']) ? $data['STAGE_ID'] : '';
if ($stageID === '') {
__CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_DEAL_STAGE_NOT_FOUND')));
}
//$DB->StartTransaction();
$fields = array('STAGE_ID' => $stageID);
$entity = new CCrmDeal(false);
$successed = $entity->Update($ID, $fields, true, true, array());
if ($successed) {
//$DB->Commit();
$errors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $ID, CCrmBizProcEventType::Edit, $errors);
$dbRes = CCrmDeal::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
$currentItem = $dbRes->GetNext();
$formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
CCrmMobileHelper::PrepareDealItem($currentItem, $formatParams);
__CrmMobileDealEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareDealData($currentItem)));
} else {
//$DB->Rollback();
__CrmMobileDealEditEndResonse(array('ERROR' => $fields['RESULT_MESSAGE']));
}
} elseif ($action === 'CONVERT_MONEY') {
__IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
$srcCurrencyID = isset($_REQUEST['SRC_CURRENCY_ID']) ? $_REQUEST['SRC_CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
$dstCurrencyID = isset($_REQUEST['DST_CURRENCY_ID']) ? $_REQUEST['DST_CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
$srcSum = isset($_REQUEST['SUM']) ? doubleval($_REQUEST['SUM']) : 0.0;
$dstSum = CCrmCurrency::ConvertMoney($srcSum, $srcCurrencyID, $dstCurrencyID);
__CrmMobileDealEditEndResonse(array('SUM' => $dstSum, 'CURRENCY_ID' => $dstCurrencyID, 'CURRENCY_NAME' => CCrmCurrency::GetCurrencyName($dstCurrencyID), 'FORMATTED_SUM' => CCrmCurrency::MoneyToString($dstSum, $dstCurrencyID)));
示例4: unset
}
unset($dbContact, $arContact);
}
// create from company
if ($companyId > 0) {
$dbCompany = CCrmCompany::GetListEx(array('ID' => 'DESC'), array('ID' => $companyId), false, array('nTopCount' => 1), array('ID', 'LEAD_ID'));
if ($arCompany = $dbCompany->Fetch()) {
if (isset($arCompany['LEAD_ID']) && intval($arCompany['LEAD_ID']) > 0) {
$arFields['~LEAD_ID'] = $arFields['LEAD_ID'] = intval($arCompany['LEAD_ID']);
}
}
unset($dbCompany, $arCompany);
}
// create from lead
if ($leadId > 0) {
$dbDeal = CCrmDeal::GetListEx(array('ID' => 'DESC'), array('LEAD_ID' => $leadId), false, array('nTopCount' => 1), array('ID'));
if ($arDeal = $dbDeal->Fetch()) {
if (isset($arDeal['ID']) && intval($arDeal['ID']) > 0) {
$arFields['~DEAL_ID'] = $arFields['DEAL_ID'] = intval($arDeal['ID']);
}
}
unset($dbDeal, $arDeal);
if (($arLead = CCrmLead::GetByID($leadId)) && is_array($arLead)) {
// get contact and/or company from lead
if ($companyId <= 0 || $contactId <= 0) {
if (isset($arLead['CONTACT_ID']) && intval($arLead['CONTACT_ID']) > 0) {
$arFields['~CONTACT_ID'] = $arFields['CONTACT_ID'] = intval($arLead['CONTACT_ID']);
}
if (isset($arLead['COMPANY_ID']) && intval($arLead['COMPANY_ID']) > 0) {
$arFields['~COMPANY_ID'] = $arFields['COMPANY_ID'] = intval($arLead['COMPANY_ID']);
}
示例5: PreparePopupItems
public static function PreparePopupItems($entityTypeNames, $addPrefix = true, $nameFormat = '', $count = 50)
{
if (!is_array($entityTypeNames)) {
$entityTypeNames = array(strval($entityTypeNames));
}
$addPrefix = (bool) $addPrefix;
$count = intval($count);
if ($count <= 0) {
$count = 50;
}
$arItems = array();
$i = 0;
foreach ($entityTypeNames as $typeName) {
$typeName = strtoupper(strval($typeName));
if ($typeName === 'CONTACT') {
$contactTypes = CCrmStatus::GetStatusList('CONTACT_TYPE');
$contactIndex = array();
$obRes = CCrmContact::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'COMPANY_TITLE', 'PHOTO', 'TYPE_ID'));
while ($arRes = $obRes->Fetch()) {
$arImg = array();
if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
if (intval($arRes['PHOTO']) > 0) {
$arImg = CFile::ResizeImageGet($arRes['PHOTO'], array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
}
}
$arRes['SID'] = $addPrefix ? 'C_' . $arRes['ID'] : $arRes['ID'];
// advanced info
$advancedInfo = array();
if (isset($arRes['TYPE_ID']) && $arRes['TYPE_ID'] != '' && isset($contactTypes[$arRes['TYPE_ID']])) {
$advancedInfo['contactType'] = array('id' => $arRes['TYPE_ID'], 'name' => $contactTypes[$arRes['TYPE_ID']]);
}
$arItems[$i] = array('title' => CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($arRes['HONORIFIC']) ? $arRes['HONORIFIC'] : '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : ''), $nameFormat), 'desc' => empty($arRes['COMPANY_TITLE']) ? "" : $arRes['COMPANY_TITLE'], 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'image' => $arImg['src'], 'type' => 'contact', 'selected' => 'N');
if (!empty($advancedInfo)) {
$arItems[$i]['advancedInfo'] = $advancedInfo;
}
unset($advancedInfo);
$contactIndex[$arRes['ID']] =& $arItems[$i];
$i++;
}
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => array_keys($contactIndex)));
while ($arRes = $obRes->Fetch()) {
if (isset($contactIndex[$arRes['ELEMENT_ID']]) && ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL')) {
$item =& $contactIndex[$arRes['ELEMENT_ID']];
if (!is_array($item['advancedInfo'])) {
$item['advancedInfo'] = array();
}
if (!is_array($item['advancedInfo']['multiFields'])) {
$item['advancedInfo']['multiFields'] = array();
}
$item['advancedInfo']['multiFields'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
unset($item);
}
}
unset($contactIndex);
} elseif ($typeName === 'COMPANY') {
$companyIndex = array();
$arCompanyTypeList = CCrmStatus::GetStatusListEx('COMPANY_TYPE');
$arCompanyIndustryList = CCrmStatus::GetStatusListEx('INDUSTRY');
$obRes = CCrmCompany::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO'));
$arFiles = array();
while ($arRes = $obRes->Fetch()) {
$arImg = array();
if (!empty($arRes['LOGO']) && !isset($arFiles[$arRes['LOGO']])) {
if (intval($arRes['LOGO']) > 0) {
$arImg = CFile::ResizeImageGet($arRes['LOGO'], array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
}
$arFiles[$arRes['LOGO']] = $arImg['src'];
}
$arRes['SID'] = $addPrefix ? 'CO_' . $arRes['ID'] : $arRes['ID'];
$arDesc = array();
if (isset($arCompanyTypeList[$arRes['COMPANY_TYPE']])) {
$arDesc[] = $arCompanyTypeList[$arRes['COMPANY_TYPE']];
}
if (isset($arCompanyIndustryList[$arRes['INDUSTRY']])) {
$arDesc[] = $arCompanyIndustryList[$arRes['INDUSTRY']];
}
$arItems[$i] = array('title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => implode(', ', $arDesc), 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $arRes['ID'])), 'image' => $arImg['src'], 'type' => 'company', 'selected' => 'N');
$companyIndex[$arRes['ID']] =& $arItems[$i];
$i++;
}
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => array_keys($companyIndex)));
while ($arRes = $obRes->Fetch()) {
if (isset($companyIndex[$arRes['ELEMENT_ID']]) && ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL')) {
$item =& $companyIndex[$arRes['ELEMENT_ID']];
if (!is_array($item['advancedInfo'])) {
$item['advancedInfo'] = array();
}
if (!is_array($item['advancedInfo']['multiFields'])) {
$item['advancedInfo']['multiFields'] = array();
}
$item['advancedInfo']['multiFields'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
unset($item);
}
}
unset($companyIndex);
} elseif ($typeName === 'LEAD') {
$leadIndex = array();
$obRes = CCrmLead::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'STATUS_ID'));
//.........这里部分代码省略.........
示例6: unset
$fieldName = $arMatch[1];
if (($fieldName == 'DATE_CREATE' || $fieldName == 'DATE_MODIFY' || $fieldName == 'BEGINDATE' || $fieldName == 'CLOSEDATE') && !preg_match('/\\d{1,2}:\\d{1,2}(:\\d{1,2})?$/' . BX_UTF_PCRE_MODIFIER, $v)) {
$v .= ' 23:59:59';
}
$arFilter['<=' . $arMatch[1]] = $v;
}
unset($arFilter[$k]);
} else {
if (strpos($k, 'UF_') !== 0 && $k != 'LOGIC') {
$arFilter['%' . $k] = $v;
unset($arFilter[$k]);
}
}
}
}
$obRes = CCrmDeal::GetListEx(array(), $arFilter, false, false, array('ID', 'TITLE', 'STAGE_ID', 'OPPORTUNITY', 'CURRENCY_ID'));
$arResult['DEAL'] = array();
$arResult['STAGE_COUNT'] = array();
$arResult['FUNNEL'] = array();
$iDealCount = 0;
while ($arDeal = $obRes->GetNext()) {
//Normalizing for compatibility
$currencyID = CCrmCurrency::NormalizeCurrencyID($arDeal['CURRENCY_ID']);
$stageID = $arDeal['STAGE_ID'];
$opportunity = (double) $arDeal['OPPORTUNITY'];
if (!isset($arResult['STAGE_COUNT'][$stageID])) {
$arResult['STAGE_COUNT'][$stageID]['COUNT'] = 1;
$arResult['STAGE_COUNT'][$stageID]['COUNT_FUNNEL'] = 1;
$arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY'] = array($currencyID => $opportunity);
$arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY_FUNNEL'] = array($currencyID => $opportunity);
} else {
示例7: Update
public function Update($ID, array &$arFields, $bCompare = true, $bUpdateSearch = true, $options = array())
{
global $DB;
$this->LAST_ERROR = '';
$ID = (int) $ID;
if (!is_array($options)) {
$options = array();
}
$arFilterTmp = array('ID' => $ID);
if (!$this->bCheckPermission) {
$arFilterTmp['CHECK_PERMISSIONS'] = 'N';
}
$obRes = self::GetListEx(array(), $arFilterTmp);
if (!($arRow = $obRes->Fetch())) {
return false;
}
$iUserId = CCrmSecurityHelper::GetCurrentUserID();
if (isset($arFields['DATE_CREATE'])) {
unset($arFields['DATE_CREATE']);
}
if (isset($arFields['DATE_MODIFY'])) {
unset($arFields['DATE_MODIFY']);
}
$arFields['~DATE_MODIFY'] = $DB->CurrentTimeFunction();
if (!isset($arFields['MODIFY_BY_ID']) || $arFields['MODIFY_BY_ID'] <= 0) {
$arFields['MODIFY_BY_ID'] = $iUserId;
}
if (isset($arFields['ASSIGNED_BY_ID']) && $arFields['ASSIGNED_BY_ID'] <= 0) {
unset($arFields['ASSIGNED_BY_ID']);
}
$assignedByID = (int) (isset($arFields['ASSIGNED_BY_ID']) ? $arFields['ASSIGNED_BY_ID'] : $arRow['ASSIGNED_BY_ID']);
$bResult = false;
if (!$this->CheckFields($arFields, $ID, $options)) {
$arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
} else {
if ($this->bCheckPermission && !CCrmAuthorizationHelper::CheckUpdatePermission(self::$TYPE_NAME, $ID, $this->cPerms)) {
$this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED');
$arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
return false;
}
$beforeEvents = GetModuleEvents('crm', 'OnBeforeCrmDealUpdate');
while ($arEvent = $beforeEvents->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
if (isset($arFields['RESULT_MESSAGE'])) {
$this->LAST_ERROR = $arFields['RESULT_MESSAGE'];
} else {
$this->LAST_ERROR = GetMessage('CRM_DEAL_UPDATE_CANCELED', array('#NAME#' => $arEvent['TO_NAME']));
$arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
}
return false;
}
}
$arAttr = array();
$arAttr['STAGE_ID'] = !empty($arFields['STAGE_ID']) ? $arFields['STAGE_ID'] : $arRow['STAGE_ID'];
$arAttr['OPENED'] = !empty($arFields['OPENED']) ? $arFields['OPENED'] : $arRow['OPENED'];
$arEntityAttr = self::BuildEntityAttr($assignedByID, $arAttr);
$sEntityPerm = $this->cPerms->GetPermType('DEAL', 'WRITE', $arEntityAttr);
$this->PrepareEntityAttrs($arEntityAttr, $sEntityPerm);
//Prevent 'OPENED' field change by user restricted by BX_CRM_PERM_OPEN permission
if ($sEntityPerm === BX_CRM_PERM_OPEN && isset($arFields['OPENED']) && $arFields['OPENED'] !== 'Y' && $assignedByID !== $iUserId) {
$arFields['OPENED'] = 'Y';
}
if (isset($arFields['ASSIGNED_BY_ID']) && $arRow['ASSIGNED_BY_ID'] != $arFields['ASSIGNED_BY_ID']) {
CCrmEvent::SetAssignedByElement($arFields['ASSIGNED_BY_ID'], 'DEAL', $ID);
}
$sonetEventData = array();
if ($bCompare) {
$arEvents = self::CompareFields($arRow, $arFields, $this->bCheckPermission);
foreach ($arEvents as $arEvent) {
$arEvent['ENTITY_TYPE'] = 'DEAL';
$arEvent['ENTITY_ID'] = $ID;
$arEvent['EVENT_TYPE'] = 1;
if (!isset($arEvent['USER_ID'])) {
$arEvent['USER_ID'] = $iUserId;
}
$CCrmEvent = new CCrmEvent();
$eventID = $CCrmEvent->Add($arEvent, $this->bCheckPermission);
if (is_int($eventID) && $eventID > 0) {
$fieldID = isset($arEvent['ENTITY_FIELD']) ? $arEvent['ENTITY_FIELD'] : '';
if ($fieldID === '') {
continue;
}
switch ($fieldID) {
case 'STAGE_ID':
$sonetEventData[CCrmLiveFeedEvent::Progress] = array('TYPE' => CCrmLiveFeedEvent::Progress, 'FIELDS' => array('TITLE' => GetMessage('CRM_DEAL_EVENT_UPDATE_STAGE'), 'MESSAGE' => '', 'PARAMS' => array('START_STATUS_ID' => $arRow['STAGE_ID'], 'FINAL_STATUS_ID' => $arFields['STAGE_ID'])));
break;
case 'ASSIGNED_BY_ID':
$sonetEventData[CCrmLiveFeedEvent::Responsible] = array('TYPE' => CCrmLiveFeedEvent::Responsible, 'FIELDS' => array('TITLE' => GetMessage('CRM_DEAL_EVENT_UPDATE_ASSIGNED_BY'), 'MESSAGE' => '', 'PARAMS' => array('START_RESPONSIBLE_ID' => $arRow['ASSIGNED_BY_ID'], 'FINAL_RESPONSIBLE_ID' => $arFields['ASSIGNED_BY_ID'])));
break;
case 'CONTACT_ID':
case 'COMPANY_ID':
if (!isset($sonetEventData[CCrmLiveFeedEvent::Client])) {
$oldContactID = isset($arRow['CONTACT_ID']) ? intval($arRow['CONTACT_ID']) : 0;
$oldCompanyID = isset($arRow['COMPANY_ID']) ? intval($arRow['COMPANY_ID']) : 0;
$sonetEventData[CCrmLiveFeedEvent::Client] = array('CODE' => 'CLIENT', 'TYPE' => CCrmLiveFeedEvent::Client, 'FIELDS' => array('TITLE' => GetMessage('CRM_DEAL_EVENT_UPDATE_CLIENT'), 'MESSAGE' => '', 'PARAMS' => array('START_CLIENT_CONTACT_ID' => $oldContactID, 'FINAL_CLIENT_CONTACT_ID' => isset($arFields['CONTACT_ID']) ? intval($arFields['CONTACT_ID']) : $oldContactID, 'START_CLIENT_COMPANY_ID' => $oldCompanyID, 'FINAL_CLIENT_COMPANY_ID' => isset($arFields['COMPANY_ID']) ? intval($arFields['COMPANY_ID']) : $oldCompanyID)));
}
break;
case 'TITLE':
$sonetEventData[CCrmLiveFeedEvent::Denomination] = array('TYPE' => CCrmLiveFeedEvent::Denomination, 'FIELDS' => array('TITLE' => GetMessage('CRM_DEAL_EVENT_UPDATE_TITLE'), 'MESSAGE' => '', 'PARAMS' => array('START_TITLE' => $arRow['TITLE'], 'FINAL_TITLE' => $arFields['TITLE'])));
break;
//.........这里部分代码省略.........
示例8: array
if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
if ($arFile = CFile::GetFileArray($arRes['PHOTO'])) {
$arFiles[$arRes['PHOTO']] = CHTTP::URN2URI($arFile['SRC']);
}
}
$arContacts[] = array('id' => $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'title' => str_replace(array(';', ','), ' ', CCrmContact::PrepareFormattedName($arRes)), 'desc' => empty($arRes['COMPANY_TITLE']) ? '' : $arRes['COMPANY_TITLE'], 'image' => isset($arFiles[$arRes['PHOTO']]) ? $arFiles[$arRes['PHOTO']] : '', 'type' => 'contact', 'selected' => false);
}
//CrmLead
$arLeads = array();
$obRes = CCrmLead::GetListEx(array('TITLE' => 'ASC'), array(), false, array('nTopCount' => 50), array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'STATUS_ID'));
while ($arRes = $obRes->Fetch()) {
$arLeads[] = array('id' => $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $arRes['ID'])), 'title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => CCrmLead::PrepareFormattedName($arRes), 'type' => 'lead', 'selected' => false);
}
//CrmDeal
$arDeals = array();
$obRes = CCrmDeal::GetListEx(array('TITLE' => 'ASC'), array(), false, array('nTopCount' => 50), array('ID', 'TITLE'));
while ($arRes = $obRes->Fetch()) {
$arDeals[] = array('id' => $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $arRes['ID'])), 'title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => '', 'type' => 'deal', 'selected' => false);
}
?>
<script type="text/javascript">
var crmCompanyElements = <?php
echo CUtil::PhpToJsObject($arCompanies);
?>
;
var crmContactElements = <?php
echo CUtil::PhpToJsObject($arContacts);
?>
;
var crmLeadElements = <?php
示例9: EmailMessageAdd
//.........这里部分代码省略.........
}
} else {
$arCommData = array(self::CreateComm($ownerTypeID, $ownerID, $addresserInfo['EMAIL']));
}
}
}
}
$arBindingData = self::ConvertCommsToBindings($arCommData);
// Check bindings for converted leads -->
// Not Existed entities are ignored. Converted leads are ignored if their associated entities (contacts, companies, deals) are contained in bindings.
$arCorrectedBindingData = array();
$arConvertedLeadData = array();
foreach ($arBindingData as $bindingKey => &$arBinding) {
if ($arBinding['TYPE_ID'] !== CCrmOwnerType::Lead) {
if (self::IsEntityExists($arBinding['TYPE_ID'], $arBinding['ID'])) {
$arCorrectedBindingData[$bindingKey] = $arBinding;
}
continue;
}
$arFields = self::GetEntity(CCrmOwnerType::Lead, $arBinding['ID'], array('STATUS_ID'));
if (!is_array($arFields)) {
continue;
}
if (isset($arFields['STATUS_ID']) && $arFields['STATUS_ID'] === 'CONVERTED') {
$arConvertedLeadData[$bindingKey] = $arBinding;
} else {
$arCorrectedBindingData[$bindingKey] = $arBinding;
}
}
unset($arBinding);
foreach ($arConvertedLeadData as &$arConvertedLead) {
$leadID = $arConvertedLead['ID'];
$exists = false;
$dbRes = CCrmCompany::GetListEx(array(), array('LEAD_ID' => $leadID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
if ($dbRes) {
while ($arRes = $dbRes->Fetch()) {
if (isset($arCorrectedBindingData[self::PrepareEntityKey(CCrmOwnerType::Company, $arRes['ID'])])) {
$exists = true;
break;
}
}
}
if ($exists) {
continue;
}
$dbRes = CCrmContact::GetListEx(array(), array('LEAD_ID' => $leadID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
if ($dbRes) {
while ($arRes = $dbRes->Fetch()) {
if (isset($arCorrectedBindingData[self::PrepareEntityKey(CCrmOwnerType::Contact, $arRes['ID'])])) {
$exists = true;
break;
}
}
}
if ($exists) {
continue;
}
$dbRes = CCrmDeal::GetListEx(array(), array('LEAD_ID' => $leadID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
if ($dbRes) {
while ($arRes = $dbRes->Fetch()) {
if (isset($arCorrectedBindingData[self::PrepareEntityKey(CCrmOwnerType::Deal, $arRes['ID'])])) {
$exists = true;
break;
}
}
}
示例10: array
$arResult['DEAL'][$arDeal['ID']] = $arDeal;
$arResult['DEAL_ID'][$arDeal['ID']] = $arDeal['ID'];
$arResult['DEAL_UF'][$arDeal['ID']] = array();
}
} else {
$navDbResult = CCrmActivity::GetEntityList(CCrmOwnerType::Deal, $userID, $arSort['nearest_activity'], $arFilter, !$isInExportMode ? $arNavParams : false);
$arResult['ROWS_COUNT'] = $navDbResult->SelectedRowsCount();
$arResult['DB_LIST'] = $navDbResult;
$arResult['DB_FILTER'] = $arFilter;
while ($arDeal = $navDbResult->Fetch()) {
$arResult['DEAL'][$arDeal['ID']] = $arDeal;
$arResult['DEAL_ID'][$arDeal['ID']] = $arDeal['ID'];
$arResult['DEAL_UF'][$arDeal['ID']] = array();
}
$arFilter['@ID'] = array_keys($arResult['DEAL']);
$dbResult = CCrmDeal::GetListEx($arSort, $arFilter, false, false, $arSelect, $arOptions);
while ($arDeal = $dbResult->GetNext()) {
$arResult['DEAL'][$arDeal['ID']] = $arDeal;
}
}
$now = time() + CTimeZone::GetOffset();
foreach ($arResult['DEAL'] as &$arDeal) {
$arDeal['CLOSEDATE'] = !empty($arDeal['CLOSEDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['CLOSEDATE']), 'SHORT', SITE_ID)) : '';
$arDeal['BEGINDATE'] = !empty($arDeal['BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['BEGINDATE']), 'SHORT', SITE_ID)) : '';
$arDeal['EVENT_DATE'] = !empty($arDeal['EVENT_DATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['EVENT_DATE']), 'SHORT', SITE_ID)) : '';
$arDeal['~CLOSEDATE'] = $arDeal['CLOSEDATE'];
$arDeal['~BEGINDATE'] = $arDeal['BEGINDATE'];
$arDeal['~EVENT_DATE'] = $arDeal['EVENT_DATE'];
$currencyID = isset($arDeal['~CURRENCY_ID']) ? $arDeal['~CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
$arDeal['~CURRENCY_ID'] = $currencyID;
$arDeal['CURRENCY_ID'] = htmlspecialcharsbx($currencyID);
示例11: strtoupper
continue;
}
$entityTypeName = strtoupper($commInfo[0]);
$entityTypeID = CCrmOwnerType::ResolveID($entityTypeName);
$entityID = intval($commInfo[1]);
if (!CCrmOwnerType::IsDefined($entityTypeID) || $entityID <= 0 || !CCrmActivity::CheckUpdatePermission($entityTypeID, $entityID, $userPerms)) {
continue;
}
$commValue = CCrmActivity::GetDefaultCommunicationValue($entityTypeID, $entityID, $commType);
if ($commValue !== '') {
$comms[] = array('TYPE' => $commType, 'VALUE' => $commValue, 'ENTITY_TYPE_ID' => $entityTypeID, 'ENTITY_ID' => $entityID);
}
}
}
if (empty($comms)) {
$dbDeal = CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('CONTACT_ID', 'CONTACT_NAME', 'CONTACT_SECOND_NAME', 'CONTACT_LAST_NAME', 'COMPANY_ID', 'COMPANY_TITLE'));
$deal = $dbDeal->Fetch();
if (is_array($deal)) {
$contactID = isset($deal['CONTACT_ID']) ? intval($deal['CONTACT_ID']) : 0;
$companyID = isset($deal['COMPANY_ID']) ? intval($deal['COMPANY_ID']) : 0;
$comms = array();
if ($contactID > 0 && CCrmActivity::CheckUpdatePermission(CCrmOwnerType::Contact, $contactID, $userPerms)) {
$commValue = CCrmActivity::GetDefaultCommunicationValue(CCrmOwnerType::Contact, $contactID, $commType);
if ($commValue !== '') {
$comms[] = array('TYPE' => $commType, 'VALUE' => $commValue, 'ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $contactID, 'ENTITY_SETTINGS' => array('NAME' => isset($deal['CONTACT_NAME']) ? $deal['CONTACT_NAME'] : '', 'SECOND_NAME' => isset($deal['CONTACT_SECOND_NAME']) ? $deal['CONTACT_SECOND_NAME'] : '', 'LAST_NAME' => isset($deal['CONTACT_LAST_NAME']) ? $deal['CONTACT_LAST_NAME'] : ''));
}
}
if (empty($comms) && $companyID > 0 && CCrmActivity::CheckUpdatePermission(CCrmOwnerType::Company, $companyID, $userPerms)) {
$commValue = CCrmActivity::GetDefaultCommunicationValue(CCrmOwnerType::Company, $companyID, $commType);
if ($commValue !== '') {
$comms[] = array('TYPE' => $commType, 'VALUE' => $commValue, 'ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $companyID, 'ENTITY_SETTINGS' => array('COMPANY_TITLE' => isset($deal['COMPANY_TITLE']) ? $deal['COMPANY_TITLE'] : ''));
示例12: time
$now = time() + CTimeZone::GetOffset();
$nowDate = ConvertTimeStamp($now, 'SHORT', SITE_ID);
$arFields = array('~CURRENCY' => $currencyID, 'CURRENCY' => htmlspecialcharsbx($currencyID));
$arFields['~STATUS_ID'] = !empty($arResult['STATUS_LIST']) ? array_shift(array_keys($arResult['STATUS_LIST'])) : '';
$arFields['STATUS_ID'] = htmlspecialcharsbx($arFields['~STATUS_ID']);
$arFields['DATE_PAY_BEFORE_STAMP'] = 0;
$arFields['~DATE_PAY_BEFORE'] = $arFields['DATE_PAY_BEFORE'] = '';
$arFields['DATE_BILL_STAMP'] = $now;
$arFields['~DATE_BILL'] = $arFields['~DATE_INSERT'] = $nowDate;
$arFields['DATE_BILL'] = $arFields['DATE_INSERT'] = htmlspecialcharsbx($nowDate);
if (isset($_REQUEST['deal_id'])) {
$dealID = max(intval($_REQUEST['deal_id']), 0);
}
if ($dealID > 0) {
$arFields['~UF_DEAL_ID'] = $arFields['UF_DEAL_ID'] = $dealID;
$dbDeal = CCrmDeal::GetListEx(array(), array('=ID' => $dealID), false, false, array('ID', 'COMPANY_ID', 'CONTACT_ID', 'CURRENCY_ID', 'ASSIGNED_BY_ID', 'TITLE', 'COMMENTS'));
$deal = $dbDeal ? $dbDeal->Fetch() : null;
if (is_array($deal)) {
$companyID = $arFields['~UF_COMPANY_ID'] = $arFields['UF_COMPANY_ID'] = isset($deal['COMPANY_ID']) ? intval($deal['COMPANY_ID']) : 0;
$contactID = $arFields['~UF_CONTACT_ID'] = $arFields['UF_CONTACT_ID'] = isset($deal['CONTACT_ID']) ? intval($deal['CONTACT_ID']) : 0;
$dealCurrencyID = isset($deal['CURRENCY_ID']) ? $deal['CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
$arFields['~ORDER_TOPIC'] = isset($deal['TITLE']) ? $deal['TITLE'] : '';
$arFields['ORDER_TOPIC'] = htmlspecialcharsbx($arFields['~ORDER_TOPIC']);
$arFields['~USER_DESCRIPTION'] = isset($deal['COMMENTS']) ? $deal['COMMENTS'] : '';
$arFields['USER_DESCRIPTION'] = htmlspecialcharsbx($arFields['~USER_DESCRIPTION']);
$arFields['~RESPONSIBLE_ID'] = $arFields['RESPONSIBLE_ID'] = isset($deal['ASSIGNED_BY_ID']) ? intval($deal['ASSIGNED_BY_ID']) : 0;
}
} else {
if (isset($_REQUEST['company_id'])) {
$companyID = max(intval($_REQUEST['company_id']), 0);
}
示例13: synchronize
/**
* @return boolean
*/
public static function synchronize($ownerID, array $entityFields = null)
{
if (!is_int($ownerID)) {
$ownerID = (int) $ownerID;
}
if ($ownerID <= 0) {
throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
}
if (!is_array($entityFields)) {
$dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE', 'OPPORTUNITY', 'CURRENCY_ID'));
$entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
if (!is_array($entityFields)) {
return false;
}
}
$stageID = isset($entityFields['STAGE_ID']) ? $entityFields['STAGE_ID'] : '';
$semanticID = \CCrmDeal::GetSemanticID($stageID);
$isLost = PhaseSemantics::isLost($semanticID);
$responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int) $entityFields['ASSIGNED_BY_ID'] : 0;
/** @var Date $startDate */
$startDate = self::parseDateString(isset($entityFields['BEGINDATE']) ? $entityFields['BEGINDATE'] : '');
if ($startDate === null) {
$startDate = new Date();
}
/** @var Date $endDate */
$endDate = self::parseDateString(isset($entityFields['CLOSEDATE']) ? $entityFields['CLOSEDATE'] : '');
if ($endDate === null) {
$endDate = new Date('9999-12-31', 'Y-m-d');
}
$sum = isset($entityFields['OPPORTUNITY']) ? (double) $entityFields['OPPORTUNITY'] : 0.0;
$currencyID = isset($entityFields['CURRENCY_ID']) ? $entityFields['CURRENCY_ID'] : '';
if ($currencyID === '') {
$currencyID = \CCrmCurrency::GetBaseCurrencyID();
}
$accountCurrencyID = \CCrmCurrency::GetAccountCurrencyID();
$sumData = \CCrmAccountingHelper::PrepareAccountingData(array('CURRENCY_ID' => $currencyID, 'SUM' => $sum));
if (is_array($sumData)) {
$sum = (double) $sumData['ACCOUNT_SUM'];
}
$latest = self::getLatest($ownerID);
if (!is_array($latest)) {
if ($semanticID === PhaseSemantics::SUCCESS) {
//Creation of stub for successfully completed entity without invoices
self::innerRegister(array('OWNER_ID' => $ownerID, 'CREATED_DATE' => new Date(), 'START_DATE' => $startDate, 'END_DATE' => $endDate, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_SEMANTIC_ID' => PhaseSemantics::SUCCESS, 'STAGE_ID' => $stageID, 'IS_LOST' => 'N', 'CURRENCY_ID' => $accountCurrencyID, 'INVOICE_SUM' => 0.0, 'INVOICE_QTY' => 0, 'TOTAL_INVOICE_SUM' => 0.0, 'TOTAL_INVOICE_QTY' => 0, 'TOTAL_SUM' => $sum));
}
return true;
}
if ($startDate->getTimestamp() === $latest['START_DATE']->getTimestamp() && $endDate->getTimestamp() === $latest['END_DATE']->getTimestamp() && $responsibleID === (int) $latest['RESPONSIBLE_ID'] && $stageID === $latest['STAGE_ID'] && $semanticID === $latest['STAGE_SEMANTIC_ID'] && $sum === (double) $latest['TOTAL_SUM']) {
return false;
}
if ($semanticID !== $latest['STAGE_SEMANTIC_ID'] && $latest['STAGE_SEMANTIC_ID'] === PhaseSemantics::SUCCESS && (int) $latest['INVOICE_QTY'] === 0) {
//Clean up stub for successfully completed entity without invoices
DealInvoiceStatisticsTable::delete(array('OWNER_ID' => $ownerID, 'CREATED_DATE' => $latest['CREATED_DATE']));
} else {
DealInvoiceStatisticsTable::synchronize($ownerID, array('START_DATE' => $startDate, 'END_DATE' => $endDate, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_SEMANTIC_ID' => $semanticID, 'STAGE_ID' => $stageID, 'IS_LOST' => $isLost ? 'Y' : 'N', 'TOTAL_SUM' => $sum));
}
return true;
}
示例14: array
if ($arParams['arUserField']['SETTINGS']['LEAD'] == 'Y' && isset($arValue['LEAD']) && !empty($arValue['LEAD'])) {
$dbRes = CCrmLead::GetListEx(array('TITLE' => 'ASC'), array('=ID' => $arValue['LEAD']), false, false, array('ID', 'TITLE'));
while ($arRes = $dbRes->Fetch()) {
$arResult['VALUE']['LEAD'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $arRes['ID'])));
}
}
if ($arParams['arUserField']['SETTINGS']['CONTACT'] == 'Y' && isset($arValue['CONTACT']) && !empty($arValue['CONTACT'])) {
$hasNameFormatter = method_exists("CCrmContact", "PrepareFormattedName");
$dbRes = CCrmContact::GetListEx(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('=ID' => $arValue['CONTACT']), false, false, $hasNameFormatter ? array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME') : array('ID', 'FULL_NAME'));
while ($arRes = $dbRes->Fetch()) {
if ($hasNameFormatter) {
$title = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($arRes['HONORIFIC']) ? $arRes['HONORIFIC'] : '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : ''));
} else {
$title = isset($arRes['FULL_NAME']) ? $arRes['FULL_NAME'] : '';
}
$arResult['VALUE']['CONTACT'][$arRes['ID']] = array('ENTITY_TITLE' => $title, 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])));
}
}
if ($arParams['arUserField']['SETTINGS']['COMPANY'] == 'Y' && isset($arValue['COMPANY']) && !empty($arValue['COMPANY'])) {
$dbRes = CCrmCompany::GetListEx(array('TITLE' => 'ASC'), array('ID' => $arValue['COMPANY']));
while ($arRes = $dbRes->Fetch()) {
$arResult['VALUE']['COMPANY'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $arRes['ID'])));
}
}
if ($arParams['arUserField']['SETTINGS']['DEAL'] == 'Y' && isset($arValue['DEAL']) && !empty($arValue['DEAL'])) {
$dbRes = CCrmDeal::GetListEx(array('TITLE' => 'ASC'), array('ID' => $arValue['DEAL']));
while ($arRes = $dbRes->Fetch()) {
$arResult['VALUE']['DEAL'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $arRes['ID'])));
}
}
}
示例15: __CrmConfigPermsEndResonse
if (COption::GetOptionString('crm', '~CRM_REBUILD_DEAL_ATTR', 'N') !== 'Y') {
__CrmConfigPermsEndResonse(array('STATUS' => 'NOT_REQUIRED', 'SUMMARY' => GetMessage('CRM_CONFIG_PERMS_REBUILD_ATTR_NOT_REQUIRED_SUMMARY')));
}
$progressData = COption::GetOptionString('crm', '~CRM_REBUILD_DEAL_ATTR_PROGRESS', '');
$progressData = $progressData !== '' ? unserialize($progressData) : array();
$lastItemID = isset($progressData['LAST_ITEM_ID']) ? intval($progressData['LAST_ITEM_ID']) : 0;
$processedItemQty = isset($progressData['PROCESSED_ITEMS']) ? intval($progressData['PROCESSED_ITEMS']) : 0;
$totalItemQty = isset($progressData['TOTAL_ITEMS']) ? intval($progressData['TOTAL_ITEMS']) : 0;
if ($totalItemQty <= 0) {
$totalItemQty = CCrmDeal::GetListEx(array(), array('CHECK_PERMISSIONS' => 'N'), array(), false);
}
$filter = array('CHECK_PERMISSIONS' => 'N');
if ($lastItemID > 0) {
$filter['>ID'] = $lastItemID;
}
$dbResult = CCrmDeal::GetListEx(array('ID' => 'ASC'), $filter, false, array('nTopCount' => 10), array('ID'));
$itemIDs = array();
$itemQty = 0;
if (is_object($dbResult)) {
while ($fields = $dbResult->Fetch()) {
$itemIDs[] = intval($fields['ID']);
$itemQty++;
}
}
if ($itemQty > 0) {
CCrmDeal::RebuildEntityAccessAttrs($itemIDs);
$progressData['TOTAL_ITEMS'] = $totalItemQty;
$processedItemQty += $itemQty;
$progressData['PROCESSED_ITEMS'] = $processedItemQty;
$progressData['LAST_ITEM_ID'] = $itemIDs[$itemQty - 1];
COption::SetOptionString('crm', '~CRM_REBUILD_DEAL_ATTR_PROGRESS', serialize($progressData));