コード例 #1
9
ファイル: crm_document.php プロジェクト: mrdeadmouse/u136006
 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'];
 }
コード例 #2
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
    $matches = array();
    if (preg_match('/^\\[(\\d+?)]/i', $search, $matches)) {
        $matches[1] = intval($matches[1]);
        if ($matches[1] > 0) {
            $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $matches[1]));
            if ($arRes = $dbRes->Fetch()) {
                $arData = array(array('ID' => $arRes['ID'], 'NAME' => str_replace(array(';', ','), ' ', (isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] . ' ' : '') . $arRes['NAME']), 'READY' => 'Y'));
                Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
                echo CUtil::PhpToJsObject($arData);
                die;
            }
        }
    }
    $arData = array();
    $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('FULL_NAME' => trim($search)));
    while ($arRes = $dbRes->Fetch()) {
        $arData[] = array('ID' => $arRes['ID'], 'NAME' => str_replace(array(';', ','), ' ', (isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] . ' ' : '') . $arRes['NAME']), 'READY' => 'Y');
    }
    if (empty($arData)) {
        $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => intval($search)));
        if ($arRes = $dbRes->Fetch()) {
            $arData = array(array('ID' => $arRes['ID'], 'NAME' => str_replace(array(';', ','), ' ', (isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] . ' ' : '') . $arRes['NAME']), 'READY' => 'Y'));
            Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
            echo CUtil::PhpToJsObject($arData);
            die;
        }
    }
    Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
    echo CUtil::PhpToJsObject($arData);
    die;
}
コード例 #3
0
ファイル: list.ajax.php プロジェクト: mrdeadmouse/u136006
 } else {
     if (preg_match('/(.*)\\[(\\d+?)\\]/i' . BX_UTF_PCRE_MODIFIER, $search, $arMatches)) {
         $arFilter['ID'] = (int) $arMatches[2];
         $arFilter['%FULL_NAME'] = trim($arMatches[1]);
         $arFilter['LOGIC'] = 'OR';
     } else {
         $arFilter['%FULL_NAME'] = trim($search);
         $arFilter['%COMPANY_TITLE'] = trim($search);
         $arFilter['LOGIC'] = 'OR';
     }
 }
 $arContactTypeList = CCrmStatus::GetStatusListEx('CONTACT_TYPE');
 $arSelect = array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'COMPANY_TITLE', 'PHOTO', 'TYPE_ID');
 $arOrder = array('LAST_NAME' => 'ASC', 'NAME' => 'ASC');
 $arData = array();
 $obRes = CCrmContact::GetList($arOrder, $arFilter, $arSelect, $nPageTop);
 $arFiles = array();
 $i = 0;
 $contactIndex = array();
 $contactTypes = CCrmStatus::GetStatusList('CONTACT_TYPE');
 while ($arRes = $obRes->Fetch()) {
     $photoID = intval($arRes['PHOTO']);
     if ($photoID > 0 && !isset($arFiles[$photoID])) {
         $arFiles[$photoID] = CFile::ResizeImageGet($photoID, array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
     }
     // advanced info
     $advancedInfo = array();
     if (isset($arRes['TYPE_ID']) && $arRes['TYPE_ID'] != '' && isset($contactTypes[$arRes['TYPE_ID']])) {
         $advancedInfo['contactType'] = array('id' => $arRes['TYPE_ID'], 'name' => $contactTypes[$arRes['TYPE_ID']]);
     }
     $arData[$i] = array('id' => $multi ? 'C_' . $arRes['ID'] : $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'title' => CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : ''), false, false), 'desc' => empty($arRes['COMPANY_TITLE']) ? "" : $arRes['COMPANY_TITLE'], 'image' => isset($arFiles[$photoID]['src']) ? $arFiles[$photoID]['src'] : '', 'type' => 'contact');
コード例 #4
0
ファイル: crm_search.php プロジェクト: mrdeadmouse/u136006
 public static function UpdateSearch($arFilter, $ENTITY_TYPE, $bOverWrite = false)
 {
     if (!CModule::IncludeModule('search')) {
         return false;
     }
     $limit = 1000;
     switch ($ENTITY_TYPE) {
         case 'CONTACT':
             $obRes = CCrmContact::GetList(array('ID' => 'ASC'), $arFilter, array(), $limit);
             $sTitleID = 'FULL_NAME';
             break;
         case 'DEAL':
             $obRes = CCrmDeal::GetList(array('ID' => 'ASC'), $arFilter, array(), $limit);
             $sTitleID = 'TITLE';
             break;
         case 'INVOICE':
             $obRes = CCrmInvoice::GetList(array('ID' => 'DESC'), $arFilter, false, array('nTopCount' => $limit), array('*'));
             $sTitleID = 'ORDER_TOPIC';
             break;
         case 'QUOTE':
             $obRes = CCrmQuote::GetList(array('ID' => 'ASC'), $arFilter, false, array('nTopCount' => intval($limit)), array());
             $sTitleID = 'TITLE';
             break;
         case 'COMPANY':
             $obRes = CCrmCompany::GetList(array('ID' => 'ASC'), $arFilter, array(), $limit);
             $sTitleID = 'TITLE';
             break;
         default:
         case 'LEAD':
             $obRes = CCrmLead::GetList(array('ID' => 'ASC'), $arFilter, array(), $limit);
             $sTitleID = 'TITLE';
             $ENTITY_TYPE = 'LEAD';
             break;
     }
     if (!isset(self::$arMess[$ENTITY_TYPE])) {
         self::$arMess[$ENTITY_TYPE] = __IncludeLang($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/components/bitrix/crm.' . strtolower($ENTITY_TYPE) . '.show/lang/' . LANGUAGE_ID . '/component.php', true);
     }
     $arAllResult = array();
     $qty = 0;
     $lastItemID = '';
     if (is_object($obRes)) {
         while (($arRow = $obRes->Fetch()) !== false) {
             $elementID = $arRow['ID'];
             $lastItemID = $ENTITY_TYPE . '.' . $elementID;
             if ($ENTITY_TYPE === 'INVOICE') {
                 $arResult = CCrmInvoice::BuildSearchCard($arRow, self::$bReIndex);
             } elseif ($ENTITY_TYPE === 'QUOTE') {
                 $arResult = CCrmQuote::BuildSearchCard($arRow, self::$bReIndex);
             } else {
                 $multiFields = array();
                 if ($ENTITY_TYPE === 'CONTACT' || $ENTITY_TYPE === 'COMPANY' || $ENTITY_TYPE === 'LEAD') {
                     $obMultiFieldRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => $ENTITY_TYPE, 'ELEMENT_ID' => $elementID));
                     while ($multiField = $obMultiFieldRes->Fetch()) {
                         $fieldValue = $multiField['VALUE'];
                         $fieldTypeID = $multiField['TYPE_ID'];
                         if ($fieldValue === '' || $fieldTypeID !== 'PHONE' && $fieldTypeID !== 'EMAIL') {
                             continue;
                         }
                         if (!isset($multiFields[$fieldTypeID])) {
                             $multiFields[$fieldTypeID] = array();
                         }
                         $multiFields[$fieldTypeID][] = $fieldValue;
                     }
                 }
                 $arResult = self::_buildEntityCard($arRow, $sTitleID, $ENTITY_TYPE, array('FM' => $multiFields));
             }
             if (self::$bReIndex) {
                 if (self::$oCallback) {
                     $res = call_user_func(array(self::$oCallback, self::$callback_method), $arResult);
                     if (!$res) {
                         return $lastItemID;
                     }
                 }
             } else {
                 CSearch::Index('crm', $ENTITY_TYPE . '.' . $arRow['ID'], $arResult, $bOverWrite);
             }
             $arAllResult[] = $arResult;
             $qty++;
         }
     }
     if (!self::$bReIndex && !empty($arFilter['ID']) && $qty === 0) {
         CSearch::DeleteIndex('crm', (int) $arFilter['ID']);
     }
     if (self::$bReIndex && $qty === $limit && $lastItemID !== '') {
         return $lastItemID;
     }
     return $arAllResult;
 }
