Ejemplo n.º 1
0
 public static function PreparePopupItems($currencyID = '', $count = 50, $enableRawPrices = false)
 {
     $currencyID = strval($currencyID);
     if (!isset($currencyID[0])) {
         $currencyID = CCrmCurrency::GetBaseCurrencyID();
     }
     $count = intval($count);
     if ($count <= 0) {
         $count = 50;
     }
     $arSelect = array('ID', 'NAME', 'PRICE', 'CURRENCY_ID');
     $arPricesSelect = $arVatsSelect = array();
     $arSelect = CCrmProduct::DistributeProductSelect($arSelect, $arPricesSelect, $arVatsSelect);
     $rs = CCrmProduct::GetList(array('ID' => 'DESC'), array('ACTIVE' => 'Y', 'CATALOG_ID' => CCrmCatalog::EnsureDefaultExists()), $arSelect, $count);
     $arProducts = array();
     $arProductId = array();
     while ($product = $rs->Fetch()) {
         foreach ($arPricesSelect as $fieldName) {
             $product[$fieldName] = null;
         }
         foreach ($arVatsSelect as $fieldName) {
             $product[$fieldName] = null;
         }
         $arProductId[] = $product['ID'];
         $arProducts[$product['ID']] = $product;
     }
     CCrmProduct::ObtainPricesVats($arProducts, $arProductId, $arPricesSelect, $arVatsSelect, $enableRawPrices);
     $measureInfos = \Bitrix\Crm\Measure::getProductMeasures($arProductId);
     $productVatInfos = CCrmProduct::PrepareCatalogProductFields($arProductId);
     unset($arProductId, $arPricesSelect, $arVatsSelect);
     $defaultMeasureInfo = \Bitrix\Crm\Measure::getDefaultMeasure();
     $result = array();
     foreach ($arProducts as $productID => &$product) {
         if ($currencyID != $product['CURRENCY_ID']) {
             $product['PRICE'] = CCrmCurrency::ConvertMoney($product['PRICE'], $product['CURRENCY_ID'], $currencyID);
             $product['CURRENCY_ID'] = $currencyID;
         }
         $customData = array('price' => $product['PRICE']);
         if (isset($measureInfos[$productID]) && !empty($measureInfos[$productID])) {
             $measureIfo = $measureInfos[$productID][0];
             $customData['measure'] = array('code' => $measureIfo['CODE'], 'name' => $measureIfo['SYMBOL']);
         } elseif ($defaultMeasureInfo !== null) {
             $customData['measure'] = array('code' => $defaultMeasureInfo['CODE'], 'name' => $defaultMeasureInfo['SYMBOL']);
         }
         if (isset($productVatInfos[$productID])) {
             $productVatInfo = $productVatInfos[$productID];
             $customData['tax'] = array('id' => $productVatInfo['TAX_ID'], 'included' => $enableRawPrices && $productVatInfo['TAX_INCLUDED']);
         }
         $result[] = array('title' => $product['NAME'], 'desc' => CCrmProduct::FormatPrice($product), 'id' => $product['ID'], 'url' => '', 'type' => 'product', 'selected' => false, 'customData' => &$customData);
         unset($customData);
     }
     unset($product, $arProducts);
     return $result;
 }
Ejemplo n.º 2
0
 public static function ensureQuotePaySystemsCreated()
 {
     if (!Loader::includeModule('sale')) {
         return;
     }
     $siteID = '';
     $languageID = '';
     $dbSites = \CSite::GetList($by = 'sort', $order = 'desc', array('DEFAULT' => 'Y', 'ACTIVE' => 'Y'));
     $defaultSite = is_object($dbSites) ? $dbSites->Fetch() : null;
     if (is_array($defaultSite)) {
         $siteID = $defaultSite['LID'];
         $languageID = $defaultSite['LANGUAGE_ID'];
     }
     if ($siteID === '') {
         $siteID = 's1';
     }
     if ($languageID === '') {
         $languageID = 'ru';
     }
     $paySysName = "quote_{$languageID}";
     $paySystems = array();
     $customPaySystemPath = \COption::GetOptionString('sale', 'path2user_ps_files', '');
     if ($customPaySystemPath === '') {
         $customPaySystemPath = BX_ROOT . '/php_interface/include/sale_payment/';
     }
     $personTypeIDs = \CCrmPaySystem::getPersonTypeIDs();
     if (isset($personTypeIDs['COMPANY'])) {
         $paySystems[] = array('NAME' => Loc::getMessage('CRM_PS_QUOTE_COMPANY', null, $languageID), 'SORT' => 200, 'DESCRIPTION' => '', 'CODE_TEMP' => $paySysName, 'ACTION' => array(array('PERSON_TYPE_ID' => $personTypeIDs['COMPANY'], 'NAME' => Loc::getMessage('CRM_PS_QUOTE_COMPANY', null, $languageID), 'ACTION_FILE' => "{$customPaySystemPath}{$paySysName}", 'RESULT_FILE' => '', 'NEW_WINDOW' => 'Y', 'PARAMS' => serialize(array('DATE_INSERT' => array('TYPE' => 'ORDER', 'VALUE' => 'DATE_BILL_DATE'), 'DATE_PAY_BEFORE' => array('TYPE' => 'ORDER', 'VALUE' => 'DATE_PAY_BEFORE'), 'BUYER_NAME' => array('TYPE' => 'PROPERTY', 'VALUE' => 'COMPANY'), 'BUYER_INN' => array('TYPE' => 'PROPERTY', 'VALUE' => 'INN'), 'BUYER_ADDRESS' => array('TYPE' => 'PROPERTY', 'VALUE' => 'COMPANY_ADR'), 'BUYER_PHONE' => array('TYPE' => 'PROPERTY', 'VALUE' => 'PHONE'), 'BUYER_FAX' => array('TYPE' => 'PROPERTY', 'VALUE' => 'FAX'), 'BUYER_PAYER_NAME' => array('TYPE' => 'PROPERTY', 'VALUE' => 'CONTACT_PERSON'), 'COMMENT1' => array('TYPE' => 'ORDER', 'VALUE' => 'USER_DESCRIPTION'))), 'HAVE_PAYMENT' => 'Y', 'HAVE_ACTION' => 'N', 'HAVE_RESULT' => 'N', 'HAVE_PREPAY' => 'N', 'HAVE_RESULT_RECEIVE' => 'N')));
     }
     if (isset($personTypeIDs['CONTACT'])) {
         $paySystems[] = array('NAME' => Loc::getMessage('CRM_PS_QUOTE_CONTACT', null, $languageID), 'SORT' => 300, 'DESCRIPTION' => '', 'CODE_TEMP' => $paySysName, 'ACTION' => array(array('PERSON_TYPE_ID' => $personTypeIDs['CONTACT'], 'NAME' => Loc::getMessage('CRM_PS_QUOTE_CONTACT', null, $languageID), 'ACTION_FILE' => "{$customPaySystemPath}{$paySysName}", 'RESULT_FILE' => '', 'NEW_WINDOW' => 'Y', 'PARAMS' => serialize(array('DATE_INSERT' => array('TYPE' => 'ORDER', 'VALUE' => 'DATE_BILL_DATE'), 'DATE_PAY_BEFORE' => array('TYPE' => 'ORDER', 'VALUE' => 'DATE_PAY_BEFORE'), 'BUYER_NAME' => array('TYPE' => 'PROPERTY', 'VALUE' => 'FIO'), 'BUYER_INN' => array('TYPE' => 'PROPERTY', 'VALUE' => 'INN'), 'BUYER_ADDRESS' => array('TYPE' => 'PROPERTY', 'VALUE' => 'ADDRESS'), 'BUYER_PHONE' => array('TYPE' => 'PROPERTY', 'VALUE' => 'PHONE'), 'BUYER_FAX' => array('TYPE' => '', 'VALUE' => ''), 'BUYER_PAYER_NAME' => array('TYPE' => 'PROPERTY', 'VALUE' => 'FIO'), 'COMMENT1' => array('TYPE' => 'ORDER', 'VALUE' => 'USER_DESCRIPTION'))), 'HAVE_PAYMENT' => 'Y', 'HAVE_ACTION' => 'N', 'HAVE_RESULT' => 'N', 'HAVE_PREPAY' => 'N', 'HAVE_RESULT_RECEIVE' => 'N')));
     }
     $currencyID = \CCrmCurrency::GetBaseCurrencyID();
     foreach ($paySystems as $paySystem) {
         $dbSalePaySystem = \CSalePaySystem::GetList(array(), array('LID' => $siteID, 'NAME' => $paySystem['NAME']), false, false, array('ID'));
         if (!$dbSalePaySystem->Fetch()) {
             $paySystemID = \CSalePaySystem::Add(array('NAME' => $paySystem['NAME'], 'DESCRIPTION' => $paySystem['DESCRIPTION'], 'SORT' => $paySystem['SORT'], 'LID' => $siteID, 'CURRENCY' => $currencyID, 'ACTIVE' => 'Y'));
             if ($paySystemID > 0) {
                 foreach ($paySystem['ACTION'] as &$action) {
                     $action['PAY_SYSTEM_ID'] = $paySystemID;
                     \CSalePaySystemAction::Add($action);
                 }
                 unset($action);
             }
         }
     }
     unset($paySystem);
 }
Ejemplo n.º 3
0
 private static function ConvertMoney($sum, $srcCurrencyID, $dstCurrencyID)
 {
     if (CModule::IncludeModule('currency')) {
         return CCrmCurrency::ConvertMoney($sum, $srcCurrencyID, $dstCurrencyID);
     }
     $exchRate = 1.0;
     // Using hardcoded exchange rates for Rub
     if ($srcCurrencyID === 'RUB') {
         if ($dstCurrencyID === 'EUR') {
             $exchRate = 39.4;
         } elseif ($dstCurrencyID === 'USD') {
             $exchRate = 31.0;
         } elseif ($dstCurrencyID === 'UAH') {
             $exchRate = 3.9;
         }
     }
     return round($sum / $exchRate, 2);
 }
Ejemplo n.º 4
0
 public static function PrepareAccountingData($arFields)
 {
     $accountCurrencyID = CCrmCurrency::GetAccountCurrencyID();
     if (!isset($accountCurrencyID[0])) {
         return false;
     }
     $currencyID = isset($arFields['CURRENCY_ID']) ? strval($arFields['CURRENCY_ID']) : '';
     if (!CCrmCurrency::GetByID($currencyID)) {
         // Currency is invalid or not assigned
         return false;
     }
     if ($currencyID === $accountCurrencyID) {
         // Avoid conversion to float since possible data lost
         return array('ACCOUNT_CURRENCY_ID' => $accountCurrencyID, 'ACCOUNT_SUM' => isset($arFields['SUM']) ? $arFields['SUM'] : 0.0);
     }
     $account = CCrmCurrency::ConvertMoney(isset($arFields['SUM']) ? doubleval($arFields['SUM']) : 0.0, $currencyID, $accountCurrencyID, isset($arFields['EXCH_RATE']) ? doubleval($arFields['EXCH_RATE']) : -1);
     return array('ACCOUNT_CURRENCY_ID' => $accountCurrencyID, 'ACCOUNT_SUM' => $account);
 }
Ejemplo n.º 5
0
 public static function AddLead($arData, $CCrmLead)
 {
     global $DB, $USER_FIELD_MANAGER;
     $CCrmBizProc = new CCrmBizProc('LEAD');
     $arData['CURRENCY_ID'] = trim($arData['CURRENCY_ID']);
     if (strlen($arData['CURRENCY_ID']) <= 0) {
         $arData['CURRENCY_ID'] = CCrmCurrency::GetBaseCurrencyID();
     }
     $arFields = array('TITLE' => trim($arData['TITLE']), 'COMPANY_TITLE' => trim($arData['COMPANY_TITLE']), 'NAME' => trim($arData['NAME']), 'LAST_NAME' => trim($arData['LAST_NAME']), 'SECOND_NAME' => trim($arData['SECOND_NAME']), 'POST' => trim($arData['POST']), 'ADDRESS' => trim($arData['ADDRESS']), 'COMMENTS' => trim($arData['COMMENTS']), 'SOURCE_DESCRIPTION' => trim($arData['SOURCE_DESCRIPTION']), 'STATUS_DESCRIPTION' => trim($arData['STATUS_DESCRIPTION']), 'OPPORTUNITY' => trim($arData['OPPORTUNITY']), 'CURRENCY_ID' => trim($arData['CURRENCY_ID']), 'ASSIGNED_BY_ID' => (int) (is_array($arData['ASSIGNED_BY_ID']) ? $arData['ASSIGNED_BY_ID'][0] : $arData['ASSIGNED_BY_ID']), 'OPENED' => 'Y');
     $arData['SOURCE_ID'] = trim($arData['SOURCE_ID']);
     $arData['STATUS_ID'] = trim($arData['STATUS_ID']);
     if (strlen($arData['STATUS_ID']) > 0) {
         $arFields['STATUS_ID'] = $arData['STATUS_ID'];
     }
     if (strlen($arData['SOURCE_ID']) > 0) {
         $arFields['SOURCE_ID'] = $arData['SOURCE_ID'];
     }
     $USER_FIELD_MANAGER->EditFormAddFields(CCrmLead::$sUFEntityID, $arFields);
     $CCrmUserType = new CCrmUserType($USER_FIELD_MANAGER, CCrmLead::$sUFEntityID);
     $CCrmUserType->PrepareImport($arFields, ',');
     $arFields['FM'] = CCrmFieldMulti::PrepareFields($arData);
     $DB->StartTransaction();
     $ID = $CCrmLead->Add($arFields);
     if ($ID === false) {
         $DB->Rollback();
         if (!empty($arFields['RESULT_MESSAGE'])) {
             $sErrorMessage = $arFields['RESULT_MESSAGE'];
         } else {
             $sErrorMessage = GetMessage('UNKNOWN_ERROR');
         }
         $res = array('error' => 400, 'error_message' => strip_tags(nl2br($sErrorMessage)));
     } else {
         $DB->Commit();
         // Ignore all BizProc errors
         try {
             $arErrors = array();
             CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Lead, $ID, CCrmBizProcEventType::Create, $arErrors);
         } catch (Exception $e) {
         }
         $res = array('error' => 201, 'ID' => $ID, 'error_message' => GetMessage('CRM_REST_OK'));
     }
     return self::_out($res);
 }
