本文整理汇总了PHP中CCrmPerms::UpdateEntityAttr方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmPerms::UpdateEntityAttr方法的具体用法?PHP CCrmPerms::UpdateEntityAttr怎么用?PHP CCrmPerms::UpdateEntityAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmPerms
的用法示例。
在下文中一共展示了CCrmPerms::UpdateEntityAttr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
$arEvent['USER_ID'] = $iUserId;
}
$CCrmEvent = new CCrmEvent();
$eventID = $CCrmEvent->Add($arEvent, $this->bCheckPermission);
}
}
// Calculation of Account Data
$accData = CCrmAccountingHelper::PrepareAccountingData(array('CURRENCY_ID' => isset($arFields['CURRENCY_ID']) ? $arFields['CURRENCY_ID'] : (isset($arRow['CURRENCY_ID']) ? $arRow['CURRENCY_ID'] : null), 'SUM' => isset($arFields['OPPORTUNITY']) ? $arFields['OPPORTUNITY'] : (isset($arRow['OPPORTUNITY']) ? $arRow['OPPORTUNITY'] : null), 'EXCH_RATE' => isset($arFields['EXCH_RATE']) ? $arFields['EXCH_RATE'] : (isset($arRow['EXCH_RATE']) ? $arRow['EXCH_RATE'] : null)));
if (is_array($accData)) {
$arFields['ACCOUNT_CURRENCY_ID'] = $accData['ACCOUNT_CURRENCY_ID'];
$arFields['OPPORTUNITY_ACCOUNT'] = $accData['ACCOUNT_SUM'];
}
$accData = CCrmAccountingHelper::PrepareAccountingData(array('CURRENCY_ID' => isset($arFields['CURRENCY_ID']) ? $arFields['CURRENCY_ID'] : (isset($arRow['CURRENCY_ID']) ? $arRow['CURRENCY_ID'] : null), 'SUM' => isset($arFields['TAX_VALUE']) ? $arFields['TAX_VALUE'] : (isset($arRow['TAX_VALUE']) ? $arRow['TAX_VALUE'] : null), 'EXCH_RATE' => isset($arFields['EXCH_RATE']) ? $arFields['EXCH_RATE'] : (isset($arRow['EXCH_RATE']) ? $arRow['EXCH_RATE'] : null)));
if (is_array($accData)) {
$arFields['TAX_VALUE_ACCOUNT'] = $accData['ACCOUNT_SUM'];
}
if (isset($arFields['STATUS_ID'])) {
$arFields['CLOSED'] = self::GetStatusSemantics($arFields['STATUS_ID']) === 'process' ? 'N' : 'Y';
}
if (isset($arFields['BEGINDATE']) && !isset($arFields['BEGINDATE'][0])) {
unset($arFields['BEGINDATE']);
}
if (isset($arFields['CLOSED']) && $arFields['CLOSED'] === 'Y' && (!isset($arFields['CLOSEDATE']) || $arFields['CLOSEDATE'] === '')) {
$arFields['CLOSEDATE'] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), 'FULL', SITE_ID);
}
if (!isset($arFields['ID'])) {
$arFields['ID'] = $ID;
}
foreach (GetModuleEvents('crm', 'OnBeforeCrmQuoteUpdate', true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
if (isset($arFields['RESULT_MESSAGE'])) {
$this->LAST_ERROR = $arFields['RESULT_MESSAGE'];
} else {
$this->LAST_ERROR = GetMessage('CRM_QUOTE_UPDATE_CANCELED', array('#NAME#' => $arEvent['TO_NAME']));
$arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
}
return false;
}
}
unset($arFields['ID']);
$sUpdate = $DB->PrepareUpdate('b_crm_quote', $arFields);
if (strlen($sUpdate) > 0) {
$clobFieldNames = array('COMMENTS', 'CONTENT', 'STORAGE_ELEMENT_IDS');
$arBinds = array();
foreach ($clobFieldNames as $fieldName) {
if (array_key_exists($fieldName, $arFields)) {
$arBinds[$fieldName] = $arFields[$fieldName];
}
}
unset($fieldName);
$sql = "UPDATE b_crm_quote SET {$sUpdate} WHERE ID = {$ID}";
if (!empty($arBinds)) {
$DB->QueryBind($sql, $arBinds, false);
} else {
$DB->Query($sql, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
}
$bResult = true;
}
if (defined("BX_COMP_MANAGED_CACHE")) {
static $arNameFields = array("TITLE");
$bClear = false;
foreach ($arNameFields as $val) {
if (isset($arFields[$val])) {
$bClear = true;
break;
}
}
if ($bClear) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("crm_entity_name_" . CCrmOwnerType::Quote . "_" . $ID);
}
}
CCrmPerms::UpdateEntityAttr('QUOTE', $ID, $arEntityAttr);
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
$GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $ID, $arFields);
if (is_array($storageElementIDs)) {
CCrmQuote::DoSaveElementIDs($ID, $storageTypeID, $storageElementIDs);
}
unset($storageTypeID, $storageElementIDs);
if ($bUpdateSearch) {
$arFilterTmp = array('ID' => $ID);
if (!$this->bCheckPermission) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
CCrmSearch::UpdateSearch($arFilterTmp, 'QUOTE', true);
}
$arFields['ID'] = $ID;
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
$CCrmFieldMulti->SetFields('QUOTE', $ID, $arFields['FM']);
}
// Responsible user sync
//CCrmActivity::Synchronize(CCrmOwnerType::Quote, $ID);
if ($bResult) {
foreach (GetModuleEvents('crm', 'OnAfterCrmQuoteUpdate', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
}
}
return $bResult;
}
示例2: Update
//.........这里部分代码省略.........
}
if (isset($arFields['CLOSEDATE'])) {
$arFields['__CLOSEDATE'] = $arFields['CLOSEDATE'];
unset($arFields['CLOSEDATE']);
}
unset($arFields['ID']);
$sUpdate = $DB->PrepareUpdate('b_crm_deal', $arFields);
if (strlen($sUpdate) > 0) {
$DB->Query("UPDATE b_crm_deal SET {$sUpdate} WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
$bResult = true;
}
//Restore BEGINDATE and CLOSEDATE
if (isset($arFields['__BEGINDATE'])) {
$arFields['BEGINDATE'] = $arFields['__BEGINDATE'];
unset($arFields['__BEGINDATE']);
}
if (isset($arFields['__CLOSEDATE'])) {
$arFields['CLOSEDATE'] = $arFields['__CLOSEDATE'];
unset($arFields['__CLOSEDATE']);
}
if (defined("BX_COMP_MANAGED_CACHE")) {
static $arNameFields = array("TITLE");
$bClear = false;
foreach ($arNameFields as $val) {
if (isset($arFields[$val])) {
$bClear = true;
break;
}
}
if ($bClear) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("crm_entity_name_" . CCrmOwnerType::Deal . "_" . $ID);
}
}
CCrmPerms::UpdateEntityAttr('DEAL', $ID, $arEntityAttr);
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
$GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $ID, $arFields);
//Statistics & History -->
$currentDbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('*', 'UF_*'));
$currentFields = $currentDbResult->Fetch();
Bitrix\Crm\Statistics\DealSumStatisticEntry::register($ID, $currentFields);
Bitrix\Crm\History\DealStageHistoryEntry::synchronize($ID, $currentFields);
Bitrix\Crm\Statistics\DealInvoiceStatisticEntry::synchronize($ID, $currentFields);
Bitrix\Crm\Statistics\DealActivityStatisticEntry::synchronize($ID, $currentFields);
if (isset($arFields['STAGE_ID'])) {
Bitrix\Crm\History\DealStageHistoryEntry::register($ID, $arFields, array('IS_NEW' => false));
}
//<-- Statistics & History
if ($bUpdateSearch) {
$arFilterTmp = array('ID' => $ID);
if (!$this->bCheckPermission) {
$arFilterTmp['CHECK_PERMISSIONS'] = 'N';
}
CCrmSearch::UpdateSearch($arFilterTmp, 'DEAL', true);
}
$arFields['ID'] = $ID;
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
$CCrmFieldMulti->SetFields('DEAL', $ID, $arFields['FM']);
}
// Responsible user sync
//CCrmActivity::Synchronize(CCrmOwnerType::Deal, $ID);
$registerSonetEvent = isset($options['REGISTER_SONET_EVENT']) && $options['REGISTER_SONET_EVENT'] === true;
if ($bResult && isset($arFields['ASSIGNED_BY_ID'])) {
CCrmSonetSubscription::ReplaceSubscriptionByEntity(CCrmOwnerType::Deal, $ID, CCrmSonetSubscriptionType::Responsibility, $arFields['ASSIGNED_BY_ID'], $arRow['ASSIGNED_BY_ID'], $registerSonetEvent);
}
if ($bResult && $bCompare && $registerSonetEvent && !empty($sonetEventData)) {
示例3: Update
//.........这里部分代码省略.........
$arRes = $dbRes->Fetch();
$arFields['FULL_NAME'] = trim((isset($arFields['NAME']) ? $arFields['NAME'] : $arRes['NAME']) . ' ' . (isset($arFields['LAST_NAME']) ? $arFields['LAST_NAME'] : $arRes['LAST_NAME']));
}
$sUpdate = $DB->PrepareUpdate('b_crm_lead', $arFields, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (strlen($sUpdate) > 0) {
$DB->Query("UPDATE b_crm_lead SET {$sUpdate} WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (isset($arFields['COMPANY_TITLE'])) {
$newCompanyTitle = $arFields['COMPANY_TITLE'];
$oldCompanyTitle = isset($arRow['COMPANY_TITLE']) ? $arRow['COMPANY_TITLE'] : '';
if ($newCompanyTitle !== $oldCompanyTitle) {
\Bitrix\Crm\Integrity\DuplicateOrganizationCriterion::register(CCrmOwnerType::Lead, $ID, $newCompanyTitle);
}
}
if (isset($arFields['LAST_NAME']) || isset($arFields['NAME']) || isset($arFields['SECOND_NAME'])) {
$lastName = isset($arFields['LAST_NAME']) ? $arFields['LAST_NAME'] : (isset($arRow['LAST_NAME']) ? $arRow['LAST_NAME'] : '');
$name = isset($arFields['NAME']) ? $arFields['NAME'] : (isset($arRow['NAME']) ? $arRow['NAME'] : '');
$secondName = isset($arFields['SECOND_NAME']) ? $arFields['SECOND_NAME'] : (isset($arRow['SECOND_NAME']) ? $arRow['SECOND_NAME'] : '');
\Bitrix\Crm\Integrity\DuplicatePersonCriterion::register(CCrmOwnerType::Lead, $ID, $lastName, $name, $secondName);
}
$bResult = true;
}
if (defined("BX_COMP_MANAGED_CACHE")) {
static $arNameFields = array("TITLE");
$bClear = false;
foreach ($arNameFields as $val) {
if (isset($arFields[$val])) {
$bClear = true;
break;
}
}
if ($bClear) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("crm_entity_name_" . CCrmOwnerType::Lead . "_" . $ID);
}
}
CCrmPerms::UpdateEntityAttr('LEAD', $ID, $arEntityAttr);
if (isset($arFields['ADDRESS']) || isset($arFields['ADDRESS_2']) || isset($arFields['ADDRESS_CITY']) || isset($arFields['ADDRESS_POSTAL_CODE']) || isset($arFields['ADDRESS_REGION']) || isset($arFields['ADDRESS_PROVINCE']) || isset($arFields['ADDRESS_COUNTRY'])) {
\Bitrix\Crm\EntityAddress::register(CCrmOwnerType::Lead, $ID, \Bitrix\Crm\EntityAddress::Primary, array('ADDRESS_1' => isset($arFields['ADDRESS']) ? $arFields['ADDRESS'] : (isset($arRow['ADDRESS']) ? $arRow['ADDRESS'] : null), 'ADDRESS_2' => isset($arFields['ADDRESS_2']) ? $arFields['ADDRESS_2'] : (isset($arRow['ADDRESS_2']) ? $arRow['ADDRESS_2'] : null), 'CITY' => isset($arFields['ADDRESS_CITY']) ? $arFields['ADDRESS_CITY'] : (isset($arRow['ADDRESS_CITY']) ? $arRow['ADDRESS_CITY'] : null), 'POSTAL_CODE' => isset($arFields['ADDRESS_POSTAL_CODE']) ? $arFields['ADDRESS_POSTAL_CODE'] : (isset($arRow['ADDRESS_POSTAL_CODE']) ? $arRow['ADDRESS_POSTAL_CODE'] : null), 'REGION' => isset($arFields['ADDRESS_REGION']) ? $arFields['ADDRESS_REGION'] : (isset($arRow['ADDRESS_REGION']) ? $arRow['ADDRESS_REGION'] : null), 'PROVINCE' => isset($arFields['ADDRESS_PROVINCE']) ? $arFields['ADDRESS_PROVINCE'] : (isset($arRow['ADDRESS_PROVINCE']) ? $arRow['ADDRESS_PROVINCE'] : null), 'COUNTRY' => isset($arFields['ADDRESS_COUNTRY']) ? $arFields['ADDRESS_COUNTRY'] : (isset($arRow['ADDRESS_COUNTRY']) ? $arRow['ADDRESS_COUNTRY'] : null), 'COUNTRY_CODE' => isset($arFields['ADDRESS_COUNTRY_CODE']) ? $arFields['ADDRESS_COUNTRY_CODE'] : (isset($arRow['ADDRESS_COUNTRY_CODE']) ? $arRow['ADDRESS_COUNTRY_CODE'] : null)));
}
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
$GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $ID, $arFields);
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
$CCrmFieldMulti->SetFields(CCrmOwnerType::LeadName, $ID, $arFields['FM']);
$multifields = \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::prepareEntityMultifieldsValues(CCrmOwnerType::Lead, $ID);
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Lead, $ID, 'EMAIL', \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($multifields, 'EMAIL'));
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Lead, $ID, 'PHONE', \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($multifields, 'PHONE'));
}
\Bitrix\Crm\Integrity\DuplicateEntityRanking::registerEntityStatistics(CCrmOwnerType::Lead, $ID, array_merge($arRow, $arFields));
if ($bUpdateSearch) {
CCrmSearch::UpdateSearch(array('ID' => $ID, 'CHECK_PERMISSIONS' => 'N'), 'LEAD', true);
}
$arFields['ID'] = $ID;
// Responsible user sync
//CCrmActivity::Synchronize(CCrmOwnerType::Lead, $ID);
// Sonet events registration
$registerSonetEvent = isset($arOptions['REGISTER_SONET_EVENT']) && $arOptions['REGISTER_SONET_EVENT'] === true;
if ($bResult && isset($arFields['ASSIGNED_BY_ID'])) {
CCrmSonetSubscription::ReplaceSubscriptionByEntity(CCrmOwnerType::Lead, $ID, CCrmSonetSubscriptionType::Responsibility, $arFields['ASSIGNED_BY_ID'], $arRow['ASSIGNED_BY_ID'], $registerSonetEvent);
}
if ($bResult && $bCompare && $registerSonetEvent && !empty($sonetEventData)) {
$modifiedByID = intval($arFields['MODIFY_BY_ID']);
foreach ($sonetEventData as &$sonetEvent) {
$sonetEventFields =& $sonetEvent['FIELDS'];
$sonetEventFields['ENTITY_TYPE_ID'] = CCrmOwnerType::Lead;
$sonetEventFields['ENTITY_ID'] = $ID;
$sonetEventFields['USER_ID'] = $modifiedByID;
$logEventID = CCrmLiveFeed::CreateLogEvent($sonetEventFields, $sonetEvent['TYPE']);
if ($logEventID && CModule::IncludeModule("im")) {
$url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Lead, $ID);
$serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
if ($sonetEventFields['PARAMS']['FINAL_RESPONSIBLE_ID'] != $modifiedByID && $sonetEvent['TYPE'] == CCrmLiveFeedEvent::Responsible) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $sonetEventFields['PARAMS']['FINAL_RESPONSIBLE_ID'], "FROM_USER_ID" => $modifiedByID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "LOG_ID" => $logEventID, "NOTIFY_EVENT" => "lead_update", "NOTIFY_TAG" => "CRM|LEAD_RESPONSIBLE|" . $ID, "NOTIFY_MESSAGE" => GetMessage("CRM_LEAD_RESPONSIBLE_IM_NOTIFY", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arFields['TITLE']) . "</a>")), "NOTIFY_MESSAGE_OUT" => GetMessage("CRM_LEAD_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($arFields['TITLE']))) . " (" . $serverName . $url . ")");
CIMNotify::Add($arMessageFields);
}
if ($sonetEvent['TYPE'] == CCrmLiveFeedEvent::Responsible && $sonetEventFields['PARAMS']['START_RESPONSIBLE_ID'] != $modifiedByID) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $sonetEventFields['PARAMS']['START_RESPONSIBLE_ID'], "FROM_USER_ID" => $modifiedByID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "LOG_ID" => $logEventID, "NOTIFY_EVENT" => "lead_update", "NOTIFY_TAG" => "CRM|LEAD_RESPONSIBLE|" . $ID, "NOTIFY_MESSAGE" => GetMessage("CRM_LEAD_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arFields['TITLE']) . "</a>")), "NOTIFY_MESSAGE_OUT" => GetMessage("CRM_LEAD_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($arFields['TITLE']))) . " (" . $serverName . $url . ")");
CIMNotify::Add($arMessageFields);
}
if ($sonetEvent['TYPE'] == CCrmLiveFeedEvent::Progress && $sonetEventFields['PARAMS']['START_STATUS_ID'] && $sonetEventFields['PARAMS']['FINAL_STATUS_ID']) {
$assignedByID = isset($arFields['ASSIGNED_BY_ID']) ? $arFields['ASSIGNED_BY_ID'] : $arRow['ASSIGNED_BY_ID'];
$infos = CCrmStatus::GetStatus('STATUS');
if ($assignedByID != $modifiedByID && array_key_exists($sonetEventFields['PARAMS']['START_STATUS_ID'], $infos) && array_key_exists($sonetEventFields['PARAMS']['FINAL_STATUS_ID'], $infos)) {
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $assignedByID, "FROM_USER_ID" => $modifiedByID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "LOG_ID" => $logEventID, "NOTIFY_EVENT" => "lead_update", "NOTIFY_TAG" => "CRM|LEAD_PROGRESS|" . $ID, "NOTIFY_MESSAGE" => GetMessage("CRM_LEAD_PROGRESS_IM_NOTIFY", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arFields['TITLE']) . "</a>", "#start_status_title#" => htmlspecialcharsbx($infos[$sonetEventFields['PARAMS']['START_STATUS_ID']]['NAME']), "#final_status_title#" => htmlspecialcharsbx($infos[$sonetEventFields['PARAMS']['FINAL_STATUS_ID']]['NAME']))), "NOTIFY_MESSAGE_OUT" => GetMessage("CRM_LEAD_PROGRESS_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($arFields['TITLE']), "#start_status_title#" => htmlspecialcharsbx($infos[$sonetEventFields['PARAMS']['START_STATUS_ID']]['NAME']), "#final_status_title#" => htmlspecialcharsbx($infos[$sonetEventFields['PARAMS']['FINAL_STATUS_ID']]['NAME']))) . " (" . $serverName . $url . ")");
CIMNotify::Add($arMessageFields);
}
}
}
unset($sonetEventFields);
}
unset($sonetEvent);
}
if ($bResult) {
$afterEvents = GetModuleEvents('crm', 'OnAfterCrmLeadUpdate');
while ($arEvent = $afterEvents->Fetch()) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
}
}
return $bResult;
}
示例4: RebuildEntityAccessAttrs
public static function RebuildEntityAccessAttrs($IDs)
{
if (!is_array($IDs)) {
$IDs = array($IDs);
}
$dbResult = self::GetListEx(array(), array('@ID' => $IDs, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'ASSIGNED_BY_ID', 'OPENED'));
if (!is_object($dbResult)) {
return;
}
while ($fields = $dbResult->Fetch()) {
$ID = intval($fields['ID']);
$assignedByID = isset($fields['ASSIGNED_BY_ID']) ? intval($fields['ASSIGNED_BY_ID']) : 0;
if ($assignedByID <= 0) {
continue;
}
$attrs = array();
if (isset($fields['OPENED'])) {
$attrs['OPENED'] = $fields['OPENED'];
}
$entityAttrs = self::BuildEntityAttr($assignedByID, $attrs);
CCrmPerms::UpdateEntityAttr('COMPANY', $ID, $entityAttrs);
}
}
示例5: Update
//.........这里部分代码省略.........
}
}
if (isset($arFields['NAME']) && isset($arFields['LAST_NAME'])) {
$arFields['FULL_NAME'] = self::GetFullName($arFields);
} else {
$dbRes = $DB->Query("SELECT NAME, LAST_NAME FROM b_crm_contact WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
$arRes = $dbRes->Fetch();
if (isset($arFields['NAME'])) {
$arRes['NAME'] = $arFields['NAME'];
}
if (isset($arFields['LAST_NAME'])) {
$arRes['LAST_NAME'] = $arFields['LAST_NAME'];
}
$arFields['FULL_NAME'] = self::GetFullName($arRes);
}
if (isset($arFields['HAS_EMAIL'])) {
unset($arFields['HAS_EMAIL']);
}
if (isset($arFields['HAS_PHONE'])) {
unset($arFields['HAS_PHONE']);
}
unset($arFields['ID']);
$sUpdate = $DB->PrepareUpdate('b_crm_contact', $arFields, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (strlen($sUpdate) > 0) {
$bResult = true;
$DB->Query("UPDATE b_crm_contact SET {$sUpdate} WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (isset($arFields['LAST_NAME']) || isset($arFields['NAME']) || isset($arFields['SECOND_NAME'])) {
$lastName = isset($arFields['LAST_NAME']) ? $arFields['LAST_NAME'] : (isset($arRow['LAST_NAME']) ? $arRow['LAST_NAME'] : '');
$name = isset($arFields['NAME']) ? $arFields['NAME'] : (isset($arRow['NAME']) ? $arRow['NAME'] : '');
$secondName = isset($arFields['SECOND_NAME']) ? $arFields['SECOND_NAME'] : (isset($arRow['SECOND_NAME']) ? $arRow['SECOND_NAME'] : '');
\Bitrix\Crm\Integrity\DuplicatePersonCriterion::register(CCrmOwnerType::Contact, $ID, $lastName, $name, $secondName);
}
}
CCrmPerms::UpdateEntityAttr('CONTACT', $ID, $arEntityAttr);
if (isset($arFields['ADDRESS']) || isset($arFields['ADDRESS_2']) || isset($arFields['ADDRESS_CITY']) || isset($arFields['ADDRESS_POSTAL_CODE']) || isset($arFields['ADDRESS_REGION']) || isset($arFields['ADDRESS_PROVINCE']) || isset($arFields['ADDRESS_COUNTRY'])) {
\Bitrix\Crm\EntityAddress::register(CCrmOwnerType::Contact, $ID, \Bitrix\Crm\EntityAddress::Primary, array('ADDRESS_1' => isset($arFields['ADDRESS']) ? $arFields['ADDRESS'] : (isset($arRow['ADDRESS']) ? $arRow['ADDRESS'] : null), 'ADDRESS_2' => isset($arFields['ADDRESS_2']) ? $arFields['ADDRESS_2'] : (isset($arRow['ADDRESS_2']) ? $arRow['ADDRESS_2'] : null), 'CITY' => isset($arFields['ADDRESS_CITY']) ? $arFields['ADDRESS_CITY'] : (isset($arRow['ADDRESS_CITY']) ? $arRow['ADDRESS_CITY'] : null), 'POSTAL_CODE' => isset($arFields['ADDRESS_POSTAL_CODE']) ? $arFields['ADDRESS_POSTAL_CODE'] : (isset($arRow['ADDRESS_POSTAL_CODE']) ? $arRow['ADDRESS_POSTAL_CODE'] : null), 'REGION' => isset($arFields['ADDRESS_REGION']) ? $arFields['ADDRESS_REGION'] : (isset($arRow['ADDRESS_REGION']) ? $arRow['ADDRESS_REGION'] : null), 'PROVINCE' => isset($arFields['ADDRESS_PROVINCE']) ? $arFields['ADDRESS_PROVINCE'] : (isset($arRow['ADDRESS_PROVINCE']) ? $arRow['ADDRESS_PROVINCE'] : null), 'COUNTRY' => isset($arFields['ADDRESS_COUNTRY']) ? $arFields['ADDRESS_COUNTRY'] : (isset($arRow['ADDRESS_COUNTRY']) ? $arRow['ADDRESS_COUNTRY'] : null), 'COUNTRY_CODE' => isset($arFields['ADDRESS_COUNTRY_CODE']) ? $arFields['ADDRESS_COUNTRY_CODE'] : (isset($arRow['ADDRESS_COUNTRY_CODE']) ? $arRow['ADDRESS_COUNTRY_CODE'] : null)));
}
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
$GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $ID, $arFields);
if (defined("BX_COMP_MANAGED_CACHE")) {
static $arNameFields = array("NAME", "LAST_NAME", "SECOND_NAME");
$bClear = false;
foreach ($arNameFields as $val) {
if (isset($arFields[$val])) {
$bClear = true;
break;
}
}
if ($bClear) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("crm_entity_name_" . CCrmOwnerType::Contact . "_" . $ID);
}
}
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
$CCrmFieldMulti->SetFields(CCrmOwnerType::ContactName, $ID, $arFields['FM']);
$multifields = \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::prepareEntityMultifieldsValues(CCrmOwnerType::Contact, $ID);
$emails = \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($multifields, 'EMAIL');
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Contact, $ID, 'EMAIL', $emails);
$phones = \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($multifields, 'PHONE');
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Contact, $ID, 'PHONE', $phones);
$hasEmail = empty($emails) ? 'N' : 'Y';
$hasPhone = empty($phones) ? 'N' : 'Y';
if ($hasEmail !== (isset($arRow['HAS_EMAIL']) ? $arRow['HAS_EMAIL'] : 'N') || $hasPhone !== (isset($arRow['HAS_PHONE']) ? $arRow['HAS_PHONE'] : 'N')) {
$DB->Query("UPDATE b_crm_contact SET HAS_EMAIL = '{$hasEmail}', HAS_PHONE = '{$hasPhone}' WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
$arFields['HAS_EMAIL'] = $hasEmail;
$arFields['HAS_PHONE'] = $hasPhone;
示例6: Add
//.........这里部分代码省略.........
}
if (isset($arFields['INVOICE_PROPERTIES'])) {
unset($arFields['INVOICE_PROPERTIES']);
}
if (count($arOrderPropsValues) <= 0) {
return false;
}
$deliveryId = null;
$paySystemId = $arFields['PAY_SYSTEM_ID'];
$arOptions = array('LOCATION_IN_CODES' => true);
// let DoCalculateOrder know we send location in CODEs
$arErrors = $arWarnings = array();
$CSaleOrder = new CSaleOrder();
$arOrder = $CSaleOrder->DoCalculateOrder($siteId, $saleUserId, $arShoppingCart, $personTypeId, $arOrderPropsValues, $deliveryId, $paySystemId, $arOptions, $arErrors, $arWarnings);
if (count($arOrder) <= 0) {
return false;
}
// </editor-fold>
if ($bRecalculate) {
foreach ($arOrder as $k => $v) {
$arRecalculated[$k] = $v;
}
return true;
}
// merge order fields
$arAdditionalFields = array();
foreach ($arFields as $k => $v) {
if ($k === 'PRODUCT_ROWS') {
continue;
}
$arAdditionalFields[$k] = $v;
}
$arOrder['LOCATION_IN_CODES'] = true;
// let DoSaveOrder know we send location in IDs
// saving order
$arErrors = array();
$orderID = $CSaleOrder->DoSaveOrder($arOrder, $arAdditionalFields, $tmpOrderId, $arErrors);
if (is_int($orderID) && $orderID > 0) {
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => $tmpOrderId === 0));
$GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $orderID, $arFields);
}
if (is_int($orderID) && $orderID > 0 && isset($options['REGISTER_SONET_EVENT']) && $options['REGISTER_SONET_EVENT'] === true) {
$prevResponsibleID = is_array($arPrevOrder) && isset($arPrevOrder['RESPONSIBLE_ID']) ? intval($arPrevOrder['RESPONSIBLE_ID']) : 0;
$responsibleID = isset($arFields['RESPONSIBLE_ID']) ? intval($arFields['RESPONSIBLE_ID']) : 0;
if ($tmpOrderId <= 0) {
self::RegisterLiveFeedEvent($arFields, $orderID, $userId);
if ($responsibleID > 0) {
CCrmSonetSubscription::RegisterSubscription(CCrmOwnerType::Invoice, $orderID, CCrmSonetSubscriptionType::Responsibility, $responsibleID);
}
} else {
$newDealID = isset($arFields['UF_DEAL_ID']) ? intval($arFields['UF_DEAL_ID']) : 0;
$oldDealID = isset($arPrevOrder['UF_DEAL_ID']) ? intval($arPrevOrder['UF_DEAL_ID']) : 0;
$newCompanyID = isset($arFields['UF_COMPANY_ID']) ? intval($arFields['UF_COMPANY_ID']) : 0;
$oldCompanyID = isset($arPrevOrder['UF_COMPANY_ID']) ? intval($arPrevOrder['UF_COMPANY_ID']) : 0;
$newContactID = isset($arFields['UF_CONTACT_ID']) ? intval($arFields['UF_CONTACT_ID']) : 0;
$oldContactID = isset($arPrevOrder['UF_CONTACT_ID']) ? intval($arPrevOrder['UF_CONTACT_ID']) : 0;
$parents = array();
$parentsChanged = $newDealID !== $oldDealID || $newCompanyID !== $oldCompanyID || $newContactID !== $oldContactID;
if ($parentsChanged) {
if ($newDealID > 0) {
$parents[] = array('ENTITY_TYPE_ID' => CCrmOwnerType::Deal, 'ENTITY_ID' => $newDealID);
}
if ($newCompanyID > 0) {
$parents[] = array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $newCompanyID);
}
if ($newContactID > 0) {
$parents[] = array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $newContactID);
}
}
$oldOrderStatus = isset($arPrevOrder['STATUS_ID']) ? $arPrevOrder['STATUS_ID'] : '';
self::SynchronizeLiveFeedEvent($orderID, array('PROCESS_PARENTS' => $parentsChanged, 'PARENTS' => $parents, 'REFRESH_DATE' => $orderStatus !== $oldOrderStatus, 'START_RESPONSIBLE_ID' => $prevResponsibleID, 'FINAL_RESPONSIBLE_ID' => $responsibleID, 'TOPIC' => isset($arPrevOrder['ORDER_TOPIC']) ? $arPrevOrder['ORDER_TOPIC'] : $orderID));
if ($responsibleID !== $prevResponsibleID) {
CCrmSonetSubscription::ReplaceSubscriptionByEntity(CCrmOwnerType::Invoice, $orderID, CCrmSonetSubscriptionType::Responsibility, $responsibleID, $prevResponsibleID, true);
}
}
}
}
if (intval($orderID) > 0 && !empty($orderStatus)) {
// set status
$this->SetStatus($orderID, $orderStatus);
// update entity permissions
CCrmPerms::UpdateEntityAttr('INVOICE', $orderID, $arEntityAttr);
$newDealID = isset($arFields['UF_DEAL_ID']) ? (int) $arFields['UF_DEAL_ID'] : 0;
$oldDealID = is_array($arPrevOrder) && isset($arPrevOrder['UF_DEAL_ID']) ? (int) $arPrevOrder['UF_DEAL_ID'] : 0;
if ($newDealID) {
Bitrix\Crm\Statistics\DealInvoiceStatisticEntry::register($newDealID);
}
if ($oldDealID > 0 && $oldDealID !== $newDealID) {
Bitrix\Crm\Statistics\DealInvoiceStatisticEntry::register($oldDealID);
}
if (isset($options['UPDATE_SEARCH']) && $options['UPDATE_SEARCH'] === true) {
$arFilterTmp = array('ID' => $orderID);
if (!$this->bCheckPermission) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
CCrmSearch::UpdateSearch($arFilterTmp, 'INVOICE', true);
}
}
return $orderID;
}