本文整理汇总了PHP中CCrmCompany::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmCompany::Update方法的具体用法?PHP CCrmCompany::Update怎么用?PHP CCrmCompany::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmCompany
的用法示例。
在下文中一共展示了CCrmCompany::Update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveOrderDataCompany
//.........这里部分代码省略.........
$arFields["ADDRESS"] .= $arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"];
}
}
if (is_array($arOrder["CONTRACTOR"]["LEGAL_ADDRESS"])) {
foreach ($arOrder["CONTRACTOR"]["LEGAL_ADDRESS"] as $key => $val) {
if ($key == "VIEW") {
continue;
}
if (!empty($arFields["ADDRESS_LEGAL"])) {
$arFields["ADDRESS_LEGAL"] .= ", ";
}
$arFields["ADDRESS_LEGAL"] .= $val;
}
if (isset($arOrder["CONTRACTOR"]["LEGAL_ADDRESS"]["VIEW"])) {
if (!empty($arFields["ADDRESS_LEGAL"])) {
$arFields["ADDRESS_LEGAL"] .= "\n";
}
$arFields["ADDRESS_LEGAL"] .= $arOrder["CONTRACTOR"]["LEGAL_ADDRESS"]["VIEW"];
}
}
if (is_array($arOrder["CONTRACTOR"]["CONTACTS"])) {
$arFields["FM"] = array();
if ($companyId > 0) {
$dbCrmFieldMulti = CCrmFieldMulti::GetList(array(), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => $companyId, "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"]);
}
}
}
$arMapTmp = array("INN", "KPP", "EGRPO", "OKVED", "OKDP", "OKOPF", "OKFC", "OKPO");
foreach ($arMapTmp as $m) {
if (isset($arOrder["CONTRACTOR"][$m])) {
$arFields["BANKING_DETAILS"] .= $m . ": " . $arOrder["CONTRACTOR"][$m] . "\n";
}
}
if (is_array($arOrder["CONTRACTOR"]["BANK_ADDRESS"])) {
foreach ($arOrder["CONTRACTOR"]["BANK_ADDRESS"] as $key => $val) {
if (!empty($arFields["BANKING_DETAILS"])) {
$arFields["BANKING_DETAILS"] .= ", ";
}
$arFields["BANKING_DETAILS"] .= $val;
}
}
$newCompany = $companyId == 0;
$obj = new CCrmCompany(false);
if ($companyId == 0) {
if (!isset($arFields['TITLE']) || strlen($arFields['TITLE']) <= 0) {
$arFields['TITLE'] = $companyXmlId;
}
$res = $obj->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res > 0) {
$companyId = (int) $res;
$this->arImportResult->numberOfCreatedCompanies++;
}
} else {
$res = $obj->Update($companyId, $arFields, true, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res) {
$this->arImportResult->numberOfUpdatedCompanies++;
}
}
if (!$res) {
if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
$this->AddError($ex->GetID(), $ex->GetString());
} else {
$this->AddError("CCA", "Company creation error");
}
if (!empty($obj->LAST_ERROR)) {
$this->AddError("CCA", $obj->LAST_ERROR);
}
return false;
}
return array($companyId, $newCompany);
}
示例2: array
}
$fieldValues = array();
if (isset($_POST['FIELD_VALUE'])) {
if (is_array($_POST['FIELD_VALUE'])) {
$fieldValues = $_POST['FIELD_VALUE'];
} else {
$fieldValues[] = $_POST['FIELD_VALUE'];
}
}
$dbResult = CCrmCompany::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::Company, $arFields, $fieldNames, $fieldValues);
$CCrmCompany = new CCrmCompany();
$disableUserFieldCheck = !$hasUserFields && isset($_POST['DISABLE_USER_FIELD_CHECK']) && strtoupper($_POST['DISABLE_USER_FIELD_CHECK']) === 'Y';
if ($CCrmCompany->Update($ID, $arFields, true, true, array('REGISTER_SONET_EVENT' => true, 'DISABLE_USER_FIELD_CHECK' => $disableUserFieldCheck))) {
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Company, $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)) {
示例3: UpdateDocument
public static function UpdateDocument($documentId, $arFields)
{
global $DB;
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
$dbDocumentList = CCrmCompany::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
$arResult = $dbDocumentList->Fetch();
if (!$arResult) {
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_COMPANY', $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['CONTACT_ID']) && !is_array($arFields['CONTACT_ID'])) {
$arFields['CONTACT_ID'] = array($arFields['CONTACT_ID']);
}
if (isset($arFields['COMMENTS']) && $arFields['COMMENTS'] !== '') {
$arFields['COMMENTS'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", $arFields['COMMENTS']);
}
$DB->StartTransaction();
$CCrmEntity = new CCrmCompany(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('COMPANY');
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();
}
}
示例4: CCrmContact
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();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $entityID, CCrmBizProcEventType::Edit, $arErrors);
}
}
}
示例5: GetMessage
if (!$CCrmCompany->CheckFields($arFields, $bEdit ? $arResult['ELEMENT']['ID'] : false)) {
if (!empty($CCrmCompany->LAST_ERROR)) {
$arResult['ERROR_MESSAGE'] .= $CCrmCompany->LAST_ERROR;
} else {
$arResult['ERROR_MESSAGE'] .= GetMessage('UNKNOWN_ERROR');
}
}
if (($arBizProcParametersValues = $CCrmBizProc->CheckFields($bEdit ? $arResult['ELEMENT']['ID'] : false, false, $arResult['ELEMENT']['ASSIGNED_BY'], $bEdit ? array($arResult['ELEMENT']['ID'] => $arEntityAttr[$arResult['ELEMENT']['ID']]) : null)) === false) {
$arResult['ERROR_MESSAGE'] .= $CCrmBizProc->LAST_ERROR;
}
if (empty($arResult['ERROR_MESSAGE'])) {
$ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0;
$DB->StartTransaction();
$bSuccess = false;
if ($bEdit) {
$bSuccess = $CCrmCompany->Update($ID, $arFields, true, true, array('REGISTER_SONET_EVENT' => true));
} else {
$ID = $CCrmCompany->Add($arFields, true, array('REGISTER_SONET_EVENT' => true));
$bSuccess = $ID !== false;
if ($bSuccess) {
$arResult['ELEMENT']['ID'] = $ID;
}
}
if ($bSuccess) {
$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)) {
示例6: isset
$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);
__CrmMobileCompanyEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareCompanyData($currentItem)));
} else {
//$DB->Rollback();
__CrmMobileCompanyEditEndResonse(array('ERROR' => strip_tags(preg_replace("/<br[^>]*>/", "\n", $fields['RESULT_MESSAGE']))));
}
}
示例7: array
}
}
} else {
if (!isset($item['FM'][$type])) {
$item['FM'][$type] = array();
}
for ($i = 0; $i < $valueCount; $i++) {
$item['FM'][$type]['n' . strval($i + 1)] = array('VALUE_TYPE' => $valueType, 'VALUE' => $values[$i]['VALUE']);
}
}
}
}
}
}
unset($valueTypes);
$CCrmCompany->Update($item['ID'], $item);
}
unset($item);
}
}
}
if ($isDuplicate) {
$arResult['duplicate']++;
if ($enableDupFile) {
__CrmImportWriteDataToFile($duplicateFilePath, isset($_SESSION['CRM_IMPORT_FILE_HEADERS']) ? $_SESSION['CRM_IMPORT_FILE_HEADERS'] : null, $arData);
}
} else {
$arCompany['PERMISSION'] = 'IMPORT';
if (!$CCrmCompany->Add($arCompany)) {
$arResult['error']++;
$arResult['error_data'][] = array('message' => $arCompany['RESULT_MESSAGE'], 'data' => $arData);
示例8: foreach
if (isset($actionData['FIELDS']) && is_array($actionData['FIELDS'])) {
foreach ($actionData['FIELDS'] as $ID => $arSrcData) {
$arEntityAttr = $CCrmCompany->cPerms->GetEntityAttr('COMPANY', array($ID));
if (!$CCrmCompany->cPerms->CheckEnityAccess('COMPANY', '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 ($CCrmCompany->Update($ID, $arUpdateData)) {
$DB->Commit();
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Company, $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[] = 'CO_' . $ID;
}