Ejemplo n.º 6
0
    public function showField($arField, $arUF = array())
    {
        $strResult = "";
        switch ($arField["FORMAT"]) {
            case "LEAD_PROGRESS":
                if (!empty($arField["VALUE"])) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">';
                    $strResult .= CCrmViewHelper::RenderLeadStatusControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Lead, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Lead, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true));
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "DEAL_PROGRESS":
                if (!empty($arField["VALUE"])) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">';
                    $strResult .= CCrmViewHelper::RenderDealStageControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Deal, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Deal, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true));
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "INVOICE_PROGRESS":
                if (!empty($arField["VALUE"])) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">';
                    $strResult .= CCrmViewHelper::RenderInvoiceStatusControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Invoice, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Invoice, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true));
                    $strResult .= "</span>";
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "LEAD_STATUS":
                $infos = CCrmStatus::GetStatus('STATUS');
                if (!empty($arField["VALUE"]) && array_key_exists($arField["VALUE"], $infos)) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= $infos[$arField["VALUE"]]["NAME"];
                    $strResult .= "</span>";
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "PERSON_NAME":
                if (is_array($arField["VALUE"])) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= CUser::FormatName(CSite::GetNameFormat(), $arField["VALUE"]);
                    $strResult .= "</span>";
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "PERSON_ID":
                if (intval($arField["VALUE"]) > 0) {
                    $dbUser = CUser::GetByID(intval($arField["VALUE"]));
                    if ($arUser = $dbUser->GetNext()) {
                        $strResult .= "#row_begin#";
                        $strResult .= "#cell_begin_left#";
                        $strResult .= $arField["TITLE"] . ":";
                        $strResult .= "#cell_end#";
                        $strResult .= "#cell_begin_right#";
                        if ($arUser["PERSONAL_PHOTO"] > 0) {
                            $arFileTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                        }
                        $strUser = "";
                        $strUser .= '<div class="feed-com-avatar crm-feed-company-avatar">';
                        if (is_array($arFileTmp) && isset($arFileTmp['src'])) {
                            if (strlen($this->params["PATH_TO_USER"]) > 0) {
                                $strUser .= '<a target="_blank" href="' . str_replace(array("#user_id#", "#USER_ID#"), intval($arField["VALUE"]), $this->params["PATH_TO_USER"]) . '"><img src="' . $arFileTmp['src'] . '" alt=""/></a>';
                            } else {
                                $strUser .= '<img src="' . $arFileTmp['src'] . '" alt=""/>';
                            }
                        }
                        $strUser .= '</div>';
                        if (strlen($this->params["PATH_TO_USER"]) > 0) {
                            $strUser .= '<a class="crm-detail-info-resp-name" target="_blank" href="' . str_replace(array("#user_id#", "#USER_ID#"), intval($arField["VALUE"]), $this->params["PATH_TO_USER"]) . '">' . CUser::FormatName(CSite::GetNameFormat(), $arUser, true, false) . '</a>';
                        } else {
                            $strUser .= '<span class="crm-detail-info-resp-name">' . CUser::FormatName(CSite::GetNameFormat(), $arUser, true, false) . '</span>';
                        }
                        if (strlen($arUser["WORK_POSITION"]) > 0) {
                            $strUser .= '<span class="crm-detail-info-resp-descr">' . $arUser["WORK_POSITION"] . '</span>';
                        }
                        $strResult .= '<span class="crm-detail-info-resp">' . $strUser . '</span>';
                        $strResult .= "#cell_end#";
                        $strResult .= "#row_end#";
                    }
                }
                break;
            case "COMPANY_ID":
                if (intval($arField["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMPANY_TYPE":
                $infos = CCrmStatus::GetStatusListEx('COMPANY_TYPE');
                if (!empty($arField["VALUE"]) && array_key_exists($arField["VALUE"], $infos)) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= $infos[$arField["VALUE"]];
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "CONTACT_ID":
                if (intval($arField["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<div class="crm-feed-client-block">';
                    $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">';
                    $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arField["VALUE"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO'));
                    if (($arRes = $dbRes->Fetch()) && intval($arRes["PHOTO"]) > 0) {
                        $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                        if (is_array($arFileTmp) && isset($arFileTmp["src"])) {
                            $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">';
                        }
                    }
                    $strResult .= '</span>';
                    $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                    $strResult .= '</div>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMBI_CLIENT":
                if (is_array($arField["VALUE"]) && (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0 || array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0 || array_key_exists("COMPANY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["COMPANY_ID"]) > 0)) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    if (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0 || array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0) {
                        if (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0) {
                            $strResult .= '<div class="crm-feed-client-block">';
                            $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">';
                            $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arField["VALUE"]["CONTACT_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO', 'COMPANY_ID'));
                            if ($arRes = $dbRes->Fetch()) {
                                $contactCompanyID = $arRes['COMPANY_ID'];
                                if (intval($arRes["PHOTO"]) > 0) {
                                    $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                                    if (is_array($arFileTmp) && isset($arFileTmp["src"])) {
                                        $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">';
                                    }
                                }
                            }
                            $strResult .= '</span>';
                            $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $arField["VALUE"]["CONTACT_ID"], 'PREFIX' => '', 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                        } else {
                            $strResult .= '<div class="crm-feed-client-block">';
                            $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">';
                            if (intval($arField['VALUE']['PHOTO_ID']) > 0) {
                                $arFileTmp = CFile::ResizeImageGet($arField['VALUE']['PHOTO_ID'], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                                if (is_array($arFileTmp) && isset($arFileTmp["src"])) {
                                    $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">';
                                }
                            }
                            $strResult .= '</span>';
                            if (array_key_exists("ENTITY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["ENTITY_ID"]) > 0) {
                                $url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Contact, $arField["VALUE"]["ENTITY_ID"], true);
                            }
                            $clientName = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($arField['VALUE']['HONORIFIC']) ? $arField['VALUE']['HONORIFIC'] : '', 'NAME' => isset($arField['VALUE']['CONTACT_NAME']) ? $arField['VALUE']['CONTACT_NAME'] : '', 'LAST_NAME' => isset($arField['VALUE']['CONTACT_LAST_NAME']) ? $arField['VALUE']['CONTACT_LAST_NAME'] : '', 'SECOND_NAME' => isset($arField['VALUE']['CONTACT_SECOND_NAME']) ? $arField['VALUE']['CONTACT_SECOND_NAME'] : ''));
                            $strResult .= strlen($url) > 0 ? '<a href="' . $url . '" class="crm-feed-client-name">' . $clientName . '</a>' : $clientName;
                        }
                        $strResult .= '<span class="crm-feed-client-company">';
                        $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => array_key_exists("COMPANY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["COMPANY_ID"]) > 0 ? $arField["VALUE"]["COMPANY_ID"] : intval($contactCompanyID), 'PREFIX' => '', 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                        $strResult .= '</span>';
                        $strResult .= '</div>';
                    } else {
                        $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $arField["VALUE"]["COMPANY_ID"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                    }
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMBI_COMPANY":
                if (is_array($arField["VALUE"]) && (array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0)) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Company, $arField["VALUE"]["ENTITY_ID"]);
                    if (intval($arField['VALUE']['LOGO_ID']) > 0) {
                        $arFileTmp = CFile::ResizeImageGet($arField['VALUE']['LOGO_ID'], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                    }
                    if (is_array($arFileTmp) && isset($arFileTmp['src'])) {
                        $strResult .= '<a class="crm-feed-user-block" href="' . $url . '">';
                        $strResult .= '<span class="feed-com-avatar crm-feed-company-avatar">';
                        $strResult .= '<img width="39" height="39" alt="" src="' . $arFileTmp['src'] . '">';
                        $strResult .= '</span>';
                        $strResult .= '<span class="crm-feed-user-name">' . $arField["VALUE"]["TITLE"] . '</span>';
                        $strResult .= '</a>';
                    } else {
                        $strResult .= '<a class="crm-feed-info-link" href="' . $url . '">' . $arField["VALUE"]["TITLE"] . '</a>';
                    }
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMBI_CLIENT_NAME":
                if (is_array($arField["VALUE"]) && (array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0 || array_key_exists("COMPANY_TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["COMPANY_TITLE"]) > 0)) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    if (array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0) {
                        $strResult .= '<div class="crm-feed-client-block">';
                        $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar"></span>';
                        $strResult .= CCrmContact::PrepareFormattedName(array("HONORIFIC" => $arField["VALUE"]["HONORIFIC"], "NAME" => $arField["VALUE"]["CONTACT_NAME"], "LAST_NAME" => $arField["VALUE"]["CONTACT_LAST_NAME"], "SECOND_NAME" => $arField["VALUE"]["CONTACT_SECOND_NAME"]));
                        $strResult .= '<span class="crm-feed-client-company">' . (strlen($arField["VALUE"]["COMPANY_TITLE"]) > 0 ? $arField["VALUE"]["COMPANY_TITLE"] : "") . '</span>';
                        $strResult .= '</div>';
                    } else {
                        $strResult .= $arField["VALUE"]["COMPANY_TITLE"];
                    }
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "DEAL_ID":
                if (intval($arField["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Deal, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N'));
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMMUNICATIONS":
                if (is_array($arField["VALUE"]) && count($arField["VALUE"]) > 0) {
                    $arCommunication = $arField["VALUE"][0];
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<div class="crm-feed-client-block">';
                    if (in_array($arCommunication["ENTITY_TYPE_ID"], array(CCrmOwnerType::Company, CCrmOwnerType::Contact, CCrmOwnerType::Lead))) {
                        $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">';
                        if ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Contact) {
                            $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arCommunication["ENTITY_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO'));
                            if (($arRes = $dbRes->Fetch()) && intval($arRes["PHOTO"]) > 0) {
                                $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false);
                                if (is_array($arFileTmp) && isset($arFileTmp["src"])) {
                                    $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">';
                                }
                            }
                        } elseif ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Company) {
                            $dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $arCommunication["ENTITY_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('LOGO'));
                            if (($arRes = $dbRes->Fetch()) && intval($arRes["LOGO"]) > 0) {
                                $arFileTmp = CFile::ResizeImageGet($arRes["LOGO"], array('width' => 30, 'height' => 30), BX_RESIZE_IMAGE_EXACT, false);
                                if (is_array($arFileTmp) && isset($arFileTmp["src"])) {
                                    $strResult .= '<img width="30" height="30" src="' . $arFileTmp['src'] . '" alt="">';
                                }
                            }
                        }
                        $strResult .= '</span>';
                    }
                    $arBaloonFields = array('ENTITY_TYPE_ID' => $arCommunication["ENTITY_TYPE_ID"], 'ENTITY_ID' => $arCommunication["ENTITY_ID"], 'PREFIX' => "", 'CLASS_NAME' => 'crm-feed-client-name', 'CHECK_PERMISSIONS' => 'N');
                    if ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Lead && is_array($arCommunication["ENTITY_SETTINGS"])) {
                        $arBaloonFields["TITLE"] = isset($arCommunication["ENTITY_SETTINGS"]["LEAD_TITLE"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["LEAD_TITLE"]) : "";
                        $arBaloonFields["NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["NAME"]) : "";
                        $arBaloonFields["LAST_NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["LAST_NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["LAST_NAME"]) : "";
                        $arBaloonFields["SECOND_NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["SECOND_NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["SECOND_NAME"]) : "";
                    }
                    $strResult .= '<div>' . CCrmViewHelper::PrepareEntityBaloonHtml($arBaloonFields) . '</div>';
                    switch ($arCommunication["TYPE"]) {
                        case 'EMAIL':
                            $strResult .= '<div><a href="mailto:' . $arCommunication["VALUE"] . '" class="crm-feed-client-phone">' . $arCommunication["VALUE"] . '</div>';
                            break;
                        case 'PHONE':
                            if (CCrmSipHelper::isEnabled()) {
                                ob_start();
                                ?>
								<script type="text/javascript">
								if (typeof (window.bSipManagerUrlDefined_<?php 
                                echo $arCommunication["ENTITY_TYPE_ID"];
                                ?>
) === 'undefined')
								{
									window.bSipManagerUrlDefined_<?php 
                                echo $arCommunication["ENTITY_TYPE_ID"];
                                ?>
 = true;
									BX.ready(
										function()
										{
											var mgr = BX.CrmSipManager.getCurrent();
											mgr.setServiceUrl(
												"CRM_<?php 
                                echo CUtil::JSEscape(CCrmOwnerType::ResolveName($arCommunication["ENTITY_TYPE_ID"]));
                                ?>
",
												"<?php 
                                echo CUtil::JSEscape($this->arSipServiceUrl[$arCommunication["ENTITY_TYPE_ID"]]);
                                ?>
"
											);

											if(typeof(BX.CrmSipManager.messages) === 'undefined')
											{
												BX.CrmSipManager.messages =
												{
													"unknownRecipient": "<?php 
                                echo GetMessageJS('CRM_LF_SIP_MGR_UNKNOWN_RECIPIENT');
                                ?>
",
													"enableCallRecording": "<?php 
                                echo GetMessageJS('CRM_LF_SIP_MGR_ENABLE_CALL_RECORDING');
                                ?>
",
													"makeCall": "<?php 
                                echo GetMessageJS('CCRM_LF_SIP_MGR_MAKE_CALL');
                                ?>
"
												};
											}
										}
									);
								}
								</script>
								<?php 
                                $strResult .= ob_get_contents();
                                ob_end_clean();
                            }
                            $strResult .= '<div><span class="crm-feed-num-block">' . CCrmViewHelper::PrepareMultiFieldHtml('PHONE', array('VALUE' => $arCommunication["VALUE"], 'VALUE_TYPE_ID' => 'WORK'), array('ENABLE_SIP' => true, 'SIP_PARAMS' => array('ENTITY_TYPE' => 'CRM_' . CCrmOwnerType::ResolveName($arCommunication["ENTITY_TYPE_ID"]), 'ENTITY_ID' => $arCommunication["ENTITY_ID"]))) . '</span></div>';
                            if (defined("BX_COMP_MANAGED_CACHE")) {
                                $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_CALLTO_SETTINGS");
                            }
                            break;
                    }
                    $strResult .= '<span class="crm-feed-client-company">' . (is_array($arCommunication["ENTITY_SETTINGS"]) && isset($arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"]) ? $arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"] : "") . '</span>';
                    $strResult .= '</div>';
                    $moreCnt = count($arField["VALUE"]) - 1;
                    if ($moreCnt > 0) {
                        $strResult .= "#clients_more_link#";
                    }
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "AVATAR_ID":
                if (intval($arField["VALUE"]) > 0) {
                    $arFileTmp = CFile::ResizeImageGet($arField["VALUE"], array('width' => $this->params["AVATAR_SIZE"], 'height' => $this->params["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT, false);
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= '<img src="' . $arFileTmp["src"] . '" border="0" alt="' . $this->params["AVATAR_SIZE"] . '" width="" height="' . $this->params["AVATAR_SIZE"] . '">';
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "SUM":
                if (intval($arField["VALUE"]["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= '<span class="crm-feed-info-sum">' . CCrmCurrency::MoneyToString($arField["VALUE"]["VALUE"], $arField["VALUE"]["CURRENCY"]) . '</span>';
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "PHONE":
            case "EMAIL":
                if (!empty($arField["VALUE"])) {
                    $infos = CCrmFieldMulti::GetEntityTypes();
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= CCrmViewHelper::PrepareFirstMultiFieldHtml($arField["FORMAT"], $arField["VALUE"], $infos[$arField["FORMAT"]]);
                    if (count($arField["VALUE"]) > 1 || !empty($arField["VALUE"]["WORK"]) && count($arField["VALUE"]["WORK"]) > 1 || !empty($arField["VALUE"]["MOBILE"]) && count($arField["VALUE"]["MOBILE"]) > 1 || !empty($arField["VALUE"]["FAX"]) && count($arField["VALUE"]["FAX"]) > 1 || !empty($arField["VALUE"]["PAGER"]) && count($arField["VALUE"]["PAGER"]) > 1 || !empty($arField["VALUE"]["OTHER"]) && count($arField["VALUE"]["OTHER"]) > 1) {
                        $anchorID = strtolower($arField["FORMAT"]);
                        $strResult .= '<span style="margin-left: 10px;" class="crm-item-tel-list" id="' . htmlspecialcharsbx($anchorID) . '"' . ' onclick="' . CCrmViewHelper::PrepareMultiFieldValuesPopup($anchorID, $anchorID, $arField["FORMAT"], $arField["VALUE"], $infos[$arField["FORMAT"]]) . '"></span>';
                    }
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                    if ($arField["FORMAT"] == "PHONE" && defined("BX_COMP_MANAGED_CACHE")) {
                        $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_CALLTO_SETTINGS");
                    }
                }
                break;
            case "TEXT_FORMATTED":
            case "TEXT_FORMATTED_BOLD":
                if ($arField["VALUE"] != CCrmLiveFeed::UntitledMessageStub) {
                    $text_formatted = $this->ParseText(htmlspecialcharsback($arField["VALUE"]), $arUF, $arParams["PARAMS"]);
                    if (strlen($text_formatted) > 0) {
                        $strResult .= "#row_begin#";
                        $strResult .= "#cell_begin_colspan2#";
                        if ($arField["FORMAT"] == "TEXT_FORMATTED_BOLD") {
                            $strResult .= "<b>" . $text_formatted . "</b>";
                        } else {
                            $strResult .= $text_formatted;
                        }
                        $strResult .= "#cell_end#";
                        $strResult .= "#row_end#";
                    }
                }
                break;
            case "COMBI_TITLE":
                if (is_array($arField["VALUE"]) && array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    if (array_key_exists("URL", $arField["VALUE"]) && strlen($arField["VALUE"]["URL"]) > 0) {
                        $strResult .= '<a href="' . $arField["VALUE"]["URL"] . '">' . $arField["VALUE"]["TITLE"] . '</a>';
                    } elseif (array_key_exists("ONCLICK", $arField["VALUE"]) && strlen($arField["VALUE"]["ONCLICK"]) > 0) {
                        $strResult .= '<a href="javascript:void(0)" onclick="' . $arField["VALUE"]["ONCLICK"] . '">' . $arField["VALUE"]["TITLE"] . '</a>';
                    } else {
                        $strResult .= $arField["VALUE"]["TITLE"];
                    }
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "COMBI_TITLE_ID":
                if (is_array($arField["VALUE"]) && array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0 && array_key_exists("ID", $arField["VALUE"]) && strlen($arField["VALUE"]["ID"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    if (array_key_exists("URL", $arField["VALUE"]) && strlen($arField["VALUE"]["URL"]) > 0) {
                        $strResult .= '<a href="' . $arField["VALUE"]["URL"] . '">' . GetMessage("C_CRM_LF_COMBI_TITLE_ID_VALUE", array("#ID#" => $arField["VALUE"]["ID"], "#TITLE#" => $arField["VALUE"]["TITLE"])) . '</a>';
                    } else {
                        $strResult .= GetMessage("C_CRM_LF_COMBI_TITLE_ID_VALUE", array("#ID#" => $arField["VALUE"]["ID"], "#TITLE#" => $arField["VALUE"]["TITLE"]));
                    }
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "TEXT_ADD":
                if (strlen($arField["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= '<span class="crm-feed-info-name">' . $arField["VALUE"] . '</span>';
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
                break;
            case "TEXT":
            default:
                if (strlen($arField["VALUE"]) > 0) {
                    $strResult .= "#row_begin#";
                    $strResult .= "#cell_begin_left#";
                    $strResult .= $arField["TITLE"] . ":";
                    $strResult .= "#cell_end#";
                    $strResult .= "#cell_begin_right#";
                    $strResult .= '<span class="crm-feed-info-text-padding">';
                    $strResult .= $arField["VALUE"];
                    $strResult .= '</span>';
                    $strResult .= "#cell_end#";
                    $strResult .= "#row_end#";
                }
        }
        return $strResult;
    }
Ejemplo n.º 7
0
     $bSep = false;
     if ($arResult['PERMS']['ADD'] && $arLead['STATUS_ID'] != 'CONVERTED') {
         if ($arResult['CONVERT']) {
             $bSep = true;
             $arActions[] = array('SEPARATOR' => true);
             $arActions[] = array('ICONCLASS' => 'convert', 'TITLE' => GetMessage('CRM_LEAD_CONVERT_TITLE'), 'TEXT' => GetMessage('CRM_LEAD_CONVERT'), 'ONCLICK' => "jsUtils.Redirect([], '" . CUtil::JSEscape($arLead['PATH_TO_LEAD_CONVERT']) . "');");
         }
     }
 }
 if ($arLead['DELETE']) {
     if (!$bSep) {
         $arActions[] = array('SEPARATOR' => true);
     }
     $arActions[] = array('ICONCLASS' => 'delete', 'TITLE' => GetMessage('CRM_LEAD_DELETE_TITLE'), 'TEXT' => GetMessage('CRM_LEAD_DELETE'), 'ONCLICK' => "crm_lead_delete_grid('" . CUtil::JSEscape(GetMessage('CRM_LEAD_DELETE_TITLE')) . "', '" . CUtil::JSEscape(GetMessage('CRM_LEAD_DELETE_CONFIRM')) . "', '" . CUtil::JSEscape(GetMessage('CRM_LEAD_DELETE')) . "', '" . CUtil::JSEscape($arLead['PATH_TO_LEAD_DELETE']) . "')");
 }
 $resultItem = array('id' => $arLead['ID'], 'actions' => $arActions, 'data' => $arLead, 'editable' => !$arLead['EDIT'] ? $arColumns : true, 'columns' => array('LEAD_SUMMARY' => CCrmViewHelper::RenderInfo($arLead['PATH_TO_LEAD_SHOW'], isset($arLead['TITLE']) ? $arLead['TITLE'] : '[' . $arLead['ID'] . ']', $arLead['LEAD_SOURCE_NAME'], '_self'), 'ACTIVITY_ID' => CCrmViewHelper::RenderNearestActivity(array('ENTITY_TYPE_NAME' => CCrmOwnerType::ResolveName(CCrmOwnerType::Lead), 'ENTITY_ID' => $arLead['ID'], 'GRID_MANAGER_ID' => $gridManagerID, 'ACTIVITY_ID' => isset($arLead['~ACTIVITY_ID']) ? intval($arLead['~ACTIVITY_ID']) : 0, 'ACTIVITY_SUBJECT' => isset($arLead['~ACTIVITY_SUBJECT']) ? $arLead['~ACTIVITY_SUBJECT'] : '', 'ACTIVITY_TIME' => isset($arLead['~ACTIVITY_TIME']) ? $arLead['~ACTIVITY_TIME'] : '', 'ACTIVITY_EXPIRED' => isset($arLead['~ACTIVITY_EXPIRED']) ? $arLead['~ACTIVITY_EXPIRED'] : false, 'MENU_ITEMS' => $arActivityMenuItems)), 'COMMENTS' => htmlspecialcharsback($arLead['COMMENTS']), 'ADDRESS' => nl2br($arLead['ADDRESS']), 'ASSIGNED_BY' => $arLead['~ASSIGNED_BY'] > 0 ? '<a href="' . $arLead['PATH_TO_USER_PROFILE'] . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '">' . $arLead['ASSIGNED_BY'] . '</a>' . '<script type="text/javascript">BX.tooltip(' . $arLead['~ASSIGNED_BY'] . ', "balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '", "");</script>' : '', 'STATUS_DESCRIPTION' => nl2br($arLead['STATUS_DESCRIPTION']), 'SOURCE_DESCRIPTION' => nl2br($arLead['SOURCE_DESCRIPTION']), 'DATE_CREATE' => '<nobr>' . FormatDate('SHORT', MakeTimeStamp($arLead['DATE_CREATE'])) . '</nobr>', 'DATE_MODIFY' => '<nobr>' . FormatDate('SHORT', MakeTimeStamp($arLead['DATE_MODIFY'])) . '</nobr>', 'SUM' => '<nobr>' . $arLead['FORMATTED_OPPORTUNITY'] . '</nobr>', 'OPPORTUNITY' => '<nobr>' . $arLead['~OPPORTUNITY'] . '</nobr>', 'CURRENCY_ID' => CCrmCurrency::GetCurrencyName($arLead['~CURRENCY_ID']), 'PRODUCT_ID' => isset($arLead['PRODUCT_ROWS']) ? htmlspecialcharsbx(CCrmProductRow::RowsToString($arLead['PRODUCT_ROWS'])) : '', 'STATUS_ID' => CCrmViewHelper::RenderLeadStatusControl(array('PREFIX' => "{$arResult['GRID_ID']}_PROGRESS_BAR_", 'ENTITY_ID' => $arLead['~ID'], 'CURRENT_ID' => $arLead['~STATUS_ID'], 'SERVICE_URL' => '/bitrix/components/bitrix/crm.lead.list/list.ajax.php', 'LEAD_CONVERT_URL' => $arLead['PATH_TO_LEAD_CONVERT'], 'READ_ONLY' => !(isset($arLead['EDIT']) && $arLead['EDIT'] === true))), 'SOURCE_ID' => $arLead['LEAD_SOURCE_NAME'], 'CREATED_BY' => $arLead['~CREATED_BY'] > 0 ? '<a href="' . $arLead['PATH_TO_USER_CREATOR'] . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '">' . $arLead['CREATED_BY_FORMATTED_NAME'] . '</a>' . '<script type="text/javascript">BX.tooltip(' . $arLead['~CREATED_BY'] . ', "balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '", "");</script>' : '', 'MODIFY_BY' => $arLead['~MODIFY_BY'] > 0 ? '<a href="' . $arLead['PATH_TO_USER_MODIFIER'] . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '">' . $arLead['MODIFY_BY_FORMATTED_NAME'] . '</a>' . '<script type="text/javascript">BX.tooltip(' . $arLead['~MODIFY_BY'] . ', "balloon_' . $arResult['GRID_ID'] . '_' . $arLead['ID'] . '", "");</script>' : '') + CCrmViewHelper::RenderListMultiFields($arLead, "LEAD_{$arLead['ID']}_", array('ENABLE_SIP' => true, 'SIP_PARAMS' => array('ENTITY_TYPE' => 'CRM_' . CCrmOwnerType::LeadName, 'ENTITY_ID' => $arLead['ID']))) + $arResult['LEAD_UF'][$sKey]);
 if (isset($arLead['~BIRTHDATE'])) {
     $resultItem['columns']['BIRTHDATE'] = '<nobr>' . FormatDate('SHORT', MakeTimeStamp($arLead['~BIRTHDATE'])) . '</nobr>';
 }
 $userActivityID = isset($arLead['~ACTIVITY_ID']) ? intval($arLead['~ACTIVITY_ID']) : 0;
 $commonActivityID = isset($arLead['~C_ACTIVITY_ID']) ? intval($arLead['~C_ACTIVITY_ID']) : 0;
 if ($userActivityID > 0) {
     $resultItem['columns']['ACTIVITY_ID'] = CCrmViewHelper::RenderNearestActivity(array('ENTITY_TYPE_NAME' => CCrmOwnerType::ResolveName(CCrmOwnerType::Lead), 'ENTITY_ID' => $arLead['~ID'], 'ENTITY_RESPONSIBLE_ID' => $arLead['~ASSIGNED_BY'], 'GRID_MANAGER_ID' => $gridManagerID, 'ACTIVITY_ID' => $userActivityID, 'ACTIVITY_SUBJECT' => isset($arLead['~ACTIVITY_SUBJECT']) ? $arLead['~ACTIVITY_SUBJECT'] : '', 'ACTIVITY_TIME' => isset($arLead['~ACTIVITY_TIME']) ? $arLead['~ACTIVITY_TIME'] : '', 'ACTIVITY_EXPIRED' => isset($arLead['~ACTIVITY_EXPIRED']) ? $arLead['~ACTIVITY_EXPIRED'] : '', 'ALLOW_EDIT' => $arLead['EDIT'], 'MENU_ITEMS' => $arActivityMenuItems));
     $counterData = array('CURRENT_USER_ID' => $currentUserID, 'ENTITY' => $arLead, 'ACTIVITY' => array('RESPONSIBLE_ID' => $currentUserID, 'TIME' => isset($arLead['~ACTIVITY_TIME']) ? $arLead['~ACTIVITY_TIME'] : '', 'IS_CURRENT_DAY' => isset($arLead['~ACTIVITY_IS_CURRENT_DAY']) ? $arLead['~ACTIVITY_IS_CURRENT_DAY'] : false));
     if (CCrmUserCounter::IsReckoned(CCrmUserCounter::CurrentLeadActivies, $counterData)) {
         $resultItem['columnClasses'] = array('ACTIVITY_ID' => 'crm-list-deal-today');
     }
 } elseif ($commonActivityID > 0) {
     $resultItem['columns']['ACTIVITY_ID'] = CCrmViewHelper::RenderNearestActivity(array('ENTITY_TYPE_NAME' => CCrmOwnerType::ResolveName(CCrmOwnerType::Lead), 'ENTITY_ID' => $arLead['~ID'], 'ENTITY_RESPONSIBLE_ID' => $arLead['~ASSIGNED_BY'], 'GRID_MANAGER_ID' => $gridManagerID, 'ACTIVITY_ID' => $commonActivityID, 'ACTIVITY_SUBJECT' => isset($arLead['~C_ACTIVITY_SUBJECT']) ? $arLead['~C_ACTIVITY_SUBJECT'] : '', 'ACTIVITY_TIME' => isset($arLead['~C_ACTIVITY_TIME']) ? $arLead['~C_ACTIVITY_TIME'] : '', 'ACTIVITY_RESPONSIBLE_ID' => isset($arLead['~C_ACTIVITY_RESP_ID']) ? intval($arLead['~C_ACTIVITY_RESP_ID']) : 0, 'ACTIVITY_RESPONSIBLE_LOGIN' => isset($arLead['~C_ACTIVITY_RESP_LOGIN']) ? $arLead['~C_ACTIVITY_RESP_LOGIN'] : '', 'ACTIVITY_RESPONSIBLE_NAME' => isset($arLead['~C_ACTIVITY_RESP_NAME']) ? $arLead['~C_ACTIVITY_RESP_NAME'] : '', 'ACTIVITY_RESPONSIBLE_LAST_NAME' => isset($arLead['~C_ACTIVITY_RESP_LAST_NAME']) ? $arLead['~C_ACTIVITY_RESP_LAST_NAME'] : '', 'ACTIVITY_RESPONSIBLE_SECOND_NAME' => isset($arLead['~C_ACTIVITY_RESP_SECOND_NAME']) ? $arLead['~C_ACTIVITY_RESP_SECOND_NAME'] : '', 'NAME_TEMPLATE' => $arParams['NAME_TEMPLATE'], 'PATH_TO_USER_PROFILE' => $arParams['PATH_TO_USER_PROFILE'], 'ALLOW_EDIT' => $arLead['EDIT'], 'MENU_ITEMS' => $arActivityMenuItems));
 } else {
     $resultItem['columns']['ACTIVITY_ID'] = CCrmViewHelper::RenderNearestActivity(array('ENTITY_TYPE_NAME' => CCrmOwnerType::ResolveName(CCrmOwnerType::Lead), 'ENTITY_ID' => $arLead['~ID'], 'ENTITY_RESPONSIBLE_ID' => $arLead['~ASSIGNED_BY'], 'GRID_MANAGER_ID' => $gridManagerID, 'ALLOW_EDIT' => $arLead['EDIT'], 'MENU_ITEMS' => $arActivityMenuItems));
Ejemplo n.º 8
0
    $stageID = isset($data['STAGE_ID']) ? $data['STAGE_ID'] : '';
    if ($stageID === '') {
        __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_DEAL_STAGE_NOT_FOUND')));
    }
    //$DB->StartTransaction();
    $fields = array('STAGE_ID' => $stageID);
    $entity = new CCrmDeal(false);
    $successed = $entity->Update($ID, $fields, true, true, array());
    if ($successed) {
        //$DB->Commit();
        $errors = array();
        CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Deal, $ID, CCrmBizProcEventType::Edit, $errors);
        $dbRes = CCrmDeal::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
        $currentItem = $dbRes->GetNext();
        $formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
        CCrmMobileHelper::PrepareDealItem($currentItem, $formatParams);
        __CrmMobileDealEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareDealData($currentItem)));
    } else {
        //$DB->Rollback();
        __CrmMobileDealEditEndResonse(array('ERROR' => $fields['RESULT_MESSAGE']));
    }
} elseif ($action === 'CONVERT_MONEY') {
    __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
    $srcCurrencyID = isset($_REQUEST['SRC_CURRENCY_ID']) ? $_REQUEST['SRC_CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
    $dstCurrencyID = isset($_REQUEST['DST_CURRENCY_ID']) ? $_REQUEST['DST_CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
    $srcSum = isset($_REQUEST['SUM']) ? doubleval($_REQUEST['SUM']) : 0.0;
    $dstSum = CCrmCurrency::ConvertMoney($srcSum, $srcCurrencyID, $dstCurrencyID);
    __CrmMobileDealEditEndResonse(array('SUM' => $dstSum, 'CURRENCY_ID' => $dstCurrencyID, 'CURRENCY_NAME' => CCrmCurrency::GetCurrencyName($dstCurrencyID), 'FORMATTED_SUM' => CCrmCurrency::MoneyToString($dstSum, $dstCurrencyID)));
} else {
    __CrmMobileDealEditEndResonse(array('ERROR' => 'Action is not supported in current context.'));
}
Ejemplo n.º 9
0
    $rows = CCrmInvoice::GetProductRows($entityID);
    foreach ($rows as &$row) {
        $item = array('PRODUCT_NAME' => isset($row['PRODUCT_NAME']) ? $row['PRODUCT_NAME'] : '', 'PRICE' => isset($row['PRICE']) ? round(doubleval($row['PRICE']), 2) : 0.0, 'VAT_RATE' => isset($row['VAT_RATE']) ? round(doubleval($row['VAT_RATE']) * 100, 2) : 0.0, 'QUANTITY' => isset($row['QUANTITY']) ? intval($row['QUANTITY']) : 0);
        $item['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($item['PRICE'], $arResult['CURRENCY_ID']);
        $arResult['ITEMS'][] =& $item;
        unset($item);
    }
    unset($row);
    // VAT - VAT ONLY
    // EXT - EXTENDED MODE WITH CUSTOM TAXES
    $arResult['TAX_MODE'] = CCrmTax::isVatMode() ? 'VAT' : 'EXT';
    if ($arResult['TAX_MODE'] === 'VAT') {
        $arResult['VAT_SUM'] = isset($arResult['TAX_SUM']) ? $arResult['TAX_SUM'] : 0.0;
        $arResult['FORMATTED_VAT_SUM'] = CCrmCurrency::MoneyToString($arResult['VAT_SUM'], $arResult['CURRENCY_ID']);
        $arResult['FORMATTED_SUM_BRUTTO'] = CCrmCurrency::MoneyToString($arResult['SUM'], $arResult['CURRENCY_ID']);
    } else {
        $arResult['TAX_LIST'] = CCrmInvoice::getTaxList($entityID);
        foreach ($arResult['TAX_LIST'] as &$taxInfo) {
            $taxInfo['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($taxInfo['VALUE_MONEY'], $arResult['CURRENCY_ID']);
        }
        unset($taxInfo);
        $arResult['TAX_LIST_PERCENT_PRECISION'] = SALE_VALUE_PRECISION;
    }
    $arResult['FORMATTED_SUM_BRUTTO'] = CCrmCurrency::MoneyToString($arResult['SUM'], $arResult['CURRENCY_ID']);
    $arResult['FORMATTED_SUM_NETTO'] = CCrmCurrency::MoneyToString($arResult['SUM'] - $arResult['TAX_SUM'], $arResult['CURRENCY_ID']);
} else {
    $arResult['TITLE'] = '';
    $arResult['CURRENCY_ID'] = CCrmCurrency::GetBaseCurrencyID();
    $arResult['SUM'] = 0.0;
}
$this->IncludeComponentTemplate();
Ejemplo n.º 10
0
            if ($currency['IS_ACCOUNTING_CURRENCY'] && $currencyID !== CCrmCurrency::GetAccountCurrencyID()) {
                CCrmCurrency::SetAccountCurrencyID($currencyID);
            } elseif (!$currency['IS_ACCOUNTING_CURRENCY'] && $currencyID === CCrmCurrency::GetAccountCurrencyID()) {
                CCrmCurrency::SetAccountCurrencyID(CCrmCurrency::GetBaseCurrencyID());
            }
            if ($currency['IS_INVOICE_CURRENCY'] && $currencyID !== CCrmCurrency::getInvoiceDefault()) {
                CCrmCurrency::setInvoiceDefault($currencyID);
            }
            LocalRedirect(isset($_POST['apply']) ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_EDIT'], array('currency_id' => $currencyID)) : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_LIST'], array('currency_id' => $currencyID)));
        }
    } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['delete'])) {
        $currencyID = isset($arParams['CURRENCY_ID']) ? strval($arParams['CURRENCY_ID']) : '';
        $currency = isset($currencyID[0]) ? CCrmCurrency::GetByID($currencyID) : null;
        if ($currency) {
            if (!CCrmCurrency::Delete($currencyID)) {
                $err = CCrmCurrency::GetLastError();
                ShowError(isset($err[0]) ? $err : GetMessage('CRM_CURRENCY_DELETE_UNKNOWN_ERROR'));
                return;
            }
        }
        LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_LIST'], array()));
    }
}
$arResult['FIELDS'] = array();
$arResult['FIELDS']['tab_1'][] = array('id' => 'currency_info', 'name' => GetMessage('CRM_CURRENCY_SECTION_MAIN'), 'type' => 'section');
$arResult['FIELDS']['tab_1'][] = array('id' => 'ID', 'name' => GetMessage('CRM_CURRENCY_FIELD_ID'), 'params' => array('size' => 10), 'value' => $currencyID, 'type' => $isEditMode ? 'label' : 'text');
$arResult['FIELDS']['tab_1'][] = array('id' => 'AMOUNT_CNT', 'name' => GetMessage('CRM_CURRENCY_FIELD_AMOUNT_CNT'), 'params' => array('size' => 10), 'value' => isset($currency['AMOUNT_CNT']) ? $currency['AMOUNT_CNT'] : '1', 'type' => $isBaseCurrency ? 'label' : 'text');
$arResult['FIELDS']['tab_1'][] = array('id' => 'DEFAULT_EXCH_RATE', 'name' => GetMessage('CRM_CURRENCY_FIELD_DEFAULT_EXCH_RATE'), 'params' => array('size' => 10), 'value' => isset($currency['AMOUNT']) ? $currency['AMOUNT'] : '1', 'type' => $isBaseCurrency ? 'label' : 'text');
$arResult['FIELDS']['tab_1'][] = array('id' => 'SORT', 'name' => GetMessage('CRM_CURRENCY_FIELD_SORT'), 'params' => array('size' => 10), 'value' => isset($currency['SORT']) ? $currency['SORT'] : '10', 'type' => 'text');
$arResult['FIELDS']['tab_1'][] = array('id' => 'BASE', 'name' => GetMessage('CRM_CURRENCY_EDIT_BASE'), 'value' => $isBaseCurrency ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'type' => 'label');
$arResult['FIELDS']['tab_1'][] = array('id' => 'ACCOUNTING', 'name' => GetMessage('CRM_CURRENCY_FIELD_ACCOUNTING'), 'value' => $currency['IS_ACCOUNTING_CURRENCY'] ? 'Y' : 'N', 'type' => 'checkbox');
Ejemplo n.º 11
0
        while ($arMultiField = $dbMultiFields->Fetch()) {
            $arFields['FM'][$arMultiField['TYPE_ID']][$arMultiField['ID']] = array('VALUE' => $arMultiField['VALUE'], 'VALUE_TYPE' => $arMultiField['VALUE_TYPE']);
        }
    }
    CCrmMobileHelper::PrepareLeadItem($arFields, $arParams, array('STATUS_LIST' => $arResult['STATUS_LIST'], 'SOURCE_LIST' => $arResult['SOURCE_LIST']));
}
$currencyID = $arFields['~CURRENCY_ID'];
$arResult['ENTITY'] = $arFields;
unset($arFields);
$arResult['PRODUCT_ROWS'] = $entityID > 0 ? CCrmProductRow::LoadRows('L', $entityID) : array();
foreach ($arResult['PRODUCT_ROWS'] as &$productRow) {
    $price = isset($productRow['PRICE']) ? doubleval($productRow['PRICE']) : 0.0;
    $qty = isset($productRow['QUANTITY']) ? doubleval($productRow['QUANTITY']) : 0;
    $sum = $productRow['SUM'] = $price * $qty;
    $productRow['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($price, $currencyID);
    $productRow['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($sum, $currencyID);
    $productRow['CURRENCY_ID'] = $currencyID;
}
unset($productRow);
$sid = bitrix_sessid();
$serviceURLTemplate = $arParams["SERVICE_URL_TEMPLATE"] ? $arParams["SERVICE_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.lead.edit/ajax.php?site_id=#SITE#&sessid=#SID#';
$arResult['SERVICE_URL'] = CComponentEngine::makePathFromTemplate($serviceURLTemplate, array('SID' => $sid));
$productRowServiceURLTemplate = $arParams["PRODUCT_ROW_URL_TEMPLATE"] ? $arParams["PRODUCT_ROW_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.product_row.edit/ajax.php?site_id=#SITE#&sessid=#SID#';
$arResult['PRODUCT_ROW_SERVICE_URL'] = CComponentEngine::makePathFromTemplate($productRowServiceURLTemplate, array('SID' => $sid));
$arResult['STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['STATUS_SELECTOR_URL_TEMPLATE'], array('type_id' => 'STATUS', 'context_id' => $contextID));
$arResult['SOURCE_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['STATUS_SELECTOR_URL_TEMPLATE'], array('type_id' => 'SOURCE', 'context_id' => $contextID));
$arResult['CURRENCY_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['CURRENCY_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['LEAD_STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['LEAD_STATUS_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['PRODUCT_ROW_EDIT_URL'] = CComponentEngine::makePathFromTemplate($arParams['PRODUCT_ROW_EDIT_URL_TEMPLATE'], array('context_id' => ''));
$arResult['PRODUCT_SELECTOR_URL_TEMPLATE'] = CComponentEngine::makePathFromTemplate($arParams['PRODUCT_SELECTOR_URL_TEMPLATE'], array());
$this->IncludeComponentTemplate();
Ejemplo n.º 12
0
	<div class="bx-user-info-data-name">
		<a href="' . $arDeal['PATH_TO_DEAL_SHOW'] . '">' . htmlspecialcharsbx($arDeal['TITLE']) . '</a>
	</div>
	<div class="bx-user-info-data-info">';
    if (!empty($arDeal['STAGE_ID'])) {
        $strCard .= '<span class="field-name">' . GetMessage('CRM_COLUMN_STAGE_ID') . '</span>:
		<span class="fields enumeration">' . $arResult['STAGE_LIST'][$arDeal['STAGE_ID']] . '</span>
		<br />';
    }
    $arProductRows = CCrmDeal::LoadProductRows($arDeal['ID']);
    if (count($arProductRows) > 0) {
        $strCard .= '<span class="field-name">' . GetMessage('CRM_COLUMN_PRODUCTS') . '</span>:<span class="fields enumeration">' . htmlspecialcharsbx(CCrmProductRow::RowsToString($arProductRows)) . '</span><br />';
    }
    if (!empty($arDeal['OPPORTUNITY'])) {
        $strCard .= '<span class="field-name">' . GetMessage('CRM_COLUMN_OPPORTUNITY') . '</span>:
		<span class="fields enumeration"><nobr>' . number_format($arDeal['OPPORTUNITY'], 2, ',', ' ') . ' ' . htmlspecialcharsbx(CCrmCurrency::GetCurrencyName($arDeal['CURRENCY_ID'])) . '</nobr></span>
		<br />';
    }
    if (!empty($arDeal['PROBABILITY'])) {
        $strCard .= '<span class="field-name">' . GetMessage('CRM_COLUMN_PROBABILITY') . '</span>:
		<span class="fields enumeration">' . intval($arDeal['PROBABILITY']) . '%</span>
		<br />';
    }
    $strCard .= '<span class="field-name">' . GetMessage('CRM_COLUMN_DATE_MODIFY') . '</span>:
		<span class="fields enumeration">' . FormatDate('x', MakeTimeStamp($arDeal['DATE_MODIFY']), time() + CTimeZone::GetOffset()) . '</span>
		<br />
		<br />';
    if (!empty($arDeal['COMPANY_TITLE'])) {
        $strCard .= '<span class="field-name">' . htmlspecialcharsbx(GetMessage('CRM_COLUMN_COMPANY_TITLE')) . '</span>:
		<a href="' . $arDeal['PATH_TO_COMPANY_SHOW'] . '">' . $arDeal['COMPANY_TITLE'] . '</a>
		<br />';
Ejemplo n.º 13
0
 public static function OnAccountCurrencyChange()
 {
     $accountCurrencyID = CCrmCurrency::GetAccountCurrencyID();
     if (!isset($accountCurrencyID[0])) {
         return;
     }
     $rs = self::GetList(array('ID' => 'ASC'), array(), array('ID', 'CURRENCY_ID', 'OPPORTUNITY', 'TAX_VALUE', 'EXCH_RATE'));
     $entity = new CCrmDeal(false);
     while ($arParams = $rs->Fetch()) {
         $ID = intval($arParams['ID']);
         $entity->Update($ID, $arParams, false, false);
         $arRows = CCrmProductRow::LoadRows('D', $ID);
         $context = array();
         if (isset($arParams['CURRENCY_ID'])) {
             $context['CURRENCY_ID'] = $arParams['CURRENCY_ID'];
         }
         if (isset($arParams['EXCH_RATE'])) {
             $context['EXCH_RATE'] = $arParams['EXCH_RATE'];
         }
         if (count($arRows) > 0) {
             CCrmProductRow::SaveRows('D', $ID, $arRows, $context);
         }
     }
 }
Ejemplo n.º 14
0
 public function map(EntityConversionMap $map, array $options = null)
 {
     $srcFields = $this->getSourceFields();
     if (empty($srcFields)) {
         return array();
     }
     $dstFields = array();
     $dstEntityTypeID = $map->getDestinationEntityTypeID();
     foreach ($map->getItems() as $item) {
         $dstFieldID = $item->getDestinationField();
         //Skip empty binding
         if ($dstFieldID === '-') {
             continue;
         }
         $srcFieldID = $item->getSourceField();
         if ((!isset($srcFields[$srcFieldID]) || $srcFields[$srcFieldID] === '') && $srcFieldID !== 'PRODUCT_ROWS') {
             $altSrcFieldID = '';
             foreach ($item->getAlternativeSourceFields() as $fieldID) {
                 if (isset($srcFields[$fieldID])) {
                     $altSrcFieldID = $fieldID;
                     break;
                 }
             }
             if ($altSrcFieldID !== '') {
                 $srcFieldID = $altSrcFieldID;
             }
         }
         if ($dstFieldID === '') {
             $dstFieldID = $srcFieldID;
         }
         if (strpos($srcFieldID, 'UF_') === 0 && strpos($dstFieldID, 'UF_') === 0) {
             self::mapUserField(\CCrmOwnerType::Deal, $srcFieldID, $srcFields, $dstEntityTypeID, $dstFieldID, $dstFields, $options);
         } elseif ($srcFieldID === 'PRODUCT_ROWS') {
             $productRows = \CCrmDeal::LoadProductRows($this->srcEntityID);
             if (count($productRows) > 0) {
                 if ($dstEntityTypeID === \CCrmOwnerType::Invoice) {
                     $currencyID = isset($srcFields['CURRENCY_ID']) ? $srcFields['CURRENCY_ID'] : '';
                     if ($currencyID === '' || !\CCrmCurrency::IsExists($currencyID)) {
                         $currencyID = \CCrmCurrency::GetBaseCurrencyID();
                     }
                     $actualRows = \CCrmInvoice::ProductRows2BasketItems($productRows, $currencyID, \CCrmInvoice::GetCurrencyID());
                     if (count($actualRows) > 0) {
                         foreach ($actualRows as &$productRow) {
                             unset($productRow['ID']);
                         }
                         unset($productRow);
                         $dstFields[$dstFieldID] = $actualRows;
                     }
                 } else {
                     foreach ($productRows as &$productRow) {
                         unset($productRow['ID']);
                     }
                     unset($productRow);
                     $dstFields[$dstFieldID] = $productRows;
                 }
             }
         } elseif (isset($srcFields[$srcFieldID])) {
             $dstFields[$dstFieldID] = $srcFields[$srcFieldID];
         }
     }
     if (!empty($dstFields)) {
         if ($dstEntityTypeID === \CCrmOwnerType::Invoice) {
             $dstFields['UF_DEAL_ID'] = $this->srcEntityID;
             //region Prepare Invoice Properties
             $dstFields['INVOICE_PROPERTIES'] = array();
             $invoiceEntity = new \CCrmInvoice(false);
             $companyID = isset($dstFields['UF_COMPANY_ID']) ? (int) $dstFields['UF_COMPANY_ID'] : 0;
             $contactID = isset($dstFields['UF_CONTACT_ID']) ? (int) $dstFields['UF_CONTACT_ID'] : 0;
             $personTypeID = 0;
             $personTypes = \CCrmPaySystem::getPersonTypeIDs();
             if ($companyID > 0 && isset($personTypes['COMPANY'])) {
                 $personTypeID = $personTypes['COMPANY'];
             } elseif (isset($personTypes['CONTACT'])) {
                 $personTypeID = $personTypes['CONTACT'];
             }
             $properties = $invoiceEntity->GetProperties(0, $personTypeID);
             if (is_array($properties)) {
                 \CCrmInvoice::__RewritePayerInfo($companyID, $contactID, $invoiceProperties);
                 foreach ($properties as $property) {
                     $dstFields['INVOICE_PROPERTIES'][$property['FIELDS']['ID']] = $property['VALUE'];
                 }
             }
             //endregion
         } elseif ($dstEntityTypeID === \CCrmOwnerType::Quote) {
             $dstFields['DEAL_ID'] = $this->srcEntityID;
         }
     }
     return $dstFields;
 }
Ejemplo n.º 15
0
        $arResult['DB_LIST'] = $dbResult;
        $arResult['DB_FILTER'] = $arFilter;
        while ($arLead = $dbResult->GetNext()) {
            $arResult['LEAD'][$arLead['ID']] = $arLead;
            $arResult['LEAD_ID'][$arLead['ID']] = $arLead['ID'];
            $arResult['LEAD_UF'][$arLead['ID']] = array();
        }
    }
}
$now = time() + CTimeZone::GetOffset();
foreach ($arResult['LEAD'] as &$arLead) {
    if (!empty($arLead['WEB']) && strpos($arLead['WEB'], '://') === false) {
        $arLead['WEB'] = 'http://' . $arLead['WEB'];
    }
    $currencyID = isset($arLead['CURRENCY_ID']) ? $arLead['CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
    $arLead['FORMATTED_OPPORTUNITY'] = CCrmCurrency::MoneyToString($arLead['~OPPORTUNITY'], $currencyID);
    $statusID = isset($arLead['STATUS_ID']) ? $arLead['STATUS_ID'] : '';
    $arLead['LEAD_STATUS_NAME'] = isset($arResult['STATUS_LIST'][$statusID]) ? $arResult['STATUS_LIST'][$statusID] : $statusID;
    $sourceID = isset($arLead['SOURCE_ID']) ? $arLead['SOURCE_ID'] : '';
    $arLead['LEAD_SOURCE_NAME'] = isset($arResult['SOURCE_LIST'][$sourceID]) ? $arResult['SOURCE_LIST'][$sourceID] : $sourceID;
    $arLead['DELETE'] = $isAdmin || $arLead['STATUS_ID'] != 'CONVERTED' && !$arResult['INTERNAL'];
    $arLead['EDIT'] = !$arResult['INTERNAL'] || $arLead['STATUS_ID'] != 'CONVERTED';
    $arLead['PATH_TO_LEAD_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_SHOW'], array('lead_id' => $arLead['ID']));
    $arLead['PATH_TO_LEAD_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_EDIT'], array('lead_id' => $arLead['ID']));
    $arLead['PATH_TO_LEAD_COPY'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_EDIT'], array('lead_id' => $arLead['ID'])), array('copy' => 1));
    $arLead['PATH_TO_LEAD_CONVERT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_CONVERT'], array('lead_id' => $arLead['ID']));
    $arLead['PATH_TO_LEAD_DELETE'] = CHTTP::urlAddParams($bInternal ? $APPLICATION->GetCurPage() : $arParams['PATH_TO_LEAD_LIST'], array('action_' . $arResult['GRID_ID'] => 'delete', 'ID' => $arLead['ID'], 'sessid' => $arResult['SESSION_ID']));
    $arLead['PATH_TO_USER_PROFILE'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_PROFILE'], array('user_id' => $arLead['ASSIGNED_BY']));
    $arLead['PATH_TO_USER_BP'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_BP'], array('user_id' => $userID));
    $arLead['PATH_TO_USER_CREATOR'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_PROFILE'], array('user_id' => $arLead['CREATED_BY']));
    $arLead['PATH_TO_USER_MODIFIER'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_PROFILE'], array('user_id' => $arLead['MODIFY_BY']));
Ejemplo n.º 16
0
     continue;
 }
 $headerID = $arHead['id'];
 $result = '';
 switch ($headerID) {
     case 'COMPANY_TYPE':
         $result = isset($arCompany['COMPANY_TYPE']) ? $arResult['COMPANY_TYPE_LIST'][$arCompany['COMPANY_TYPE']] : '';
         break;
     case 'EMPLOYEES':
         $result = isset($arCompany['EMPLOYEES']) ? $arResult['EMPLOYEES_LIST'][$arCompany['EMPLOYEES']] : '';
         break;
     case 'INDUSTRY':
         $result = isset($arCompany['INDUSTRY']) ? $arResult['INDUSTRY_LIST'][$arCompany['INDUSTRY']] : '';
         break;
     case 'CURRENCY_ID':
         $result = isset($arCompany['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($arCompany['CURRENCY_ID']) : '';
         break;
     case 'CREATED_BY':
         $result = isset($arCompany['CREATED_BY_FORMATTED_NAME']) ? $arCompany['CREATED_BY_FORMATTED_NAME'] : '';
         break;
     case 'MODIFY_BY':
         $result = isset($arCompany['MODIFY_BY_FORMATTED_NAME']) ? $arCompany['MODIFY_BY_FORMATTED_NAME'] : '';
         break;
     default:
         if (isset($arResult['COMPANY_UF'][$i]) && isset($arResult['COMPANY_UF'][$i][$headerID])) {
             $result = $arResult['COMPANY_UF'][$i][$headerID];
         } elseif (is_array($arResult['COMPANY'][$i][$headerID])) {
             $result = implode(', ', $arCompany[$headerID]);
         } else {
             $result = $arCompany[$headerID];
         }
Ejemplo n.º 17
0
 protected static function getCurrencyName($ID, $htmlEncode = false)
 {
     $currency = CCrmCurrency::GetByID($ID);
     if ($currency) {
         return $currency['FULL_NAME'];
     }
     // Old style (for compatibility only)
     $statuses = CCrmStatus::GetStatus('CURRENCY');
     $name = array_key_exists($ID, $statuses) ? $statuses[$ID]['NAME'] : $ID;
     return $htmlEncode ? htmlspecialcharsbx($name) : $name;
 }
Ejemplo n.º 18
0
}
if ($mode === 'GET_USER_INFO') {
    $result = array();
    if (!CCrmInstantEditorHelper::PrepareUserInfo(isset($_POST['USER_ID']) ? intval($_POST['USER_ID']) : 0, $result)) {
        __CrmCompanyShowEndJsonResonse(array('ERROR' => 'COULD NOT PREPARE USER INFO!'));
    } else {
        __CrmCompanyShowEndJsonResonse(array('USER_INFO' => $result));
    }
}
if ($mode === 'GET_FORMATTED_SUM') {
    $sum = isset($_POST['SUM']) ? $_POST['SUM'] : 0.0;
    $currencyID = isset($_POST['CURRENCY_ID']) ? $_POST['CURRENCY_ID'] : '';
    if ($currencyID === '') {
        $currencyID = CCrmCurrency::GetBaseCurrencyID();
    }
    __CrmCompanyShowEndJsonResonse(array('FORMATTED_SUM' => CCrmCurrency::MoneyToString($sum, $currencyID, '#')));
}
if ($mode === 'GET_USER_SELECTOR') {
    if (!CCrmCompany::CheckUpdatePermission(0, $currentUserPermissions)) {
        __CrmCompanyShowEndHtmlResonse();
    }
    $name = isset($_POST['NAME']) ? $_POST['NAME'] : '';
    $GLOBALS['APPLICATION']->RestartBuffer();
    Header('Content-Type: text/html; charset=' . LANG_CHARSET);
    $APPLICATION->IncludeComponent('bitrix:intranet.user.selector.new', '.default', array('MULTIPLE' => 'N', 'NAME' => $name, 'POPUP' => 'Y', 'SITE_ID' => SITE_ID), null, array('HIDE_ICONS' => 'Y'));
    __CrmCompanyShowEndHtmlResonse();
}
if ($mode === 'GET_VISUAL_EDITOR') {
    if (!CCrmCompany::CheckUpdatePermission(0, $currentUserPermissions)) {
        __CrmCompanyShowEndHtmlResonse();
    }
Ejemplo n.º 19
0
 private function MapField(&$entityInfo, $fieldName)
 {
     $result = '';
     $typeID = isset($entityInfo['TYPE_ID']) ? intval($entityInfo['TYPE_ID']) : CCrmOwnerType::Undefined;
     $fields = isset($entityInfo['FIELDS']) ? $entityInfo['FIELDS'] : array();
     $isHtml = $this->contentType === CCrmContentType::Html;
     $isBBCode = $this->contentType === CCrmContentType::BBCode;
     $isPlainText = $this->contentType === CCrmContentType::PlainText;
     if ($typeID === CCrmOwnerType::Lead) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'NAME':
             case 'SECOND_NAME':
             case 'LAST_NAME':
             case 'TITLE':
             case 'COMPANY_TITLE':
             case 'SOURCE_DESCRIPTION':
             case 'STATUS_DESCRIPTION':
             case 'POST':
             case 'ADDRESS':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'SOURCE':
                 $result = self::MapReferenceValue(self::PrepareSources(), $fields, 'SOURCE_ID', $isHtml);
                 break;
             case 'STATUS':
                 $result = self::MapReferenceValue(self::PrepareLeadStatuses(), $fields, 'STATUS_ID', $isHtml);
                 break;
             case 'FORMATTED_NAME':
                 $result = CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => '', 'NAME' => isset($fields['NAME']) ? $fields['NAME'] : '', 'SECOND_NAME' => isset($fields['SECOND_NAME']) ? $fields['SECOND_NAME'] : '', 'LAST_NAME' => isset($fields['LAST_NAME']) ? $fields['LAST_NAME'] : ''), false, $isHtml);
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'OPPORTUNITY':
                 $result = isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0;
                 break;
             case 'OPPORTUNITY_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Deal) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'TITLE':
                 $result = self::MapFieldValue($fields, 'TITLE', $isHtml);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareDealTypes(), $fields, 'TYPE_ID', $isHtml);
                 break;
             case 'STAGE':
                 $result = self::MapReferenceValue(self::PrepareDealStages(), $fields, 'STAGE_ID', $isHtml);
                 break;
             case 'PROBABILITY':
                 $result = (isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0) . ' %';
                 break;
             case 'BEGINDATE':
                 $result = isset($fields['BEGINDATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['BEGINDATE'])) : '';
                 break;
             case 'CLOSEDATE':
                 $result = isset($fields['CLOSEDATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['CLOSEDATE'])) : '';
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'OPPORTUNITY':
                 $result = isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0;
                 break;
             case 'OPPORTUNITY_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
             case 'COMPANY':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Company, isset($fields['COMPANY_ID']) ? intval($fields['COMPANY_ID']) : 0);
                 break;
             case 'CONTACT':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Contact, isset($fields['CONTACT_ID']) ? intval($fields['CONTACT_ID']) : 0);
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Contact) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'NAME':
             case 'SECOND_NAME':
             case 'LAST_NAME':
             case 'POST':
             case 'ADDRESS':
             case 'SOURCE_DESCRIPTION':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'FORMATTED_NAME':
                 $result = CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => '', 'NAME' => isset($fields['NAME']) ? $fields['NAME'] : '', 'SECOND_NAME' => isset($fields['SECOND_NAME']) ? $fields['SECOND_NAME'] : '', 'LAST_NAME' => isset($fields['LAST_NAME']) ? $fields['LAST_NAME'] : ''), false, $isHtml);
                 break;
             case 'SOURCE':
                 $result = self::MapReferenceValue(self::PrepareSources(), $fields, 'SOURCE_ID', $isHtml);
                 break;
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareContactTypes(), $fields, 'TYPE_ID', $isHtml);
                 break;
             case 'COMPANY':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Company, isset($fields['COMPANY_ID']) ? intval($fields['COMPANY_ID']) : 0);
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Company) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'TITLE':
             case 'COMPANY_TITLE':
             case 'SOURCE_DESCRIPTION':
             case 'ADDRESS':
             case 'ADDRESS_LEGAL':
             case 'BANKING_DETAILS':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'COMPANY_TYPE':
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareCompanyTypes(), $fields, 'COMPANY_TYPE', $isHtml);
                 break;
             case 'INDUSTRY':
                 $result = self::MapReferenceValue(self::PrepareIndustries(), $fields, 'INDUSTRY', $isHtml);
                 break;
             case 'EMPLOYEES':
                 $result = self::MapReferenceValue(self::PrepareEmployees(), $fields, 'EMPLOYEES', $isHtml);
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'REVENUE':
                 $result = isset($fields['REVENUE']) ? $fields['REVENUE'] : 0.0;
                 break;
             case 'REVENUE_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['REVENUE']) ? $fields['REVENUE'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
         }
     }
     return $result;
 }
Ejemplo n.º 20
0
        } else {
            if (strpos($k, 'UF_') !== 0 && $k != 'LOGIC') {
                $arFilter['%' . $k] = $v;
                unset($arFilter[$k]);
            }
        }
    }
}
$obRes = CCrmDeal::GetListEx(array(), $arFilter, false, false, array('ID', 'TITLE', 'STAGE_ID', 'OPPORTUNITY', 'CURRENCY_ID'));
$arResult['DEAL'] = array();
$arResult['STAGE_COUNT'] = array();
$arResult['FUNNEL'] = array();
$iDealCount = 0;
while ($arDeal = $obRes->GetNext()) {
    //Normalizing for compatibility
    $currencyID = CCrmCurrency::NormalizeCurrencyID($arDeal['CURRENCY_ID']);
    $stageID = $arDeal['STAGE_ID'];
    $opportunity = (double) $arDeal['OPPORTUNITY'];
    if (!isset($arResult['STAGE_COUNT'][$stageID])) {
        $arResult['STAGE_COUNT'][$stageID]['COUNT'] = 1;
        $arResult['STAGE_COUNT'][$stageID]['COUNT_FUNNEL'] = 1;
        $arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY'] = array($currencyID => $opportunity);
        $arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY_FUNNEL'] = array($currencyID => $opportunity);
    } else {
        $arResult['STAGE_COUNT'][$stageID]['COUNT']++;
        $arResult['STAGE_COUNT'][$stageID]['COUNT_FUNNEL']++;
        if (!isset($arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY'][$currencyID])) {
            $arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY'][$currencyID] = 0;
        }
        $arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY'][$currencyID] += $opportunity;
        if (!isset($arResult['STAGE_COUNT'][$stageID]['OPPORTUNITY_FUNNEL'][$currencyID])) {
Ejemplo n.º 21
0
 if (!isset($dealData[$headerID])) {
     switch ($arHead['id']) {
         case 'STAGE_ID':
             $stageID = !empty($arDeal['STAGE_ID']) ? $arDeal['STAGE_ID'] : '';
             $dealData['STAGE_ID'] = isset($arResult['STAGE_LIST'][$stageID]) ? $arResult['STAGE_LIST'][$stageID] : $stageID;
             break;
         case 'STATE_ID':
             $stateID = !empty($arDeal['STATE_ID']) ? $arDeal['STATE_ID'] : '';
             $dealData['STATE_ID'] = isset($arResult['STATE_LIST'][$stateID]) ? $arResult['STATE_LIST'][$stateID] : $stateID;
             break;
         case 'TYPE_ID':
             $typeID = !empty($arDeal['TYPE_ID']) ? $arDeal['TYPE_ID'] : '';
             $dealData['TYPE_ID'] = isset($arResult['TYPE_LIST'][$typeID]) ? $arResult['TYPE_LIST'][$typeID] : $typeID;
             break;
         case 'CURRENCY_ID':
             $dealData['CURRENCY_ID'] = CCrmCurrency::GetCurrencyName($arDeal['CURRENCY_ID']);
             break;
         case 'EVENT_ID':
             $eventID = !empty($arDeal['EVENT_ID']) ? $arDeal['EVENT_ID'] : '';
             $dealData['EVENT_ID'] = isset($arResult['EVENT_LIST'][$eventID]) ? $arResult['EVENT_LIST'][$eventID] : $eventID;
             break;
         case 'COMPANY_ID':
             $dealData['COMPANY_ID'] = isset($arDeal['COMPANY_TITLE']) ? $arDeal['COMPANY_TITLE'] : '';
             break;
         case 'CONTACT_ID':
             $dealData['CONTACT_ID'] = isset($arDeal['CONTACT_FORMATTED_NAME']) ? $arDeal['CONTACT_FORMATTED_NAME'] : '';
             break;
         case 'CREATED_BY':
             $dealData['CREATED_BY'] = isset($arDeal['CREATED_BY_FORMATTED_NAME']) ? $arDeal['CREATED_BY_FORMATTED_NAME'] : '';
             break;
         case 'MODIFY_BY':
Ejemplo n.º 22
0
 function __CrmQuickPanelViewPrepareMoney($sum, $currencyID, $editable, $serviceUrl, &$entityContext)
 {
     $formattedSum = CCrmCurrency::MoneyToString($sum, $currencyID, '#');
     $formattedSumWithCurrency = CCrmCurrency::MoneyToString($sum, $currencyID, '');
     return array('type' => 'money', 'editable' => $editable, 'data' => array('currencyId' => $currencyID, 'value' => $sum, 'text' => $formattedSum, 'formatted_sum' => $formattedSum, 'formatted_sum_with_currency' => $formattedSumWithCurrency, 'serviceUrl' => $serviceUrl));
 }
Ejemplo n.º 23
0
 /**
  * @return array
  */
 public function initializeDemoData(array $data)
 {
     if (!(isset($data['items']) && is_array($data['items']))) {
         return $data;
     }
     foreach ($data['items'] as &$item) {
         $config = $this->findConfigByName(isset($item['name']) ? $item['name'] : '');
         if (!$config) {
             continue;
         }
         $item['title'] = $config->getTitle();
         if (!(isset($item['positions']) && is_array($item['positions']))) {
             continue;
         }
         $format = $config->getFomatParams();
         foreach ($item['positions'] as &$position) {
             $legend = isset($position['legend']) ? (double) $position['legend'] : 0.0;
             $legendType = 'text';
             if (isset($format['enableDecimals']) && $format['enableDecimals'] == 'N') {
                 $legend = round($legend, 0);
             }
             if (isset($format['isCurrency']) && $format['isCurrency'] == 'Y') {
                 $legend = \CCrmCurrency::MoneyToString($legend, \CCrmCurrency::GetAccountCurrencyID());
                 $legendType = 'html';
             }
             $position['legend'] = $legend;
             $position['legendType'] = $legendType;
         }
         unset($position);
     }
     unset($item);
     return $data;
 }
Ejemplo n.º 24
0
 public static function Delete($ID)
 {
     if (!CModule::IncludeModule('currency')) {
         self::$LAST_ERROR = GetMessage('CRM_CURRERCY_MODULE_IS_NOT_INSTALLED');
         return false;
     }
     IncludeModuleLangFile(__FILE__);
     global $APPLICATION;
     $ID = strval($ID);
     if (strlen($ID) !== 3) {
         //Invalid ID is supplied. Are you A.Krasichkov?
         //self::$LAST_ERROR = GetMessage('CRM_CURRERCY_MODULE_INVALID_ID');
         return false;
     }
     if ($ID === self::GetBaseCurrencyID()) {
         self::$LAST_ERROR = GetMessage('CRM_CURRERCY_ERR_DELETION_OF_BASE_CURRENCY');
         return false;
     }
     if ($ID === self::GetAccountCurrencyID()) {
         self::$LAST_ERROR = GetMessage('CRM_CURRERCY_ERR_DELETION_OF_ACCOUNTING_CURRENCY');
         return false;
     }
     if (!CCurrency::Delete($ID)) {
         $ex = $APPLICATION->GetException();
         if ($ex) {
             self::$LAST_ERROR = $ex->GetString();
         }
         return false;
     }
     self::ClearCache();
     return true;
 }
Ejemplo n.º 25
0
         $arLead[$currentKey] = $result !== false ? $result : $data;
     }
 } elseif ($currentKey == 'SOURCE_ID') {
     if (isset($arStatus['SOURCE_LIST'][$data])) {
         // 1. Try to interpret value as ID
         $arLead[$currentKey] = $data;
     } else {
         $result = array_search($data, $arStatus['SOURCE_LIST']);
         $arLead[$currentKey] = $result !== false ? $result : $data;
     }
 } elseif ($currentKey == 'CURRENCY_ID') {
     $currency = CCrmCurrency::GetByName($data);
     if (!$currency) {
         $currency = CCrmCurrency::GetByID($data);
     }
     $arLead[$currentKey] = $currency ? $currency['CURRENCY'] : CCrmCurrency::GetBaseCurrencyID();
 } elseif ($currentKey == 'PRODUCT_ID') {
     // For compatibility
     $arProduct = CCrmProduct::GetByOriginID('CRM_PROD_' . $data);
     if (is_array($arProduct)) {
         $arProductRow = array('PRODUCT_ID' => $arProduct['ID'], 'QUANTITY' => 1);
         // PRICE equals to OPPORTUNITY. We will set PRICE latter
     } else {
         $arProduct = CCrmProduct::GetByName($data);
         if ($arProduct) {
             $arProductRow['PRODUCT_ID'] = $arProduct['ID'];
         } else {
             $arProductRow['PRODUCT_ID'] = 0;
         }
         $arProductRow['PRODUCT_NAME'] = $data;
     }
Ejemplo n.º 26
0
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'EMPLOYEES', 'name' => GetMessage('CRM_FIELD_EMPLOYEES'), 'type' => 'label', 'value' => $arResult['EMPLOYEES_LIST'][$arResult['ELEMENT']['~EMPLOYEES']], 'isTactile' => true);
// <-- EMPLOYEES
// REVENUE -->
// REVENUE is displayed in sidebar. The field is added for COMPATIBILITY ONLY
$currencyID = CCrmCurrency::GetBaseCurrencyID();
if (isset($arResult['ELEMENT']['CURRENCY_ID']) && $arResult['ELEMENT']['CURRENCY_ID'] !== '') {
    $currencyID = $arResult['ELEMENT']['CURRENCY_ID'];
}
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'REVENUE';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'REVENUE', 'name' => GetMessage('CRM_FIELD_REVENUE'), 'value' => isset($arResult['ELEMENT']['REVENUE']) ? CCrmCurrency::MoneyToString($arResult['ELEMENT']['REVENUE'], $currencyID, '#') : '', 'type' => 'custom', 'isTactile' => true);
// <-- REVENUE
// CURRENCY -->
$arResult['FIELDS']['tab_1'][] = array('id' => 'CURRENCY_ID', 'name' => GetMessage('CRM_FIELD_CURRENCY_ID'), 'type' => 'label', 'value' => CCrmCurrency::GetCurrencyName($currencyID), 'isTactile' => true);
// <-- CURRENCY
// COMMENTS -->
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'COMMENTS';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'COMMENTS', 'name' => GetMessage('CRM_FIELD_COMMENTS'), 'type' => 'custom', 'value' => isset($arResult['ELEMENT']['~COMMENTS']) ? $arResult['ELEMENT']['~COMMENTS'] : '', 'params' => array(), 'isTactile' => true);
// <-- COMMENTS
// OPENED -->
// OPENED is displayed in sidebar. The field is added for COMPATIBILITY ONLY
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'OPENED';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'OPENED', 'name' => GetMessage('CRM_FIELD_OPENED'), 'type' => 'label', 'params' => array(), 'value' => $arResult['ELEMENT']['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'isTactile' => true);
// <-- OPENED
$arResult['FIELDS']['tab_1'][] = array('id' => 'section_contact_info', 'name' => GetMessage('CRM_SECTION_CONTACT_INFO'), 'type' => 'section', 'isTactile' => true);
Ejemplo n.º 27
0
    if (!(is_string($componentPage) && isset($componentPage[0]) && isset($arDefaultUrlTemplates404[$componentPage]))) {
        $componentPage = 'currency_list';
    }
    CComponentEngine::InitComponentVariables($componentPage, $arComponentVariables, $arVariableAliases, $arVariables);
    foreach ($arUrlTemplates as $url => $value) {
        $key = 'PATH_TO_' . strtoupper($url);
        $arResult[$key] = isset($arParams[$key][0]) ? $arParams[$key] : $arParams['SEF_FOLDER'] . $value;
    }
} else {
    $arComponentVariables = array(isset($arParams['VARIABLE_ALIASES']['currency_id']) ? $arParams['VARIABLE_ALIASES']['currency_id'] : 'currency_id');
    $arDefaultVariableAliases = array('currency_id' => 'currency_id');
    $arVariables = array();
    $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases, $arParams['VARIABLE_ALIASES']);
    CComponentEngine::InitComponentVariables(false, $arComponentVariables, $arVariableAliases, $arVariables);
    $componentPage = 'currency_list';
    if (isset($_REQUEST['edit'])) {
        $componentPage = 'currency_edit';
    } elseif (isset($_REQUEST['show'])) {
        $componentPage = 'currency_show';
    }
    $curPage = $APPLICATION->GetCurPage();
    $arResult['PATH_TO_CURRENCY_LIST'] = $curPage;
    $arResult['PATH_TO_CURRENCY_ADD'] = $curPage . '?add';
    $arResult['PATH_TO_CURRENCY_EDIT'] = $curPage . '?' . $arVariableAliases['currency_id'] . '=#currency_id#&edit';
    $arResult['PATH_TO_CURRENCY_SHOW'] = $curPage . '?' . $arVariableAliases['currency_id'] . '=#currency_id#&show';
}
$arResult = array_merge(array('VARIABLES' => $arVariables, 'ALIASES' => $arParams['SEF_MODE'] == 'Y' ? array() : $arVariableAliases, 'CURRENCY_ID' => isset($arVariables['currency_id']) ? strval($arVariables['currency_id']) : ''), $arResult);
if (!CCrmCurrency::EnsureReady()) {
    ShowError(CCrmCurrency::GetLastError());
}
$this->IncludeComponentTemplate($componentPage);
Ejemplo n.º 28
0
 function __CrmEntitySummaryRenderHorSectionItem(&$item)
 {
     $type = isset($item['TYPE']) ? strtoupper($item['TYPE']) : '';
     $title = isset($item['TITLE']) ? $item['TITLE'] : '';
     if ($title !== '') {
         $title .= ':';
     }
     $params = isset($item['PARAMS']) && is_array($item['PARAMS']) ? $item['PARAMS'] : array();
     if ($type === '') {
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>', '<span class="crm-detail-info-item-text">', htmlspecialcharsbx(isset($item['VALUE']) ? $item['VALUE'] : ''), '</span>';
     } elseif ($type === 'PROGRESS') {
         echo '<div class="crm-detail-stage crm-detail-info-item">', '<div class="crm-detail-stage-name">', htmlspecialcharsbx($title), '</div>', CCrmViewHelper::RenderProgressControl($params), '</div>';
     } elseif ($type === 'SELECT') {
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>';
         echo '<span class="crm-detail-info-item-text">';
         $params['CONTAINER_CLASS'] = 'crm-item-type';
         $params['TEXT_CLASS'] = 'crm-item-type-text';
         $params['ARROW_CLASS'] = 'crm-item-type-text-corner';
         CCrmViewHelper::RenderSelector($params);
         echo '</span>';
     } elseif ($type === 'CLIENT_INFO') {
         echo '<div class="crm-item-client"><span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>', '<span class="crm-detail-info-item-text">', CCrmViewHelper::PrepareClientInfoV2($params), '</span></div>';
     } elseif ($type === 'CLIENT_BALLOON') {
         if (isset($params['name'])) {
             $title = $params['name'];
             if ($title !== '') {
                 $title .= ':';
             }
         }
         echo '<div class="crm-item-client-ballon"><span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>', '<span class="crm-detail-info-item-text">';
         if (isset($params['value'])) {
             echo $params['value'];
         } else {
             echo CCrmViewHelper::PrepareEntityBaloonHtml($params);
         }
         echo '</span></div>';
     } elseif ($type === 'MULTIFIELD') {
         $typeName = isset($params['TYPE']) ? $params['TYPE'] : '';
         $values = isset($params['VALUES']) ? $params['VALUES'] : array();
         $valueTypes = isset($params['VALUE_TYPES']) ? $params['VALUE_TYPES'] : array();
         $valueCount = isset($params['VALUE_COUNT']) ? intval($params['VALUE_COUNT']) : 0;
         $displayIfEmpty = isset($params['DISPLAY_IF_EMPTY']) ? $params['DISPLAY_IF_EMPTY'] : true;
         if (!$displayIfEmpty && $valueCount <= 0) {
             return;
         }
         $options = isset($item['OPTIONS']) && is_array($item['OPTIONS']) ? $item['OPTIONS'] : array();
         $enableSip = is_array($options) && isset($options['ENABLE_SIP']) && (bool) $options['ENABLE_SIP'];
         $titleClassName = 'crm-detail-info-item-name';
         if ($enableSip) {
             $titleClassName .= ' crm-detail-info-item-name-tel-sip';
         }
         $contentClassName = 'crm-detail-info-item-text crm-item-tel';
         if ($enableSip) {
             $contentClassName .= ' crm-item-tel-tel-sip';
         }
         echo '<span class="' . $titleClassName . '">', htmlspecialcharsbx($title), '</span>', '<span class="' . $contentClassName . '">';
         echo CCrmViewHelper::PrepareFirstMultiFieldHtml($typeName, $values, $valueTypes, array(), $options);
         if ($valueCount > 1) {
             $prefix = isset($params['PREFIX']) ? $params['PREFIX'] : '';
             $anchorID = ($prefix !== '' ? "{$prefix}_" : '') . strtolower($typeName);
             echo '<span class="crm-item-tel-list" id="', htmlspecialcharsbx($anchorID), '"', ' onclick="', CCrmViewHelper::PrepareMultiFieldValuesPopup($anchorID, $anchorID, $typeName, $values, $valueTypes, $options), '"></span>';
         }
         echo '</span>';
     } elseif ($type === 'RESPONSIBLE') {
         CCrmViewHelper::RenderResponsiblePanel($params);
     } elseif ($type === 'MODIFICATION_INFO') {
         $date = isset($params['DATE']) ? $params['DATE'] : '';
         $userName = isset($params['USER_NAME']) ? $params['USER_NAME'] : '';
         $pathToUser = isset($params['PATH_TO_USER']) ? $params['PATH_TO_USER'] : '';
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>', '<span class="crm-detail-info-item-text">';
         echo $date !== '' ? FormatDate('SHORT', MakeTimeStamp($date)) : '-';
         if ($userName !== '' && $pathToUser !== '') {
             echo ', <a class="crm-detail-info-link" href="', htmlspecialcharsbx($pathToUser), '">', htmlspecialcharsbx($userName), '</a>';
         }
         echo '</span>';
     } elseif ($type === 'DURATION') {
         $from = !empty($params['FROM']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($params['FROM']), 'SHORT', SITE_ID)) : '-';
         $to = !empty($params['TO']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($params['TO']), 'SHORT', SITE_ID)) : '-';
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>', '<span class="crm-detail-info-item-text crm-item-date">';
         echo '<i>', htmlspecialcharsbx(GetMessage('CRM_DURATION_FROM')), '</i>', '<span class="crm-item-date-calendar">', htmlspecialcharsbx($from), '</span>', '<i>', htmlspecialcharsbx(GetMessage('CRM_DURATION_TO')), '</i>', '<span class="crm-item-date-calendar">', htmlspecialcharsbx($to), '</span>';
         echo '</span>';
     } elseif ($type === 'MONEY') {
         $fieldID = isset($params['FIELD_ID']) ? $params['FIELD_ID'] : '';
         $value = isset($params['VALUE']) ? $params['VALUE'] : '';
         $currencyID = isset($params['CURRENCY_ID']) ? $params['CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID();
         $editable = isset($params['EDITABLE']) ? $params['EDITABLE'] : false;
         echo '<div class="crm-item-sum', $editable ? ' crm-instant-editor-fld-block' : '', '">';
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>';
         if (!$editable) {
             echo '<span class="crm-detail-info-item-text">', CCrmCurrency::MoneyToString($value, $currencyID), '</span>';
         } else {
             echo '<span class="crm-detail-info-item-text">';
             CCrmViewHelper::RenderInstantEditorField(array('TYPE' => 'TEXT', 'FIELD_ID' => $fieldID, 'VALUE' => $value, 'SUFFIX_HTML' => "&nbsp;{$currencyID}", 'INPUT_WIDTH' => 80));
             echo '</span>';
         }
         echo '</div>';
     } elseif ($type === 'PERCENT') {
         $fieldID = isset($params['FIELD_ID']) ? $params['FIELD_ID'] : '';
         $value = isset($params['VALUE']) ? $params['VALUE'] : '';
         $editable = isset($params['EDITABLE']) ? $params['EDITABLE'] : false;
         echo '<div', $editable ? ' class="crm-instant-editor-fld-block"' : '', '>';
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>';
         if (!$editable) {
             echo '<span class="crm-detail-info-item-text">', htmlspecialcharsbx($value), '&nbsp;%</span>';
         } else {
             echo '<span class="crm-detail-info-item-text">';
             CCrmViewHelper::RenderInstantEditorField(array('TYPE' => 'TEXT', 'FIELD_ID' => $fieldID, 'VALUE' => $value, 'SUFFIX_HTML' => "%", 'INPUT_WIDTH' => 30));
             echo '</span>';
         }
         echo '</div>';
     } elseif ($type === 'TEXT') {
         $fieldID = isset($params['FIELD_ID']) ? $params['FIELD_ID'] : '';
         $value = isset($params['VALUE']) ? $params['VALUE'] : '';
         $editable = isset($params['EDITABLE']) ? $params['EDITABLE'] : false;
         $width = isset($params['WIDTH']) ? $params['WIDTH'] : 50;
         echo '<div', $editable ? ' class="crm-instant-editor-fld-block"' : '', '>';
         echo '<span class="crm-detail-info-item-name">', htmlspecialcharsbx($title), '</span>';
         if (!$editable) {
             echo '<span class="crm-detail-info-item-text">', htmlspecialcharsbx($value), '</span>';
         } else {
             echo '<span class="crm-detail-info-item-text"><span class="crm-detail-item-text-alignment">';
             CCrmViewHelper::RenderInstantEditorField(array('TYPE' => 'TEXT', 'FIELD_ID' => $fieldID, 'VALUE' => $value, 'INPUT_WIDTH' => $width));
             echo '</span></span>';
         }
         echo '</div>';
     } elseif ($type === 'CUSTOM') {
         $fieldID = isset($params['FIELD_ID']) ? $params['FIELD_ID'] : '';
         $value = isset($params['VALUE']) ? $params['VALUE'] : '';
         echo $value;
     }
 }
Ejemplo n.º 29
0
 if ($iRoleIDChif <= 0) {
     $iRoleIDChif = $CCrmRole->Add($arRoles['chif']);
 }
 if ($iRoleIDMan <= 0) {
     $iRoleIDMan = $CCrmRole->Add($arRoles['man']);
 }
 if (WIZARD_MARKETING_AND_SALES_GROUP > 0) {
     $arRel['G' . WIZARD_MARKETING_AND_SALES_GROUP] = array($iRoleID);
 }
 $CCrmRole->SetRelation($arRel);
 /* INSTALL DEMO-DATA */
 // copy files
 CopyDirFiles(WIZARD_ABSOLUTE_PATH . "/site/services/crm/images/", WIZARD_SITE_PATH . '/upload/crm', true, true);
 // Create default product catalog
 $catalogID = CCrmCatalog::EnsureDefaultExists();
 $currencyID = CCrmCurrency::GetBaseCurrencyID();
 // Creation of demo products
 require_once "product.demo.php";
 if (COption::GetOptionString('crm', '~CRM_INVOICE_INSTALL_12_5_7', 'N') !== 'Y') {
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/crm/install/sale_link.php";
 }
 CCrmProductDemo::Create($catalogID);
 // Add lead
 require_once "lead.demo.php";
 $CCrmLead = new CCrmLead();
 foreach ($arLeads as $ID => $arParams) {
     $arProductRows = null;
     if (isset($arParams['PRODUCT_ROWS'])) {
         $arProductRows = $arParams['PRODUCT_ROWS'];
         unset($arParams['PRODUCT_ROWS']);
     }
Ejemplo n.º 30
0
     continue;
 }
 $headerID = $arHead['id'];
 $result = '';
 switch ($headerID) {
     case 'COMPANY_TYPE':
         $result = $arResult['COMPANY_TYPE_LIST'][$arCompany['COMPANY_TYPE']];
         break;
     case 'EMPLOYEES':
         $result = $arResult['EMPLOYEES_LIST'][$arCompany['EMPLOYEES']];
         break;
     case 'INDUSTRY':
         $result = $arResult['INDUSTRY_LIST'][$arCompany['INDUSTRY']];
         break;
     case 'CURRENCY_ID':
         $result = CCrmCurrency::GetCurrencyName($arCompany['CURRENCY_ID']);
         break;
     case 'CREATED_BY':
         $result = $arCompany['CREATED_BY_FORMATTED_NAME'];
         break;
     case 'MODIFY_BY':
         $result = $arCompany['MODIFY_BY_FORMATTED_NAME'];
         break;
     default:
         if (isset($arResult['COMPANY_UF'][$i]) && isset($arResult['COMPANY_UF'][$i][$headerID])) {
             $result = $arResult['COMPANY_UF'][$i][$headerID];
         } elseif (is_array($arCompany[$headerID])) {
             $result = implode(', ', $arCompany[$headerID]);
         } else {
             $result = strval($arCompany[$headerID]);
         }