本文整理汇总了PHP中CCrmFieldMulti::PrepareFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmFieldMulti::PrepareFields方法的具体用法?PHP CCrmFieldMulti::PrepareFields怎么用?PHP CCrmFieldMulti::PrepareFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmFieldMulti
的用法示例。
在下文中一共展示了CCrmFieldMulti::PrepareFields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
public function Add($data)
{
global $DB;
if (($r = self::CheckAuth()) !== false) {
return $r;
}
$arFieldsInfo = CCrmLead::GetFields();
$arFields = array();
$arEl = $data->elementsByName('Field');
foreach ($arEl as $child) {
$children = $child->children();
$sFieldName = $child->getAttribute('id');
// Fix for issue #40193
if (!isset($arFieldsInfo[$sFieldName])) {
continue;
}
if (!is_null($children)) {
$arFields[$sFieldName] = array();
foreach ($children as $child) {
$arFields[$sFieldName][] = $child->content;
}
} else {
$arFields[$sFieldName] = $child->content;
}
}
CCrmFieldMulti::PrepareFields($arFields);
$CCrmUserType = new CCrmUserType($GLOBALS['USER_FIELD_MANAGER'], CCrmLead::$sUFEntityID);
$CCrmUserType->InternalizeFields($arFields, ',');
$CCrmBizProc = new CCrmBizProc('LEAD');
if (false === $CCrmBizProc->CheckFields(false, true)) {
return new CSoapFault('CCrmLead::Add Bizproc', htmlspecialcharsbx(strip_tags(nl2br($CCrmBizProc->LAST_ERROR))));
}
$CCrmLead = new CCrmLead();
$DB->StartTransaction();
$ID = $CCrmLead->Add($arFields);
if ($ID !== false && !$CCrmBizProc->StartWorkflow($ID)) {
$DB->Rollback();
return new CSoapFault('CCrmLead::Add Bizproc', htmlspecialcharsbx(strip_tags(nl2br($CCrmBizProc->LAST_ERROR))));
}
if ($ID === false) {
$DB->Rollback();
return new CSoapFault('CCrmLead::Add', htmlspecialcharsbx(strip_tags(nl2br($arFields['RESULT_MESSAGE']))));
}
$DB->Commit();
return 'ok';
}
示例2: AddLead
public static function AddLead($arData, $CCrmLead)
{
global $DB, $USER_FIELD_MANAGER;
$CCrmBizProc = new CCrmBizProc('LEAD');
$arData['CURRENCY_ID'] = trim($arData['CURRENCY_ID']);
if (strlen($arData['CURRENCY_ID']) <= 0) {
$arData['CURRENCY_ID'] = CCrmCurrency::GetBaseCurrencyID();
}
$arFields = array('TITLE' => trim($arData['TITLE']), 'COMPANY_TITLE' => trim($arData['COMPANY_TITLE']), 'NAME' => trim($arData['NAME']), 'LAST_NAME' => trim($arData['LAST_NAME']), 'SECOND_NAME' => trim($arData['SECOND_NAME']), 'POST' => trim($arData['POST']), 'ADDRESS' => trim($arData['ADDRESS']), 'COMMENTS' => trim($arData['COMMENTS']), 'SOURCE_DESCRIPTION' => trim($arData['SOURCE_DESCRIPTION']), 'STATUS_DESCRIPTION' => trim($arData['STATUS_DESCRIPTION']), 'OPPORTUNITY' => trim($arData['OPPORTUNITY']), 'CURRENCY_ID' => trim($arData['CURRENCY_ID']), 'ASSIGNED_BY_ID' => (int) (is_array($arData['ASSIGNED_BY_ID']) ? $arData['ASSIGNED_BY_ID'][0] : $arData['ASSIGNED_BY_ID']), 'OPENED' => 'Y');
$arData['SOURCE_ID'] = trim($arData['SOURCE_ID']);
$arData['STATUS_ID'] = trim($arData['STATUS_ID']);
if (strlen($arData['STATUS_ID']) > 0) {
$arFields['STATUS_ID'] = $arData['STATUS_ID'];
}
if (strlen($arData['SOURCE_ID']) > 0) {
$arFields['SOURCE_ID'] = $arData['SOURCE_ID'];
}
$USER_FIELD_MANAGER->EditFormAddFields(CCrmLead::$sUFEntityID, $arFields);
$CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, CCrmLead::$sUFEntityID);
$CCrmUserType->PrepareImport($arFields, ',');
$arFields['FM'] = CCrmFieldMulti::PrepareFields($arData);
$DB->StartTransaction();
$ID = $CCrmLead->Add($arFields);
if ($ID === false) {
$DB->Rollback();
if (!empty($arFields['RESULT_MESSAGE'])) {
$sErrorMessage = $arFields['RESULT_MESSAGE'];
} else {
$sErrorMessage = GetMessage('UNKNOWN_ERROR');
}
$res = array('error' => 400, 'error_message' => strip_tags(nl2br($sErrorMessage)));
} else {
$DB->Commit();
// Ignore all BizProc errors
try {
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Lead, $ID, CCrmBizProcEventType::Create, $arErrors);
} catch (Exception $e) {
}
$res = array('error' => 201, 'ID' => $ID, 'error_message' => GetMessage('CRM_REST_OK'));
}
return self::_out($res);
}
示例3: uniqid
} else {
$leadlID = uniqid();
}
// For compatibility only. Try sync product PRICE
if (isset($arLead['PRODUCT_ROWS']) && count($arLead['PRODUCT_ROWS']) == 1 && !isset($arLead['PRODUCT_ROWS'][0]['PRICE']) && isset($arLead['OPPORTUNITY'])) {
$arLead['PRODUCT_ROWS'][0]['PRICE'] = doubleval($arLead['OPPORTUNITY']);
}
if ($canBreak && count($arLeads) >= 20) {
break;
}
$arLeads[$leadlID] = $arLead;
$filePos = $csvFile->GetPos();
}
$csvFile->CloseFile();
foreach ($arLeads as $arLead) {
CCrmFieldMulti::PrepareFields($arLead);
$isDuplicate = false;
if ($dupCtrlType !== 'NO_CONTROL' && ($enableDupCtrlByPerson || $enableDupCtrlByOrganization || $enableDupCtrlByPhone || $enableDupCtrlByEmail)) {
$fieldNames = array();
if ($enableDupCtrlByPerson) {
$fieldNames[] = 'NAME';
$fieldNames[] = 'SECOND_NAME';
$fieldNames[] = 'LAST_NAME';
}
if ($enableDupCtrlByOrganization) {
$fieldNames[] = 'COMPANY_TITLE';
}
if ($enableDupCtrlByPhone) {
$fieldNames[] = 'FM.PHONE';
}
if ($enableDupCtrlByEmail) {
示例4: Add
public function Add($data)
{
if (($r = self::CheckAuth()) !== false) {
return $r;
}
$arFieldsInfo = CCrmContact::GetFields();
$arFields = array();
$arEl = $data->elementsByName('Field');
foreach ($arEl as $el) {
$children = $el->children();
$sFieldName = $el->getAttribute('id');
// Fix for issue #40193
if (!isset($arFieldsInfo[$sFieldName])) {
continue;
}
if (!is_null($children)) {
$arFields[$sFieldName] = array();
foreach ($children as $child) {
$arFields[$sFieldName][] = $child->content;
}
} else {
$arFields[$sFieldName] = $el->content;
}
}
CCrmFieldMulti::PrepareFields($arFields);
if (isset($arFields['PHOTO'])) {
$arFile = null;
if (CCrmUrlUtil::HasScheme($arFields['PHOTO']) && CCrmUrlUtil::IsSecureUrl($arFields['PHOTO'])) {
$arFile = CFile::MakeFileArray($arFields['PHOTO']);
if (is_array($arFile)) {
$arFile += array('MODULE_ID' => 'crm');
}
}
if (is_array($arFile)) {
$arFields['PHOTO'] = $arFile;
} else {
unset($arFields['PHOTO']);
}
}
$arUserFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields(CCrmContact::$sUFEntityID);
foreach ($arUserFields as $FIELD_NAME => $arUserField) {
if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file') {
if (!isset($arFields[$FIELD_NAME])) {
continue;
}
if (is_array($arFields[$FIELD_NAME])) {
$arFiles = array();
foreach ($arFields[$FIELD_NAME] as $sFilePath) {
if (!(CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath))) {
continue;
}
$arFile = CFile::MakeFileArray($sFilePath);
if (is_array($arFile)) {
$arFile += array('MODULE_ID' => 'crm');
$arFiles[] = $arFile;
}
}
$arFields[$FIELD_NAME] = $arFiles;
} else {
$arFile = null;
$sFilePath = $arFields[$FIELD_NAME];
if (CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath)) {
$arFile = CFile::MakeFileArray($sFilePath);
if (is_array($arFile)) {
$arFile += array('MODULE_ID' => 'crm');
}
}
if (is_array($arFile)) {
$arFields[$FIELD_NAME] = $arFile;
} else {
unset($arFields[$FIELD_NAME]);
}
}
}
}
$CCrmContact = new CCrmContact();
return $CCrmContact->Add($arFields) ? 'ok' : new CSoapFault('CCrmLead::Add', htmlspecialcharsbx(strip_tags(nl2br($arFields['RESULT_MESSAGE']))));
}
示例5: AddLead
public static function AddLead($params)
{
if (!CModule::IncludeModule('crm')) {
return false;
}
if (strlen($params['PHONE_NUMBER']) <= 0 || intval($params['USER_ID']) <= 0) {
return false;
}
$result = VI\PhoneTable::getList(array('select' => array('USER_ID', 'PHONE_MNEMONIC'), 'filter' => array('=PHONE_NUMBER' => $params['PHONE_NUMBER'])));
if ($row = $result->fetch()) {
return false;
}
$title = GetMessage($params['INCOMING'] ? 'VI_CRM_CALL_INCOMING' : 'VI_CRM_CALL_OUTGOING');
$arFields = array('TITLE' => $params['PHONE_NUMBER'] . ' - ' . $title, 'OPENED' => 'Y', 'PHONE_WORK' => $params['PHONE_NUMBER']);
$statuses = CCrmStatus::GetStatusList("SOURCE");
if (isset($statuses[$params['CRM_SOURCE']])) {
$arFields['SOURCE_ID'] = $params['CRM_SOURCE'];
} else {
if (isset($statuses['CALL'])) {
$arFields['SOURCE_ID'] = 'CALL';
} else {
if (isset($statuses['OTHER'])) {
$arFields['SOURCE_ID'] = 'OTHER';
}
}
}
$portalNumbers = CVoxImplantConfig::GetPortalNumbers();
$portalNumber = isset($portalNumbers[$params['SEARCH_ID']]) ? $portalNumbers[$params['SEARCH_ID']] : '';
if ($portalNumber) {
$arFields['SOURCE_DESCRIPTION'] = GetMessage('VI_CRM_CALL_TO_PORTAL_NUMBER', array('#PORTAL_NUMBER#' => $portalNumber));
}
$arFields['FM'] = CCrmFieldMulti::PrepareFields($arFields);
$CCrmLead = new CCrmLead(false);
$ID = $CCrmLead->Add($arFields, true, array('CURRENT_USER' => $params['USER_ID'], 'DISABLE_USER_FIELD_CHECK' => true));
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Lead, $ID, CCrmBizProcEventType::Create, $arErrors);
CVoxImplantHistory::WriteToLog($arFields, 'LEAD CREATED');
return $ID;
}
示例6: AddLead
public static function AddLead($params)
{
if (!CModule::IncludeModule('crm')) {
return false;
}
if (strlen($params['PHONE_NUMBER']) <= 0 || intval($params['USER_ID']) <= 0) {
return false;
}
$dateNow = new Bitrix\Main\Type\DateTime();
$title = GetMessage($params['INCOMING'] ? 'VI_CRM_CALL_INCOMING' : 'VI_CRM_CALL_OUTGOING');
$arFields = array('TITLE' => $title . ' ' . $dateNow->format('H:i d.m.Y'), 'OPENED' => 'Y', 'PHONE_WORK' => $params['PHONE_NUMBER']);
$statuses = CCrmStatus::GetStatusList("SOURCE");
if (isset($statuses['CALL'])) {
$arFields['SOURCE_ID'] = 'CALL';
}
$portalNumbers = CVoxImplantConfig::GetPortalNumbers();
$portalNumber = isset($portalNumbers[$params['SEARCH_ID']]) ? $portalNumbers[$params['SEARCH_ID']] : '';
if ($portalNumber) {
$arFields['SOURCE_DESCRIPTION'] = GetMessage('VI_CRM_CALL_TO_PORTAL_NUMBER', array('#PORTAL_NUMBER#' => $portalNumber));
}
$arFields['FM'] = CCrmFieldMulti::PrepareFields($arFields);
$CCrmLead = new CCrmLead(false);
$ID = $CCrmLead->Add($arFields, true, array('CURRENT_USER' => $params['USER_ID'], 'DISABLE_USER_FIELD_CHECK' => true));
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Lead, $ID, CCrmBizProcEventType::Create, $arErrors);
CVoxImplantHistory::WriteToLog($arFields, 'LEAD CREATED');
return $ID;
}
示例7: unset
}
}
}
if (!isset($arCompany['ASSIGNED_BY_ID']) && $defaultUserID > 0) {
$arCompany['ASSIGNED_BY_ID'] = $defaultUserID;
}
//Try to map full address to first address line
if (isset($arCompany['FULL_ADDRESS']) && !isset($arCompany['ADDRESS'])) {
$arCompany['ADDRESS'] = $arCompany['FULL_ADDRESS'];
unset($arCompany['FULL_ADDRESS']);
}
if (isset($arCompany['FULL_REG_ADDRESS']) && !isset($arCompany['REG_ADDRESS'])) {
$arCompany['REG_ADDRESS'] = $arCompany['FULL_REG_ADDRESS'];
unset($arCompany['FULL_REG_ADDRESS']);
}
CCrmFieldMulti::PrepareFields($arCompany);
$isDuplicate = false;
if ($dupCtrlType !== 'NO_CONTROL' && ($enableDupCtrlByOrganization || $enableDupCtrlByPhone || $enableDupCtrlByEmail)) {
$fieldNames = array();
if ($enableDupCtrlByOrganization) {
$fieldNames[] = 'TITLE';
}
if ($enableDupCtrlByPhone) {
$fieldNames[] = 'FM.PHONE';
}
if ($enableDupCtrlByEmail) {
$fieldNames[] = 'FM.EMAIL';
}
$adapter = \Bitrix\Crm\EntityAdapterFactory::create($arCompany, CCrmOwnerType::Company);
$dups = $dupChecker->findDuplicates($adapter, new \Bitrix\Crm\Integrity\DuplicateSearchParams($fieldNames));
$dupIDs = array();