本文整理汇总了PHP中CCrmDeal::GetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmDeal::GetList方法的具体用法?PHP CCrmDeal::GetList怎么用?PHP CCrmDeal::GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmDeal
的用法示例。
在下文中一共展示了CCrmDeal::GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if (isset($arCalList['LEAD']) && !empty($arCalList['LEAD'])) {
$dbRes = CCrmLead::GetList(array('TITLE' => 'ASC', 'LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => array_keys($arCalList['LEAD'])));
while ($arRes = $dbRes->Fetch()) {
$arCalList['LEAD'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_SHOW'], array('lead_id' => $arRes['ID'])));
}
}
if (isset($arCalList['CONTACT']) && !empty($arCalList['CONTACT'])) {
$dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => array_keys($arCalList['CONTACT'])));
while ($arRes = $dbRes->Fetch()) {
$arCalList['CONTACT'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['LAST_NAME'] . ' ' . $arRes['NAME'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arRes['ID'])));
}
}
if (isset($arCalList['COMPANY']) && !empty($arCalList['COMPANY'])) {
$dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), array('ID' => array_keys($arCalList['COMPANY'])));
while ($arRes = $dbRes->Fetch()) {
$arCalList['COMPANY'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_COMPANY_SHOW'], array('company_id' => $arRes['ID'])));
}
}
if (isset($arCalList['DEAL']) && !empty($arCalList['DEAL'])) {
$dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), array('ID' => array_keys($arCalList['DEAL'])));
while ($arRes = $dbRes->Fetch()) {
$arCalList['DEAL'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $arRes['ID'])));
}
}
foreach ($arResult['CAL'] as $key => $ar) {
$arResult['CAL'][$key]['ENTITY_TITLE'] = htmlspecialcharsbx($arCalList[$ar['ENTITY_TYPE']][$ar['ENTITY_ID']]['ENTITY_TITLE']);
$arResult['CAL'][$key]['ENTITY_LINK'] = $arCalList[$ar['ENTITY_TYPE']][$ar['ENTITY_ID']]['ENTITY_LINK'];
}
}
$this->IncludeComponentTemplate();
return $arResult['ROWS_COUNT'];
示例2: GetDocumentType
public static function GetDocumentType($documentId)
{
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
switch ($arDocumentID['TYPE']) {
case 'CONTACT':
$dbDocumentList = CCrmContact::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
break;
case 'COMPANY':
$dbDocumentList = CCrmCompany::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
break;
case 'DEAL':
$dbDocumentList = CCrmDeal::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
break;
case 'LEAD':
$dbDocumentList = CCrmLead::GetList(array(), array('ID' => $arDocumentID['ID'], "CHECK_PERMISSIONS" => "N"), array('ID'));
break;
}
$arResult = $dbDocumentList->Fetch();
if (!$arResult) {
throw new Exception(GetMessage('CRM_DOCUMENT_ELEMENT_IS_NOT_FOUND'));
}
return $arDocumentID['TYPE'];
}
示例3: 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();
}
}
示例4: SaveOrderDataDeal
private function SaveOrderDataDeal($arOrder, $contactId = null, $companyId = null)
{
$dealId = 0;
$dealTitle = "";
$dbDeal = CCrmDeal::GetList(array(), array("ORIGINATOR_ID" => $this->externalSaleId, "ORIGIN_ID" => $arOrder["ID"], "CHECK_PERMISSIONS" => "N"));
if ($arDeal = $dbDeal->Fetch()) {
$dealId = $arDeal["ID"];
$dealTitle = $arDeal["TITLE"];
}
$newDeal = $dealId == 0;
if ($this->arExternalSale == null) {
$this->arExternalSale = CCrmExternalSale::GetDefaultSettings($this->externalSaleId);
}
$arFields = array('ORIGINATOR_ID' => $this->externalSaleId, 'ORIGIN_ID' => $arOrder["ID"], 'BEGINDATE' => $arOrder["DATE_INSERT"], 'CURRENCY_ID' => $arOrder["CURRENCY"], 'EXCH_RATE' => $arOrder["CURRENCY_RATE"], 'OPPORTUNITY' => $arOrder["PRICE"]);
// Prevent reset comment if order comment is empty
if (isset($arOrder["COMMENT"]) && $arOrder["COMMENT"] !== "") {
$arFields["COMMENTS"] = $arOrder["COMMENT"];
}
if ($contactId != null && intval($contactId) > 0) {
$arFields["CONTACT_ID"] = $contactId;
}
if ($companyId != null && intval($companyId) > 0) {
$arFields["COMPANY_ID"] = $companyId;
}
static $arStageList = null;
if ($arStageList == null) {
$arStageList = CCrmStatus::GetStatusList('DEAL_STAGE');
}
// Prevent reset stage for existed deals
if ($newDeal && array_key_exists("NEW", $arStageList)) {
$arFields["STAGE_ID"] = "NEW";
}
$arAdditionalInfo = array();
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"];
//.........这里部分代码省略.........
示例5: InstallService
function InstallService($serviceID, $serviceStage)
{
$wizard =& $this->GetWizard();
if (CModule::IncludeModule("iblock")) {
$type = substr($serviceID, 0, -1);
if ($type == "iblockElement") {
$dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID"));
while ($arItem = $dbItem->Fetch()) {
CIBlockElement::Delete($arItem["ID"]);
}
} elseif ($type == "iblockSectionElement") {
$dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID"));
while ($arItem = $dbItem->Fetch()) {
CIBlockElement::Delete($arItem["ID"]);
}
$dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, array("ID"));
while ($arItem = $dbItem->Fetch()) {
CIBlockSection::Delete($arItem["ID"]);
}
} elseif ($serviceID == "iblockDepartmentsElement") {
$dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => "departments"));
while ($arItem = $dbItem->Fetch()) {
if ($arItem["DEPTH_LEVEL"] > 2) {
CIBlockSection::Delete($arItem["ID"]);
}
}
} elseif ($serviceID == "tasks") {
if (CModule::IncludeModule("tasks")) {
$dbItem = CTasks::GetList(array(), array("SITE_ID" => $wizard->GetVar("siteID")));
while ($arItem = $dbItem->Fetch()) {
CTasks::Delete($arItem["ID"]);
}
}
} elseif ($serviceID == "calendar") {
if (CModule::IncludeModule("calendar")) {
$dbItem = CCalendarEvent::GetList();
foreach ($dbItem as $arItem) {
CCalendarEvent::Delete(array("id" => $arItem["ID"]));
}
}
} elseif ($serviceID == "meeting") {
if (CModule::IncludeModule("meeting")) {
$dbItem = CMeeting::GetList(array(), array());
while ($arItem = $dbItem->Fetch()) {
if ($arItem["ID"]) {
CMeeting::Delete($arItem["ID"]);
}
}
}
} elseif ($serviceID == "user") {
if ($serviceStage == "user") {
$dbUser = CUser::GetList($by = "ID", $order = "DESC", array(">ID" => 1));
while ($arUser = $dbUser->Fetch()) {
CUser::Delete($arUser["ID"]);
}
}
} elseif ($serviceID == "crm") {
if ($serviceStage == "crm") {
if (CModule::IncludeModule('crm')) {
$CCrmLead = new CCrmLead();
$resLead = CCrmLead::GetList(array(), array(), array(), false);
while ($rowLead = $resLead->Fetch()) {
$CCrmLead->Delete($rowLead["ID"]);
}
$CCrmContact = new CCrmContact();
$resContact = CCrmContact::GetList(array(), array(), array(), false);
while ($rowContact = $resContact->Fetch()) {
$CCrmContact->Delete($rowContact["ID"]);
}
$CCrmCompany = new CCrmCompany();
$resCompany = CCrmCompany::GetList(array(), array(), array(), false);
while ($rowCompany = $resCompany->Fetch()) {
$CCrmCompany->Delete($rowCompany["ID"]);
}
$CCrmDeal = new CCrmDeal();
$resDeal = CCrmDeal::GetList(array(), array(), array(), false);
while ($rowDeal = $resDeal->Fetch()) {
$CCrmDeal->Delete($rowDeal["ID"]);
}
}
}
} elseif ($serviceID == "cache") {
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_html.php";
if ($serviceStage == "cache1") {
BXClearCache(true);
} elseif ($serviceStage == "cache2") {
$GLOBALS["CACHE_MANAGER"]->CleanAll();
} elseif ($serviceStage == "cache3") {
$GLOBALS["stackCacheManager"]->CleanAll();
} elseif ($serviceStage == "cache4") {
CHTMLPagesCache::CleanAll();
}
COption::SetOptionString("main", "wizard_clear_exec", "Y", false, $wizard->GetVar("siteID"));
}
}
}
示例6: prepareCrmSelectorItem
protected function prepareCrmSelectorItem($ufInfo)
{
/** @global CUser $USER */
global $USER;
$result = false;
$selectorItem = array();
if (!CModule::IncludeModule('crm')) {
return $result;
}
$CCrmPerms = new CCrmPerms($USER->GetID());
$nPermittedEntityTypes = 0;
if ($ufInfo['SETTINGS']['LEAD'] == 'Y' && !$CCrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE, 'READ')) {
$nPermittedEntityTypes++;
}
if ($ufInfo['SETTINGS']['CONTACT'] == 'Y' && !$CCrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE, 'READ')) {
$nPermittedEntityTypes++;
}
if ($ufInfo['SETTINGS']['COMPANY'] == 'Y' && !$CCrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE, 'READ')) {
$nPermittedEntityTypes++;
}
if ($ufInfo['SETTINGS']['DEAL'] == 'Y' && !$CCrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE, 'READ')) {
$nPermittedEntityTypes++;
}
if ($ufInfo['SETTINGS']['QUOTE'] == 'Y' && !$CCrmPerms->HavePerm('QUOTE', BX_CRM_PERM_NONE, 'READ')) {
$nPermittedEntityTypes++;
}
if ($ufInfo['SETTINGS']['PRODUCT'] == 'Y' && $CCrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ')) {
$nPermittedEntityTypes++;
}
$usePrefix = true;
/*$nPermittedEntityTypes > 1;*/
// last 50 entity
$entityTypes = array();
$elements = array();
$arSettings = $ufInfo['SETTINGS'];
if (isset($arSettings['LEAD']) && $arSettings['LEAD'] == 'Y') {
$entityTypes[] = 'lead';
$arSelect = array('ID', 'TITLE', 'FULL_NAME', 'STATUS_ID');
$obRes = CCrmLead::GetList(array('ID' => 'DESC'), array(), $arSelect, 50);
$arFiles = array();
while ($arRes = $obRes->Fetch()) {
$arRes['SID'] = $usePrefix ? 'L_' . $arRes['ID'] : $arRes['ID'];
$elements[] = array('title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => $arRes['FULL_NAME'], 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $arRes['ID'])), 'type' => 'lead', 'selected' => 'N');
}
}
if (isset($arSettings['CONTACT']) && $arSettings['CONTACT'] == 'Y') {
$entityTypes[] = 'contact';
$arSelect = array('ID', 'FULL_NAME', 'COMPANY_TITLE', 'PHOTO');
$obRes = CCrmContact::GetList(array('ID' => 'DESC'), array(), $arSelect, 50);
while ($arRes = $obRes->Fetch()) {
$strImg = '';
if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
if ($arFile = CFile::GetFileArray($arRes['PHOTO'])) {
$arImg = CFile::ResizeImageGet($arFile, array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
if (is_array($arImg) && isset($arImg['src'])) {
$strImg = CHTTP::URN2URI($arImg['src'], '', true);
}
}
}
$arRes['SID'] = $usePrefix ? 'C_' . $arRes['ID'] : $arRes['ID'];
$elements[] = array('title' => str_replace(array(';', ','), ' ', $arRes['FULL_NAME']), 'desc' => empty($arRes['COMPANY_TITLE']) ? '' : $arRes['COMPANY_TITLE'], 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'image' => $strImg, 'type' => 'contact', 'selected' => 'N');
}
}
if (isset($arSettings['COMPANY']) && $arSettings['COMPANY'] == 'Y') {
$entityTypes[] = 'company';
$arCompanyTypeList = CCrmStatus::GetStatusListEx('COMPANY_TYPE');
$arCompanyIndustryList = CCrmStatus::GetStatusListEx('INDUSTRY');
$arSelect = array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO');
$obRes = CCrmCompany::GetList(array('ID' => 'DESC'), array(), $arSelect, 50);
$arFiles = array();
while ($arRes = $obRes->Fetch()) {
$strImg = '';
if (!empty($arRes['LOGO']) && !isset($arFiles[$arRes['LOGO']])) {
if ($arFile = CFile::GetFileArray($arRes['LOGO'])) {
$arImg = CFile::ResizeImageGet($arFile, array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
if (is_array($arImg) && isset($arImg['src'])) {
$strImg = CHTTP::URN2URI($arImg['src'], '', true);
}
}
$arFiles[$arRes['LOGO']] = $strImg;
}
$arRes['SID'] = $usePrefix ? 'CO_' . $arRes['ID'] : $arRes['ID'];
$arDesc = array();
if (isset($arCompanyTypeList[$arRes['COMPANY_TYPE']])) {
$arDesc[] = $arCompanyTypeList[$arRes['COMPANY_TYPE']];
}
if (isset($arCompanyIndustryList[$arRes['INDUSTRY']])) {
$arDesc[] = $arCompanyIndustryList[$arRes['INDUSTRY']];
}
$elements[] = array('title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => implode(', ', $arDesc), 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $arRes['ID'])), 'image' => $strImg, 'type' => 'company', 'selected' => 'N');
}
}
if (isset($arSettings['DEAL']) && $arSettings['DEAL'] == 'Y') {
$entityTypes[] = 'deal';
$arDealStageList = CCrmStatus::GetStatusListEx('DEAL_STAGE');
$arSelect = array('ID', 'TITLE', 'STAGE_ID', 'COMPANY_TITLE', 'CONTACT_FULL_NAME');
$obRes = CCrmDeal::GetList(array('ID' => 'DESC'), array(), $arSelect, 50);
while ($arRes = $obRes->Fetch()) {
$arRes['SID'] = $usePrefix ? 'D_' . $arRes['ID'] : $arRes['ID'];
$clientTitle = !empty($arRes['COMPANY_TITLE']) ? $arRes['COMPANY_TITLE'] : '';
//.........这里部分代码省略.........
示例7: foreach
if (COption::GetOptionString('crm', '~crm_11_0_6_convertion', 'N') !== 'Y') {
$baseCurrencyID = "USD";
$rsLang = CLanguage::GetByID("ru");
if ($arLang = $rsLang->Fetch()) {
$baseCurrencyID = "RUB";
} else {
$rsLang = CLanguage::GetByID("de");
if ($arLang = $rsLang->Fetch()) {
$baseCurrencyID = "EUR";
}
}
$arProducts = CCrmStatus::GetStatusList('PRODUCT', true);
foreach ($arProducts as $prodCode => $prodName) {
CCrmProduct::Add(array('NAME' => $prodName, 'ACTIVE' => 'Y', 'CURRENCY_ID' => $baseCurrencyID, 'PRICE' => 1, 'ORIGIN_ID' => 'CRM_PROD_' . $prodCode, 'ORIGINATOR_ID' => 'CRM_PRODUCT_REFERENCE'));
}
$rsDeals = CCrmDeal::GetList(array('ID' => 'ASC'), array("CHECK_PERMISSIONS" => "N"), array('ID', 'PRODUCT_ID', 'OPPORTUNITY', 'CURRENCY_ID'));
while ($arDeal = $rsDeals->Fetch()) {
$ID = isset($arDeal['ID']) ? intval($arDeal['ID']) : 0;
if ($ID <= 0) {
continue;
}
$productID = isset($arDeal['PRODUCT_ID']) ? $arDeal['PRODUCT_ID'] : '';
if (isset($productID[0])) {
$arProductRows = CCrmDeal::LoadProductRows($ID);
if (count($arProductRows) > 0) {
// Already converted
continue;
}
$arProduct = CCrmProduct::GetByOriginID('CRM_PROD_' . $productID);
if (!is_array($arProduct)) {
continue;
示例8: ListAddEnumFieldsValue
//.........这里部分代码省略.........
}
}
$arReplaceValue[$ID][$FIELD_NAME] = '';
} else {
if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'file' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'employee' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'iblock_element' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'enumeration' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'iblock_section') {
$bSecondLoop = true;
$arVal = $arValue[$ID][$FIELD_NAME];
$arReplaceValue[$ID][$FIELD_NAME] = '';
if (!is_array($arVal)) {
$arVal = array($arVal);
}
foreach ($arVal as $value) {
$arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']]['FIELD'][$ID][$FIELD_NAME][$value] = $value;
$arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']]['ID'][] = $value;
}
} else {
if ($arUserField['MULTIPLE'] == 'Y' && is_array($arValue[$ID][$FIELD_NAME])) {
array_walk($arValue[$ID][$FIELD_NAME], create_function('&$v', '$v = htmlspecialcharsbx($v);'));
$arReplaceValue[$ID][$FIELD_NAME] = implode($delimiter, $arValue[$ID][$FIELD_NAME]);
}
}
}
}
}
}
unset($arUserField);
// The second loop for special field
if ($bSecondLoop) {
$arValueReplace = array();
$arList = array();
foreach ($arValuePrepare as $KEY => $VALUE) {
// collect multi data
if ($KEY == 'iblock_section') {
$dbRes = CIBlockSection::GetList(array('left_margin' => 'asc'), array('ID' => $VALUE['ID']), false);
while ($arRes = $dbRes->Fetch()) {
$arList[$KEY][$arRes['ID']] = $arRes;
}
} elseif ($KEY == 'file') {
$dbRes = CFile::GetList(array(), array('@ID' => implode(',', $VALUE['ID'])));
while ($arRes = $dbRes->Fetch()) {
$arList[$KEY][$arRes['ID']] = $arRes;
}
} elseif ($KEY == 'iblock_element') {
$dbRes = CIBlockElement::GetList(array('SORT' => 'DESC', 'NAME' => 'ASC'), array('ID' => $VALUE['ID']), false);
while ($arRes = $dbRes->Fetch()) {
$arList[$KEY][$arRes['ID']] = $arRes;
}
} elseif ($KEY == 'employee') {
$dbRes = CUser::GetList($by = 'last_name', $order = 'asc', array('ID' => implode('|', $VALUE['ID'])));
while ($arRes = $dbRes->Fetch()) {
$arList[$KEY][$arRes['ID']] = $arRes;
}
} elseif ($KEY == 'enumeration') {
foreach ($VALUE['ID'] as $___value) {
$rsEnum = CUserFieldEnum::GetList(array(), array('ID' => $___value));
while ($arRes = $rsEnum->Fetch()) {
$arList[$KEY][$arRes['ID']] = $arRes;
}
}
} elseif ($KEY == 'crm') {
if (isset($VALUE['LEAD']) && !empty($VALUE['LEAD'])) {
$dbRes = CCrmLead::GetList(array('TITLE' => 'ASC', 'LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $VALUE['LEAD']));
while ($arRes = $dbRes->Fetch()) {
$arList[$KEY]['LEAD'][$arRes['ID']] = $arRes;
}
}
示例9: array
}
}
if (isset($arEntityList['CONTACT']) && !empty($arEntityList['CONTACT'])) {
$dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $arEntityList['CONTACT']));
while ($arRes = $dbRes->Fetch()) {
$arEntityList['CONTACT'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['LAST_NAME'] . ' ' . $arRes['NAME'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arRes['ID'])));
}
}
if (isset($arEntityList['COMPANY']) && !empty($arEntityList['COMPANY'])) {
$dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), array('ID' => $arEntityList['COMPANY']));
while ($arRes = $dbRes->Fetch()) {
$arEntityList['COMPANY'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_COMPANY_SHOW'], array('company_id' => $arRes['ID'])));
}
}
if (isset($arEntityList['DEAL']) && !empty($arEntityList['DEAL'])) {
$dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), array('ID' => $arEntityList['DEAL']));
while ($arRes = $dbRes->Fetch()) {
$arEntityList['DEAL'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $arRes['ID'])));
}
}
if (isset($arEntityList['QUOTE']) && !empty($arEntityList['QUOTE'])) {
$dbRes = CCrmQuote::GetList(array('TITLE' => 'ASC'), array('ID' => $arEntityList['QUOTE']));
while ($arRes = $dbRes->Fetch()) {
$arEntityList['QUOTE'][$arRes['ID']] = array('ENTITY_TITLE' => empty($arRes['TITLE']) ? $arRes['QUOTE_NUMBER'] : $arRes['QUOTE_NUMBER'] . ' - ' . $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_QUOTE_SHOW'], array('quote_id' => $arRes['ID'])));
}
}
foreach ($arResult['EVENT'] as $key => $ar) {
$arResult['EVENT'][$key]['ENTITY_TITLE'] = htmlspecialcharsbx($arEntityList[$ar['ENTITY_TYPE']][$ar['ENTITY_ID']]['ENTITY_TITLE']);
$arResult['EVENT'][$key]['ENTITY_LINK'] = $arEntityList[$ar['ENTITY_TYPE']][$ar['ENTITY_ID']]['ENTITY_LINK'];
}
}
示例10: trim
if (is_numeric($search)) {
$arFilter['ID'] = (int) $search;
} else {
if (preg_match('/(.*)\\[(\\d+?)\\]/i' . BX_UTF_PCRE_MODIFIER, $search, $arMatches)) {
$arFilter['ID'] = (int) $arMatches[2];
$arFilter['%TITLE'] = trim($arMatches[1]);
$arFilter['LOGIC'] = 'OR';
} else {
$arFilter['%TITLE'] = $search;
}
}
$arDealStageList = CCrmStatus::GetStatusListEx('DEAL_STAGE');
$arSelect = array('ID', 'TITLE', 'STAGE_ID', 'COMPANY_TITLE', 'CONTACT_FULL_NAME');
$arOrder = array('TITLE' => 'ASC');
$arData = array();
$obRes = CCrmDeal::GetList($arOrder, $arFilter, $arSelect, $nPageTop);
$arFiles = array();
while ($arRes = $obRes->Fetch()) {
$clientTitle = !empty($arRes['COMPANY_TITLE']) ? $arRes['COMPANY_TITLE'] : '';
$clientTitle .= ($clientTitle !== '' && !empty($arRes['CONTACT_FULL_NAME']) ? ', ' : '') . $arRes['CONTACT_FULL_NAME'];
$arData[] = array('id' => $multi ? 'D_' . $arRes['ID'] : $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $arRes['ID'])), 'title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => $clientTitle, 'type' => 'deal');
}
Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo CUtil::PhpToJsObject($arData);
die;
} elseif ($action === 'SAVE_PROGRESS') {
$ID = isset($_REQUEST['ID']) ? intval($_REQUEST['ID']) : 0;
$typeName = isset($_REQUEST['TYPE']) ? $_REQUEST['TYPE'] : '';
$stageID = isset($_REQUEST['VALUE']) ? $_REQUEST['VALUE'] : '';
$targetTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Deal);
if ($stageID === '' || $ID <= 0 || $typeName !== $targetTypeName) {
示例11: TryInternalizeCrmEntityID
private static function TryInternalizeCrmEntityID($type, $value, &$ID)
{
if (preg_match('/^\\[([A-Z]+)\\]/i', $value, $m) > 0) {
$valueType = CCrmOwnerType::Undefined;
$prefix = strtoupper($m[1]);
if ($prefix === 'L') {
$valueType = CCrmOwnerType::Lead;
} elseif ($prefix === 'C') {
$valueType = CCrmOwnerType::Contact;
} elseif ($prefix === 'CO') {
$valueType = CCrmOwnerType::Company;
} elseif ($prefix === 'D') {
$valueType = CCrmOwnerType::Deal;
}
if ($valueType !== CCrmOwnerType::Undefined && $valueType !== $type) {
return false;
}
$value = substr($value, strlen($m[0]));
}
// 1. Try to interpret data as entity ID
// 2. Try to interpret data as entity name
if ($type === CCrmOwnerType::Lead) {
if (is_numeric($value)) {
$arEntity = CCrmLead::GetByID($value);
if ($arEntity) {
$ID = intval($arEntity['ID']);
return true;
}
}
$rsEntities = CCrmLead::GetListEx(array(), array('=TITLE' => $value), false, false, array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
} elseif ($type === CCrmOwnerType::Contact) {
if (is_numeric($value)) {
$arEntity = CCrmContact::GetByID($value);
if ($arEntity) {
$ID = intval($arEntity['ID']);
return true;
}
}
// Try to interpret value as FULL_NAME
$rsEntities = CCrmContact::GetListEx(array(), array('=FULL_NAME' => $value), false, false, array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
if (preg_match('/\\s*([^\\s]+)\\s+([^\\s]+)\\s*/', $value, $match) > 0) {
// Try to interpret value as '#NAME# #LAST_NAME#'
$rsEntities = CCrmContact::GetListEx(array(), array('=NAME' => $match[1], '=LAST_NAME' => $match[2]), false, false, array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
// Try to interpret value as '#LAST_NAME# #NAME#'
$rsEntities = CCrmContact::GetListEx(array(), array('=LAST_NAME' => $match[1], '=NAME' => $match[2]), false, false, array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
} else {
// Try to interpret value as '#LAST_NAME#'
$rsEntities = CCrmContact::GetListEx(array(), array('=LAST_NAME' => $value), false, false, array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
}
} elseif ($type === CCrmOwnerType::Company) {
if (is_numeric($value)) {
$arEntity = CCrmCompany::GetByID($value);
if ($arEntity) {
$ID = intval($arEntity['ID']);
return true;
}
}
$rsEntities = CCrmCompany::GetList(array(), array('=TITLE' => $value), array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
} elseif ($type === CCrmOwnerType::Deal) {
if (is_numeric($value)) {
$arEntity = CCrmDeal::GetByID($value);
if ($arEntity) {
$ID = intval($arEntity['ID']);
return true;
}
}
$rsEntities = CCrmDeal::GetList(array(), array('=TITLE' => $value), array('ID'));
while ($arEntity = $rsEntities->Fetch()) {
$ID = intval($arEntity['ID']);
return true;
}
}
return false;
}
示例12: CompareFields
public static function CompareFields($arFieldsOrig, $arFieldsModif, $bCheckPerms = true)
{
$arMsg = array();
if (array_key_exists('QUOTE_NUMBER', $arFieldsModif)) {
$origQuoteNumber = isset($arFieldsOrig['QUOTE_NUMBER']) ? $arFieldsOrig['QUOTE_NUMBER'] : '';
$modifQuoteNumber = isset($arFieldsModif['QUOTE_NUMBER']) ? $arFieldsModif['QUOTE_NUMBER'] : '';
if ($origQuoteNumber != $modifQuoteNumber) {
$arMsg[] = array('ENTITY_FIELD' => 'QUOTE_NUMBER', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_QUOTE_NUMBER'), 'EVENT_TEXT_1' => !empty($origQuoteNumber) ? $origQuoteNumber : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifQuoteNumber) ? $modifQuoteNumber : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
}
unset($origQuoteNumber, $modifQuoteNumber);
}
if (array_key_exists('TITLE', $arFieldsModif)) {
$origTitle = isset($arFieldsOrig['TITLE']) ? $arFieldsOrig['TITLE'] : '';
$modifTitle = isset($arFieldsModif['TITLE']) ? $arFieldsModif['TITLE'] : '';
if ($origTitle != $modifTitle) {
$arMsg[] = array('ENTITY_FIELD' => 'TITLE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TITLE'), 'EVENT_TEXT_1' => !empty($origTitle) ? $origTitle : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifTitle) ? $modifTitle : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
}
unset($origTitle, $modifTitle);
}
if (array_key_exists('LEAD_ID', $arFieldsModif)) {
$origLeadId = isset($arFieldsOrig['LEAD_ID']) ? intval($arFieldsOrig['LEAD_ID']) : 0;
$modifLeadId = isset($arFieldsModif['LEAD_ID']) ? intval($arFieldsModif['LEAD_ID']) : 0;
if ($origLeadId != $modifLeadId) {
$arLead = array();
$arFilterTmp = array('@ID' => array($origLeadId, $modifLeadId));
if (!$bCheckPerms) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
$dbRes = CCrmLead::GetListEx(array('TITLE' => 'ASC'), $arFilterTmp);
while ($arRes = $dbRes->Fetch()) {
$arLead[$arRes['ID']] = $arRes['TITLE'];
}
$arMsg[] = array('ENTITY_FIELD' => 'LEAD_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_LEAD_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arLead, $origLeadId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arLead, $modifLeadId));
}
unset($origLeadId, $modifLeadId);
}
if (array_key_exists('DEAL_ID', $arFieldsModif)) {
$origDealId = isset($arFieldsOrig['DEAL_ID']) ? intval($arFieldsOrig['DEAL_ID']) : 0;
$modifDealId = isset($arFieldsModif['DEAL_ID']) ? intval($arFieldsModif['DEAL_ID']) : 0;
if ($origDealId != $modifDealId) {
$arDeal = array();
$arFilterTmp = array('ID' => array($origDealId, $modifDealId));
if (!$bCheckPerms) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
$dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), $arFilterTmp);
while ($arRes = $dbRes->Fetch()) {
$arDeal[$arRes['ID']] = $arRes['TITLE'];
}
$arMsg[] = array('ENTITY_FIELD' => 'DEAL_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_DEAL_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arDeal, $origDealId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arDeal, $modifDealId));
}
unset($origDealId, $modifDealId);
}
if (array_key_exists('COMPANY_ID', $arFieldsModif)) {
$origCompanyId = isset($arFieldsOrig['COMPANY_ID']) ? intval($arFieldsOrig['COMPANY_ID']) : 0;
$modifCompanyId = isset($arFieldsModif['COMPANY_ID']) ? intval($arFieldsModif['COMPANY_ID']) : 0;
if ($origCompanyId != $modifCompanyId) {
$arCompany = array();
$arFilterTmp = array('ID' => array($origCompanyId, $modifCompanyId));
if (!$bCheckPerms) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
$dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), $arFilterTmp);
while ($arRes = $dbRes->Fetch()) {
$arCompany[$arRes['ID']] = $arRes['TITLE'];
}
$arMsg[] = array('ENTITY_FIELD' => 'COMPANY_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_COMPANY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arCompany, $origCompanyId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arCompany, $modifCompanyId));
}
unset($origCompanyId, $modifCompanyId);
}
if (array_key_exists('CONTACT_ID', $arFieldsModif)) {
$origContactId = isset($arFieldsOrig['CONTACT_ID']) ? intval($arFieldsOrig['CONTACT_ID']) : 0;
$modifContactId = isset($arFieldsModif['CONTACT_ID']) ? intval($arFieldsModif['CONTACT_ID']) : 0;
if ($origContactId != $modifContactId) {
$arContact = array();
$arFilterTmp = array('@ID' => array($origContactId, $modifContactId));
if (!$bCheckPerms) {
$arFilterTmp["CHECK_PERMISSIONS"] = "N";
}
$dbRes = CCrmContact::GetListEx(array(), $arFilterTmp);
while ($arRes = $dbRes->Fetch()) {
$arContact[$arRes['ID']] = CCrmContact::PrepareFormattedName($arRes);
}
$arMsg[] = array('ENTITY_FIELD' => 'CONTACT_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CONTACT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arContact, $origContactId), 'EVENT_TEXT_2' => CrmCompareFieldsList($arContact, $modifContactId));
}
unset($origContactId, $modifContactId);
}
if (array_key_exists('ASSIGNED_BY_ID', $arFieldsModif)) {
$origAssignedById = isset($arFieldsOrig['ASSIGNED_BY_ID']) ? intval($arFieldsOrig['ASSIGNED_BY_ID']) : 0;
$modifAssignedById = isset($arFieldsModif['ASSIGNED_BY_ID']) ? intval($arFieldsModif['ASSIGNED_BY_ID']) : 0;
if ($origAssignedById != $modifAssignedById) {
$arUser = array();
$dbUsers = CUser::GetList($sort_by = 'last_name', $sort_dir = 'asc', array('ID' => implode('|', array(intval($origAssignedById), intval($modifAssignedById)))), array('FIELDS' => array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', 'TITLE', 'EMAIL')));
while ($arRes = $dbUsers->Fetch()) {
$arUser[$arRes['ID']] = CUser::FormatName(CSite::GetNameFormat(false), $arRes);
}
$arMsg[] = array('ENTITY_FIELD' => 'ASSIGNED_BY_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_ASSIGNED_BY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arUser, $origAssignedById), 'EVENT_TEXT_2' => CrmCompareFieldsList($arUser, $modifAssignedById));
}
unset($origAssignedById, $modifAssignedById);
}
//.........这里部分代码省略.........
示例13: PrepareEntityInfo
public static function PrepareEntityInfo($entityTypeName, $entityID, $options = array())
{
$entityTypeName = strtoupper(strval($entityTypeName));
$entityID = intval($entityID);
if (!is_array($options)) {
$options = array();
}
$result = array('TITLE' => "{$entityTypeName}_{$entityID}", 'URL' => '');
if ($entityTypeName === '' || $entityID <= 0) {
return $result;
}
if ($entityTypeName === 'CONTACT') {
$contactTypes = CCrmStatus::GetStatusList('CONTACT_TYPE');
$obRes = CCrmContact::GetList(array(), array('=ID' => $entityID), array('NAME', 'SECOND_NAME', 'LAST_NAME', 'TYPE_ID'));
if ($arRes = $obRes->Fetch()) {
$nameTemplate = isset($options['NAME_TEMPLATE']) ? $options['NAME_TEMPLATE'] : '';
if ($nameTemplate === '') {
$nameTemplate = \Bitrix\Crm\Format\PersonNameFormatter::getFormat();
}
$result['TITLE'] = CUser::FormatName($nameTemplate, array('LOGIN' => '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : ''), false, false);
$result['URL'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $entityID));
// advanced info
$advancedInfo = array();
if (isset($arRes['TYPE_ID']) && $arRes['TYPE_ID'] != '' && isset($contactTypes[$arRes['TYPE_ID']])) {
$advancedInfo['CONTACT_TYPE'] = array('ID' => $arRes['TYPE_ID'], 'NAME' => $contactTypes[$arRes['TYPE_ID']]);
}
if (!empty($advancedInfo)) {
$result['ADVANCED_INFO'] = $advancedInfo;
}
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $entityID));
while ($arRes = $obRes->Fetch()) {
if ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL') {
if (!is_array($result['ADVANCED_INFO'])) {
$result['ADVANCED_INFO'] = array();
}
if (!is_array($result['ADVANCED_INFO']['MULTY_FIELDS'])) {
$result['ADVANCED_INFO']['MULTY_FIELDS'] = array();
}
$result['ADVANCED_INFO']['MULTY_FIELDS'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
}
}
}
} elseif ($entityTypeName === 'COMPANY') {
$obRes = CCrmCompany::GetList(array(), array('=ID' => $entityID), array('TITLE'));
if ($arRes = $obRes->Fetch()) {
$result['TITLE'] = $arRes['TITLE'];
$result['URL'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $entityID));
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => $entityID));
while ($arRes = $obRes->Fetch()) {
if ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL') {
if (!is_array($result['ADVANCED_INFO'])) {
$result['ADVANCED_INFO'] = array();
}
if (!is_array($result['ADVANCED_INFO']['MULTY_FIELDS'])) {
$result['ADVANCED_INFO']['MULTY_FIELDS'] = array();
}
$result['ADVANCED_INFO']['MULTY_FIELDS'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
}
}
}
} elseif ($entityTypeName === 'LEAD') {
$obRes = CCrmLead::GetList(array(), array('=ID' => $entityID), array('TITLE'));
if ($arRes = $obRes->Fetch()) {
$result['TITLE'] = $arRes['TITLE'];
$result['URL'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $entityID));
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'LEAD', 'ELEMENT_ID' => $entityID));
while ($arRes = $obRes->Fetch()) {
if ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL') {
if (!is_array($result['ADVANCED_INFO'])) {
$result['ADVANCED_INFO'] = array();
}
if (!is_array($result['ADVANCED_INFO']['MULTY_FIELDS'])) {
$result['ADVANCED_INFO']['MULTY_FIELDS'] = array();
}
$result['ADVANCED_INFO']['MULTY_FIELDS'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
}
}
}
} elseif ($entityTypeName === 'DEAL') {
$obRes = CCrmDeal::GetList(array(), array('=ID' => $entityID), array('TITLE'));
if ($arRes = $obRes->Fetch()) {
$result['TITLE'] = $arRes['TITLE'];
$result['URL'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $entityID));
}
} elseif ($entityTypeName === 'QUOTE') {
$obRes = CCrmQuote::GetList(array(), array('=ID' => $entityID), false, false, array('QUOTE_NUMBER', 'TITLE'));
if ($arRes = $obRes->Fetch()) {
$result['TITLE'] = empty($arRes['TITLE']) ? $arRes['QUOTE_NUMBER'] : $arRes['QUOTE_NUMBER'] . ' - ' . $arRes['TITLE'];
$result['URL'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_quote_show'), array('quote_id' => $entityID));
}
}
return $result;
}
示例14: CCrmPerms
global $APPLICATION;
$CCrmPerms = new CCrmPerms($USER->GetID());
if (!$USER->IsAuthorized() || $CCrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE)) {
return;
}
$arResult = array();
$_GET['USER_ID'] = preg_replace('/^(CONTACT|COMPANY|LEAD|DEAL)_/i' . BX_UTF_PCRE_MODIFIER, '', $_GET['USER_ID']);
$iDealId = (int) $_GET['USER_ID'];
if ($iDealId > 0) {
__IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
$arParams['PATH_TO_DEAL_SHOW'] = CrmCheckPath('PATH_TO_DEAL_SHOW', $arParams['PATH_TO_DEAL_SHOW'], $APPLICATION->GetCurPage() . '?deal_id=#deal_id#&show');
$arParams['PATH_TO_DEAL_EDIT'] = CrmCheckPath('PATH_TO_DEAL_EDIT', $arParams['PATH_TO_DEAL_EDIT'], $APPLICATION->GetCurPage() . '?deal_id=#deal_id#&edit');
$arParams['PATH_TO_CONTACT_SHOW'] = CrmCheckPath('PATH_TO_CONTACT_SHOW', $arParams['PATH_TO_CONTACT_SHOW'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&show');
$arParams['PATH_TO_COMPANY_SHOW'] = CrmCheckPath('PATH_TO_COMPANY_SHOW', $arParams['PATH_TO_COMPANY_SHOW'], $APPLICATION->GetCurPage() . '?company_id=#company_id#&show');
$arResult['STAGE_LIST'] = CCrmStatus::GetStatusListEx('DEAL_STAGE');
$obRes = CCrmDeal::GetList(array(), array('ID' => $iDealId));
$arDeal = $obRes->Fetch();
if ($arDeal == false) {
return;
}
$res = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'DEAL', 'ELEMENT_ID' => $iDealId));
while ($ar = $res->Fetch()) {
if (empty($arDeal[$ar['COMPLEX_ID']])) {
$arDeal[$ar['COMPLEX_ID']] = CCrmFieldMulti::GetTemplateByComplex($ar['COMPLEX_ID'], $ar['VALUE']);
}
}
$arDeal['PATH_TO_DEAL_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $iDealId));
$arDeal['PATH_TO_DEAL_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_EDIT'], array('deal_id' => $iDealId));
$arDeal['PATH_TO_CONTACT_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arDeal['CONTACT_ID']));
$arDeal['PATH_TO_COMPANY_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_COMPANY_SHOW'], array('company_id' => $arDeal['COMPANY_ID']));
$arDeal['CONTACT_NAME'] = CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('NAME' => $arDeal['NAME'], 'LAST_NAME' => $arDeal['LAST_NAME'], 'SECOND_NAME' => $arDeal['SECOND_NAME']), true, false);
示例15: trim
}
$arParams['RESULT_TAB'] = trim($arParams['RESULT_TAB']);
$arResult['FORM_TYPE'] = ToUpper($arParams['FORM_TYPE']);
if (!in_array($arResult['FORM_TYPE'], array('LIST', 'SHOW', 'EDIT'))) {
$arResult['FORM_TYPE'] = 'LIST';
}
$arResult['ENTITY_TYPE'] = ToUpper($arParams['ENTITY_TYPE']);
$arResult['ENTITY_ID'] = $arParams['ENTITY_ID'];
$arResult['ENTITY_ID'] = is_array($arResult['ENTITY_ID']) ? $arResult['ENTITY_ID'] : array($arResult['ENTITY_ID']);
$arFilter = array('ID' => $arResult['ENTITY_ID']);
switch ($arResult['ENTITY_TYPE']) {
case 'CONTACT':
$obRes = CCrmContact::GetList(array('ID' => 'ASC'), $arFilter, array('ID', 'ASSIGNED_BY_ID'));
break;
case 'DEAL':
$obRes = CCrmDeal::GetList(array('ID' => 'ASC'), $arFilter, array('ID', 'ASSIGNED_BY_ID'));
break;
case 'COMPANY':
$obRes = CCrmCompany::GetList(array('ID' => 'ASC'), $arFilter, array('ID', 'ASSIGNED_BY_ID'));
break;
default:
case 'LEAD':
$obRes = CCrmLead::GetList(array('ID' => 'ASC'), $arFilter, array('ID', 'ASSIGNED_BY_ID'));
$arResult['ENTITY_TYPE'] = 'LEAD';
break;
}
$arID = array();
while ($arRow = $obRes->Fetch()) {
$arID[$arRow['ID']] = $arRow['ASSIGNED_BY_ID'];
}
if (empty($arID)) {