本文整理汇总了PHP中CCrmDeal::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmDeal::Update方法的具体用法?PHP CCrmDeal::Update怎么用?PHP CCrmDeal::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmDeal
的用法示例。
在下文中一共展示了CCrmDeal::Update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
}
$ID = isset($data['ID']) ? intval($data['ID']) : 0;
if ($ID <= 0) {
__CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND')));
}
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__));
示例2: SaveOrderDataDeal
//.........这里部分代码省略.........
if ($contactId != null && intval($contactId) > 0) {
if (isset($arOrder["CONTRACTOR"]["FULL_NAME"]) && $arOrder["CONTRACTOR"]["FULL_NAME"] != "") {
$arAdditionalInfo['CONTACT_FULL_NAME'] = $arOrder["CONTRACTOR"]["FULL_NAME"];
} elseif (isset($arOrder["CONTRACTOR"]["NAME"]) && $arOrder["CONTRACTOR"]["NAME"] != "") {
$arAdditionalInfo['CONTACT_FULL_NAME'] = $arOrder["CONTRACTOR"]["NAME"];
}
}
if ($companyId != null && intval($companyId) > 0) {
if (isset($arOrder["CONTRACTOR"]["OFFICIAL_NAME"]) && $arOrder["CONTRACTOR"]["OFFICIAL_NAME"] != "") {
$arAdditionalInfo['COMPANY_FULL_NAME'] = $arOrder["CONTRACTOR"]["OFFICIAL_NAME"];
} elseif (isset($arOrder["CONTRACTOR"]["NAME"]) && $arOrder["CONTRACTOR"]["NAME"] != "") {
$arAdditionalInfo['COMPANY_FULL_NAME'] = $arOrder["CONTRACTOR"]["NAME"];
}
}
if (is_array($arOrder["PROPERTIES"])) {
foreach ($arOrder["PROPERTIES"] as $arProp) {
if (!empty($arProp["VALUE"])) {
$arAdditionalInfo[strtoupper($arProp["NAME"])] = $arProp["VALUE"];
if ($arAdditionalInfo[strtoupper($arProp["NAME"])] == "true") {
$arAdditionalInfo[strtoupper($arProp["NAME"])] = true;
} elseif ($arAdditionalInfo[strtoupper($arProp["NAME"])] == "false") {
$arAdditionalInfo[strtoupper($arProp["NAME"])] = false;
}
}
switch (strtoupper($arProp["NAME"])) {
case 'FINALSTATUS':
if ($arProp["VALUE"] == 'true') {
$arFields["CLOSED"] = "Y";
//$arFields["CLOSEDATE"] = $arOrder["DATE_UPDATE"];
} else {
$arFields["CLOSED"] = "N";
//$arFields["CLOSEDATE"] = false;
}
break;
case 'CANCELED':
if ($arProp["VALUE"] == 'true') {
if (array_key_exists("LOSE", $arStageList)) {
$arFields["STAGE_ID"] = "LOSE";
}
$arFields["PROBABILITY"] = 0;
}
break;
case 'ORDERPAID':
if ($arProp["VALUE"] == 'true') {
if (array_key_exists("WON", $arStageList)) {
$arFields["STAGE_ID"] = "WON";
}
$arFields["PROBABILITY"] = 100;
}
break;
case 'ORDERSTATUS':
//$arFields["CLOSED"] = "Y";
//$arFields["CLOSEDATE"] = $arOrder["DATE_UPDATE"];
break;
}
}
}
$arFields["ADDITIONAL_INFO"] = serialize($arAdditionalInfo);
$accountNumber = isset($arOrder["ACCOUNT_NUMBER"]) && $arOrder["ACCOUNT_NUMBER"] !== '' ? $arOrder["ACCOUNT_NUMBER"] : $arOrder["ID"];
$obj = new CCrmDeal(false);
if ($dealId == 0) {
$arFields['TITLE'] = sprintf("%s #%s", $this->arExternalSale["PREFIX"], $accountNumber);
$arFields['OPENED'] = $this->arExternalSale["PUBLIC"];
$arFields["TYPE_ID"] = 'SALE';
$arFields["CLOSEDATE"] = ConvertTimeStamp(time() + CTimeZone::GetOffset() + 86400, "FULL");
if (!isset($arFields["PROBABILITY"])) {
$arFields["PROBABILITY"] = $this->arExternalSale["PROBABILITY"];
}
$assignedById = $this->arExternalSale["RESPONSIBLE"];
if ($assignedById > 0) {
$arFields["ASSIGNED_BY_ID"] = $assignedById;
}
$res = $obj->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res > 0) {
$dealId = (int) $res;
$this->arImportResult->numberOfCreatedDeals++;
}
} else {
if ($dealTitle === 'Deal') {
$arFields['TITLE'] = sprintf("%s #%s", $this->arExternalSale["PREFIX"], $accountNumber);
}
// Disable properties change events generation ($bCompare = false) and user fields check 'DISABLE_USER_FIELD_CHECK' = true.
$res = $obj->Update($dealId, $arFields, false, true, array('DISABLE_USER_FIELD_CHECK' => true));
if ($res) {
$this->arImportResult->numberOfUpdatedDeals++;
}
}
if (!$res) {
if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
$this->AddError($ex->GetID(), $ex->GetString());
} else {
$this->AddError("CDA", "Deal creation error");
}
if (!empty($obj->LAST_ERROR)) {
$this->AddError("CDA", $obj->LAST_ERROR);
}
return false;
}
return array($dealId, $newDeal);
}
示例3: CCrmContact
$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);
}
}
}
break;
case 'QUOTE':
if (isset($_POST['STATUS_ID'])) {
$statusID = $_POST['STATUS_ID'];
$dbResult = CCrmQuote::GetList(array(), array('=ID' => $entityID), false, false, array('STATUS_ID'));
$arPrevious = $dbResult ? $dbResult->Fetch() : null;
if (is_array($arPrevious) && isset($arPrevious['STATUS_ID']) && $arPrevious['STATUS_ID'] !== $statusID) {
$CCrmDeal = new CCrmQuote();
$arField = array('STATUS_ID' => $statusID);
if ($CCrmDeal->Update($entityID, $arField)) {
示例4: SynchronizeProductRows
public function SynchronizeProductRows($ID)
{
$arTotalInfo = CCrmProductRow::CalculateTotalInfo('D', $ID);
if (is_array($arTotalInfo)) {
$arFields = array('OPPORTUNITY' => isset($arTotalInfo['OPPORTUNITY']) ? $arTotalInfo['OPPORTUNITY'] : 0.0, 'TAX_VALUE' => isset($arTotalInfo['TAX_VALUE']) ? $arTotalInfo['TAX_VALUE'] : 0.0);
$entity = new CCrmDeal();
$entity->Update($ID, $arFields);
}
}
示例5: executePhase
public function executePhase()
{
if ($this->currentPhase === LeadConversionPhase::COMPANY_CREATION || $this->currentPhase === LeadConversionPhase::CONTACT_CREATION || $this->currentPhase === LeadConversionPhase::DEAL_CREATION) {
if ($this->currentPhase === LeadConversionPhase::COMPANY_CREATION) {
$entityTypeID = \CCrmOwnerType::Company;
} elseif ($this->currentPhase === LeadConversionPhase::CONTACT_CREATION) {
$entityTypeID = \CCrmOwnerType::Contact;
} else {
$entityTypeID = \CCrmOwnerType::Deal;
}
$entityTypeName = \CCrmOwnerType::ResolveName($entityTypeID);
$config = $this->config->getItem($entityTypeID);
if (!$config->isActive()) {
return false;
}
/** @var \CCrmPerms $permissions */
$permissions = $this->getUserPermissions();
$entityID = isset($this->contextData[$entityTypeName]) ? $this->contextData[$entityTypeName] : 0;
if ($entityID > 0) {
if ($entityTypeID === \CCrmOwnerType::Company) {
if (!\CCrmCompany::Exists($entityID)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Company, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
}
$entity = new \CCrmCompany(false);
} elseif ($entityTypeID === \CCrmOwnerType::Contact) {
if (!\CCrmContact::Exists($entityID)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Contact, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
}
$entity = new \CCrmContact(false);
} else {
if (!\CCrmDeal::Exists($entityID)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
}
$entity = new \CCrmDeal(false);
}
if (!\CCrmAuthorizationHelper::CheckUpdatePermission($entityTypeName, $entityID, $permissions)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::UPDATE_DENIED);
}
$fields = array('LEAD_ID' => $this->entityID);
$entity->Update($entityID, $fields);
$this->resultData[$entityTypeName] = $entityID;
return true;
}
if (!\CCrmAuthorizationHelper::CheckCreatePermission($entityTypeName, $permissions)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::CREATE_DENIED);
}
if (UserFieldSynchronizer::needForSynchronization(\CCrmOwnerType::Lead, $entityTypeID)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::NOT_SYNCHRONIZED);
}
if (!ConversionSettings::getCurrent()->isAutocreationEnabled()) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::AUTOCREATION_DISABLED);
}
if (\CCrmBizProcHelper::HasAutoWorkflows($entityTypeID, \CCrmBizProcEventType::Create)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::HAS_WORKFLOWS);
}
/** @var LeadConversionMapper $mapper */
$mapper = $this->getMapper();
$map = self::prepareMap($entityTypeID);
$fields = $mapper->map($map);
if (empty($fields)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::EMPTY_FIELDS);
}
if ($entityTypeID === \CCrmOwnerType::Company) {
$entity = new \CCrmCompany(false);
$entityID = $entity->Add($fields);
if ($entityID <= 0) {
throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Company, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
}
//region BizProcess
$arErrors = array();
\CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Company, $entityID, \CCrmBizProcEventType::Create, $arErrors);
//endregion
$this->resultData[\CCrmOwnerType::CompanyName] = $entityID;
} elseif ($entityTypeID === \CCrmOwnerType::Contact) {
if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
$fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
}
$entity = new \CCrmContact(false);
if (!$entity->CheckFields($fields)) {
throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::INVALID_FIELDS, $entity->LAST_ERROR);
}
$entityID = $entity->Add($fields);
if ($entityID <= 0) {
throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Contact, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
}
//region BizProcess
$arErrors = array();
\CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Contact, $entityID, \CCrmBizProcEventType::Create, $arErrors);
//endregion
$this->resultData[\CCrmOwnerType::ContactName] = $entityID;
} else {
if (isset($this->resultData[\CCrmOwnerType::ContactName])) {
$fields['CONTACT_ID'] = $this->resultData[\CCrmOwnerType::ContactName];
}
if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
$fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
}
$productRows = isset($fields['PRODUCT_ROWS']) && is_array($fields['PRODUCT_ROWS']) ? $fields['PRODUCT_ROWS'] : array();
if (!empty($productRows)) {
$result = \CCrmProductRow::CalculateTotalInfo('D', 0, false, $fields, $productRows);
//.........这里部分代码省略.........
示例6: GetMessage
$arResult['ERROR_MESSAGE'] = '';
if (!$CCrmDeal->CheckFields($arFields, $bEdit ? $arResult['ELEMENT']['ID'] : false)) {
if (!empty($CCrmDeal->LAST_ERROR)) {
$arResult['ERROR_MESSAGE'] .= $CCrmDeal->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'])) {
$DB->StartTransaction();
$bSuccess = false;
if ($bEdit) {
$bSuccess = $CCrmDeal->Update($arResult['ELEMENT']['ID'], $arFields, true, true, array('REGISTER_SONET_EVENT' => true));
} else {
if ($originatorId > 0 && $originId > 0) {
$arFields['ORIGINATOR_ID'] = $originatorId;
$arFields['ORIGIN_ID'] = $originId;
}
$ID = $CCrmDeal->Add($arFields, true, array('REGISTER_SONET_EVENT' => true));
$bSuccess = $ID !== false;
if ($bSuccess) {
$arResult['ELEMENT']['ID'] = $ID;
}
}
if ($bSuccess) {
// Save settings
if (is_array($productRowSettings) && count($productRowSettings) > 0) {
$arSettings = CCrmProductRow::LoadSettings('D', $arResult['ELEMENT']['ID']);
示例7: UpdateDocument
public static function UpdateDocument($documentId, $arFields)
{
global $DB;
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
$dbDocumentList = CCrmDeal::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;
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
if ($arDocumentFields[$key]["Type"] == "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 ($arDocumentFields[$key]["Type"] == "select" && substr($key, 0, 3) == "UF_") {
self::InternalizeEnumerationField('CRM_DEAL', $arFields, $key);
} elseif ($arDocumentFields[$key]["Type"] == "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 ($arDocumentFields[$key]["Type"] == "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['COMPANY_ID']) && !is_array($arFields['COMPANY_ID']))
$arFields['COMPANY_ID'] = array($arFields['COMPANY_ID']);*/
if (isset($arFields['COMMENTS']) && $arFields['COMMENTS'] !== '') {
$arFields['COMMENTS'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", $arFields['COMMENTS']);
}
$DB->StartTransaction();
$CCrmEntity = new CCrmDeal(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('DEAL');
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: createDeals
public function createDeals(array $params)
{
$date = isset($params['DATE']) ? $params['DATE'] : null;
if (!$date) {
$date = $date = new Date();
}
$dateFormat = Date::convertFormatToPhp(FORMAT_DATE);
$count = isset($params['COUNT']) ? (int) $params['COUNT'] : 0;
if ($count <= 0) {
return;
}
$duration = isset($params['DURATION']) ? (int) $params['DURATION'] : 0;
if ($duration <= 0) {
$duration = 7;
}
$probability = isset($params['PROBABILITY']) ? (int) $params['PROBABILITY'] : 0;
if ($probability <= 0) {
$probability = 10;
}
$typeID = isset($params['TYPE_ID']) ? $params['TYPE_ID'] : '';
if ($typeID === '') {
$typeID = 'SALE';
}
$prefix = isset($params['PREFIX']) ? $params['PREFIX'] : '';
if ($prefix === '') {
$prefix = $this->id;
}
$stageIDs = isset($params['STAGE_IDS']) && is_array($params['STAGE_IDS']) ? $params['STAGE_IDS'] : array();
if (empty($stageIDs)) {
$stageIDs[] = 'NEW';
}
$stageCount = count($stageIDs);
$userIDs = isset($params['USER_IDS']) && is_array($params['USER_IDS']) ? $params['USER_IDS'] : array();
if (empty($userIDs)) {
$userIDs[] = \CCrmSecurityHelper::GetCurrentUserID();
}
$currencyID = isset($params['CURRENCY_ID']) ? $params['CURRENCY_ID'] : '';
if ($currencyID === '') {
$currencyID = \CCrmCurrency::GetBaseCurrencyID();
}
$minSum = isset($params['MIN_SUM']) ? (int) $params['MIN_SUM'] : 0;
if ($minSum <= 0) {
$minSum = 100;
}
$maxSum = isset($params['MAX_SUM']) ? (int) $params['MAX_SUM'] : 0;
if ($maxSum <= 0) {
$maxSum = 1000;
}
$clientInfos = isset($params['CLIENT_INFOS']) && is_array($params['CLIENT_INFOS']) ? $params['CLIENT_INFOS'] : array();
$callCount = isset($params['CALL_COUNT']) ? (int) $params['CALL_COUNT'] : 0;
$meetingCount = isset($params['MEETING_COUNT']) ? (int) $params['MEETING_COUNT'] : 0;
$invoiceCount = isset($params['INVOICE_COUNT']) ? (int) $params['INVOICE_COUNT'] : 0;
$number = isset($params['NUMBER']) ? (int) $params['NUMBER'] : 0;
if ($number <= 0) {
$number = 0;
}
$dealEntity = new \CCrmDeal(false);
for ($i = 0; $i < $count; $i++) {
$number++;
$title = "{$prefix} deal # {$number}";
$beginDate = clone $date;
$opportunity = mt_rand($minSum, $maxSum);
$fields = array('TITLE' => $title, 'TYPE_ID' => $typeID, 'STAGE_ID' => $stageIDs[0], 'PROBABILITY' => $probability, 'CURRENCY_ID' => $currencyID, 'OPPORTUNITY' => $opportunity, 'ASSIGNED_BY_ID' => self::getRandomItem($userIDs), 'BEGINDATE' => $beginDate->format($dateFormat), 'CLOSEDATE' => $beginDate->add("{$duration} days")->format($dateFormat), 'ORIGINATOR_ID' => $this->id);
$contactID = 0;
$companyID = 0;
$clientInfo = self::getRandomItem($clientInfos);
if (is_array($clientInfo)) {
if (isset($clientInfo['CONTACT_ID'])) {
$contactID = $clientInfo['CONTACT_ID'];
}
if (isset($clientInfo['COMPANY_ID'])) {
$companyID = $clientInfo['COMPANY_ID'];
}
}
if ($contactID > 0) {
$fields['CONTACT_ID'] = $contactID;
}
if ($companyID > 0) {
$fields['COMPANY_ID'] = $companyID;
}
$ID = $dealEntity->Add($fields, true, array('ENABLE_CLOSE_DATE_SYNC' => false));
$lastStage = $stageIDs[$stageCount - 1];
if ($stageCount > 1) {
$lastStageIndex = mt_rand(1, $stageCount - 1);
$lastStage = $stageIDs[$lastStageIndex];
for ($j = 1; $j <= $lastStageIndex; $j++) {
$fields = array('STAGE_ID' => $stageIDs[$j]);
$dealEntity->Update($ID, $fields, true, true, array('ENABLE_CLOSE_DATE_SYNC' => false));
}
}
$clientTypeID = \CCrmOwnerType::Undefined;
$clientID = 0;
if ($contactID > 0) {
$clientTypeID = \CCrmOwnerType::Contact;
$clientID = $contactID;
} elseif ($companyID > 0) {
$clientTypeID = \CCrmOwnerType::Company;
$clientID = $companyID;
}
if ($clientID > 0) {
//.........这里部分代码省略.........
示例9: strncmp
}
} else {
$fieldNames[] = $_POST['FIELD_NAME'];
if (!$hasUserFields) {
$hasUserFields = strncmp($_POST['FIELD_NAME'], 'UF_', 3) === 0;
}
}
}
if (count($fieldNames) == 0) {
__CrmDealShowEndJsonResonse(array('ERROR' => 'FIELD_NAME IS NOT DEFINED!'));
}
$fieldValues = array();
if (isset($_POST['FIELD_VALUE'])) {
if (is_array($_POST['FIELD_VALUE'])) {
$fieldValues = $_POST['FIELD_VALUE'];
} else {
$fieldValues[] = $_POST['FIELD_VALUE'];
}
}
$dbResult = CCrmDeal::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::Deal, $arFields, $fieldNames, $fieldValues);
$disableUserFieldCheck = !$hasUserFields && isset($_POST['DISABLE_USER_FIELD_CHECK']) && strtoupper($_POST['DISABLE_USER_FIELD_CHECK']) === 'Y';
if ($CCrmDeal->Update($ID, $arFields, true, true, array('REGISTER_SONET_EVENT' => true, 'DISABLE_USER_FIELD_CHECK' => $disableUserFieldCheck))) {
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $ID, CCrmBizProcEventType::Edit, $arErrors);
}
}
}
die;
示例10: foreach
if (isset($actionData['FIELDS']) && is_array($actionData['FIELDS'])) {
foreach ($actionData['FIELDS'] as $ID => $arSrcData) {
$arEntityAttr = $CCrmPerms->GetEntityAttr('DEAL', array($ID));
if (!$CCrmPerms->CheckEnityAccess('DEAL', '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 ($CCrmDeal->Update($ID, $arUpdateData)) {
$DB->Commit();
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $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[] = 'D_' . $ID;
}
示例11: unset
}
if (isset($arFields['CREATED_BY_ID'])) {
unset($arFields['CREATED_BY_ID']);
}
if (isset($arFields['DATE_CREATE'])) {
unset($arFields['DATE_CREATE']);
}
if (isset($arFields['MODIFY_BY_ID'])) {
unset($arFields['MODIFY_BY_ID']);
}
if (isset($arFields['DATE_MODIFY'])) {
unset($arFields['DATE_MODIFY']);
}
$arFields['STAGE_ID'] = $stageID;
$CCrmDeal = new CCrmDeal(false);
if ($CCrmDeal->Update($ID, $arFields, true, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true))) {
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $ID, CCrmBizProcEventType::Edit, $arErrors);
}
__CrmDealListEndResonse(array('TYPE' => $targetTypeName, 'ID' => $ID, 'VALUE' => $stageID));
} elseif ($action === 'REBUILD_STATISTICS') {
__IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
if (!CCrmDeal::CheckUpdatePermission(0)) {
__CrmDealListEndResonse(array('ERROR' => 'Access denied.'));
}
if (COption::GetOptionString('crm', '~CRM_REBUILD_DEAL_STATISTICS', 'N') !== 'Y') {
__CrmDealListEndResonse(array('STATUS' => 'NOT_REQUIRED', 'SUMMARY' => GetMessage('CRM_DEAL_LIST_REBUILD_STATISTICS_NOT_REQUIRED_SUMMARY')));
}
$progressData = COption::GetOptionString('crm', '~CRM_REBUILD_DEAL_STATISTICS_PROGRESS', '');
$progressData = $progressData !== '' ? unserialize($progressData) : array();
$lastItemID = isset($progressData['LAST_ITEM_ID']) ? intval($progressData['LAST_ITEM_ID']) : 0;