コード例 #5
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
 if ($bSuccess) {
     // Save settings
     if (is_array($productRowSettings) && count($productRowSettings) > 0) {
         $arSettings = CCrmProductRow::LoadSettings('I', $arResult['ELEMENT']['ID']);
         foreach ($productRowSettings as $k => $v) {
             $arSettings[$k] = $v;
         }
         CCrmProductRow::SaveSettings('I', $arResult['ELEMENT']['ID'], $arSettings);
     }
     unset($arSettings);
 }
 // link contact to company
 if ($bSuccess) {
     if ($arFields['UF_CONTACT_ID'] > 0 && $arFields['UF_COMPANY_ID'] > 0) {
         $CrmContact = new CCrmContact();
         $dbRes = CCrmContact::GetList(array(), array('ID' => $arFields['UF_CONTACT_ID']), array('COMPANY_ID'));
         $arContactInfo = $dbRes->Fetch();
         if ($arContactInfo && intval($arContactInfo['COMPANY_ID']) <= 0) {
             $arContactFields = array('COMPANY_ID' => $arFields['UF_COMPANY_ID']);
             $bSuccess = $CrmContact->Update($arFields['UF_CONTACT_ID'], $arContactFields, false, true, array('DISABLE_USER_FIELD_CHECK' => true));
             if (!$bSuccess) {
                 $arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
             }
         }
         unset($arContactInfo, $dbRes, $CrmContact);
     }
 }
 if ($bSuccess) {
     $DB->Commit();
 } else {
     $DB->Rollback();
コード例 #6
0
 private function SaveOrderDataContact($arOrder)
 {
     if (!isset($arOrder["CONTRACTOR"]) || !is_array($arOrder["CONTRACTOR"])) {
         return false;
     }
     $contactId = 0;
     $contactXmlId = $arOrder["CONTRACTOR"]["ID"];
     if (isset($arOrder["CONTRACTOR"]["FIRST_NAME"]) && $arOrder["CONTRACTOR"]["FIRST_NAME"] != "") {
         $contactXmlId .= "|" . $arOrder["CONTRACTOR"]["FIRST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["LAST_NAME"]) && $arOrder["CONTRACTOR"]["LAST_NAME"] != "") {
         $contactXmlId .= "|" . $arOrder["CONTRACTOR"]["LAST_NAME"];
     }
     $dbContact = CCrmContact::GetList(array(), array("ORIGINATOR_ID" => $this->externalSaleId, "ORIGIN_ID" => $contactXmlId, "CHECK_PERMISSIONS" => "N"));
     if ($arContact = $dbContact->Fetch()) {
         $contactId = $arContact["ID"];
     }
     $arFields = array('ORIGINATOR_ID' => $this->externalSaleId, 'ORIGIN_ID' => $contactXmlId, 'TYPE_ID' => 'CLIENT', 'OPENED' => 'Y');
     $sources = CCrmStatus::GetStatusList('SOURCE');
     if (isset($sources['WEB'])) {
         $arFields['SOURCE_ID'] = 'WEB';
     }
     if (isset($arOrder["CONTRACTOR"]["FIRST_NAME"]) && $arOrder["CONTRACTOR"]["FIRST_NAME"] != "") {
         $arFields['NAME'] = $arOrder["CONTRACTOR"]["FIRST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["LAST_NAME"]) && $arOrder["CONTRACTOR"]["LAST_NAME"] != "") {
         $arFields['LAST_NAME'] = $arOrder["CONTRACTOR"]["LAST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["SECOND_NAME"]) && $arOrder["CONTRACTOR"]["SECOND_NAME"] != "") {
         $arFields['SECOND_NAME'] = $arOrder["CONTRACTOR"]["SECOND_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["BIRTHDAY"]) && $arOrder["CONTRACTOR"]["BIRTHDAY"] != "") {
         $arFields['BIRTHDATE'] = $arOrder["CONTRACTOR"]["BIRTHDAY"];
     }
     if (isset($arOrder["CONTRACTOR"]["FULL_NAME"]) && $arOrder["CONTRACTOR"]["FULL_NAME"] != "") {
         $arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["FULL_NAME"];
     } elseif (isset($arOrder["CONTRACTOR"]["NAME"]) && $arOrder["CONTRACTOR"]["NAME"] != "") {
         $arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["NAME"];
     }
     if (is_array($arOrder["CONTRACTOR"]["ADDRESS"])) {
         foreach ($arOrder["CONTRACTOR"]["ADDRESS"] as $key => $val) {
             if ($key == "VIEW") {
                 continue;
             }
             if (!empty($arFields["ADDRESS"])) {
                 $arFields["ADDRESS"] .= ", ";
             }
             $arFields["ADDRESS"] .= $val;
         }
         if (isset($arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"])) {
             if (!empty($arFields["ADDRESS"])) {
                 $arFields["ADDRESS"] .= "\n";
             }
             $arFields["ADDRESS"] .= $arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"];
         }
     }
     if (is_array($arOrder["CONTRACTOR"]["CONTACTS"])) {
         $arFields["FM"] = array();
         if ($contactId > 0) {
             $dbCrmFieldMulti = CCrmFieldMulti::GetList(array(), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $contactId, "CHECK_PERMISSIONS" => "N"));
             while ($arCrmFieldMulti = $dbCrmFieldMulti->Fetch()) {
                 $arFields["FM"][$arCrmFieldMulti["TYPE_ID"]][$arCrmFieldMulti["ID"]] = array("VALUE_TYPE" => $arCrmFieldMulti["VALUE_TYPE"], "VALUE" => $arCrmFieldMulti["VALUE"]);
             }
         }
         $arMapTmp = array("MAIL" => "EMAIL", "E-MAIL" => "EMAIL", "WORKPHONE" => "PHONE");
         $arInc = array();
         foreach ($arOrder["CONTRACTOR"]["CONTACTS"] as $val) {
             $t = strtoupper(preg_replace("/\\s/", "", $val["TYPE"]));
             if (!isset($arMapTmp[$t])) {
                 continue;
             }
             $bFound = false;
             $tNew = $arMapTmp[$t];
             if (isset($arFields["FM"][$tNew]) && is_array($arFields["FM"][$tNew])) {
                 if (count($arFields["FM"][$tNew]) >= 50) {
                     //Disable adding new communication after threshold is exceeded
                     $bFound = true;
                 } else {
                     foreach ($arFields["FM"][$tNew] as $k => $v) {
                         if ($v["VALUE"] == $val["VALUE"]) {
                             $bFound = true;
                             break;
                         }
                     }
                 }
             }
             if (!$bFound) {
                 $arInc[$tNew]++;
                 $arFields["FM"][$tNew]["n" . $arInc[$tNew]] = array("VALUE_TYPE" => "WORK", "VALUE" => $val["VALUE"]);
             }
         }
     }
     $newContact = $contactId == 0;
     $obj = new CCrmContact(false);
     if ($contactId == 0) {
         if ((!isset($arFields['NAME']) || strlen($arFields['NAME']) <= 0) && (!isset($arFields['LAST_NAME']) || strlen($arFields['LAST_NAME']) <= 0)) {
             $arFields['LAST_NAME'] = $contactXmlId;
         }
         $res = $obj->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true));
         if ($res > 0) {
             $contactId = (int) $res;
             $this->arImportResult->numberOfCreatedContacts++;
         }
     } else {
         $res = $obj->Update($contactId, $arFields, true, true, array('DISABLE_USER_FIELD_CHECK' => true));
         if ($res) {
             $this->arImportResult->numberOfUpdatedContacts++;
         }
     }
     if (!$res) {
         if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false) {
             $this->AddError($ex->GetID(), $ex->GetString());
         } else {
             $this->AddError("CCA", "Contact creation error");
         }
         if (!empty($obj->LAST_ERROR)) {
             $this->AddError("CCA", $obj->LAST_ERROR);
         }
         return false;
     }
     return array($contactId, $newContact);
 }
コード例 #7
0
ファイル: crm_deal.php プロジェクト: mrdeadmouse/u136006
 public static function CompareFields($arFieldsOrig, $arFieldsModif, $bCheckPerms = true)
 {
     $arMsg = array();
     if (isset($arFieldsOrig['TITLE']) && isset($arFieldsModif['TITLE']) && $arFieldsOrig['TITLE'] != $arFieldsModif['TITLE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'TITLE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_TITLE'), 'EVENT_TEXT_1' => $arFieldsOrig['TITLE'], 'EVENT_TEXT_2' => $arFieldsModif['TITLE']);
     }
     if (isset($arFieldsOrig['COMPANY_ID']) && isset($arFieldsModif['COMPANY_ID']) && (int) $arFieldsOrig['COMPANY_ID'] != (int) $arFieldsModif['COMPANY_ID']) {
         $arCompany = array();
         $arFilterTmp = array('ID' => array($arFieldsOrig['COMPANY_ID'], $arFieldsModif['COMPANY_ID']));
         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_FIELD_COMPARE_COMPANY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arCompany, $arFieldsOrig['COMPANY_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arCompany, $arFieldsModif['COMPANY_ID']));
     }
     if (isset($arFieldsOrig['CONTACT_ID']) && isset($arFieldsModif['CONTACT_ID']) && (int) $arFieldsOrig['CONTACT_ID'] != (int) $arFieldsModif['CONTACT_ID']) {
         $arContact = array();
         $arFilterTmp = array('ID' => array($arFieldsOrig['CONTACT_ID'], $arFieldsModif['CONTACT_ID']));
         if (!$bCheckPerms) {
             $arFilterTmp["CHECK_PERMISSIONS"] = "N";
         }
         $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), $arFilterTmp);
         while ($arRes = $dbRes->Fetch()) {
             $arContact[$arRes['ID']] = $arRes['LAST_NAME'] . ' ' . $arRes['NAME'];
         }
         $arMsg[] = array('ENTITY_FIELD' => 'CONTACT_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CONTACT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arContact, $arFieldsOrig['CONTACT_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arContact, $arFieldsModif['CONTACT_ID']));
     }
     if (isset($arFieldsOrig['ASSIGNED_BY_ID']) && isset($arFieldsModif['ASSIGNED_BY_ID']) && (int) $arFieldsOrig['ASSIGNED_BY_ID'] != (int) $arFieldsModif['ASSIGNED_BY_ID']) {
         $arUser = array();
         $dbUsers = CUser::GetList($sort_by = 'last_name', $sort_dir = 'asc', array('ID' => implode('|', array(intval($arFieldsOrig['ASSIGNED_BY_ID']), intval($arFieldsModif['ASSIGNED_BY_ID'])))), array('SELECT' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', '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_FIELD_COMPARE_ASSIGNED_BY_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arUser, $arFieldsOrig['ASSIGNED_BY_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arUser, $arFieldsModif['ASSIGNED_BY_ID']));
     }
     if (isset($arFieldsOrig['STAGE_ID']) && isset($arFieldsModif['STAGE_ID']) && $arFieldsOrig['STAGE_ID'] != $arFieldsModif['STAGE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('DEAL_STAGE');
         $arMsg[] = array('ENTITY_FIELD' => 'STAGE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_STAGE'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['STAGE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['STAGE_ID'])));
     }
     /*
     if (isset($arFieldsOrig['STATE_ID']) && isset($arFieldsModif['STATE_ID'])
     	&& $arFieldsOrig['STATE_ID'] != $arFieldsModif['STATE_ID'])
     {
     	$CCrmStatus = new CCrmStatus('DEAL_STATE');
     	$arStatusOrig = $CCrmStatus->GetStatusByStatusId($arFieldsOrig['STATE_ID']);
     	$arStatusModif = $CCrmStatus->GetStatusByStatusId($arFieldsModif['STATE_ID']);
     
     	$arMsg[] = Array(
     		'ENTITY_FIELD' => 'STATE_ID',
     		'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_STATE'),
     		'EVENT_TEXT_1' => isset($arStatusOrig['NAME'])? $arStatusOrig['NAME']: GetMessage('CRM_FIELD_COMPARE_EMPTY'),
     		'EVENT_TEXT_2' => isset($arStatusModif['NAME'])? $arStatusModif['NAME']: GetMessage('CRM_FIELD_COMPARE_EMPTY'),
     	);
     }
     */
     if (isset($arFieldsOrig['TYPE_ID']) && isset($arFieldsModif['TYPE_ID']) && $arFieldsOrig['TYPE_ID'] != $arFieldsModif['TYPE_ID']) {
         $arStatus = CCrmStatus::GetStatusList('DEAL_TYPE');
         $arMsg[] = array('ENTITY_FIELD' => 'TYPE_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_DEAL_TYPE'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsOrig['TYPE_ID'])), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $arFieldsModif['TYPE_ID'])));
     }
     if (isset($arFieldsOrig['COMMENTS']) && isset($arFieldsModif['COMMENTS']) && $arFieldsOrig['COMMENTS'] != $arFieldsModif['COMMENTS']) {
         $arMsg[] = array('ENTITY_FIELD' => 'COMMENTS', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_COMMENTS'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['COMMENTS']) ? $arFieldsOrig['COMMENTS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['COMMENTS']) ? $arFieldsModif['COMMENTS'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     //		if (isset($arFieldsOrig['PRODUCT_ID']) && isset($arFieldsModif['PRODUCT_ID'])
     //			&& $arFieldsOrig['PRODUCT_ID'] != $arFieldsModif['PRODUCT_ID'])
     //		{
     //			$arStatus = CCrmStatus::GetStatusList('PRODUCT');
     //			$arMsg[] = Array(
     //				'ENTITY_FIELD' => 'PRODUCT_ID',
     //				'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_PRODUCT'),
     //				'EVENT_TEXT_1' => CrmCompareFieldsList($arStatus, $arFieldsOrig['PRODUCT_ID']),
     //				'EVENT_TEXT_2' => CrmCompareFieldsList($arStatus, $arFieldsModif['PRODUCT_ID'])
     //			);
     //		}
     if (isset($arFieldsOrig['OPPORTUNITY']) && isset($arFieldsModif['OPPORTUNITY']) && $arFieldsOrig['OPPORTUNITY'] != $arFieldsModif['OPPORTUNITY'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
         $arStatus = CCrmCurrencyHelper::PrepareListItems();
         $arMsg[] = array('ENTITY_FIELD' => 'OPPORTUNITY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_OPPORTUNITY'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
     }
     if (isset($arFieldsOrig['TAX_VALUE']) && isset($arFieldsModif['TAX_VALUE']) && $arFieldsOrig['TAX_VALUE'] != $arFieldsModif['TAX_VALUE'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
         $arStatus = CCrmCurrencyHelper::PrepareListItems();
         $arMsg[] = array('ENTITY_FIELD' => 'TAX_VALUE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_TAX_VALUE'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
     }
     if (isset($arFieldsOrig['PROBABILITY']) && isset($arFieldsModif['PROBABILITY']) && $arFieldsOrig['PROBABILITY'] != $arFieldsModif['PROBABILITY']) {
         $arMsg[] = array('ENTITY_FIELD' => 'PROBABILITY', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_PROBABILITY'), 'EVENT_TEXT_1' => intval($arFieldsOrig['PROBABILITY']) . '%', 'EVENT_TEXT_2' => intval($arFieldsModif['PROBABILITY']) . '%');
     }
     if (array_key_exists('BEGINDATE', $arFieldsOrig) && array_key_exists('BEGINDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) != $arFieldsModif['BEGINDATE'] && $arFieldsOrig['BEGINDATE'] != $arFieldsModif['BEGINDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'BEGINDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_BEGINDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['BEGINDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['BEGINDATE']) ? $arFieldsModif['BEGINDATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('CLOSEDATE', $arFieldsOrig) && array_key_exists('CLOSEDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) != $arFieldsModif['CLOSEDATE'] && $arFieldsOrig['CLOSEDATE'] != $arFieldsModif['CLOSEDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSEDATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CLOSEDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['CLOSEDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['CLOSEDATE']) ? $arFieldsModif['CLOSEDATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('EVENT_DATE', $arFieldsOrig) && array_key_exists('EVENT_DATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['EVENT_DATE'])) != $arFieldsModif['EVENT_DATE'] && $arFieldsOrig['EVENT_DATE'] != $arFieldsModif['EVENT_DATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_DATE', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_DATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['EVENT_DATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['EVENT_DATE'])) : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['EVENT_DATE']) ? $arFieldsModif['EVENT_DATE'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['EVENT_ID']) && isset($arFieldsModif['EVENT_ID']) && $arFieldsOrig['EVENT_ID'] != $arFieldsModif['EVENT_ID']) {
         $arStatus = CCrmStatus::GetStatusList('EVENT_TYPE');
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arStatus, $arFieldsOrig['EVENT_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arStatus, $arFieldsModif['EVENT_ID']));
     }
     if (isset($arFieldsOrig['EVENT_DESCRIPTION']) && isset($arFieldsModif['EVENT_DESCRIPTION']) && $arFieldsOrig['EVENT_DESCRIPTION'] != $arFieldsModif['EVENT_DESCRIPTION']) {
         $arMsg[] = array('ENTITY_FIELD' => 'EVENT_DESCRIPTION', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_EVENT_DESCRIPTION'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['EVENT_DESCRIPTION']) ? $arFieldsOrig['EVENT_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['EVENT_DESCRIPTION']) ? $arFieldsModif['EVENT_DESCRIPTION'] : GetMessage('CRM_FIELD_COMPARE_EMPTY'));
     }
     if (isset($arFieldsOrig['CLOSED']) && isset($arFieldsModif['CLOSED']) && $arFieldsOrig['CLOSED'] != $arFieldsModif['CLOSED']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSED', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_CLOSED'), 'EVENT_TEXT_1' => $arFieldsOrig['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
     }
     $origLocationId = isset($arFieldsOrig['LOCATION_ID']) ? $arFieldsOrig['LOCATION_ID'] : '';
     $modifLocationId = isset($arFieldsModif['LOCATION_ID']) ? $arFieldsModif['LOCATION_ID'] : '';
     if ($origLocationId != $modifLocationId) {
         $origLocationString = $modifLocationString = '';
         if (IsModuleInstalled('sale') && CModule::IncludeModule('sale')) {
             $location = new CSaleLocation();
             $origLocationString = $origLocationId > 0 ? $location->GetLocationString($origLocationId) : '';
             $modifLocationString = $modifLocationId > 0 ? $location->GetLocationString($modifLocationId) : '';
         }
         if (empty($origLocationString) && intval($origLocationId) > 0) {
             $origLocationString = '[' . $origLocationId . ']';
         }
         if (empty($modifLocationString) && intval($modifLocationId) > 0) {
             $modifLocationString = '[' . $modifLocationId . ']';
         }
         $arMsg[] = array('ENTITY_FIELD' => 'LOCATION_ID', 'EVENT_NAME' => GetMessage('CRM_FIELD_COMPARE_LOCATION_ID'), 'EVENT_TEXT_1' => $origLocationString, 'EVENT_TEXT_2' => $modifLocationString);
         unset($origLocationString, $modifLocationString);
     }
     unset($origLocationId, $modifLocationId);
     return $arMsg;
 }
コード例 #8
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
     if ($arRes = $dbRes->Fetch()) {
         $arResult['ENTITY_TITLE'] = $arRes['TITLE'];
         $arResult['STATUS_ID'] = $arRes['STATUS_ID'];
     }
     $arResult['STATUS_LIST'] = array();
     $arEventType = CCrmStatus::GetStatusList('QUOTE_STATUS');
     foreach ($arEventType as $key => $value) {
         if ($CCrmPerms->GetPermType('QUOTE', 'WRITE', array('QUOTE_STATUS' . $key)) > BX_CRM_PERM_NONE) {
             $arResult['STATUS_LIST']['REFERENCE'][] = $value;
             $arResult['STATUS_LIST']['REFERENCE_ID'][] = $key;
         }
     }
     if ($arParams['EVENT_TYPE'] === 'PHONE') {
         $contactID = isset($arRes['CONTACT_ID']) ? intval($arRes['CONTACT_ID']) : 0;
         if ($contactID > 0) {
             $rsContacts = CCrmContact::GetList(array(), array('ID' => $contactID), array('FULL_NAME'), 1);
             $arContact = $rsContacts->Fetch();
             if ($arContact) {
                 $arResult['PHONE_GROUPS'][] = array('TITLE' => $arContact['FULL_NAME'], 'PHONES' => __CrmEventGetPhones('CONTACT', $contactID));
             }
         }
         $companyID = isset($arRes['COMPANY_ID']) ? intval($arRes['COMPANY_ID']) : 0;
         if ($companyID > 0) {
             $rsCompanies = CCrmCompany::GetList(array(), array('ID' => $companyID), array('TITLE'), 1);
             $arCompany = $rsCompanies->Fetch();
             if ($arCompany) {
                 $arResult['PHONE_GROUPS'][] = array('TITLE' => $arCompany['TITLE'], 'PHONES' => __CrmEventGetPhones('COMPANY', $companyID));
             }
         }
     }
 }
コード例 #9
0
 public static function UpdateDocument($documentId, $arFields)
 {
     global $DB;
     $arDocumentID = self::GetDocumentInfo($documentId);
     if (empty($arDocumentID)) {
         throw new CBPArgumentNullException('documentId');
     }
     $dbDocumentList = CCrmContact::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_") {
             $db = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "CRM_CONTACT", "FIELD_NAME" => $key));
             if ($ar = $db->Fetch()) {
                 $arV = array();
                 $db = CUserTypeEnum::GetList($ar);
                 while ($ar = $db->GetNext()) {
                     $arV[$ar["XML_ID"]] = $ar["ID"];
                 }
                 foreach ($arFields[$key] as &$value) {
                     if (array_key_exists($value, $arV)) {
                         $value = $arV[$value];
                     }
                 }
                 unset($value);
             }
         } elseif ($fieldType == "file") {
             $arFileOptions = array('ENABLE_ID' => true);
             foreach ($arFields[$key] as &$value) {
                 //Issue #40380. Secure URLs and file IDs are allowed.
                 $file = false;
                 CCrmFileProxy::TryResolveFile($value, $file, $arFileOptions);
                 $value = $file;
             }
             unset($value);
         } elseif ($fieldType == "S:HTML") {
             foreach ($arFields[$key] as &$value) {
                 $value = array("VALUE" => $value);
             }
             unset($value);
         }
         if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
             if (count($arFields[$key]) > 0) {
                 $a = array_values($arFields[$key]);
                 $arFields[$key] = $a[0];
             } else {
                 $arFields[$key] = null;
             }
         }
     }
     if (isset($arFields['COMMENTS']) && $arFields['COMMENTS'] !== '') {
         $arFields['COMMENTS'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", $arFields['COMMENTS']);
     }
     $DB->StartTransaction();
     $CCrmEntity = new CCrmContact(false);
     $res = $CCrmEntity->Update($arDocumentID['ID'], $arFields);
     if (!$res) {
         $DB->Rollback();
         throw new Exception($CCrmEntity->LAST_ERROR);
     }
     if (COption::GetOptionString("crm", "start_bp_within_bp", "N") == "Y") {
         $CCrmBizProc = new CCrmBizProc('CONTACT');
         if (false === $CCrmBizProc->CheckFields($arDocumentID['ID'], true)) {
             throw new Exception($CCrmBizProc->LAST_ERROR);
         }
         if ($res && !$CCrmBizProc->StartWorkflow($arDocumentID['ID'])) {
             $DB->Rollback();
             throw new Exception($CCrmBizProc->LAST_ERROR);
         }
     }
     if ($res) {
         $DB->Commit();
     }
 }
コード例 #10
0
ファイル: class.php プロジェクト: Satariall/izurit
 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'] : '';
             $clientTitle .= ($clientTitle !== '' && !empty($arRes['CONTACT_FULL_NAME']) ? ', ' : '') . $arRes['CONTACT_FULL_NAME'];
             $elements[] = array('title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => $clientTitle, 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $arRes['ID'])), 'type' => 'deal', 'selected' => 'N');
         }
     }
     if (isset($arSettings['QUOTE']) && $arSettings['QUOTE'] == 'Y') {
         $entityTypes[] = 'quote';
         $arSelect = array('ID', 'QUOTE_NUMBER', 'TITLE', 'COMPANY_TITLE', 'CONTACT_FULL_NAME');
         $obRes = CCrmQuote::GetList(array('ID' => 'DESC'), array(), false, array('nTopCount' => 50), array('ID', 'QUOTE_NUMBER', 'TITLE', 'COMPANY_TITLE', 'CONTACT_FULL_NAME'));
         while ($arRes = $obRes->Fetch()) {
             $arRes['SID'] = $usePrefix ? 'Q_' . $arRes['ID'] : $arRes['ID'];
             $clientTitle = !empty($arRes['COMPANY_TITLE']) ? $arRes['COMPANY_TITLE'] : '';
             $clientTitle .= ($clientTitle !== '' && !empty($arRes['CONTACT_FULL_NAME']) ? ', ' : '') . $arRes['CONTACT_FULL_NAME'];
             $quoteTitle = empty($arRes['TITLE']) ? $arRes['QUOTE_NUMBER'] : $arRes['QUOTE_NUMBER'] . ' - ' . $arRes['TITLE'];
             $elements[] = array('title' => empty($quoteTitle) ? '' : str_replace(array(';', ','), ' ', $quoteTitle), 'desc' => $clientTitle, 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_quote_show'), array('quote_id' => $arRes['ID'])), 'type' => 'quote', 'selected' => 'N');
         }
     }
     if (isset($arSettings['PRODUCT']) && $arSettings['PRODUCT'] == 'Y') {
         $entityTypes[] = 'product';
         $arSelect = array('ID', 'NAME', 'PRICE', 'CURRENCY_ID');
         $arPricesSelect = $arVatsSelect = array();
         $arSelect = CCrmProduct::DistributeProductSelect($arSelect, $arPricesSelect, $arVatsSelect);
         $obRes = CCrmProduct::GetList(array('ID' => 'DESC'), array('ACTIVE' => 'Y'), $arSelect, 50);
         $arProducts = $arProductId = array();
         while ($arRes = $obRes->Fetch()) {
             foreach ($arPricesSelect as $fieldName) {
                 $arRes[$fieldName] = null;
             }
             foreach ($arVatsSelect as $fieldName) {
                 $arRes[$fieldName] = null;
             }
             $arProductId[] = $arRes['ID'];
             $arProducts[$arRes['ID']] = $arRes;
         }
         CCrmProduct::ObtainPricesVats($arProducts, $arProductId, $arPricesSelect, $arVatsSelect);
         unset($arProductId, $arPricesSelect, $arVatsSelect);
         foreach ($arProducts as $arRes) {
             $arRes['SID'] = $usePrefix ? 'PROD_' . $arRes['ID'] : $arRes['ID'];
             $elements[] = array('title' => $arRes['NAME'], 'desc' => CCrmProduct::FormatPrice($arRes), 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_product_show'), array('product_id' => $arRes['ID'])), 'type' => 'product', 'selected' => 'N');
         }
         unset($arProducts);
     }
     $selectorItem['USER_TYPE_ID'] = $ufInfo['USER_TYPE_ID'];
     $selectorItem['ENTITY_ID'] = $ufInfo['ENTITY_ID'];
     $selectorItem['FIELD_NAME'] = $ufInfo['FIELD_NAME'];
     $selectorItem['PREFIX'] = $usePrefix ? 'Y' : 'N';
     $selectorItem['MULTIPLE'] = 'Y';
     //$ufInfo['MULTIPLE'];
     $selectorItem['ENTITY_TYPE'] = $entityTypes;
     $selectorItem['ELEMENT'] = $elements;
     $result = $selectorItem;
     return $result;
 }
コード例 #11
0
ファイル: crm_usertype.php プロジェクト: mrdeadmouse/u136006
 public function ListAddEnumFieldsValue($arParams, &$arValue, &$arReplaceValue, $delimiter = '<br />', $textonly = false, $arOptions = array())
 {
     global $APPLICATION;
     $arUserFields = $this->GetUserFields($this->sEntityID, 0, LANGUAGE_ID);
     $bSecondLoop = false;
     $arValuePrepare = array();
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     // The first loop to collect all the data fields
     foreach ($arUserFields as $FIELD_NAME => &$arUserField) {
         foreach ($arValue as $ID => $data) {
             if (!isset($arValue[$ID][$FIELD_NAME]) && $arUserField['USER_TYPE']['USER_TYPE_ID'] != 'boolean') {
                 continue;
             }
             if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'boolean') {
                 if (isset($arValue[$ID][$FIELD_NAME])) {
                     $arValue[$ID][$FIELD_NAME] == ($arValue[$ID][$FIELD_NAME] == 1 || $arValue[$ID][$FIELD_NAME] == 'Y' ? 'Y' : 'N');
                 }
                 $arVal = $arValue[$ID][$FIELD_NAME];
                 if (!is_array($arVal)) {
                     $arVal = array($arVal);
                 }
                 foreach ($arVal as $val) {
                     $val = (string) $val;
                     if (strlen($val) <= 0) {
                         //Empty value is always 'N' (not default field value)
                         $val = 'N';
                     }
                     $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . ($val == 1 ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
                     if ($arUserField['MULTIPLE'] == 'Y') {
                         $arValue[$ID][$FIELD_NAME][] = $val == 1 || $val == 'Y' ? 'Y' : 'N';
                     } else {
                         $arValue[$ID][$FIELD_NAME] = $val == 1 || $val == 'Y' ? 'Y' : 'N';
                     }
                 }
             } elseif ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'crm_status') {
                 $ar = CCrmStatus::GetStatusList($arUserField['SETTINGS']['ENTITY_TYPE']);
                 $arReplaceValue[$ID][$FIELD_NAME] = isset($ar[$arValue[$ID][$FIELD_NAME]]) ? $ar[$arValue[$ID][$FIELD_NAME]] : '';
             } else {
                 if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'crm') {
                     $arParams['CRM_ENTITY_TYPE'] = array();
                     if ($arUserField['SETTINGS']['LEAD'] == 'Y') {
                         $arParams['CRM_ENTITY_TYPE'][] = 'LEAD';
                     }
                     if ($arUserField['SETTINGS']['CONTACT'] == 'Y') {
                         $arParams['CRM_ENTITY_TYPE'][] = 'CONTACT';
                     }
                     if ($arUserField['SETTINGS']['COMPANY'] == 'Y') {
                         $arParams['CRM_ENTITY_TYPE'][] = 'COMPANY';
                     }
                     if ($arUserField['SETTINGS']['DEAL'] == 'Y') {
                         $arParams['CRM_ENTITY_TYPE'][] = 'DEAL';
                     }
                     $arParams['CRM_PREFIX'] = false;
                     if (count($arParams['CRM_ENTITY_TYPE']) > 1) {
                         $arParams['CRM_PREFIX'] = true;
                     }
                     $bSecondLoop = true;
                     $arVal = $arValue[$ID][$FIELD_NAME];
                     if (!is_array($arVal)) {
                         $arVal = array($arVal);
                     }
                     foreach ($arVal as $value) {
                         if ($arParams['CRM_PREFIX']) {
                             $ar = explode('_', $value);
                             $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']][CUserTypeCrm::GetLongEntityType($ar[0])][] = intval($ar[1]);
                             $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']]['FIELD'][$ID][$FIELD_NAME][CUserTypeCrm::GetLongEntityType($ar[0])][intval($ar[1])] = intval($ar[1]);
                         } else {
                             if (is_numeric($value)) {
                                 $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']][$arParams['CRM_ENTITY_TYPE'][0]][] = $value;
                                 $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']]['FIELD'][$ID][$FIELD_NAME][$arParams['CRM_ENTITY_TYPE'][0]][$value] = $value;
                             } else {
                                 $ar = explode('_', $value);
                                 $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']][CUserTypeCrm::GetLongEntityType($ar[0])][] = intval($ar[1]);
                                 $arValuePrepare[$arUserField['USER_TYPE']['USER_TYPE_ID']]['FIELD'][$ID][$FIELD_NAME][CUserTypeCrm::GetLongEntityType($ar[0])][intval($ar[1])] = intval($ar[1]);
                             }
                         }
                     }
                     $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;
                     }
                 }
                 if (isset($VALUE['CONTACT']) && !empty($VALUE['CONTACT'])) {
                     $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $VALUE['CONTACT']));
                     while ($arRes = $dbRes->Fetch()) {
                         $arList[$KEY]['CONTACT'][$arRes['ID']] = $arRes;
                     }
                 }
                 if (isset($VALUE['COMPANY']) && !empty($VALUE['COMPANY'])) {
                     $dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), array('ID' => $VALUE['COMPANY']));
                     while ($arRes = $dbRes->Fetch()) {
                         $arList[$KEY]['COMPANY'][$arRes['ID']] = $arRes;
                     }
                 }
                 if (isset($VALUE['DEAL']) && !empty($VALUE['DEAL'])) {
                     $dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), array('ID' => $VALUE['DEAL']));
                     while ($arRes = $dbRes->Fetch()) {
                         $arList[$KEY]['DEAL'][$arRes['ID']] = $arRes;
                     }
                 }
             }
             // assemble multi data
             foreach ($VALUE['FIELD'] as $ID => $arFIELD_NAME) {
                 foreach ($arFIELD_NAME as $FIELD_NAME => $FIELD_VALUE) {
                     foreach ($FIELD_VALUE as $FIELD_VALUE_NAME => $FIELD_VALUE_ID) {
                         if ($KEY == 'iblock_section') {
                             $sname = htmlspecialcharsbx($arList[$KEY][$FIELD_VALUE_ID]['NAME']);
                             $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . $sname;
                         }
                         if ($KEY == 'iblock_element') {
                             $sname = htmlspecialcharsbx($arList[$KEY][$FIELD_VALUE_ID]['NAME']);
                             if (!$textonly) {
                                 $surl = GetIBlockElementLinkById($arList[$KEY][$FIELD_VALUE_ID]['ID']);
                                 if ($surl && strlen($surl) > 0) {
                                     $sname = '<a href="' . $surl . '">' . $sname . '</a>';
                                 }
                             }
                             $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . $sname;
                         } else {
                             if ($KEY == 'employee') {
                                 $sname = CUser::FormatName(CSite::GetNameFormat(false), $arList[$KEY][$FIELD_VALUE_ID], false, true);
                                 if (!$textonly) {
                                     $ar['PATH_TO_USER_PROFILE'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_user_profile'), array('user_id' => $arList[$KEY][$FIELD_VALUE_ID]['ID']));
                                     $sname = '<a href="' . $ar['PATH_TO_USER_PROFILE'] . '" id="balloon_' . $arParams['GRID_ID'] . '_' . $arList[$KEY][$FIELD_VALUE_ID]['ID'] . '">' . $sname . '</a>' . '<script type="text/javascript">BX.tooltip(' . $arList[$KEY][$FIELD_VALUE_ID]['ID'] . ', "balloon_' . $arParams['GRID_ID'] . '_' . $arList[$KEY][$FIELD_VALUE_ID]['ID'] . '", "");</script>';
                                 }
                                 $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . $sname;
                             } else {
                                 if ($KEY == 'enumeration') {
                                     $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . htmlspecialcharsbx($arList[$KEY][$FIELD_VALUE_ID]['VALUE']);
                                 } else {
                                     if ($KEY == 'file') {
                                         $fileInfo = $arList[$KEY][$FIELD_VALUE_ID];
                                         if ($textonly) {
                                             $fileUrl = CFile::GetFileSRC($fileInfo);
                                         } else {
                                             $fileUrlTemplate = isset($arOptions['FILE_URL_TEMPLATE']) ? $arOptions['FILE_URL_TEMPLATE'] : '';
                                             $fileUrl = $fileUrlTemplate === '' ? CFile::GetFileSRC($fileInfo) : CComponentEngine::MakePathFromTemplate($fileUrlTemplate, array('owner_id' => $ID, 'field_name' => $FIELD_NAME, 'file_id' => $fileInfo['ID']));
                                         }
                                         $sname = $textonly ? $fileUrl : '<a href="' . htmlspecialcharsbx($fileUrl) . '" target="_blank">' . htmlspecialcharsbx($arList[$KEY][$FIELD_VALUE_ID]['FILE_NAME']) . '</a>';
                                         $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . $sname;
                                     } else {
                                         if ($KEY == 'crm') {
                                             foreach ($FIELD_VALUE_ID as $CID) {
                                                 $link = '';
                                                 $title = '';
                                                 $prefix = '';
                                                 if ($FIELD_VALUE_NAME == 'LEAD') {
                                                     $link = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $CID));
                                                     $title = $arList[$KEY]['LEAD'][$CID]['TITLE'];
                                                     $prefix = 'L';
                                                 } elseif ($FIELD_VALUE_NAME == 'CONTACT') {
                                                     $link = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $CID));
                                                     $title = CCrmContact::GetFullName($arList[$KEY]['CONTACT'][$CID], true);
                                                     $prefix = 'C';
                                                 } elseif ($FIELD_VALUE_NAME == 'COMPANY') {
                                                     $link = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $CID));
                                                     $title = $arList[$KEY]['COMPANY'][$CID]['TITLE'];
                                                     $prefix = 'CO';
                                                 } elseif ($FIELD_VALUE_NAME == 'DEAL') {
                                                     $link = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $CID));
                                                     $title = $arList[$KEY]['DEAL'][$CID]['TITLE'];
                                                     $prefix = 'D';
                                                 }
                                                 $sname = htmlspecialcharsbx($title);
                                                 if (!$textonly) {
                                                     $tooltip = '<script type="text/javascript">BX.tooltip(' . $CID . ', "balloon_' . $ID . '_' . $FIELD_NAME . '_' . $FIELD_VALUE_NAME . '_' . $CID . '", "/bitrix/components/bitrix/crm.' . strtolower($FIELD_VALUE_NAME) . '.show/card.ajax.php", "crm_balloon' . ($FIELD_VALUE_NAME == 'LEAD' || $FIELD_VALUE_NAME == 'DEAL' || $FIELD_VALUE_NAME == 'QUOTE' ? '_no_photo' : '_' . strtolower($FIELD_VALUE_NAME)) . '", true);</script>';
                                                     $sname = '<a href="' . $link . '" target="_blank" id="balloon_' . $ID . '_' . $FIELD_NAME . '_' . $FIELD_VALUE_NAME . '_' . $CID . '">' . $sname . '</a>' . $tooltip;
                                                 } else {
                                                     $sname = "[{$prefix}]{$sname}";
                                                 }
                                                 $arReplaceValue[$ID][$FIELD_NAME] .= (!empty($arReplaceValue[$ID][$FIELD_NAME]) ? $delimiter : '') . $sname;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: ws_contact.php プロジェクト: mrdeadmouse/u136006
 public function GetAttachmentCollection($listName, $listItemID)
 {
     $start = microtime(true);
     if (!($listName_original = self::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listName = ToUpper(self::makeGUID($listName_original));
     $listItemID = intval($listItemID);
     $dbRes = CCrmContact::GetList(array(), array('ID' => $listItemID), array('PHOTO'));
     $obData = new CXMLCreator('Attachments');
     if (($arContact = $dbRes->Fetch()) && $arContact['PHOTO']) {
         $arImage = self::InitImage($arContact['PHOTO'], 100, 100);
         $obData->addChild($obAttachment = new CXMLCreator('Attachment'));
         $obAttachment->setData(CHTTP::URN2URI($arImage['CACHE']['src']));
     }
     return array('GetAttachmentCollectionResult' => $obData);
 }
コード例 #13
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
     } else {
         $result = array_search($data, $arStatus['EVENT_LIST']);
         $arDeal[$currentKey] = $result !== false ? $result : $data;
     }
 } elseif ($currentKey == 'CLOSED' || $currentKey == 'OPENED') {
     $arDeal[$currentKey] = isset($arStatus[$currentKey . '_LIST'][$data]) ? $data : array_search($data, $arStatus[$currentKey . '_LIST']);
     if ($arDeal[$currentKey] === false) {
         unset($arDeal[$currentKey]);
     }
 } elseif ($currentKey == 'COMPANY_ID') {
     $obRes = CCrmCompany::GetList(array(), array('TITLE' => $data), array('ID'));
     if (($arRow = $obRes->Fetch()) !== false) {
         $arDeal[$currentKey] = $arRow['ID'];
     }
 } elseif ($currentKey == 'CONTACT_ID') {
     $obRes = CCrmContact::GetList(array(), array('FULL_NAME' => $data), array('ID'));
     if (($arRow = $obRes->Fetch()) !== false) {
         $arDeal[$currentKey] = $arRow['ID'];
     }
 } elseif ($currentKey == 'ASSIGNED_BY_ID') {
     $userID = 0;
     if (is_numeric($data)) {
         // 1. Try to interpret value as user ID
         $userID = is_int($data) ? $data : intval($data);
         if ($userID > 0 && !isset($usersByID[$userID])) {
             $dbUsers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => $userID), array('FIELDS' => array('ID')));
             $user = is_object($dbUsers) ? $dbUsers->Fetch() : null;
             if (is_array($user)) {
                 $usersByID[$userID] = $user;
             } else {
                 //Reset user
コード例 #14
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
    }
    if (isset($arInvoice['UF_DEAL_ID']) && intval($arInvoice['UF_DEAL_ID']) > 0) {
        if (!isset($arDealList[$arInvoice['UF_DEAL_ID']]) || !is_array($arDealList[$arInvoice['UF_DEAL_ID']])) {
            $arDealList[$arInvoice['UF_DEAL_ID']] = array();
        }
        $arDealList[$arInvoice['UF_DEAL_ID']][] = $entityID;
    }
    if (isset($arInvoice['UF_QUOTE_ID']) && intval($arInvoice['UF_QUOTE_ID']) > 0) {
        if (!isset($arQuoteList[$arInvoice['UF_QUOTE_ID']]) || !is_array($arQuoteList[$arInvoice['UF_QUOTE_ID']])) {
            $arQuoteList[$arInvoice['UF_QUOTE_ID']] = array();
        }
        $arQuoteList[$arInvoice['UF_QUOTE_ID']][] = $entityID;
    }
}
if (count($arContactList) > 0) {
    $dbRes = CCrmContact::GetList(array(), array('ID' => array_keys($arContactList)), array('ID', 'LOGIN', 'NAME', 'LAST_NAME', 'SECOND_NAME'));
    if ($dbRes) {
        $arContact = array();
        $contactFormattedName = '';
        while ($arContact = $dbRes->Fetch()) {
            if (isset($arContactList[$arContact['ID']]) && is_array($arContactList[$arContact['ID']]) && count($arContactList[$arContact['ID']]) > 0) {
                foreach ($arContactList[$arContact['ID']] as $invoiceId) {
                    $arResult['INVOICE'][$invoiceId]['CONTACT_FORMATTED_NAME'] = $contactFormattedName = CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => $arContact['LOGIN'], 'NAME' => $arContact['NAME'], 'LAST_NAME' => $arContact['LAST_NAME'], 'SECOND_NAME' => $arContact['SECOND_NAME']));
                    $arResult['INVOICE'][$invoiceId]['CONTACT_LINK_HTML'] = CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $arContact['ID'], 'PREFIX' => uniqid("crm_contact_link_"), 'TITLE' => $contactFormattedName, 'CLASS_NAME' => ''));
                }
                unset($invoiceId);
            }
        }
        unset($arContact, $contactFormattedName);
    }
    unset($dbRes);
