本文整理汇总了PHP中CCrmContact::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmContact::Update方法的具体用法?PHP CCrmContact::Update怎么用?PHP CCrmContact::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmContact
的用法示例。
在下文中一共展示了CCrmContact::Update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveOrderDataContact
//.........这里部分代码省略.........
if (isset($arOrder["CONTRACTOR"]["FIRST_NAME"]) && $arOrder["CONTRACTOR"]["FIRST_NAME"] != "") {
$arFields['NAME'] = $arOrder["CONTRACTOR"]["FIRST_NAME"];
}
if (isset($arOrder["CONTRACTOR"]["LAST_NAME"]) && $arOrder["CONTRACTOR"]["LAST_NAME"] != "") {
$arFields['LAST_NAME'] = $arOrder["CONTRACTOR"]["LAST_NAME"];
}
if (isset($arOrder["CONTRACTOR"]["SECOND_NAME"]) && $arOrder["CONTRACTOR"]["SECOND_NAME"] != "") {
$arFields['SECOND_NAME'] = $arOrder["CONTRACTOR"]["SECOND_NAME"];
}
if (isset($arOrder["CONTRACTOR"]["BIRTHDAY"]) && $arOrder["CONTRACTOR"]["BIRTHDAY"] != "") {
$arFields['BIRTHDATE'] = $arOrder["CONTRACTOR"]["BIRTHDAY"];
}
if (isset($arOrder["CONTRACTOR"]["FULL_NAME"]) && $arOrder["CONTRACTOR"]["FULL_NAME"] != "") {
$arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["FULL_NAME"];
} elseif (isset($arOrder["CONTRACTOR"]["NAME"]) && $arOrder["CONTRACTOR"]["NAME"] != "") {
$arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["NAME"];
}
if (is_array($arOrder["CONTRACTOR"]["ADDRESS"])) {
foreach ($arOrder["CONTRACTOR"]["ADDRESS"] as $key => $val) {
if ($key == "VIEW") {
continue;
}
if (!empty($arFields["ADDRESS"])) {
$arFields["ADDRESS"] .= ", ";
}
$arFields["ADDRESS"] .= $val;
}
if (isset($arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"])) {
if (!empty($arFields["ADDRESS"])) {
$arFields["ADDRESS"] .= "\n";
}
$arFields["ADDRESS"] .= $arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"];
}
}
if (is_array($arOrder["CONTRACTOR"]["CONTACTS"])) {
$arFields["FM"] = array();
if ($contactId > 0) {
$dbCrmFieldMulti = CCrmFieldMulti::GetList(array(), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $contactId, "CHECK_PERMISSIONS" => "N"));
while ($arCrmFieldMulti = $dbCrmFieldMulti->Fetch()) {
$arFields["FM"][$arCrmFieldMulti["TYPE_ID"]][$arCrmFieldMulti["ID"]] = array("VALUE_TYPE" => $arCrmFieldMulti["VALUE_TYPE"], "VALUE" => $arCrmFieldMulti["VALUE"]);
}
}
$arMapTmp = array("MAIL" => "EMAIL", "E-MAIL" => "EMAIL", "WORKPHONE" => "PHONE");
$arInc = array();
foreach ($arOrder["CONTRACTOR"]["CONTACTS"] as $val) {
$t = strtoupper(preg_replace("/\\s/", "", $val["TYPE"]));
if (!isset($arMapTmp[$t])) {
continue;
}
$bFound = false;
$tNew = $arMapTmp[$t];
if (isset($arFields["FM"][$tNew]) && is_array($arFields["FM"][$tNew])) {
if (count($arFields["FM"][$tNew]) >= 50) {
//Disable adding new communication after threshold is exceeded
$bFound = true;
} else {
foreach ($arFields["FM"][$tNew] as $k => $v) {
if ($v["VALUE"] == $val["VALUE"]) {
$bFound = true;
break;
}
}
}
}
if (!$bFound) {
$arInc[$tNew]++;
$arFields["FM"][$tNew]["n" . $arInc[$tNew]] = array("VALUE_TYPE" => "WORK", "VALUE" => $val["VALUE"]);
}
}
}
$newContact = $contactId == 0;
$obj = new CCrmContact(false);
if ($contactId == 0) {
if ((!isset($arFields['NAME']) || strlen($arFields['NAME']) <= 0) && (!isset($arFields['LAST_NAME']) || strlen($arFields['LAST_NAME']) <= 0)) {
$arFields['LAST_NAME'] = $contactXmlId;
}
$res = $obj->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res > 0) {
$contactId = (int) $res;
$this->arImportResult->numberOfCreatedContacts++;
}
} else {
$res = $obj->Update($contactId, $arFields, true, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res) {
$this->arImportResult->numberOfUpdatedContacts++;
}
}
if (!$res) {
if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
$this->AddError($ex->GetID(), $ex->GetString());
} else {
$this->AddError("CCA", "Contact creation error");
}
if (!empty($obj->LAST_ERROR)) {
$this->AddError("CCA", $obj->LAST_ERROR);
}
return false;
}
return array($contactId, $newContact);
}
示例2: unset
CCrmProductRow::SaveSettings(CCrmQuote::OWNER_TYPE, $arResult['ELEMENT']['ID'], $arSettings);
}
unset($arSettings);
}
if ($bSuccess && $processProductRows && ($bEdit || !empty($arProd))) {
// Suppress owner synchronization
$bSuccess = $CCrmQuote::SaveProductRows($arResult['ELEMENT']['ID'], $arProd, true, true, false);
if (!$bSuccess) {
$arResult['ERROR_MESSAGE'] = GetMessage('PRODUCT_ROWS_SAVING_ERROR');
}
}
if ($bSuccess) {
if ($arFields['CONTACT_ID'] > 0 && $arFields['COMPANY_ID'] > 0 && isset($_POST['NEW_CONTACT_ID']) && $arFields['CONTACT_ID'] == $_POST['NEW_CONTACT_ID']) {
$CrmContact = new CCrmContact();
$arContactFields = array('COMPANY_ID' => $arFields['COMPANY_ID']);
$bSuccess = $CrmContact->Update($arFields['CONTACT_ID'], $arContactFields, false, true, array('DISABLE_USER_FIELD_CHECK' => true));
if (!$bSuccess) {
$arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
}
}
}
if ($bSuccess) {
$DB->Commit();
} else {
$DB->Rollback();
$arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
}
}
/*if (intval($_POST['SYNC_ORDER_ID']) > 0)
{
$imp = new CCrmExternalSaleImport($originatorId);
示例3: foreach
if (isset($actionData['FIELDS']) && is_array($actionData['FIELDS'])) {
foreach ($actionData['FIELDS'] as $ID => $arSrcData) {
$arEntityAttr = $CCrmPerms->GetEntityAttr('CONTACT', array($ID));
if (!$CCrmPerms->CheckEnityAccess('CONTACT', 'WRITE', $arEntityAttr[$ID])) {
continue;
}
$arUpdateData = array();
reset($arResult['HEADERS']);
foreach ($arResult['HEADERS'] as $arHead) {
if (isset($arHead['editable']) && $arHead['editable'] == true && isset($arSrcData[$arHead['id']])) {
$arUpdateData[$arHead['id']] = $arSrcData[$arHead['id']];
}
}
if (!empty($arUpdateData)) {
$DB->StartTransaction();
if ($CCrmContact->Update($ID, $arUpdateData)) {
$DB->Commit();
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Contact, $ID, CCrmBizProcEventType::Edit, $arErrors);
} else {
$DB->Rollback();
}
}
}
}
} elseif ($actionData['NAME'] == 'tasks') {
if (isset($actionData['ID']) && is_array($actionData['ID'])) {
$arTaskID = array();
foreach ($actionData['ID'] as $ID) {
$arTaskID[] = 'C_' . $ID;
}
示例4: GetMessage
$arResult['ERROR_MESSAGE'] = '';
if (!$CCrmContact->CheckFields($arFields, $isEditMode ? $arResult['ELEMENT']['ID'] : false)) {
if (!empty($CCrmContact->LAST_ERROR)) {
$arResult['ERROR_MESSAGE'] .= $CCrmContact->LAST_ERROR;
} else {
$arResult['ERROR_MESSAGE'] .= GetMessage('UNKNOWN_ERROR');
}
}
if ($arBizProcParametersValues = $CCrmBizProc->CheckFields($isEditMode ? $arResult['ELEMENT']['ID'] : false, false, $arResult['ELEMENT']['ASSIGNED_BY'], $isEditMode ? array($arResult['ELEMENT']['ID'] => $arEntityAttr[$arResult['ELEMENT']['ID']]) : null) === false) {
$arResult['ERROR_MESSAGE'] .= $CCrmBizProc->LAST_ERROR;
}
if (empty($arResult['ERROR_MESSAGE'])) {
$DB->StartTransaction();
$success = false;
if ($isEditMode) {
$success = $CCrmContact->Update($arResult['ELEMENT']['ID'], $arFields, true, true, array('REGISTER_SONET_EVENT' => true));
} else {
$ID = $CCrmContact->Add($arFields, true, array('REGISTER_SONET_EVENT' => true));
$success = $ID !== false;
if ($success) {
$arResult['ELEMENT']['ID'] = $ID;
}
}
if ($success) {
$DB->Commit();
} else {
$DB->Rollback();
$arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
}
}
if (empty($arResult['ERROR_MESSAGE']) && !$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) {
示例5: CCrmContact
if ($companyID > 0 && !CCrmCompany::Exists($companyID)) {
$companyID = 0;
}
if ($statusID === 'CONVERTED') {
if ($contactID !== 0) {
$CCrmEvent->Add(array('ENTITY_TYPE' => 'CONTACT', 'ENTITY_ID' => $contactID, 'EVENT_ID' => $eventID, 'EVENT_TEXT_1' => $eventDesc, 'DATE_CREATE' => $eventDate, 'FILES' => $eventFiles));
}
if ($companyID !== 0) {
$CCrmEvent->Add(array('ENTITY_TYPE' => 'COMPANY', 'ENTITY_ID' => $companyID, 'EVENT_ID' => $eventID, 'EVENT_TEXT_1' => $eventDesc, 'DATE_CREATE' => $eventDate, 'FILES' => $eventFiles));
}
}
}
break;
case 'CONTACT':
$CCrmContact = new CCrmContact();
$CCrmContact->Update($_POST['ENTITY_ID'], $arField = array(), false);
break;
case 'COMPANY':
$CCrmCompany = new CCrmCompany();
$CCrmCompany->Update($_POST['ENTITY_ID'], $arField = array(), false);
break;
case 'DEAL':
if (isset($_POST['STAGE_ID'])) {
$stageID = $_POST['STAGE_ID'];
$dbResult = CCrmDeal::GetListEx(array(), array('=ID' => $entityID), false, false, array('STAGE_ID'));
$arPrevious = $dbResult ? $dbResult->Fetch() : null;
if (is_array($arPrevious) && isset($arPrevious['STAGE_ID']) && $arPrevious['STAGE_ID'] !== $stageID) {
$CCrmDeal = new CCrmDeal();
$arField = array('STAGE_ID' => $stageID);
if ($CCrmDeal->Update($entityID, $arField)) {
$arErrors = array();
示例6: CCrmContact
$fields['PHOTO'] = $photoID;
}
if (isset($data['FM']) && is_array($data['FM']) && !empty($data['FM'])) {
$fields['FM'] = $data['FM'];
}
$entity = new CCrmContact(false);
if (!$entity->CheckFields($fields, !$isNew ? $ID : false, array('DISABLE_USER_FIELD_CHECK' => true))) {
__CrmMobileContactEditEndResonse(array('ERROR' => strip_tags(preg_replace("/<br[^>]*>/", "\n", $entity->LAST_ERROR))));
} else {
//$DB->StartTransaction();
$successed = false;
if ($isNew) {
$ID = $entity->Add($fields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
$successed = $ID !== false;
} else {
$successed = $entity->Update($ID, $fields, true, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
}
if ($successed) {
//$DB->Commit();
$errors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Contact, $ID, $isNew ? CCrmBizProcEventType::Create : CCrmBizProcEventType::Edit, $errors);
$dbRes = CCrmContact::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
$currentItem = $dbRes->GetNext();
$formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
CCrmMobileHelper::PrepareContactItem($currentItem, $formatParams);
__CrmMobileContactEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareContactData($currentItem)));
} else {
//$DB->Rollback();
__CrmMobileContactEditEndResonse(array('ERROR' => strip_tags(preg_replace("/<br[^>]*>/", "\n", $fields['RESULT_MESSAGE']))));
}
}
示例7: UpdateDocument
public static function UpdateDocument($documentId, $arFields)
{
global $DB;
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
if (!CCrmContact::Exists($arDocumentID['ID'])) {
throw new Exception(GetMessage('CRM_DOCUMENT_ELEMENT_IS_NOT_FOUND'));
}
$arDocumentFields = self::GetDocumentFields($arDocumentID['TYPE']);
$arKeys = array_keys($arFields);
foreach ($arKeys as $key) {
if (!array_key_exists($key, $arDocumentFields)) {
//Fix for issue #40374
unset($arFields[$key]);
continue;
}
$fieldType = $arDocumentFields[$key]["Type"];
if (in_array($fieldType, array("phone", "email", "im", "web"), true)) {
CCrmDocument::PrepareEntityMultiFields($arFields, strtoupper($fieldType));
continue;
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
if ($fieldType == "user") {
$ar = array();
foreach ($arFields[$key] as $v1) {
if (substr($v1, 0, strlen("user_")) == "user_") {
$ar[] = substr($v1, strlen("user_"));
} else {
$a1 = self::GetUsersFromUserGroup($v1, $documentId);
foreach ($a1 as $a11) {
$ar[] = $a11;
}
}
}
$arFields[$key] = $ar;
} elseif ($fieldType == "select" && substr($key, 0, 3) == "UF_") {
self::InternalizeEnumerationField('CRM_CONTACT', $arFields, $key);
} elseif ($fieldType == "file") {
$arFileOptions = array('ENABLE_ID' => true);
foreach ($arFields[$key] as &$value) {
//Issue #40380. Secure URLs and file IDs are allowed.
$file = false;
CCrmFileProxy::TryResolveFile($value, $file, $arFileOptions);
$value = $file;
}
unset($value);
} elseif ($fieldType == "S:HTML") {
foreach ($arFields[$key] as &$value) {
$value = array("VALUE" => $value);
}
unset($value);
}
if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
if (count($arFields[$key]) > 0) {
$a = array_values($arFields[$key]);
$arFields[$key] = $a[0];
} else {
$arFields[$key] = null;
}
}
}
if (isset($arFields['COMMENTS']) && $arFields['COMMENTS'] !== '') {
$arFields['COMMENTS'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", $arFields['COMMENTS']);
}
$DB->StartTransaction();
$CCrmEntity = new CCrmContact(false);
$res = $CCrmEntity->Update($arDocumentID['ID'], $arFields);
if (!$res) {
$DB->Rollback();
throw new Exception($CCrmEntity->LAST_ERROR);
}
if (COption::GetOptionString("crm", "start_bp_within_bp", "N") == "Y") {
$CCrmBizProc = new CCrmBizProc('CONTACT');
if (false === $CCrmBizProc->CheckFields($arDocumentID['ID'], true)) {
throw new Exception($CCrmBizProc->LAST_ERROR);
}
if ($res && !$CCrmBizProc->StartWorkflow($arDocumentID['ID'])) {
$DB->Rollback();
throw new Exception($CCrmBizProc->LAST_ERROR);
}
}
if ($res) {
$DB->Commit();
}
}
示例8: array
}
$fieldValues = array();
if (isset($_POST['FIELD_VALUE'])) {
if (is_array($_POST['FIELD_VALUE'])) {
$fieldValues = $_POST['FIELD_VALUE'];
} else {
$fieldValues[] = $_POST['FIELD_VALUE'];
}
}
$dbResult = CCrmContact::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('*', 'UF_*'));
$arFields = is_object($dbResult) ? $dbResult->Fetch() : null;
if (is_array($arFields)) {
CCrmInstantEditorHelper::PrepareUpdate(CCrmOwnerType::Contact, $arFields, $fieldNames, $fieldValues);
$entity = new CCrmContact();
$disableUserFieldCheck = !$hasUserFields && isset($_POST['DISABLE_USER_FIELD_CHECK']) && strtoupper($_POST['DISABLE_USER_FIELD_CHECK']) === 'Y';
if ($entity->Update($ID, $arFields, true, true, array('REGISTER_SONET_EVENT' => true, 'DISABLE_USER_FIELD_CHECK' => $disableUserFieldCheck))) {
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Contact, $ID, CCrmBizProcEventType::Edit, $arErrors);
$result = array();
$count = count($fieldNames);
for ($i = 0; $i < $count; $i++) {
$fieldName = $fieldNames[$i];
if (strpos($fieldName, 'FM.') === 0) {
//Filed name like 'FM.PHONE.WORK.1279'
$fieldParams = explode('.', $fieldName);
if (count($fieldParams) >= 3) {
$result[$fieldName] = array('VIEW_HTML' => CCrmViewHelper::PrepareMultiFieldHtml($fieldParams[1], array('VALUE_TYPE_ID' => $fieldParams[2], 'VALUE' => isset($fieldValues[$i]) ? $fieldValues[$i] : '')));
}
}
}
if (!empty($result)) {
示例9: array
//$DB->StartTransaction();
$successed = false;
if ($isNew) {
$ID = $entity->Add($fields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
$successed = $ID !== false;
if ($successed) {
$contactID = isset($data['CONTACT_ID']) ? intval($data['CONTACT_ID']) : 0;
if ($contactID > 0 && CCrmContact::Exists($contactID)) {
$dbContacts = CCrmContact::GetListEx(array(), array('=ID' => $contactID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('COMPANY_ID'));
$contact = $dbContacts ? $dbContacts->Fetch() : null;
if (is_array($contact)) {
$contactCompanyID = isset($contact['COMPANY_ID']) ? intval($contact['COMPANY_ID']) : 0;
if ($contactCompanyID !== $ID) {
$contactFields = array('COMPANY_ID' => $ID);
$contactEntity = new CCrmContact(false);
$contactEntity->Update($contactID, $contactFields);
}
}
}
}
} else {
$successed = $entity->Update($ID, $fields, true, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
}
if ($successed) {
//$DB->Commit();
$errors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Company, $ID, $isNew ? CCrmBizProcEventType::Create : CCrmBizProcEventType::Edit, $errors);
$dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
$currentItem = $dbRes->GetNext();
$formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
CCrmMobileHelper::PrepareCompanyItem($currentItem, $formatParams);
示例10: array
if ($email !== '') {
if (!isset($arFields['FM'])) {
$arFields['FM'] = array();
}
$arFields['FM']['EMAIL'] = array('n0' => array('VALUE_TYPE' => 'WORK', 'VALUE' => $email));
}
$phone = isset($data['phone']) ? $data['phone'] : '';
if ($phone !== '') {
if (!isset($arFields['FM'])) {
$arFields['FM'] = array();
}
$arFields['FM']['PHONE'] = array('n0' => array('VALUE_TYPE' => 'WORK', 'VALUE' => $phone));
}
$CrmContact = new CCrmContact();
if ($ID > 0) {
if ($CrmContact->Update($ID, $arFields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true))) {
$info = CCrmEntitySelectorHelper::PrepareEntityInfo('CONTACT', $ID);
echo CUtil::PhpToJSObject(array('DATA' => $data, 'INFO' => array('title' => $info['TITLE'], 'url' => $info['URL'])));
}
} else {
$ID = $CrmContact->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
if (is_int($ID) && $ID > 0) {
$data['id'] = $ID;
$info = CCrmEntitySelectorHelper::PrepareEntityInfo('CONTACT', $ID, array('NAME_TEMPLATE' => isset($_POST['NAME_TEMPLATE']) ? $_POST['NAME_TEMPLATE'] : ''));
echo CUtil::PhpToJSObject(array('DATA' => $data, 'INFO' => array('title' => $info['TITLE'], 'url' => $info['URL'])));
} else {
echo CUtil::PhpToJSObject(array('ERROR' => $CrmContact->LAST_ERROR));
}
}
} elseif ($action === 'ENABLE_SONET_SUBSCRIPTION') {
$userID = CCrmSecurityHelper::GetCurrentUserID();