本文整理汇总了PHP中CCrmContact::UpdateCompanyId方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmContact::UpdateCompanyId方法的具体用法?PHP CCrmContact::UpdateCompanyId怎么用?PHP CCrmContact::UpdateCompanyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmContact
的用法示例。
在下文中一共展示了CCrmContact::UpdateCompanyId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
}
}
if (empty($arResult['ERROR_MESSAGE']) && !$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) {
$arResult['ERROR_MESSAGE'] = $CCrmBizProc->LAST_ERROR;
}
$ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0;
if (!empty($arResult['ERROR_MESSAGE'])) {
ShowError($arResult['ERROR_MESSAGE']);
$arResult['ELEMENT'] = CCrmComponentHelper::PrepareEntityFields(array_merge(array('ID' => $ID), $arFields), CCrmContact::GetFields());
} else {
if (!isset($_POST['COMPANY_ID']) && isset($_POST['COMPANY_NAME'])) {
if (CCrmCompany::CheckCreatePermission()) {
$arFields = array('TITLE' => trim($_POST['COMPANY_NAME']), 'CONTACT_ID' => array($ID));
$CCrmCompany = new CCrmCompany();
$companyId = $CCrmCompany->Add($arFields);
$CCrmContact->UpdateCompanyId($ID, $companyId);
}
}
if (isset($_POST['apply'])) {
if (CCrmContact::CheckUpdatePermission($ID)) {
LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => $ID)));
}
} elseif (isset($_POST['saveAndAdd'])) {
$redirectUrl = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => 0));
if ($companyID > 0) {
$redirectUrl = CCrmUrlUtil::AddUrlParams($redirectUrl, array('company_id' => $companyID));
}
LocalRedirect($redirectUrl);
} elseif (isset($_POST['saveAndView'])) {
if (CCrmContact::CheckReadPermission($ID)) {
LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $ID)));
示例2: Update
//.........这里部分代码省略.........
$DB->Query("UPDATE b_crm_company SET {$sUpdate} WHERE ID = {$ID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
$bResult = true;
$newTitle = isset($arFields['TITLE']) ? $arFields['TITLE'] : '';
$oldTitle = isset($arRow['TITLE']) ? $arRow['TITLE'] : '';
if ($newTitle !== '' && $newTitle !== $oldTitle) {
\Bitrix\Crm\Integrity\DuplicateOrganizationCriterion::register(CCrmOwnerType::Company, $ID, $newTitle);
}
}
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::Company . "_" . $ID);
}
}
CCrmPerms::UpdateEntityAttr('COMPANY', $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 (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
$CCrmFieldMulti->SetFields('COMPANY', $ID, $arFields['FM']);
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Company, $ID, 'EMAIL', \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($arFields['FM'], 'EMAIL'));
\Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::register(CCrmOwnerType::Company, $ID, 'PHONE', \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion::extractMultifieldsValues($arFields['FM'], 'PHONE'));
}
\Bitrix\Crm\Integrity\DuplicateEntityRanking::registerEntityStatistics(CCrmOwnerType::Company, $ID, array_merge($arRow, $arFields));
if ($bUpdateSearch) {
CCrmSearch::UpdateSearch(array('ID' => $ID, 'CHECK_PERMISSIONS' => 'N'), 'COMPANY', true);
}
$arFields['ID'] = $ID;
if (isset($arFields['CONTACT_ID']) && is_array($arFields['CONTACT_ID'])) {
if (!empty($arFields['CONTACT_ID'])) {
$arCurrentContact = array();
$res = CCrmContact::GetContactByCompanyId($arFields['ID']);
while ($ar = $res->Fetch()) {
$arCurrentContact[] = $ar['ID'];
}
$arAdd = array_diff($arFields['CONTACT_ID'], $arCurrentContact);
$arDelete = array_diff($arCurrentContact, $arFields['CONTACT_ID']);
$CCrmContact = new CCrmContact();
$CCrmContact->UpdateCompanyId($arAdd, $arFields['ID']);
$CCrmContact->UpdateCompanyId($arDelete, 0);
if (isset($GLOBALS["USER"])) {
if (!class_exists('CUserOptions')) {
include_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/classes/" . $GLOBALS['DBType'] . "/favorites.php";
}
CUserOptions::SetOption("crm", "crm_contact_search", array('last_selected' => implode(',', $arAdd)));
}
} else {
$arDelete = array();
$res = CCrmContact::GetContactByCompanyId($arFields['ID']);
while ($ar = $res->Fetch()) {
$arDelete[] = $ar['ID'];
}
$CCrmContact = new CCrmContact();
$CCrmContact->UpdateCompanyId($arDelete, 0);
}
}
$registerSonetEvent = isset($options['REGISTER_SONET_EVENT']) && $options['REGISTER_SONET_EVENT'] === true;
if ($bResult && isset($arFields['ASSIGNED_BY_ID'])) {
CCrmSonetSubscription::ReplaceSubscriptionByEntity(CCrmOwnerType::Company, $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::Company;
$sonetEventFields['ENTITY_ID'] = $ID;
$sonetEventFields['USER_ID'] = $modifiedByID;
$logEventID = CCrmLiveFeed::CreateLogEvent($sonetEventFields, $sonetEvent['TYPE']);
if ($logEventID && $sonetEvent['TYPE'] == CCrmLiveFeedEvent::Responsible && CModule::IncludeModule("im")) {
$url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Company, $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) {
$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" => "company_update", "NOTIFY_TAG" => "CRM|COMPANY_RESPONSIBLE|" . $ID, "NOTIFY_MESSAGE" => GetMessage("CRM_COMPANY_RESPONSIBLE_IM_NOTIFY", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arFields['TITLE']) . "</a>")), "NOTIFY_MESSAGE_OUT" => GetMessage("CRM_COMPANY_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($arFields['TITLE']))) . " (" . $serverName . $url . ")");
CIMNotify::Add($arMessageFields);
}
if ($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" => "company_update", "NOTIFY_TAG" => "CRM|COMPANY_RESPONSIBLE|" . $ID, "NOTIFY_MESSAGE" => GetMessage("CRM_COMPANY_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arFields['TITLE']) . "</a>")), "NOTIFY_MESSAGE_OUT" => GetMessage("CRM_COMPANY_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($arFields['TITLE']))) . " (" . $serverName . $url . ")");
CIMNotify::Add($arMessageFields);
}
}
unset($sonetEventFields);
}
unset($sonetEvent);
}
if ($bResult) {
$afterEvents = GetModuleEvents('crm', 'OnAfterCrmCompanyUpdate');
while ($arEvent = $afterEvents->Fetch()) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
}
}
return $bResult;
}