コード例 #15
0
ファイル: wizard.php プロジェクト: mrdeadmouse/u136006
 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"));
         }
     }
 }
コード例 #16
0
ファイル: result_modifier.php プロジェクト: spas-viktor/books
     $ar = array();
     while ($arRes = $obRes->Fetch()) {
         $arRes['SID'] = $arResult['PREFIX'] == 'Y' ? 'L_' . $arRes['ID'] : $arRes['ID'];
         if (isset($arResult['SELECTED'][$arRes['SID']])) {
             unset($arResult['SELECTED'][$arRes['SID']]);
             $sSelected = 'Y';
         } else {
             $sSelected = 'N';
         }
         $ar[] = 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' => $sSelected);
     }
     $arResult['ELEMENT'] = array_merge($ar, $arResult['ELEMENT']);
 }
 if ($arSettings['CONTACT'] == 'Y' && isset($arSelected['CONTACT']) && !empty($arSelected['CONTACT'])) {
     $arSelect = array('ID', 'FULL_NAME', 'COMPANY_TITLE', 'PHOTO');
     $obRes = CCrmContact::GetList(array('ID' => 'DESC'), array('ID' => $arSelected['CONTACT']), $arSelect);
     $ar = array();
     while ($arRes = $obRes->Fetch()) {
         $arImg = array();
         if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
             if (intval($arRes['PHOTO']) > 0) {
                 $arImg = CFile::ResizeImageGet($arRes['PHOTO'], array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
             }
         }
         $arRes['SID'] = $arResult['PREFIX'] == 'Y' ? 'C_' . $arRes['ID'] : $arRes['ID'];
         if (isset($arResult['SELECTED'][$arRes['SID']])) {
             unset($arResult['SELECTED'][$arRes['SID']]);
             $sSelected = 'Y';
         } else {
             $sSelected = 'N';
         }
コード例 #17
0
ファイル: template.php プロジェクト: mrdeadmouse/u136006
<?php

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
global $APPLICATION, $USER;
$APPLICATION->SetAdditionalCSS('/bitrix/js/crm/css/crm.css');
$APPLICATION->SetAdditionalCSS("/bitrix/themes/.default/crm-entity-show.css");
if (SITE_TEMPLATE_ID === 'bitrix24') {
    $APPLICATION->SetAdditionalCSS("/bitrix/themes/.default/bitrix24/crm-entity-show.css");
}
//CrmContact
$obRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array(), array('ID', 'FULL_NAME', 'COMPANY_TITLE', 'PHOTO'), 50);
$arFiles = array();
$arContacts = array();
while ($arRes = $obRes->Fetch()) {
    if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
        if ($arFile = CFile::GetFileArray($arRes['PHOTO'])) {
            $arFiles[$arRes['PHOTO']] = CHTTP::URN2URI($arFile["SRC"]);
        }
    }
    $arContacts[] = array('id' => $arRes['ID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'title' => str_replace(array(';', ','), ' ', $arRes['FULL_NAME']), 'desc' => empty($arRes['COMPANY_TITLE']) ? '' : $arRes['COMPANY_TITLE'], 'image' => isset($arFiles[$arRes['PHOTO']]) ? $arFiles[$arRes['PHOTO']] : '', 'type' => 'contact', 'selected' => false);
}
$arResult['PREFIX'] = isset($arResult['PREFIX']) ? strval($arResult['PREFIX']) : 'activity_list';
$editorCfg = array('OWNER_TYPE' => $arResult['OWNER_TYPE'], 'OWNER_ID' => $arResult['OWNER_ID'], 'READ_ONLY' => $arResult['READ_ONLY'], 'ENABLE_UI' => true, 'ENABLE_TASK_ADD' => $arResult['ENABLE_TASK_ADD'], 'ENABLE_CALENDAR_EVENT_ADD' => $arResult['ENABLE_CALENDAR_EVENT_ADD'], 'ENABLE_EMAIL_ADD' => $arResult['ENABLE_EMAIL_ADD']);
if (!function_exists('__CrmActivityListRenderItems')) {
    function __CrmActivityListRenderItems($items, $showMode, $showTop, &$editorCfg)
    {
        $editorItems = array();
        $count = count($items);
        $now = time() + CTimeZone::GetOffset();
コード例 #18
0
 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;
 }
コード例 #19
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
        $arResult['CAL'][$arCal['ID'] . '_' . $sCalRel] = $arCal;
        $i++;
    }
    if ($iAddTask != 0) {
        $arResult['ROWS_COUNT'] += $iAddTask;
    }
}
if ($arResult['ACTIVITY_ENTITY_LINK'] == 'Y') {
    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'])));
        }
コード例 #20
0
ファイル: card.ajax.php プロジェクト: mrdeadmouse/u136006
}
global $APPLICATION;
$CCrmPerms = new CCrmPerms($USER->GetID());
if (!$USER->IsAuthorized() || $CCrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE)) {
    return;
}
$arResult = array();
$_GET['USER_ID'] = preg_replace('/^(CONTACT|COMPANY|LEAD|DEAL)_/i' . BX_UTF_PCRE_MODIFIER, '', $_GET['USER_ID']);
$iContactId = (int) $_GET['USER_ID'];
if ($iContactId > 0) {
    __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
    $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_CONTACT_EDIT'] = CrmCheckPath('PATH_TO_CONTACT_EDIT', $arParams['PATH_TO_CONTACT_EDIT'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&edit');
    $arParams['PATH_TO_COMPANY_SHOW'] = CrmCheckPath('PATH_TO_COMPANY_SHOW', $arParams['PATH_TO_COMPANY_SHOW'], $APPLICATION->GetCurPage() . '?company_id=#company_id#&show');
    $arResult['TYPE_LIST'] = CCrmStatus::GetStatusListEx('CONTACT_TYPE');
    $obRes = CCrmContact::GetList(array(), array('ID' => $iContactId));
    $arContact = $obRes->Fetch();
    if ($arContact == false) {
        return;
    }
    $res = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $iContactId));
    while ($ar = $res->Fetch()) {
        if (empty($arContact[$ar['COMPLEX_ID']])) {
            $arContact[$ar['COMPLEX_ID']] = CCrmFieldMulti::GetTemplateByComplex($ar['COMPLEX_ID'], $ar['VALUE']);
        }
    }
    $arContact['PATH_TO_CONTACT_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $iContactId));
    $arContact['PATH_TO_CONTACT_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => $iContactId));
    $arContact['PATH_TO_COMPANY_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_COMPANY_SHOW'], array('company_id' => $arContact['COMPANY_ID']));
    $strCard = '
<div class="bx-user-info-data-cont-video  bx-user-info-fields" id="bx_user_info_data_cont_1">
コード例 #21
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
            return;
        }
    }
}
$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()) {
コード例 #22
0
ファイル: crm_quote.php プロジェクト: mrdeadmouse/u136006
 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::GetList(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::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), $arFilterTmp);
             while ($arRes = $dbRes->Fetch()) {
                 $arContact[$arRes['ID']] = $arRes['LAST_NAME'] . ' ' . $arRes['NAME'];
             }
             $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('SELECT' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'LOGIN', '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);
     }
     if (array_key_exists('STATUS_ID', $arFieldsModif)) {
         $origStatusId = isset($arFieldsOrig['STATUS_ID']) ? $arFieldsOrig['STATUS_ID'] : '';
         $modifStatusId = isset($arFieldsModif['STATUS_ID']) ? $arFieldsModif['STATUS_ID'] : '';
         if ($origStatusId != $modifStatusId) {
             $arStatus = CCrmStatus::GetStatusList('QUOTE_STATUS');
             $arMsg[] = array('ENTITY_FIELD' => 'STATUS_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_STATUS_ID'), 'EVENT_TEXT_1' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $origStatusId)), 'EVENT_TEXT_2' => htmlspecialcharsbx(CrmCompareFieldsList($arStatus, $modifStatusId)));
         }
         unset($origStatusId, $modifStatusId);
     }
     if (array_key_exists('COMMENTS', $arFieldsModif)) {
         $origComments = isset($arFieldsOrig['COMMENTS']) ? $arFieldsOrig['COMMENTS'] : '';
         $modifComments = isset($arFieldsModif['COMMENTS']) ? $arFieldsModif['COMMENTS'] : '';
         if ($origComments != $modifComments) {
             $arMsg[] = array('ENTITY_FIELD' => 'COMMENTS', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_COMMENTS'), 'EVENT_TEXT_1' => !empty($origComments) ? $origComments : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifComments) ? $modifComments : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origComments, $modifComments);
     }
     if (array_key_exists('CONTENT', $arFieldsModif)) {
         $origContent = isset($arFieldsOrig['CONTENT']) ? $arFieldsOrig['CONTENT'] : '';
         $modifContent = isset($arFieldsModif['CONTENT']) ? $arFieldsModif['CONTENT'] : '';
         if ($origContent != $modifContent) {
             $arMsg[] = array('ENTITY_FIELD' => 'CONTENT', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CONTENT'), 'EVENT_TEXT_1' => !empty($origContent) ? $origContent : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifContent) ? $modifContent : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origContent, $modifContent);
     }
     if (array_key_exists('TERMS', $arFieldsModif)) {
         $origTerms = isset($arFieldsOrig['TERMS']) ? $arFieldsOrig['TERMS'] : '';
         $modifTerms = isset($arFieldsModif['TERMS']) ? $arFieldsModif['TERMS'] : '';
         if ($origTerms != $modifTerms) {
             $arMsg[] = array('ENTITY_FIELD' => 'TERMS', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TERMS'), 'EVENT_TEXT_1' => !empty($origTerms) ? $origTerms : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifTerms) ? $modifTerms : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
         }
         unset($origTerms, $modifTerms);
     }
     if (array_key_exists('OPPORTUNITY', $arFieldsModif) || array_key_exists('CURRENCY_ID', $arFieldsModif)) {
         $origOpportunity = isset($arFieldsOrig['OPPORTUNITY']) ? round(doubleval($arFieldsOrig['OPPORTUNITY']), 2) : 0.0;
         $modifOpportunity = isset($arFieldsModif['OPPORTUNITY']) ? round(doubleval($arFieldsModif['OPPORTUNITY']), 2) : $origOpportunity;
         $origCurrencyId = isset($arFieldsOrig['CURRENCY_ID']) ? $arFieldsOrig['CURRENCY_ID'] : '';
         $modifCurrencyId = isset($arFieldsModif['CURRENCY_ID']) ? $arFieldsModif['CURRENCY_ID'] : $origCurrencyId;
         if ($origOpportunity != $modifOpportunity || $origCurrencyId != $modifCurrencyId) {
             $arStatus = CCrmCurrencyHelper::PrepareListItems();
             $arMsg[] = array('ENTITY_FIELD' => 'OPPORTUNITY', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_OPPORTUNITY'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $origCurrencyId, '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['OPPORTUNITY']) . (($val = CrmCompareFieldsList($arStatus, $modifCurrencyId, '')) != '' ? ' (' . $val . ')' : ''));
         }
         unset($origOpportunity, $modifOpportunity, $origCurrencyId, $modifCurrencyId);
     }
     if (array_key_exists('TAX_VALUE', $arFieldsModif) || array_key_exists('CURRENCY_ID', $arFieldsModif)) {
         if (isset($arFieldsOrig['TAX_VALUE']) && isset($arFieldsModif['TAX_VALUE']) && $arFieldsOrig['TAX_VALUE'] != $arFieldsModif['TAX_VALUE'] || isset($arFieldsOrig['CURRENCY_ID']) && isset($arFieldsModif['CURRENCY_ID']) && $arFieldsOrig['CURRENCY_ID'] != $arFieldsModif['CURRENCY_ID']) {
             $arStatus = CCrmCurrencyHelper::PrepareListItems();
             $arMsg[] = array('ENTITY_FIELD' => 'TAX_VALUE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_TAX_VALUE'), 'EVENT_TEXT_1' => floatval($arFieldsOrig['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsOrig['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''), 'EVENT_TEXT_2' => floatval($arFieldsModif['TAX_VALUE']) . (($val = CrmCompareFieldsList($arStatus, $arFieldsModif['CURRENCY_ID'], '')) != '' ? ' (' . $val . ')' : ''));
         }
     }
     if (array_key_exists('BEGINDATE', $arFieldsOrig) && array_key_exists('BEGINDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) != $arFieldsModif['BEGINDATE'] && $arFieldsOrig['BEGINDATE'] != $arFieldsModif['BEGINDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'BEGINDATE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_BEGINDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['BEGINDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['BEGINDATE'])) : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['BEGINDATE']) ? $arFieldsModif['BEGINDATE'] : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('CLOSEDATE', $arFieldsOrig) && array_key_exists('CLOSEDATE', $arFieldsModif) && ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) != $arFieldsModif['CLOSEDATE'] && $arFieldsOrig['CLOSEDATE'] != $arFieldsModif['CLOSEDATE']) {
         $arMsg[] = array('ENTITY_FIELD' => 'CLOSEDATE', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CLOSEDATE'), 'EVENT_TEXT_1' => !empty($arFieldsOrig['CLOSEDATE']) ? ConvertTimeStamp(strtotime($arFieldsOrig['CLOSEDATE'])) : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($arFieldsModif['CLOSEDATE']) ? $arFieldsModif['CLOSEDATE'] : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
     }
     if (array_key_exists('OPENED', $arFieldsModif)) {
         if (isset($arFieldsOrig['OPENED']) && isset($arFieldsModif['OPENED']) && $arFieldsOrig['OPENED'] != $arFieldsModif['OPENED']) {
             $arMsg[] = array('ENTITY_FIELD' => 'OPENED', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_OPENED'), 'EVENT_TEXT_1' => $arFieldsOrig['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
         }
     }
     if (array_key_exists('CLOSED', $arFieldsModif)) {
         if (isset($arFieldsOrig['CLOSED']) && isset($arFieldsModif['CLOSED']) && $arFieldsOrig['CLOSED'] != $arFieldsModif['CLOSED']) {
             $arMsg[] = array('ENTITY_FIELD' => 'CLOSED', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_CLOSED'), 'EVENT_TEXT_1' => $arFieldsOrig['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'EVENT_TEXT_2' => $arFieldsModif['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'));
         }
     }
     // person type
     if (array_key_exists('PERSON_TYPE_ID', $arFieldsModif)) {
         $bPersonTypeChanged = isset($arFieldsOrig['PERSON_TYPE_ID']) && isset($arFieldsModif['PERSON_TYPE_ID']) && intval($arFieldsOrig['PERSON_TYPE_ID']) !== intval($arFieldsModif['PERSON_TYPE_ID']);
         if ($bPersonTypeChanged) {
             $arPersonTypes = CCrmPaySystem::getPersonTypesList();
             if ($bPersonTypeChanged) {
                 $arMsg[] = array('ENTITY_FIELD' => 'PERSON_TYPE_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_PERSON_TYPE_ID'), 'EVENT_TEXT_1' => CrmCompareFieldsList($arPersonTypes, $arFieldsOrig['PERSON_TYPE_ID']), 'EVENT_TEXT_2' => CrmCompareFieldsList($arPersonTypes, $arFieldsModif['PERSON_TYPE_ID']));
             }
         }
     }
     if (array_key_exists('LOCATION_ID', $arFieldsModif)) {
         $origLocationId = isset($arFieldsOrig['LOCATION_ID']) ? $arFieldsOrig['LOCATION_ID'] : '';
         $modifLocationId = isset($arFieldsModif['LOCATION_ID']) ? $arFieldsModif['LOCATION_ID'] : '';
         if ($origLocationId != $modifLocationId) {
             $origLocationString = $modifLocationString = '';
             if (IsModuleInstalled('sale') && CModule::IncludeModule('sale')) {
                 $location = new CSaleLocation();
                 $origLocationString = $origLocationId > 0 ? $location->GetLocationString($origLocationId) : '';
                 $modifLocationString = $modifLocationId > 0 ? $location->GetLocationString($modifLocationId) : '';
             }
             if (empty($origLocationString) && intval($origLocationId) > 0) {
                 $origLocationString = '[' . $origLocationId . ']';
             }
             if (empty($modifLocationString) && intval($modifLocationId) > 0) {
                 $modifLocationString = '[' . $modifLocationId . ']';
             }
             $arMsg[] = array('ENTITY_FIELD' => 'LOCATION_ID', 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_LOCATION_ID'), 'EVENT_TEXT_1' => $origLocationString, 'EVENT_TEXT_2' => $modifLocationString);
             unset($origLocationString, $modifLocationString);
         }
         unset($origLocationId, $modifLocationId);
     }
     $origClientFieldValue = $modifClientFieldValue = '';
     foreach (self::$clientFields as $fieldName) {
         if (array_key_exists($fieldName, $arFieldsModif)) {
             $origClientFieldValue = isset($arFieldsOrig[$fieldName]) ? $arFieldsOrig[$fieldName] : '';
             $modifClientFieldValue = isset($arFieldsModif[$fieldName]) ? $arFieldsModif[$fieldName] : '';
             if ($origClientFieldValue != $modifClientFieldValue) {
                 $arMsg[] = array('ENTITY_FIELD' => $fieldName, 'EVENT_NAME' => GetMessage('CRM_QUOTE_FIELD_COMPARE_' . $fieldName), 'EVENT_TEXT_1' => !empty($origClientFieldValue) ? $origClientFieldValue : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => !empty($modifClientFieldValue) ? $modifClientFieldValue : GetMessage('CRM_QUOTE_FIELD_COMPARE_EMPTY'));
             }
         }
     }
     unset($fieldName, $origClientFieldValue, $modifClientFieldValue);
     // Processing of the files
     if (array_key_exists('STORAGE_TYPE_ID', $arFieldsModif) && array_key_exists('STORAGE_ELEMENT_IDS', $arFieldsModif) && strlen($arFieldsModif['STORAGE_ELEMENT_IDS']) > 0) {
         $newStorageTypeID = isset($arFieldsModif['STORAGE_TYPE_ID']) ? intval($arFieldsModif['STORAGE_TYPE_ID']) : CCrmQuoteStorageType::Undefined;
         $oldStorageTypeID = isset($arFieldsOrig['STORAGE_TYPE_ID']) ? intval($arFieldsOrig['STORAGE_TYPE_ID']) : CCrmQuoteStorageType::Undefined;
         self::PrepareStorageElementIDs($arFieldsModif);
         $newElementIDs = $arFieldsModif['STORAGE_ELEMENT_IDS'];
         self::PrepareStorageElementIDs($arFieldsOrig);
         $oldElementIDs = $arFieldsOrig['STORAGE_ELEMENT_IDS'];
         if ($newStorageTypeID === $oldStorageTypeID && is_array($newElementIDs) && is_array($oldElementIDs)) {
             $arRemovedElementIDs = array_values(array_diff($oldElementIDs, $newElementIDs));
             if (!empty($arRemovedElementIDs)) {
                 foreach ($arRemovedElementIDs as $elementID) {
                     self::PrepareFileEvent($oldStorageTypeID, $elementID, 'REMOVE', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
             unset($arRemovedElementIDs);
             $arAddedElementIDs = array_values(array_diff($newElementIDs, $oldElementIDs));
             if (!empty($arAddedElementIDs)) {
                 foreach ($arAddedElementIDs as $elementID) {
                     self::PrepareFileEvent($newStorageTypeID, $elementID, 'ADD', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
             unset($arAddedElementIDs);
         } else {
             if ($newStorageTypeID !== $oldStorageTypeID && is_array($newElementIDs) && is_array($oldElementIDs)) {
                 foreach ($oldElementIDs as $elementID) {
                     self::PrepareFileEvent($oldStorageTypeID, $elementID, 'REMOVE', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
                 foreach ($newElementIDs as $elementID) {
                     self::PrepareFileEvent($newStorageTypeID, $elementID, 'ADD', $arFieldsModif, $arMsg);
                 }
                 unset($elementID);
             }
         }
         unset($newStorageTypeID, $oldStorageTypeID, $newElementIDs, $oldElementIDs);
     }
     return $arMsg;
 }
コード例 #23
0
             $arValue[$arParams['ENTITY_TYPE'][0]][] = $value;
         } else {
             $ar = explode('_', $value);
             $arValue[CUserTypeCrm::GetLongEntityType($ar[0])][] = intval($ar[1]);
         }
     }
 }
 $arResult['VALUE'] = array();
 if ($arParams['arUserField']['SETTINGS']['LEAD'] == 'Y' && isset($arValue['LEAD']) && !empty($arValue['LEAD'])) {
     $dbRes = CCrmLead::GetList(array('TITLE' => 'ASC', 'LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $arValue['LEAD']));
     while ($arRes = $dbRes->Fetch()) {
         $arResult['VALUE']['LEAD'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $arRes['ID'])));
     }
 }
 if ($arParams['arUserField']['SETTINGS']['CONTACT'] == 'Y' && isset($arValue['CONTACT']) && !empty($arValue['CONTACT'])) {
     $dbRes = CCrmContact::GetList(array('LAST_NAME' => 'ASC', 'NAME' => 'ASC'), array('ID' => $arValue['CONTACT']));
     while ($arRes = $dbRes->Fetch()) {
         $arResult['VALUE']['CONTACT'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['FULL_NAME'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])));
     }
 }
 if ($arParams['arUserField']['SETTINGS']['COMPANY'] == 'Y' && isset($arValue['COMPANY']) && !empty($arValue['COMPANY'])) {
     $dbRes = CCrmCompany::GetList(array('TITLE' => 'ASC'), array('ID' => $arValue['COMPANY']));
     while ($arRes = $dbRes->Fetch()) {
         $arResult['VALUE']['COMPANY'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $arRes['ID'])));
     }
 }
 if ($arParams['arUserField']['SETTINGS']['DEAL'] == 'Y' && isset($arValue['DEAL']) && !empty($arValue['DEAL'])) {
     $dbRes = CCrmDeal::GetList(array('TITLE' => 'ASC'), array('ID' => $arValue['DEAL']));
     while ($arRes = $dbRes->Fetch()) {
         $arResult['VALUE']['DEAL'][$arRes['ID']] = array('ENTITY_TITLE' => $arRes['TITLE'], 'ENTITY_LINK' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $arRes['ID'])));
     }
コード例 #24
0
ファイル: report_helper.php プロジェクト: DarneoStudio/bitrix
 public static function collectUFValues($rows, $columnInfo, $total)
 {
     // uf columns
     $fileColumns = array();
     $diskFileColumns = array();
     $employeeColumns = array();
     $crmColumns = array();
     $crmStatusColumns = array();
     $iblockElementColumns = array();
     $iblockSectionColumns = array();
     if (is_array($columnInfo)) {
         foreach ($columnInfo as $k => $cInfo) {
             if ($cInfo['isUF'] && is_array($cInfo['ufInfo']) && isset($cInfo['ufInfo']['USER_TYPE_ID'])) {
                 switch ($cInfo['ufInfo']['USER_TYPE_ID']) {
                     case 'file':
                         $fileColumns[$k] = true;
                         break;
                     case 'disk_file':
                         $diskFileColumns[$k] = true;
                         break;
                     case 'employee':
                         $employeeColumns[$k] = true;
                         break;
                     case 'crm':
                         $crmColumns[$k] = true;
                         break;
                     case 'crm_status':
                         $crmStatusColumns[$k] = true;
                         break;
                     case 'iblock_element':
                         $iblockElementColumns[$k] = true;
                         break;
                     case 'iblock_section':
                         $iblockSectionColumns[$k] = true;
                         break;
                 }
             }
         }
     }
     $arFileID = array();
     $arDiskFileID = array();
     $arEmployeeID = array();
     $arCrmID = array();
     $arCrmStatusID = array();
     $arCrmStatusEntityType = array();
     $arIblockElementID = array();
     $arIblockSectionID = array();
     if (count($fileColumns) > 0 || count($diskFileColumns) > 0 || count($employeeColumns) > 0 || count($crmColumns) > 0 || count($crmStatusColumns) > 0 || count($iblockElementColumns) > 0 || count($iblockSectionColumns) > 0) {
         foreach ($rows as $row) {
             foreach ($row as $k => $v) {
                 // file
                 if (isset($fileColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arFileID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arFileID[] = $value;
                         }
                     }
                 }
                 // disk file
                 if (isset($diskFileColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arDiskFileID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arDiskFileID[] = $value;
                         }
                     }
                 }
                 // employee
                 if (isset($employeeColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arEmployeeID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arEmployeeID[] = $value;
                         }
                     }
                 }
                 // crm
                 if (isset($crmColumns[$k])) {
                     $prefixByType = array('lead' => 'L', 'contact' => 'C', 'company' => 'CO', 'deal' => 'D', 'quote' => 'Q');
                     $maxPrefixLength = 2;
                     // 'CO'
                     $singleTypePrefix = '';
                     if (is_array($columnInfo[$k]['ufInfo']['SETTINGS'])) {
                         $supportedTypes = array();
                         foreach ($columnInfo[$k]['ufInfo']['SETTINGS'] as $type => $supported) {
                             if ($supported === 'Y') {
                                 $supportedTypes[$type] = true;
                             }
                         }
                         $supportedTypes = array_keys($supportedTypes);
                         if (count($supportedTypes) === 1) {
                             if (isset($prefixByType[strtolower($supportedTypes[0])])) {
                                 $singleTypePrefix = $prefixByType[strtolower($supportedTypes[0])];
                             }
                         }
                         unset($supportedTypes, $type, $supported);
                     }
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             if (strlen($subv) > 0) {
                                 $prefix = '';
                                 if (($pos = strpos(substr($subv, 0, $maxPrefixLength + 1), '_')) !== false && $pos > 0) {
                                     $prefix = substr($subv, 0, $pos);
                                 }
                                 if (empty($prefix)) {
                                     $subv = $singleTypePrefix . '_' . $subv;
                                 }
                                 unset($prefix, $pos);
                                 $value = explode('_', trim(strval($subv)));
                                 if (strlen($value[0]) > 0 && strlen($value[1]) > 0) {
                                     if (!is_array($arCrmID[$value[0]])) {
                                         $arCrmID[$value[0]] = array();
                                     }
                                     $arCrmID[$value[0]][] = $value[1];
                                 }
                             }
                         }
                     } else {
                         if (strlen($v) > 0) {
                             $prefix = '';
                             if (($pos = strpos(substr($v, 0, $maxPrefixLength + 1), '_')) !== false && $pos > 0) {
                                 $prefix = substr($v, 0, $pos);
                             }
                             if (empty($prefix)) {
                                 $v = $singleTypePrefix . '_' . $v;
                             }
                             unset($prefix, $pos);
                             $value = explode('_', trim(strval($v)));
                             if (strlen($value[0]) > 0 && strlen($value[1]) > 0) {
                                 if (!is_array($arCrmID[$value[0]])) {
                                     $arCrmID[$value[0]] = array();
                                 }
                                 $arCrmID[$value[0]][] = $value[1];
                             }
                         }
                     }
                     unset($maxPrefixLength);
                 }
                 // crm_status
                 if (isset($crmStatusColumns[$k])) {
                     if (!isset($arCrmStatusEntityType[$k])) {
                         if (isset($columnInfo[$k]['ufInfo']['SETTINGS']['ENTITY_TYPE'])) {
                             $arCrmStatusEntityType[$k] = strval($columnInfo[$k]['ufInfo']['SETTINGS']['ENTITY_TYPE']);
                         }
                     }
                     if (!empty($arCrmStatusEntityType[$k])) {
                         if (is_array($v)) {
                             foreach ($v as $subv) {
                                 if (strlen($subv) > 0) {
                                     if (!is_array($arCrmStatusID[$arCrmStatusEntityType[$k]])) {
                                         $arCrmStatusID[$arCrmStatusEntityType[$k]] = array();
                                     }
                                     $arCrmStatusID[$arCrmStatusEntityType[$k]][] = $subv;
                                 }
                             }
                         } else {
                             if (strlen($v) > 0) {
                                 if (!is_array($arCrmStatusID[$arCrmStatusEntityType[$k]])) {
                                     $arCrmStatusID[$arCrmStatusEntityType[$k]] = array();
                                 }
                                 $arCrmStatusID[$arCrmStatusEntityType[$k]][] = $v;
                             }
                         }
                     }
                 }
                 // iblock_element
                 if (isset($iblockElementColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arIblockElementID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arIblockElementID[] = $value;
                         }
                     }
                 }
                 // iblock_section
                 if (isset($iblockSectionColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arIblockSectionID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arIblockSectionID[] = $value;
                         }
                     }
                 }
             }
         }
     }
     // collect files
     if (count($fileColumns) > 0) {
         if (count($arFileID) > 0) {
             $arFileID = array_unique($arFileID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arFileID);
         $arID = array();
         $file = new CFile();
         foreach ($arFileID as $fileID) {
             $arID[$cnt++] = $fileID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = $file->GetList(array(), array('@ID' => implode(',', $arID)));
                 if (is_object($res)) {
                     while ($arFile = $res->Fetch()) {
                         if ($arFile) {
                             if (array_key_exists("~src", $arFile)) {
                                 if ($arFile["~src"]) {
                                     $arFile["SRC"] = $arFile["~src"];
                                 } else {
                                     $arFile["SRC"] = $file->GetFileSRC($arFile, false, false);
                                 }
                             } else {
                                 $arFile["SRC"] = $file->GetFileSRC($arFile, false);
                             }
                             self::$ufFiles[intval($arFile['ID'])] = $arFile;
                         }
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect disk files
     if (count($diskFileColumns) > 0) {
         if (count($arDiskFileID) > 0) {
             $arDiskFileID = array_unique($arDiskFileID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arDiskFileID);
         $arID = array();
         foreach ($arDiskFileID as $diskFileID) {
             $arID[$cnt++] = $diskFileID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = \Bitrix\Disk\AttachedObject::getList(array('filter' => array('ID' => $arID), 'select' => array('ID', 'NAME' => 'OBJECT.NAME', 'SIZE' => 'OBJECT.SIZE')));
                 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
                 if (is_object($res)) {
                     while ($arDiskFile = $res->Fetch()) {
                         if ($arDiskFile) {
                             $arDiskFile['DOWNLOAD_URL'] = $urlManager->getUrlUfController('download', array('attachedId' => $arDiskFile['ID']));
                             self::$ufDiskFiles[intval($arDiskFile['ID'])] = $arDiskFile;
                         }
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect employees
     if (count($employeeColumns) > 0) {
         if (count($arEmployeeID) > 0) {
             $arEmployeeID = array_unique($arEmployeeID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arEmployeeID);
         $arID = array();
         foreach ($arEmployeeID as $employeeID) {
             $arID[$cnt++] = $employeeID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = \Bitrix\Main\UserTable::getList(array('filter' => array('ID' => $arID), 'select' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'TITLE')));
                 if (is_object($res)) {
                     while ($arUser = $res->fetch()) {
                         self::$ufEmployees[intval($arUser['ID'])] = $arUser;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect crm elements
     if (count($crmColumns) > 0 && CModule::IncludeModule('crm')) {
         foreach ($arCrmID as $typeIndex => $arSubID) {
             if (count($arSubID) > 0) {
                 $arCrmID[$typeIndex] = array_unique($arSubID);
             }
             $i = 0;
             $cnt = 0;
             $stepCnt = 500;
             $nIDs = count($arSubID);
             $arID = array();
             foreach ($arSubID as $crmID) {
                 $arID[$cnt++] = $crmID;
                 $i++;
                 if ($cnt === $stepCnt || $i === $nIDs) {
                     $res = null;
                     switch ($typeIndex) {
                         case 'L':
                             $res = CCrmLead::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'FULL_NAME', 'STATUS_ID'));
                             break;
                         case 'C':
                             $res = CCrmContact::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'FULL_NAME', 'COMPANY_TITLE', 'PHOTO'));
                             break;
                         case 'CO':
                             $res = CCrmCompany::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO'));
                             break;
                         case 'D':
                             $res = CCrmDeal::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'STAGE_ID', 'COMPANY_TITLE', 'CONTACT_FULL_NAME'));
                             break;
                     }
                     if (is_object($res)) {
                         while ($arCrmElement = $res->Fetch()) {
                             self::$ufCrmElements[$typeIndex . '_' . $arCrmElement['ID']] = $arCrmElement;
                         }
                     }
                     $cnt = 0;
                     $arID = array();
                 }
             }
         }
     }
     // collect crm statuses
     if (count($crmStatusColumns) > 0 && CModule::IncludeModule('crm')) {
         foreach ($arCrmStatusID as $entityType => $arSubID) {
             if (count($arSubID) > 0) {
                 $arCrmID[$entityType] = array_unique($arSubID);
             }
             $res = null;
             $res = CCrmStatus::GetStatusList($entityType);
             if (is_array($res) && count($res) > 0) {
                 foreach ($arSubID as $crmStatusID) {
                     if (isset($res[$crmStatusID])) {
                         if (!isset(self::$ufCrmStatuses[$entityType])) {
                             self::$ufCrmStatuses[$entityType] = array();
                         }
                     }
                     self::$ufCrmStatuses[$entityType][$crmStatusID] = $res[$crmStatusID];
                 }
             }
         }
     }
     // collect iblock elements
     if (count($iblockElementColumns) > 0 && CModule::IncludeModule('iblock')) {
         if (count($arIblockElementID) > 0) {
             $arIblockElementID = array_unique($arIblockElementID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arIblockElementID);
         $arID = array();
         foreach ($arIblockElementID as $iblockElementID) {
             $arID[$cnt++] = $iblockElementID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = CIBlockElement::GetList(array('SORT' => 'ASC'), array('=ID' => $arID));
                 if (is_object($res)) {
                     while ($arIblockElement = $res->GetNext()) {
                         self::$ufIblockElements[intval($arIblockElement['ID'])] = $arIblockElement;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect iblock sections
     if (count($iblockSectionColumns) > 0 && CModule::IncludeModule('iblock')) {
         if (count($arIblockSectionID) > 0) {
             $arIblockSectionID = array_unique($arIblockSectionID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arIblockSectionID);
         $arID = array();
         foreach ($arIblockSectionID as $iblockSectionID) {
             $arID[$cnt++] = $iblockSectionID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = CIBlockSection::GetList(array('left_margin' => 'asc'), array('ID' => $arID), false, array('ID', 'NAME', 'SECTION_PAGE_URL'));
                 if (is_object($res)) {
                     while ($arIblockSection = $res->GetNext()) {
                         self::$ufIblockSections[intval($arIblockSection['ID'])] = $arIblockSection;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
 }