$arFields['STAGE_TEXT'] = htmlspecialcharsbx($arFields['~STAGE_TEXT']); $arFields['~TYPE_NAME'] = isset($arFields['~TYPE_ID']) && isset($arResult['TYPE_LIST'][$arFields['~TYPE_ID']]) ? $arResult['TYPE_LIST'][$arFields['~TYPE_ID']] : ''; $arFields['TYPE_NAME'] = htmlspecialcharsbx($arFields['~TYPE_NAME']); $arFields['~FORMATTED_OPPORTUNITY'] = CCrmCurrency::MoneyToString($arFields['~OPPORTUNITY'], $arFields['~CURRENCY_ID']); $arFields['FORMATTED_OPPORTUNITY'] = strip_tags($arFields['~FORMATTED_OPPORTUNITY']); $arFields['~CONTACT_FORMATTED_NAME'] = CUser::FormatName($arParams['NAME_TEMPLATE'], array('LOGIN' => '', 'NAME' => $arFields['~CONTACT_NAME'], 'LAST_NAME' => $arFields['~CONTACT_LAST_NAME'], 'SECOND_NAME' => $arFields['~CONTACT_SECOND_NAME']), false, false); $arFields['CONTACT_FORMATTED_NAME'] = htmlspecialcharsbx($arFields['~CONTACT_FORMATTED_NAME']); $arFields['ASSIGNED_BY_SHOW_URL'] = ''; $arFields['~ASSIGNED_BY_FORMATTED_NAME'] = ''; if ($arFields['~ASSIGNED_BY_ID'] <= 0) { $arFields['~ASSIGNED_BY_FORMATTED_NAME'] = GetMessage('CRM_DEAL_VIEW_RESPONSIBLE_NOT_ASSIGNED'); } else { $arFields['ASSIGNED_BY_SHOW_URL'] = $arParams['USER_PROFILE_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['USER_PROFILE_URL_TEMPLATE'], array('user_id' => $arFields['~ASSIGNED_BY_ID'])) : ''; $arFields['~ASSIGNED_BY_FORMATTED_NAME'] = CUser::FormatName($arParams['NAME_TEMPLATE'], array('LOGIN' => $arFields['~ASSIGNED_BY_LOGIN'], 'NAME' => $arFields['~ASSIGNED_BY_NAME'], 'LAST_NAME' => $arFields['~ASSIGNED_BY_LAST_NAME'], 'SECOND_NAME' => $arFields['~ASSIGNED_BY_SECOND_NAME']), true, false); } $arFields['ASSIGNED_BY_FORMATTED_NAME'] = htmlspecialcharsbx($arFields['~ASSIGNED_BY_FORMATTED_NAME']); $arFields['PRODUCT_ROWS_QUANTITY'] = CAllCrmProductRow::GetRowQuantity(CCrmOwnerTypeAbbr::ResolveByTypeID(CCrmOwnerType::Deal), $entityID); $arFields['PRODUCT_ROWS_URL'] = $arParams['PRODUCT_ROW_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['PRODUCT_ROW_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Deal, 'entity_id' => $entityID)) : ''; $arFields['ACTITITY_QUANTITY'] = CAllCrmActivity::GetCount(array('BINDINGS' => array(array('OWNER_TYPE_ID' => CCrmOwnerType::Deal, 'OWNER_ID' => $entityID)))); $arFields['ACTIVITY_LIST_URL'] = $arParams['ACTIVITY_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Deal, 'entity_id' => $entityID)) : ''; $arFields['EVENT_LIST_URL'] = $arParams['EVENT_LIST_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['EVENT_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Deal, 'entity_id' => $entityID)) : ''; $arFields['~BEGINDATE'] = !empty($arFields['~BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arFields['~BEGINDATE']), 'SHORT', SITE_ID)) : ''; $arFields['BEGINDATE'] = htmlspecialcharsbx($arFields['~BEGINDATE']); $arFields['~CLOSEDATE'] = !empty($arFields['~CLOSEDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arFields['~CLOSEDATE']), 'SHORT', SITE_ID)) : ''; $arFields['CLOSEDATE'] = htmlspecialcharsbx($arFields['~CLOSEDATE']); $arFields['EDIT_URL'] = $arParams['DEAL_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['DEAL_EDIT_URL_TEMPLATE'], array('deal_id' => $entityID)) : ''; $arResult['DEAL_STAGE_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['DEAL_STAGE_SELECTOR_URL_TEMPLATE'], array('context_id' => '')); $arFields['INVOICE_EDIT_URL'] = $arParams['INVOICE_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['INVOICE_EDIT_URL_TEMPLATE'], array('contact_id' => '', 'company_id' => '', 'deal_id' => $entityID)) : ''; $arResult['ENTITY'] =& $arFields; unset($arFields); $this->IncludeComponentTemplate();
$arSort['title'] = $arSort['quote_summary']; unset($arSort['quote_summary']); } if (isset($arParams['IS_EXTERNAL_CONTEXT'])) { $arOptions['IS_EXTERNAL_CONTEXT'] = $arParams['IS_EXTERNAL_CONTEXT']; } //FIELD_OPTIONS $arSelect = array_unique($arSelect, SORT_STRING); $obRes = CCrmQuote::GetList($arSort, $arFilter, false, !$isInExportMode ? $arNavParams : false, $arSelect, $arOptions); $arResult['QUOTE'] = array(); $arResult['QUOTE_ID'] = array(); $arResult['QUOTE_UF'] = array(); $now = time() + CTimeZone::GetOffset(); while ($arQuote = $obRes->GetNext()) { $arQuote['CLOSEDATE'] = !empty($arQuote['CLOSEDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arQuote['CLOSEDATE']), 'SHORT', SITE_ID)) : ''; $arQuote['BEGINDATE'] = !empty($arQuote['BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arQuote['BEGINDATE']), 'SHORT', SITE_ID)) : ''; /*$arQuote['EVENT_DATE'] = !empty($arQuote['EVENT_DATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arQuote['EVENT_DATE']), 'SHORT', SITE_ID)) : '';*/ $arQuote['~CLOSEDATE'] = $arQuote['CLOSEDATE']; $arQuote['~BEGINDATE'] = $arQuote['BEGINDATE']; /*$arQuote['~EVENT_DATE'] = $arQuote['EVENT_DATE'];*/ $currencyID = isset($arQuote['~CURRENCY_ID']) ? $arQuote['~CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID(); $arQuote['~CURRENCY_ID'] = $currencyID; $arQuote['CURRENCY_ID'] = htmlspecialcharsbx($currencyID); $arQuote['FORMATTED_OPPORTUNITY'] = CCrmCurrency::MoneyToString($arQuote['~OPPORTUNITY'], $arQuote['~CURRENCY_ID']); $entityID = $arQuote['ID']; $arQuote['PATH_TO_QUOTE_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_QUOTE_SHOW'], array('quote_id' => $entityID)); $arQuote['PATH_TO_QUOTE_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_QUOTE_EDIT'], array('quote_id' => $entityID)); $arQuote['PATH_TO_QUOTE_COPY'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_QUOTE_EDIT'], array('quote_id' => $entityID)), array('copy' => 1)); $arQuote['PATH_TO_QUOTE_DELETE'] = CHTTP::urlAddParams($bInternal ? $APPLICATION->GetCurPage() : $arParams['PATH_TO_QUOTE_LIST'], array('action_' . $arResult['GRID_ID'] => 'delete', 'ID' => $entityID, 'sessid' => bitrix_sessid())); $contactID = isset($arQuote['~CONTACT_ID']) ? intval($arQuote['~CONTACT_ID']) : 0; $arQuote['PATH_TO_CONTACT_SHOW'] = $contactID <= 0 ? '' : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $contactID));
function __CrmActivityListRenderGadgetItem(&$item, $displayClient, $editorID, $prefix) { static $ownerDataCache = array(); $typeID = isset($item['~TYPE_ID']) ? intval($item['~TYPE_ID']) : CCrmActivityType::Undefined; $direction = isset($item['~DIRECTION']) ? intval($item['~DIRECTION']) : CCrmActivityDirection::Undefined; $deadline = isset($item['~DEADLINE']) ? $item['~DEADLINE'] : ''; $completed = (isset($item['~COMPLETED']) ? $item['~COMPLETED'] : 'N') === 'Y'; $expired = !$completed && $deadline !== '' && MakeTimeStamp($deadline) <= ($now = time() + CTimeZone::GetOffset()); $subject = isset($item['~SUBJECT']) ? htmlspecialcharsbx($item['~SUBJECT']) : $item['~ID']; $descr = isset($item['~DESCRIPTION']) ? htmlspecialcharsbx($item['~DESCRIPTION']) : ''; $priority = isset($item['~PRIORITY']) ? intval($item['~PRIORITY']) : CCrmActivityPriority::None; $js = "BX.CrmActivityEditor.viewActivity('{$editorID}', {$item['~ID']}, { 'enableInstantEdit':false, 'enableEditButton':false });"; $containerClassName = 'crm-gadg-block crm-gadg-to-do'; $typeTitle = ''; if ($typeID === CCrmActivityType::Meeting) { $containerClassName .= ' crm-gadg-meeting'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_MEETING')); } elseif ($typeID === CCrmActivityType::Call) { if ($direction === CCrmActivityDirection::Outgoing) { $containerClassName .= ' crm-gadg-call-outgoing'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_CALL_OUTGOING')); } else { $containerClassName .= ' crm-gadg-call-incoming'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_CALL_INCOMING')); } } elseif ($typeID === CCrmActivityType::Email) { if ($direction === CCrmActivityDirection::Outgoing) { $containerClassName .= ' crm-gadg-email-outgoing'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_EMAIL_OUTGOING')); } else { $containerClassName .= ' crm-gadg-email-incoming'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_EMAIL_INCOMING')); } } elseif ($typeID === CCrmActivityType::Task) { $containerClassName .= ' crm-gadg-task'; $typeTitle = htmlspecialcharsbx(GetMessage('CRM_ACTION_TYPE_TASK')); } if (!$expired && $priority === CCrmActivityPriority::High) { $containerClassName .= ' crm-gadg-to-do-important'; } if ($expired) { $containerClassName .= ' crm-gadg-red'; } echo '<div class="', $containerClassName, '">'; echo '<a href="#" onclick="', $js, ' return false;" class="crm-to-do-type" title="', $typeTitle, '"></a>'; echo '<div class="crm-gadg-title">'; echo '<a href="#" class="crm-gadg-link" title="', $subject, '" onclick="', $js, ' return false;" >', $subject, '</a>', '<span class="crm-gadg-title-deadline"> ', $deadline !== '' ? CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($deadline))) : ''; if ($priority === CCrmActivityPriority::High) { echo '<span class="crm-gadg-to-do-important-icon" title="', htmlspecialcharsbx(GetMessage('CRM_ACTION_IMPORTANT')), '"></span>'; } echo '</span>'; if ($expired) { echo '<span class="crm-gadg-title-status"> ', htmlspecialcharsbx(GetMessage('CRM_ACTION_EXPIRED')), '</span>'; } elseif ($completed) { echo '<span class="crm-gadg-title-status"> ', htmlspecialcharsbx(GetMessage('CRM_ACTION_COMPLETED')), '</span>'; } echo '</div>'; if ($descr !== '') { echo '<div class="crm-gadg-text">', $descr, '</div>'; } echo '<div class="crm-gadg-footer">'; $ownerTypeID = isset($item['OWNER_TYPE_ID']) ? intval($item['OWNER_TYPE_ID']) : 0; $ownerID = isset($item['OWNER_ID']) ? intval($item['OWNER_ID']) : 0; $referenceCaption = ''; $referenceHtml = ''; if ($ownerTypeID > 0 && $ownerID > 0) { if ($ownerTypeID === CCrmOwnerType::Lead) { $referenceCaption = htmlspecialcharsbx(GetMessage('CRM_ACTION_REFERENCE_LEAD')); $key = "{$ownerTypeID}_{$ownerID}"; if (!(isset($ownerDataCache[$key]) && isset($ownerDataCache[$key]['TITLE']))) { $dbRes = CCrmLead::GetListEx(array(), array('ID' => $ownerID), false, false, array('TITLE')); if ($arRes = $dbRes->Fetch()) { $ownerDataCache[$key] = array('TITLE' => $arRes['TITLE']); } } $referenceHtml = CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Lead, 'ENTITY_ID' => $ownerID, 'PREFIX' => uniqid("{$prefix}_"), 'TITLE' => $ownerDataCache[$key]['TITLE'], 'CLASS_NAME' => 'crm-gadg-link')); } elseif ($ownerTypeID === CCrmOwnerType::Deal) { $referenceCaption = htmlspecialcharsbx(GetMessage('CRM_ACTION_REFERENCE_DEAL')); $key = "{$ownerTypeID}_{$ownerID}"; if (!(isset($ownerDataCache[$key]) && isset($ownerDataCache[$key]['TITLE']))) { $dbRes = CCrmDeal::GetListEx(array(), array('ID' => $ownerID), false, false, array('TITLE')); if ($arRes = $dbRes->Fetch()) { $ownerDataCache[$key] = array('TITLE' => $arRes['TITLE']); } } $referenceHtml = CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Deal, 'ENTITY_ID' => $ownerID, 'PREFIX' => uniqid("{$prefix}_"), 'TITLE' => $ownerDataCache[$key]['TITLE'], 'CLASS_NAME' => 'crm-gadg-link')); } } if ($referenceHtml !== '') { echo '<div class="crm-gadg-footer-row">'; echo '<span class="crm-gadg-footer-left">', $referenceCaption, ':</span>'; echo '<span class="crm-gadg-footer-right">', $referenceHtml, '</span>'; echo '</div>'; } if ($displayClient) { //Looking for first contact or company $clientHtml = ''; $commLoaded = isset($item['COMMUNICATIONS_LOADED']) ? $item['COMMUNICATIONS_LOADED'] : true; if ($commLoaded && is_array($item['COMMUNICATIONS'])) { $comms = $item['COMMUNICATIONS']; } else { //Communications are disabled. Try to load first 3 communications to resolve client $comms = CCrmActivity::GetCommunications($item['~ID'], 3); } foreach ($comms as &$comm) { $commOwnerTypeID = isset($comm['ENTITY_TYPE_ID']) ? intval($comm['ENTITY_TYPE_ID']) : 0; $commOwnerID = isset($comm['ENTITY_ID']) ? intval($comm['ENTITY_ID']) : 0; if ($commOwnerTypeID <= 0 || $commOwnerID <= 0) { continue; } $settings = isset($comm['ENTITY_SETTINGS']) ? $comm['ENTITY_SETTINGS'] : array(); if ($commOwnerTypeID === CCrmOwnerType::Company) { $clientHtml = CCrmViewHelper::PrepareClientBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $commOwnerID, 'PREFIX' => uniqid("{$prefix}_"), 'TITLE' => isset($settings['COMPANY_TITLE']) ? $settings['COMPANY_TITLE'] : '', 'CLASS_NAME' => 'crm-gadg-link')); break; } elseif ($commOwnerTypeID === CCrmOwnerType::Contact) { $clientHtml = CCrmViewHelper::PrepareClientBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $commOwnerID, 'PREFIX' => uniqid("{$prefix}_"), 'NAME' => isset($settings['NAME']) ? $settings['NAME'] : '', 'LAST_NAME' => isset($settings['LAST_NAME']) ? $settings['LAST_NAME'] : '', 'SECOND_NAME' => isset($settings['SECOND_NAME']) ? $settings['SECOND_NAME'] : '', 'CLASS_NAME' => 'crm-gadg-link')); break; } } unset($comm); if ($clientHtml !== '') { echo '<div class="crm-gadg-footer-row">'; echo '<span class="crm-gadg-footer-left">', htmlspecialcharsbx(GetMessage('CRM_ACTION_CUSTOMER')), ':</span>'; echo '<span class="crm-gadg-footer-right">', $clientHtml, '</span>'; echo '</div>'; } } echo '</div>'; echo '</div>'; }
function __CrmActivityListRenderItems($items, $showMode, $showTop, &$editorCfg) { $editorItems = array(); $count = count($items); $now = time() + CTimeZone::GetOffset(); $toolbarID = ''; if ($editorCfg['ENABLE_TOOLBAR']) { $toolbarID = $editorCfg['EDITOR_ID'] . '_toolbar'; ?> <ul id="<?php echo htmlspecialcharsbx($toolbarID); ?> " class="crm-view-actions"> <?php if ($editorCfg['ENABLE_TASK_ADD']) { ?> <li class="crm-activity-command-add-task"> <i></i> <span><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_LIST_ADD_TASK')); ?> </span> </li> <?php } ?> <?php if ($editorCfg['ENABLE_CALENDAR_EVENT_ADD']) { ?> <li class="crm-activity-command-add-call"> <i></i> <span><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_LIST_ADD_CALL')); ?> </span> </li> <li class="crm-activity-command-add-meeting"> <i></i> <span><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_LIST_ADD_MEETING')); ?> </span> </li> <?php } ?> <?php if ($editorCfg['ENABLE_EMAIL_ADD']) { ?> <li class="crm-activity-command-add-email"> <i></i> <span><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_LIST_ADD_EMAIL')); ?> </span> </li> <?php } ?> </ul> <?php } ?> <table class="crm-view-table crm-activity-table"> <thead> <tr class="crm-activity-table-head" style="<?php echo $count > 0 ? '' : 'display:none;'; ?> " > <td> </td> <td><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_ROW_COL_TTL_TYPE')); ?> </td> <td><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_ROW_COL_TTL_SUBJECT')); ?> </td> <td><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_ROW_COL_TTL_DEAD_LINE')); ?> </td> <td><?php echo htmlspecialcharsbx(GetMessage('CRM_ACTIVITY_ROW_COL_TTL_RESPONSIBLE')); ?> </td> </tr> </thead> <tbody> <?php $processed = 0; for ($i = 0; $i < $count; $i++) { $item =& $items[$i]; if ($showMode == 'NOT_COMPLETED' && $item['COMPLETED'] == 'Y' || $showMode == 'COMPLETED' && $item['COMPLETED'] == 'N') { continue; } $processed++; $commData = array(); if (isset($item['COMMUNICATIONS'])) { foreach ($item['COMMUNICATIONS'] as &$arComm) { CCrmActivity::PrepareCommunicationInfo($arComm); $commData[] = array('id' => $arComm['ID'], 'type' => $arComm['TYPE'], 'value' => $arComm['VALUE'], 'entityId' => $arComm['ENTITY_ID'], 'entityType' => CCrmOwnerType::ResolveName($arComm['ENTITY_TYPE_ID']), 'entityTitle' => $arComm['TITLE']); } unset($arComm); } $rowID = $editorCfg['PREFIX']; if ($rowID !== '') { $rowID .= '_'; } $rowID .= '_row_' . strval($processed); $editorItem = array('ID' => $item['~ID'], 'rowID' => $rowID, 'typeID' => $item['~TYPE_ID'], 'subject' => strval($item['~SUBJECT']), 'description' => strval($item['~DESCRIPTION']), 'direction' => intval($item['~DIRECTION']), 'location' => strval($item['~LOCATION']), 'start' => isset($item['~START_TIME']) ? ConvertTimeStamp(MakeTimeStamp($item['~START_TIME']), 'FULL', SITE_ID) : '', 'end' => isset($item['~END_TIME']) ? ConvertTimeStamp(MakeTimeStamp($item['~END_TIME']), 'FULL', SITE_ID) : '', 'deadline' => isset($item['~DEADLINE']) ? ConvertTimeStamp(MakeTimeStamp($item['~DEADLINE']), 'FULL', SITE_ID) : '', 'completed' => strval($item['~COMPLETED']) == 'Y', 'notifyType' => intval($item['~NOTIFY_TYPE']), 'notifyValue' => intval($item['~NOTIFY_VALUE']), 'priority' => intval($item['~PRIORITY']), 'responsibleID' => isset($item['~RESPONSIBLE_ID'][0]) ? intval($item['~RESPONSIBLE_ID']) : 0, 'responsibleName' => isset($item['~RESPONSIBLE_FULL_NAME'][0]) ? $item['~RESPONSIBLE_FULL_NAME'] : GetMessage('CRM_UNDEFINED_VALUE'), 'storageTypeID' => intval($item['STORAGE_TYPE_ID']), 'files' => $item['FILES'], 'webdavelements' => $item['WEBDAV_ELEMENTS'], 'associatedEntityID' => isset($item['~ASSOCIATED_ENTITY_ID']) ? intval($item['~ASSOCIATED_ENTITY_ID']) : 0, 'communications' => $commData); if (isset($item['OWNER_TYPE_ID']) && isset($item['OWNER_ID'])) { $editorItem['ownerType'] = CCrmOwnerType::ResolveName($item['OWNER_TYPE_ID']); $editorItem['ownerID'] = $item['OWNER_ID']; $editorItem['ownerTitle'] = CCrmOwnerType::GetCaption($item['OWNER_TYPE_ID'], $item['OWNER_ID']); $editorItem['ownerUrl'] = CCrmOwnerType::GetShowUrl($item['OWNER_TYPE_ID'], $item['OWNER_ID']); } $editorItems[] = $editorItem; $rowClass = 'crm-activity-row'; if ($processed % 2 === 0) { $rowClass .= ' crm-activity-row-even'; } if (intval($item['~PRIORITY']) === CCrmActivityPriority::High) { $rowClass .= ' crm-activity-row-important'; } ?> <tr id="<?php echo htmlspecialcharsbx($rowID); ?> " class="<?php echo htmlspecialcharsbx($rowClass); ?> " style="<?php echo $showTop > 0 && $processed > $showTop ? 'display:none;' : ''; ?> "> <td><!--Delete--> <?php if (!$arResult['READ_ONLY']) { ?> <span class="crm-view-table-column-delete"></span> <?php } ?> </td> <td> <!--Type--> <a class="crm-activity-type" href="#"><?php echo $item['TYPE_NAME']; ?> </a> </td> <td> <!--Subject--> <a class="crm-activity-subject" href="#"><?php echo $item['SUBJECT']; ?> </a> </td> <td> <!--End time--> <?php $deadline = isset($item['~DEADLINE']) ? MakeTimeStamp($item['~DEADLINE']) : null; ?> <span <?php echo $item['~COMPLETED'] !== 'Y' && $deadline !== null && $deadline < $now ? 'style="color:#ff0000;"' : ''; ?> > <?php echo $deadline !== null ? htmlspecialcharsbx(CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', $deadline))) : ''; ?> </span> </td> <td> <!--Responsible--> <span> <?php echo isset($item['RESPONSIBLE_FULL_NAME'][0]) ? $item['RESPONSIBLE_FULL_NAME'] : GetMessage('CRM_UNDEFINED_VALUE'); ?> </span> </td> </tr> <?php } unset($item); ?> </tbody> </table> <?php if ($showTop > 0 && $processed > $showTop) { ?> <div class="crm-activity-show-all-wrapper"> <a href="#" class="crm-activity-command-show-all" ><?php echo str_replace('#COUNT#', strval($processed), GetMessage('CRM_ACTIVITY_SHOW_ALL')); ?> </a> </div> <?php } $GLOBALS['APPLICATION']->IncludeComponent('bitrix:crm.activity.editor', '', array('CONTAINER_ID' => $editorCfg['CONTAINER_ID'], 'EDITOR_ID' => $editorCfg['EDITOR_ID'], 'EDITOR_TYPE' => $editorCfg['EDITOR_TYPE'], 'PREFIX' => $editorCfg['PREFIX'], 'OWNER_TYPE' => $editorCfg['OWNER_TYPE'], 'OWNER_ID' => $editorCfg['OWNER_ID'], 'ENABLE_TASK_ADD' => $editorCfg['ENABLE_TASK_ADD'], 'ENABLE_CALENDAR_EVENT_ADD' => $editorCfg['ENABLE_CALENDAR_EVENT_ADD'], 'ENABLE_EMAIL_ADD' => $editorCfg['ENABLE_EMAIL_ADD'], 'READ_ONLY' => $editorCfg['READ_ONLY'], 'ENABLE_UI' => $editorCfg['ENABLE_UI'], 'ENABLE_TOOLBAR' => $editorCfg['ENABLE_TOOLBAR'], 'TOOLBAR_ID' => $toolbarID, 'BUTTON_ID' => $editorCfg['BUTTON_ID'], 'EDITOR_ITEMS' => $editorItems), null, array('HIDE_ICONS' => 'Y')); }
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' => " {$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), ' %</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; } }
foreach ($arErrors as $err) { $arResult['ERROR_MESSAGE'] .= $err[1].'<br />'; } } } }*/ /*---bizproc---if (empty($arResult['ERROR_MESSAGE'])) { if (!$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) $arResult['ERROR_MESSAGE'] = $CCrmBizProc->LAST_ERROR; }*/ $ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0; if (!empty($arResult['ERROR_MESSAGE'])) { ShowError($arResult['ERROR_MESSAGE']); $arResult['ELEMENT'] = CCrmComponentHelper::PrepareEntityFields(array_merge(array('ID' => $ID), $arFields), CCrmQuote::GetFields()); } else { /*if (intval($_POST['SYNC_ORDER_ID']) > 0) { LocalRedirect( CComponentEngine::MakePathFromTemplate( $arParams['PATH_TO_QUOTE_SHOW'], array('quote_id' => $ID) ) ); }*/ if (isset($_POST['apply'])) { if (CCrmQuote::CheckUpdatePermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_QUOTE_EDIT'], array('quote_id' => $ID))); } } elseif (isset($_POST['saveAndAdd'])) {
public static function PrepareActivityData(&$fields) { $typeID = isset($fields['TYPE_ID']) ? intval($fields['TYPE_ID']) : CCrmActivityType::Undefined; $direction = isset($fields['DIRECTION']) ? intval($fields['DIRECTION']) : CCrmActivityDirection::Undefined; $isCompleted = $fields['COMPLETED'] === 'Y'; $imageFileName = ''; if ($typeID === CCrmActivityType::Call) { $imageFileName = $direction === CCrmActivityDirection::Incoming ? 'call_in' : 'call_out'; } elseif ($typeID === CCrmActivityType::Email) { $imageFileName = $direction === CCrmActivityDirection::Incoming ? 'email_in' : 'email_out'; } elseif ($typeID === CCrmActivityType::Meeting) { $imageFileName = 'cont'; } elseif ($typeID === CCrmActivityType::Task) { $imageFileName = 'check'; } if ($imageFileName !== '' && $isCompleted) { $imageFileName .= '_disabled'; } $imageUrl = $imageFileName !== '' ? SITE_DIR . 'bitrix/templates/mobile_app/images/crm/' . $imageFileName . '.png?ver=1' : ''; $data = array('ID' => $fields['ID'], 'TYPE_ID' => $fields['TYPE_ID'], 'OWNER_ID' => $fields['OWNER_ID'], 'OWNER_TYPE' => CCrmOwnerType::ResolveName($fields['OWNER_TYPE_ID']), 'SUBJECT' => isset($fields['SUBJECT']) ? $fields['SUBJECT'] : '', 'DESCRIPTION' => isset($fields['DESCRIPTION']) ? $fields['DESCRIPTION'] : '', 'LOCATION' => isset($fields['LOCATION']) ? $fields['LOCATION'] : '', 'START_TIME' => isset($fields['START_TIME']) ? CCrmComponentHelper::RemoveSeconds(ConvertTimeStamp(MakeTimeStamp($fields['START_TIME']), 'FULL', SITE_ID)) : '', 'END_TIME' => isset($fields['END_TIME']) ? CCrmComponentHelper::RemoveSeconds(ConvertTimeStamp(MakeTimeStamp($fields['END_TIME']), 'FULL', SITE_ID)) : '', 'DEAD_LINE' => isset($fields['DEAD_LINE']) ? CCrmComponentHelper::RemoveSeconds(ConvertTimeStamp(MakeTimeStamp($fields['DEAD_LINE']), 'FULL', SITE_ID)) : '', 'COMPLETED' => isset($fields['COMPLETED']) ? $fields['COMPLETED'] === 'Y' : false, 'PRIORITY' => isset($fields['PRIORITY']) ? intval($fields['PRIORITY']) : CCrmActivityPriority::None, 'IS_IMPORTANT' => isset($fields['IS_IMPORTANT']) ? $fields['IS_IMPORTANT'] : false, 'IS_EXPIRED' => isset($fields['IS_EXPIRED']) ? $fields['IS_EXPIRED'] : false, 'OWNER_TITLE' => isset($fields['OWNER_TITLE']) ? $fields['OWNER_TITLE'] : '', 'SHOW_URL' => isset($fields['SHOW_URL']) ? $fields['SHOW_URL'] : '', 'LIST_IMAGE_URL' => $imageUrl, 'VIEW_IMAGE_URL' => $imageUrl, 'STORAGE_TYPE_ID' => $fields['STORAGE_TYPE_ID'], 'FILES' => isset($fields['FILES']) ? $fields['FILES'] : array(), 'WEBDAV_ELEMENTS' => isset($fields['WEBDAV_ELEMENTS']) ? $fields['WEBDAV_ELEMENTS'] : array()); //COMMUNICATIONS if (isset($fields['COMMUNICATIONS'])) { $communications = $fields['COMMUNICATIONS']; foreach ($communications as &$comm) { CCrmActivity::PrepareCommunicationInfo($comm); $comm['ENTITY_TYPE'] = CCrmOwnerType::ResolveName($comm['ENTITY_TYPE_ID']); unset($comm['ENTITY_TYPE_ID']); if (isset($comm['ENTITY_SETTINGS'])) { // entity settings is useless for client unset($comm['ENTITY_SETTINGS']); } } unset($comm); $data['COMMUNICATIONS'] = $communications; } return $data; }
'actionName': '<?php echo CUtil::JSEscape($actionName); ?> ', 'dialog': <?php echo CUtil::PhpToJSObject($dialogSettings); ?> } ); } ); </script><?php } break; case 'crm_client_selector': CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/crm.js'); $params = isset($field['componentParams']) ? $field['componentParams'] : array(); if (!empty($params)) { $entityID = $inputValue = isset($params['INPUT_VALUE']) ? $params['INPUT_VALUE'] : ''; $entityType = isset($params['ENTITY_TYPE']) ? $params['ENTITY_TYPE'] : ''; switch (substr($entityID, 0, 2)) { case 'C_': $valEntityType = 'contact'; break; case 'CO': $valEntityType = 'company'; break; default: $valEntityType = ''; } $entityID = intval(substr($entityID, intval(strpos($entityID, '_')) + 1));
} } LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_TAX_LIST'], array())); } } $arResult['FIELDS'] = array(); /* $arResult['FIELDS']['tab_props'][] = array( 'id' => 'tax_info', 'name' => GetMessage('CRM_TAX_SECTION_MAIN'), 'type' => 'section' ); */ if (strlen($arParams['TAX_ID']) > 0) { $arResult['FIELDS']['tab_props'][] = array('id' => 'ID', 'name' => GetMessage('CRM_TAX_FIELD_ID'), 'value' => $taxID, 'type' => 'label'); $arResult['FIELDS']['tab_props'][] = array('id' => 'TIMESTAMP_X', 'name' => GetMessage('CRM_TAX_FIELD_TIMESTAMP_X'), 'value' => CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($tax['TIMESTAMP_X']))), 'type' => 'label'); } /* $arResult['FIELDS']['tab_props'][] = array( 'id' => 'LID', 'name' => GetMessage('CRM_TAX_FIELD_LID'), 'value' => $tax['LID'], 'type' => 'list', 'items' => CCrmTax::getSitesList() ); */ $arResult['FIELDS']['tab_props'][] = array('id' => 'NAME', 'name' => GetMessage('CRM_TAX_FIELD_NAME'), 'value' => htmlspecialcharsbx($tax['NAME']), 'type' => 'text'); $arResult['FIELDS']['tab_props'][] = array('id' => 'CODE', 'name' => GetMessage('CRM_TAX_FIELD_CODE'), 'value' => htmlspecialcharsbx($tax['CODE']), 'type' => 'text'); $arResult['FIELDS']['tab_props'][] = array('id' => 'DESCRIPTION', 'name' => GetMessage('CRM_TAX_FIELD_DESCRIPTION'), 'value' => $tax['DESCRIPTION'], 'type' => 'textarea'); $toolbarButtons = array(); if (Loader::includeModule('sale') && CSaleLocation::isLocationProEnabled()) {
$arResult['FIELDS']['tab_1'][] = array('id' => 'PROBABILITY', 'name' => GetMessage('CRM_FIELD_PROBABILITY'), 'type' => 'label', 'params' => array('size' => 50), 'value' => isset($arResult['ELEMENT']['~PROBABILITY']) ? $arResult['ELEMENT']['~PROBABILITY'] : '', 'isTactile' => true); // <-- PROBABILITY // ASSIGNED_BY_ID is displayed in sidebar. The field is added for COMPATIBILITY ONLY if ($enableInstantEdit) { $arResult['EDITABLE_FIELDS'][] = 'ASSIGNED_BY_ID'; } $arResult['FIELDS']['tab_1'][] = array('id' => 'ASSIGNED_BY_ID', 'name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID'), 'type' => 'custom', 'value' => CCrmViewHelper::PrepareFormResponsible($arResult['ELEMENT']['~ASSIGNED_BY_ID'], $arParams['NAME_TEMPLATE'], $arParams['PATH_TO_USER_PROFILE']), 'isTactile' => true); // <-- ASSIGNED_BY_ID if ($enableInstantEdit) { $arResult['EDITABLE_FIELDS'][] = 'BEGINDATE'; } $arResult['FIELDS']['tab_details'][] = array('id' => 'BEGINDATE', 'name' => GetMessage('CRM_FIELD_BEGINDATE'), 'params' => array('size' => 20), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['BEGINDATE']), 'SHORT', SITE_ID)) : '', 'isTactile' => true); if ($enableInstantEdit) { $arResult['EDITABLE_FIELDS'][] = 'CLOSEDATE'; } $arResult['FIELDS']['tab_details'][] = array('id' => 'CLOSEDATE', 'name' => GetMessage('CRM_FIELD_CLOSEDATE'), 'params' => array('size' => 20), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['CLOSEDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['CLOSEDATE']), 'SHORT', SITE_ID)) : '', 'isTactile' => true); // TYPE --> if ($enableInstantEdit) { $arResult['EDITABLE_FIELDS'][] = 'TYPE_ID'; } $arResult['FIELDS']['tab_1'][] = array('id' => 'TYPE_ID', 'name' => GetMessage('CRM_FIELD_TYPE_ID'), 'type' => 'label', 'items' => $arResult['TYPE_LIST'], 'value' => $arResult['ELEMENT']['TYPE_TEXT'], 'isTactile' => true); // <-- TYPE // CLOSED --> $arResult['FIELDS']['tab_1'][] = array('id' => 'CLOSED', 'name' => GetMessage('CRM_FIELD_CLOSED'), 'type' => 'label', 'value' => isset($arResult['ELEMENT']['CLOSED']) ? $arResult['ELEMENT']['CLOSED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO') : GetMessage('MAIN_NO'), 'isTactile' => true); // <-- CLOSED // 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);
public static function RenderProgressControl($arParams) { if (!is_array($arParams)) { return ''; } CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/progress_control.js'); $entityTypeName = isset($arParams['ENTITY_TYPE_NAME']) ? $arParams['ENTITY_TYPE_NAME'] : ''; $leadTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Lead); $dealTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Deal); $invoiceTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Invoice); $quoteTypeName = CCrmOwnerType::ResolveName(CCrmOwnerType::Quote); $infos = isset($arParams['INFOS']) ? $arParams['INFOS'] : null; if (!is_array($infos) || empty($infos)) { if ($entityTypeName === $leadTypeName) { if (!self::$LEAD_STATUSES) { self::$LEAD_STATUSES = CCrmStatus::GetStatus('STATUS'); } $infos = self::$LEAD_STATUSES; } elseif ($entityTypeName === $dealTypeName) { if (!self::$DEAL_STAGES) { self::$DEAL_STAGES = CCrmStatus::GetStatus('DEAL_STAGE'); } $infos = self::$DEAL_STAGES; } elseif ($entityTypeName === $quoteTypeName) { if (!self::$QUOTE_STATUSES) { self::$QUOTE_STATUSES = CCrmStatus::GetStatus('QUOTE_STATUS'); } $infos = self::$QUOTE_STATUSES; } elseif ($entityTypeName === $invoiceTypeName) { if (!self::$INVOICE_STATUSES) { self::$INVOICE_STATUSES = CCrmStatus::GetStatus('INVOICE_STATUS'); } $infos = self::$INVOICE_STATUSES; } } if (!is_array($infos) || empty($infos)) { return ''; } $registerSettings = isset($arParams['REGISTER_SETTINGS']) && is_bool($arParams['REGISTER_SETTINGS']) ? $arParams['REGISTER_SETTINGS'] : false; $registrationScript = ''; if ($registerSettings) { if ($entityTypeName === $leadTypeName) { $registrationScript = self::RenderLeadStatusSettings(); } elseif ($entityTypeName === $dealTypeName) { $registrationScript = self::RenderDealStageSettings(); } elseif ($entityTypeName === $quoteTypeName) { $registrationScript = self::RenderQuoteStatusSettings(); } elseif ($entityTypeName === $invoiceTypeName) { $registrationScript = self::RenderInvoiceStatusSettings(); } } $finalID = isset($arParams['FINAL_ID']) ? $arParams['FINAL_ID'] : ''; if ($finalID === '') { if ($entityTypeName === $leadTypeName) { $finalID = 'CONVERTED'; } elseif ($entityTypeName === $dealTypeName) { $finalID = 'WON'; } elseif ($entityTypeName === $quoteTypeName) { $finalID = 'APPROVED'; } elseif ($entityTypeName === $invoiceTypeName) { $finalID = 'P'; } } $finalUrl = isset($arParams['FINAL_URL']) ? $arParams['FINAL_URL'] : ''; if ($finalUrl === '' && $entityTypeName === $leadTypeName) { $arParams['FINAL_URL'] = isset($arParams['LEAD_CONVERT_URL']) ? $arParams['LEAD_CONVERT_URL'] : ''; } $currentInfo = null; $currentID = isset($arParams['CURRENT_ID']) ? $arParams['CURRENT_ID'] : ''; if ($currentID !== '' && isset($infos[$currentID])) { $currentInfo = $infos[$currentID]; } $currentSort = is_array($currentInfo) && isset($currentInfo['SORT']) ? intval($currentInfo['SORT']) : -1; $finalInfo = null; if ($finalID !== '' && isset($infos[$finalID])) { $finalInfo = $infos[$finalID]; } $finalSort = is_array($finalInfo) && isset($finalInfo['SORT']) ? intval($finalInfo['SORT']) : -1; $isSuccessful = $currentSort === $finalSort; $isFailed = $currentSort > $finalSort; $stepHtml = ''; foreach ($infos as &$info) { $ID = isset($info['STATUS_ID']) ? $info['STATUS_ID'] : ''; $sort = isset($info['SORT']) ? intval($info['SORT']) : 0; if ($sort > $finalSort) { break; } $stepHtml .= '<td class="crm-list-stage-bar-part'; if ($sort <= $currentSort) { $stepHtml .= ' crm-list-stage-passed'; } $stepHtml .= '"><div class="crm-list-stage-bar-block crm-stage-' . htmlspecialcharsbx(strtolower($ID)) . '"><div class="crm-list-stage-bar-btn"></div></div></td>'; } unset($info); $wrapperClass = ''; if ($isSuccessful) { $wrapperClass = ' crm-list-stage-end-good'; } elseif ($isFailed) { $wrapperClass = ' crm-list-stage-end-bad'; } $prefix = isset($arParams['PREFIX']) ? $arParams['PREFIX'] : ''; $entityID = isset($arParams['ENTITY_ID']) ? intval($arParams['ENTITY_ID']) : 0; $controlID = isset($arParams['CONTROL_ID']) ? $arParams['CONTROL_ID'] : ''; if ($controlID === '') { $controlID = $entityTypeName !== '' && $entityID > 0 ? "{$prefix}{$entityTypeName}_{$entityID}" : uniqid($prefix); } $isReadOnly = isset($arParams['READ_ONLY']) ? (bool) $arParams['READ_ONLY'] : false; $legendContainerID = isset($arParams['LEGEND_CONTAINER_ID']) ? $arParams['LEGEND_CONTAINER_ID'] : ''; $displayLegend = $legendContainerID === '' && (!isset($arParams['DISPLAY_LEGEND']) || $arParams['DISPLAY_LEGEND']); $legendHtml = ''; if ($displayLegend) { $legendHtml = '<div class="crm-list-stage-bar-title">' . htmlspecialcharsbx(isset($infos[$currentID]) && isset($infos[$currentID]['NAME']) ? $infos[$currentID]['NAME'] : $currentID) . '</div>'; } return $registrationScript . '<div class="crm-list-stage-bar' . $wrapperClass . '" id="' . htmlspecialcharsbx($controlID) . '"><table class="crm-list-stage-bar-table"><tr>' . $stepHtml . '</tr></table>' . '<script type="text/javascript">BX.ready(function(){ BX.CrmProgressControl.create("' . CUtil::JSEscape($controlID) . '"' . ', BX.CrmParamBag.create({"containerId": "' . CUtil::JSEscape($controlID) . '"' . ', "entityType":"' . CUtil::JSEscape($entityTypeName) . '"' . ', "entityId":"' . CUtil::JSEscape($entityID) . '"' . ', "legendContainerId":"' . CUtil::JSEscape($legendContainerID) . '"' . ', "serviceUrl":"' . (isset($arParams['SERVICE_URL']) ? CUtil::JSEscape($arParams['SERVICE_URL']) : '') . '"' . ', "finalUrl":"' . (isset($arParams['FINAL_URL']) ? CUtil::JSEscape($arParams['FINAL_URL']) : '') . '"' . ', "finalScript":"' . (isset($arParams['FINAL_SCRIPT']) ? CUtil::JSEscape($arParams['FINAL_SCRIPT']) : '') . '"' . ', "currentStepId":"' . CUtil::JSEscape($currentID) . '"' . ', "readOnly":' . ($isReadOnly ? 'true' : 'false') . ' }));});</script>' . '</div>' . $legendHtml; }
$arResult['GRID_ID'] = 'CRM_INVOICE_LIST_V12' . ($isExternal ? "_E" : ""); $arResult['BACK_URL'] = $arParams['PATH_TO_INVOICE_LIST']; $enableInstantEdit = $arResult['ENABLE_INSTANT_EDIT'] = $arResult['CAN_EDIT']; $arResult['FIELDS'] = array(); $readOnlyMode = !$enableInstantEdit || $isExternal; $arResult['FIELDS']['tab_1'][] = array('id' => 'section_invoice_info', 'name' => GetMessage('CRM_SECTION_INVOICE_INFO'), 'type' => 'section', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'ACCOUNT_NUMBER', 'name' => GetMessage('CRM_FIELD_ACCOUNT_NUMBER'), 'params' => array('size' => 100), 'value' => isset($arResult['ELEMENT']['ACCOUNT_NUMBER']) ? $arResult['ELEMENT']['ACCOUNT_NUMBER'] : '', 'type' => 'label', 'required' => true, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'ORDER_TOPIC', 'name' => GetMessage('CRM_FIELD_ORDER_TOPIC'), 'params' => array('size' => 255), 'value' => isset($arResult['ELEMENT']['ORDER_TOPIC']) ? $arResult['ELEMENT']['ORDER_TOPIC'] : '', 'type' => 'label', 'required' => true, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'STATUS_ID', 'name' => GetMessage('CRM_FIELD_STATUS_ID'), 'type' => 'label', 'value' => $arResult['ELEMENT']['STATUS_TEXT'], 'required' => true, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'PAY_VOUCHER_DATE', 'name' => GetMessage('CRM_FIELD_PAY_VOUCHER_DATE'), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['PAY_VOUCHER_DATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['PAY_VOUCHER_DATE']), 'SHORT', SITE_ID)) : '', 'visible' => $bStatusSuccess, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'PAY_VOUCHER_NUM', 'name' => GetMessage('CRM_FIELD_PAY_VOUCHER_NUM'), 'type' => 'label', 'value' => isset($arResult['ELEMENT']['PAY_VOUCHER_NUM']) ? $arResult['ELEMENT']['PAY_VOUCHER_NUM'] : '', 'visible' => $bStatusSuccess, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'REASON_MARKED_SUCCESS', 'name' => GetMessage('CRM_FIELD_REASON_MARKED_SUCCESS'), 'value' => isset($arResult['ELEMENT']['REASON_MARKED_SUCCESS']) ? $arResult['ELEMENT']['REASON_MARKED_SUCCESS'] : '', 'type' => 'label', 'visible' => $bStatusSuccess, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'DATE_MARKED', 'name' => GetMessage('CRM_FIELD_DATE_MARKED'), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['DATE_MARKED']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['DATE_MARKED']), 'SHORT', SITE_ID)) : '', 'visible' => $bStatusFailed, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'REASON_MARKED', 'name' => GetMessage('CRM_FIELD_REASON_MARKED'), 'value' => isset($arResult['ELEMENT']['REASON_MARKED']) ? $arResult['ELEMENT']['REASON_MARKED'] : '', 'type' => 'label', 'visible' => $bStatusFailed, 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'DATE_BILL', 'name' => GetMessage('CRM_FIELD_DATE_BILL'), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['DATE_BILL']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['DATE_BILL']), 'SHORT', SITE_ID)) : '', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'DATE_PAY_BEFORE', 'name' => GetMessage('CRM_FIELD_DATE_PAY_BEFORE'), 'type' => 'label', 'value' => !empty($arResult['ELEMENT']['DATE_PAY_BEFORE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['DATE_PAY_BEFORE']), 'SHORT', SITE_ID)) : '', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'RESPONSIBLE_ID', 'name' => GetMessage('CRM_FIELD_RESPONSIBLE_ID'), 'type' => 'custom', 'value' => isset($arResult['ELEMENT']['RESPONSIBLE_ID']) ? CCrmViewHelper::PrepareFormResponsible($arResult['ELEMENT']['RESPONSIBLE_ID'], $arParams['NAME_TEMPLATE'], $arParams['PATH_TO_USER_PROFILE']) : '', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'CURRENCY_ID', 'name' => GetMessage('CRM_FIELD_CURRENCY_ID'), 'params' => array('size' => 50), 'type' => 'label', 'value' => htmlspecialcharsbx(isset($arResult['CURRENCY_LIST'][$currencyID]) ? $arResult['CURRENCY_LIST'][$currencyID] : $currencyID), 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'UF_DEAL_ID', 'name' => GetMessage('CRM_FIELD_UF_DEAL_ID'), 'value' => isset($arResult['ELEMENT']['UF_DEAL_TITLE']) ? !CCrmDeal::CheckReadPermission($dealID) ? htmlspecialcharsbx($arResult['ELEMENT']['UF_DEAL_TITLE']) : '<a href="' . $arResult['PATH_TO_DEAL_SHOW'] . '" id="balloon_' . $arResult['GRID_ID'] . '_D_' . $dealID . '">' . htmlspecialcharsbx($arResult['ELEMENT']['UF_DEAL_TITLE']) . '</a>' . '<script type="text/javascript">BX.tooltip("DEAL_' . $dealID . '", "balloon_' . $arResult['GRID_ID'] . '_D_' . $dealID . '", "/bitrix/components/bitrix/crm.deal.show/card.ajax.php", "crm_balloon_deal", true);</script>' : GetMessage('CRM_INVOICE_DEAL_NOT_ASSIGNED'), 'type' => 'custom', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'UF_QUOTE_ID', 'name' => GetMessage('CRM_FIELD_UF_QUOTE_ID'), 'value' => isset($arResult['ELEMENT']['UF_QUOTE_TITLE']) ? !CCrmQuote::CheckReadPermission($quoteID) ? htmlspecialcharsbx($arResult['ELEMENT']['UF_QUOTE_TITLE']) : '<a href="' . $arResult['PATH_TO_QUOTE_SHOW'] . '" id="balloon_' . $arResult['GRID_ID'] . '_Q_' . $quoteID . '">' . htmlspecialcharsbx($arResult['ELEMENT']['UF_QUOTE_TITLE']) . '</a>' . '<script type="text/javascript">BX.tooltip("QUOTE_' . $quoteID . '", "balloon_' . $arResult['GRID_ID'] . '_Q_' . $quoteID . '", "/bitrix/components/bitrix/crm.quote.show/card.ajax.php", "crm_balloon_quote", true);</script>' : GetMessage('CRM_INVOICE_QUOTE_NOT_ASSIGNED'), 'type' => 'custom', 'isTactile' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'section_invoice_payer', 'name' => GetMessage('CRM_SECTION_INVOICE_PAYER'), 'type' => 'section', 'isTactile' => true); $clientField = array('id' => 'CLIENT_ID', 'name' => GetMessage('CRM_FIELD_CLIENT_ID'), 'value' => '', 'type' => 'custom', 'isTactile' => true); $contactHtml = ''; if ($contactID > 0) { $formattedName = isset($arResult['ELEMENT']['UF_CONTACT_FORMATTED_NAME']) ? htmlspecialcharsbx($arResult['ELEMENT']['UF_CONTACT_FORMATTED_NAME']) : ''; $contactHtml = $formattedName !== '' ? !CCrmContact::CheckReadPermission($contactID) ? $formattedName : '<a href="' . $arResult['PATH_TO_CONTACT_SHOW'] . '" id="balloon_' . $arResult['GRID_ID'] . '_C_' . $contactID . '">' . $formattedName . '</a>' . '<script type="text/javascript">BX.tooltip("CONTACT_' . $contactID . '", "balloon_' . $arResult['GRID_ID'] . '_C_' . $contactID . '", "' . SITE_DIR . 'bitrix/components/bitrix/crm.contact.show/card.ajax.php", "crm_balloon_contact", true);</script>' : ''; } if ($companyID > 0) { $title = isset($arResult['ELEMENT']['UF_COMPANY_TITLE']) ? htmlspecialcharsbx($arResult['ELEMENT']['UF_COMPANY_TITLE']) : ''; $clientField['value'] = $title !== '' ? !CCrmCompany::CheckReadPermission($companyID) ? $title : '<a href="' . $arResult['PATH_TO_COMPANY_SHOW'] . '" id="balloon_' . $arResult['GRID_ID'] . '_CO_' . $companyID . '">' . $title . '</a>' . '<script type="text/javascript">BX.tooltip("COMPANY_' . $companyID . '", "balloon_' . $arResult['GRID_ID'] . '_CO_' . $companyID . '", "' . SITE_DIR . 'bitrix/components/bitrix/crm.company.show/card.ajax.php", "crm_balloon_company", true);</script>' : GetMessage('CRM_INVOICE_CLIENT_NOT_ASSIGNED'); } elseif ($contactID > 0) {
$APPLICATION->ResetException(); if (!empty($errCode)) { $errMsg = GetMessage('CRM_ERR_SAVE_INVOICE_' . $errCode); } if ($errMsg == '') { $errMsg = $ex->GetString(); } } $arResult['ERROR_MESSAGE'] = (!empty($errMsg) ? $errMsg : GetMessage('UNKNOWN_ERROR')) . "<br />\n"; unset($errCode, $errMsg); } } $ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0; if (!empty($arResult['ERROR_MESSAGE'])) { ShowError($arResult['ERROR_MESSAGE']); $arResult['ELEMENT'] = CCrmComponentHelper::PrepareEntityFields(array_merge(array('ID' => $ID), $arFields), array('ORDER_TOPIC' => array('TYPE' => 'string'), 'STATUS_ID' => array('TYPE' => 'int'), 'DATE_INSERT' => array('TYPE' => 'datetime'), 'DATE_BILL' => array('TYPE' => 'date'), 'DATE_PAY_BEFORE' => array('TYPE' => 'date'), 'RESPONSIBLE_ID' => array('TYPE' => 'int'), 'COMMENTS' => array('TYPE' => 'string'), 'USER_DESCRIPTION' => array('TYPE' => 'string'), 'ACCOUNT_NUMBER' => array('TYPE' => 'string'), 'UF_QUOTE_ID' => array('TYPE' => 'int'), 'UF_DEAL_ID' => array('TYPE' => 'int'), 'UF_COMPANY_ID' => array('TYPE' => 'int'), 'UF_CONTACT_ID' => array('TYPE' => 'int'), 'PAY_VOUCHER_NUM' => array('TYPE' => 'string'), 'PAY_VOUCHER_DATE' => array('TYPE' => 'datetime'), 'REASON_MARKED' => array('TYPE' => 'string'), 'DATE_MARKED' => array('TYPE' => 'datetime'))); } else { if (isset($_POST['apply'])) { if (CCrmInvoice::CheckUpdatePermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'], array('invoice_id' => $ID))); } } elseif (isset($_POST['saveAndAdd'])) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'], array('invoice_id' => 0))); } elseif (isset($_POST['saveAndView'])) { if (CCrmInvoice::CheckReadPermission($ID)) { LocalRedirect(empty($arResult['INVOICE_REFERER']) ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_SHOW'], array('invoice_id' => $ID)) : $arResult['INVOICE_REFERER']); } } // save LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_LIST'], array())); }
$gridOptions = new CCrmGridOptions($arResult['GRID_ID']); $gridSorting = $gridOptions->GetSorting(array('sort' => array('NAME' => 'asc'), 'vars' => array('by' => 'by', 'order' => 'order'))); $sort = $arResult['SORT'] = $gridSorting['sort']; $arResult['SORT_VARS'] = $gridSorting['vars']; $arLangs = array(); $dbLangsList = CSite::GetList($b = "sort", $o = "asc"); while ($arLang = $dbLangsList->Fetch()) { $arLangs[$arLang["LID"]] = "[" . $arLang["LID"] . "] " . $arLang["NAME"]; } $taxies = array(); $allTaxies = CCrmTax::GetAll(); foreach ($allTaxies as $k => $v) { $tax = array(); $tax['ID'] = $tax['~ID'] = $k; // Key is Currency ID $tax['TIMESTAMP_X'] = $tax['~TIMESTAMP_X'] = CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($v['TIMESTAMP_X']))); $tax['LID'] = $arLangs[$v['LID']]; $tax['NAME'] = $v['NAME']; $tax['CODE'] = $v['CODE']; $tax['PATH_TO_TAX_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_TAX_SHOW'], array('tax_id' => $k)); $tax['PATH_TO_TAX_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_TAX_EDIT'], array('tax_id' => $k)); $tax['PATH_TO_TAX_SHOW_RATES'] = CHTTP::urlAddParams($tax['PATH_TO_TAX_EDIT'], array("FORM_ID" => $arResult['EDIT_FORM_ID'], $arResult['EDIT_FORM_ID'] . "_active_tab" => 'tab_rateslist')); $tax['PATH_TO_TAX_DELETE'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_TAX_LIST'], array('tax_id' => $k)), array('action_' . $arResult['GRID_ID'] => 'delete', 'ID' => $k, 'sessid' => bitrix_sessid())); $rateNum = 0; $dbRes = CSaleTaxRate::GetList(array(), array("TAX_ID" => $tax['ID'])); while ($dbRes->Fetch()) { $rateNum++; } if ($rateNum > 0) { $rateNumShow = "<a href=\"" . $tax['PATH_TO_TAX_SHOW_RATES'] . "\">" . $rateNum . "</a>"; } else {
while ($arDeal = $navDbResult->Fetch()) { $arResult['DEAL'][$arDeal['ID']] = $arDeal; $arResult['DEAL_ID'][$arDeal['ID']] = $arDeal['ID']; $arResult['DEAL_UF'][$arDeal['ID']] = array(); } $arFilter['@ID'] = array_keys($arResult['DEAL']); $dbResult = CCrmDeal::GetListEx($arSort, $arFilter, false, false, $arSelect, $arOptions); while ($arDeal = $dbResult->GetNext()) { $arResult['DEAL'][$arDeal['ID']] = $arDeal; } } $now = time() + CTimeZone::GetOffset(); foreach ($arResult['DEAL'] as &$arDeal) { $arDeal['CLOSEDATE'] = !empty($arDeal['CLOSEDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['CLOSEDATE']), 'SHORT', SITE_ID)) : ''; $arDeal['BEGINDATE'] = !empty($arDeal['BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['BEGINDATE']), 'SHORT', SITE_ID)) : ''; $arDeal['EVENT_DATE'] = !empty($arDeal['EVENT_DATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arDeal['EVENT_DATE']), 'SHORT', SITE_ID)) : ''; $arDeal['~CLOSEDATE'] = $arDeal['CLOSEDATE']; $arDeal['~BEGINDATE'] = $arDeal['BEGINDATE']; $arDeal['~EVENT_DATE'] = $arDeal['EVENT_DATE']; $currencyID = isset($arDeal['~CURRENCY_ID']) ? $arDeal['~CURRENCY_ID'] : CCrmCurrency::GetBaseCurrencyID(); $arDeal['~CURRENCY_ID'] = $currencyID; $arDeal['CURRENCY_ID'] = htmlspecialcharsbx($currencyID); $arDeal['FORMATTED_OPPORTUNITY'] = CCrmCurrency::MoneyToString($arDeal['~OPPORTUNITY'], $arDeal['~CURRENCY_ID']); $entityID = $arDeal['ID']; $arDeal['PATH_TO_DEAL_SHOW'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $entityID)); $arDeal['PATH_TO_DEAL_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_EDIT'], array('deal_id' => $entityID)); $arDeal['PATH_TO_DEAL_COPY'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_EDIT'], array('deal_id' => $entityID)), array('copy' => 1)); $arDeal['PATH_TO_DEAL_DELETE'] = CHTTP::urlAddParams($bInternal ? $APPLICATION->GetCurPage() : $arParams['PATH_TO_DEAL_LIST'], array('action_' . $arResult['GRID_ID'] => 'delete', 'ID' => $entityID, 'sessid' => $arResult['SESSION_ID'])); $contactID = isset($arDeal['~CONTACT_ID']) ? intval($arDeal['~CONTACT_ID']) : 0; $arDeal['PATH_TO_CONTACT_SHOW'] = $contactID <= 0 ? '' : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $contactID)); $arDeal['~CONTACT_FORMATTED_NAME'] = $contactID <= 0 ? '' : CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => '', 'NAME' => isset($arDeal['~CONTACT_NAME']) ? $arDeal['~CONTACT_NAME'] : '', 'LAST_NAME' => isset($arDeal['~CONTACT_LAST_NAME']) ? $arDeal['~CONTACT_LAST_NAME'] : '', 'SECOND_NAME' => isset($arDeal['~CONTACT_SECOND_NAME']) ? $arDeal['~CONTACT_SECOND_NAME'] : ''), false, false);
if (isset($arSelectMap['SUM'])) { $arSelectMap['OPPORTUNITY'] = $arSelectMap['CURRENCY_ID'] = true; } if (isset($arSelectMap['FULL_ADDRESS'])) { $arSelectMap['ADDRESS'] = $arSelectMap['ADDRESS_2'] = $arSelectMap['ADDRESS_CITY'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_REGION'] = $arSelectMap['ADDRESS_PROVINCE'] = $arSelectMap['ADDRESS_COUNTRY'] = true; } // ID must present in select if (!isset($arSelectMap['ID'])) { $arSelectMap['ID'] = true; } } if ($isInExportMode) { if (!in_array('PRODUCT_ID', $arSelectedHeaders)) { $arSelectedHeaders[] = 'PRODUCT_ID'; } CCrmComponentHelper::PrepareExportFieldsList($arSelectedHeaders, array('LEAD_SUMMARY' => array('TITLE', 'SOURCE_ID'), 'LEAD_FORMATTED_NAME' => array('NAME', 'SECOND_NAME', 'LAST_NAME'), 'SUM' => array('OPPORTUNITY', 'CURRENCY_ID'), 'ACTIVITY_ID' => array())); if (!in_array('ID', $arSelectedHeaders)) { $arSelectedHeaders[] = 'ID'; } $arResult['SELECTED_HEADERS'] = $arSelectedHeaders; } $nTopCount = false; if ($arResult['GADGET'] == 'Y') { $nTopCount = $arParams['LEAD_COUNT']; } if ($nTopCount > 0) { $arNavParams['nTopCount'] = $nTopCount; } if ($isInExportMode) { $arFilter['PERMISSION'] = 'EXPORT'; }
if ($commValue !== '') { $comms[] = array('TYPE' => $commType, 'VALUE' => $commValue, 'ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $companyID, 'ENTITY_SETTINGS' => array('COMPANY_TITLE' => isset($deal['COMPANY_TITLE']) ? $deal['COMPANY_TITLE'] : '')); } } } } $arFields['COMMUNICATIONS'] =& $comms; unset($comms); } } } } CCrmMobileHelper::PrepareActivityItem($arFields, $arParams, array('ENABLE_COMMUNICATIONS' => true, 'ENABLE_FILES' => true)); //Trim seconds $arFields['START_TIME'] = CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', $arFields['START_TIME_STAMP'])); $arFields['END_TIME'] = CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', $arFields['END_TIME_STAMP'])); $arResult['ENTITY'] = $arFields; unset($arFields); if ($typeID === CCrmActivityType::Call || $typeID === CCrmActivityType::Meeting) { $arResult['NOTIFY_TYPES'] = CCrmActivityNotifyType::PrepareListItems(); } elseif ($typeID === CCrmActivityType::Email) { $arResult['CRM_EMAIL'] = CCrmMailHelper::ExtractEmail(COption::GetOptionString('crm', 'mail', '')); $lastEmailAddresser = CUserOptions::GetOption('crm', 'activity_email_addresser', ''); if ($lastEmailAddresser === '') { $arResult['USER_LAST_USED_NAME'] = ''; $arResult['USER_LAST_USED_EMAIL'] = ''; } else { $info = CCrmMailHelper::ParseEmail($lastEmailAddresser); $arResult['USER_LAST_USED_NAME'] = $info['NAME']; $arResult['USER_LAST_USED_EMAIL'] = $info['EMAIL']; }
CJSCore::Init($jsCoreInit); if ($arResult['ENABLE_DISK']) { CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/disk_uploader.js'); $APPLICATION->SetAdditionalCSS('/bitrix/components/bitrix/disk.uf.file/templates/.default/style.css'); } if ($arResult['ENABLE_WEBDAV']) { $APPLICATION->SetAdditionalCSS('/bitrix/components/bitrix/webdav/templates/.default/style.css'); $APPLICATION->SetAdditionalCSS('/bitrix/components/bitrix/webdav.user.field/templates/.default/style.css'); $APPLICATION->SetAdditionalCSS('/bitrix/js/webdav/css/file_dialog.css'); CCrmComponentHelper::RegisterScriptLink('/bitrix/js/main/core/core_dd.js'); CCrmComponentHelper::RegisterScriptLink('/bitrix/js/main/file_upload_agent.js'); CCrmComponentHelper::RegisterScriptLink('/bitrix/js/webdav/file_dialog.js'); CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/webdav_uploader.js'); } $elementID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0; $arResult['CRM_CUSTOM_PAGE_TITLE'] = GetMessage($elementID > 0 ? 'CRM_QUOTE_SHOW_TITLE' : 'CRM_QUOTE_SHOW_NEW_TITLE', array('#QUOTE_NUMBER#' => !empty($arResult['ELEMENT']['QUOTE_NUMBER']) ? $arResult['ELEMENT']['QUOTE_NUMBER'] : '-', '#BEGINDATE#' => !empty($arResult['ELEMENT']['BEGINDATE']) ? CCrmComponentHelper::TrimDateTimeString(ConvertTimeStamp(MakeTimeStamp($arResult['ELEMENT']['BEGINDATE']), 'SHORT', SITE_ID)) : '-')); $arTabs = array(); $arTabs[] = array('id' => 'tab_1', 'name' => GetMessage('CRM_TAB_1'), 'title' => GetMessage('CRM_TAB_1_TITLE'), 'icon' => '', 'fields' => $arResult['FIELDS']['tab_1']); $productFieldset = array(); foreach ($arTabs[0]['fields'] as $k => &$field) { if ($field['id'] === 'section_product_rows') { $productFieldset['NAME'] = $field['name']; unset($arTabs[0]['fields'][$k]); } if ($field['id'] === 'PRODUCT_ROWS') { $productFieldset['HTML'] = $field['value']; unset($arTabs[0]['fields'][$k]); break; } } unset($field);
if ($completed === 'Y') { $completedClassName = 'crm-activity-completed'; $completedTitle = GetMessage('CRM_ACTION_COMPLETED'); $completedOnClick = 'return false;'; } else { $completedClassName = 'crm-activity-not-completed'; $completedTitle = GetMessage($item['CAN_COMPLETE'] ? 'CRM_ACTION_CLICK_TO_COMPLETE' : 'CRM_ACTION_NOT_COMPLETED'); $completedOnClick = $item['CAN_COMPLETE'] ? 'BX.CrmActivityEditor.items[\'' . $gridEditorID . '\'].setActivityCompleted(' . $item['ID'] . ', true); return false;' : 'return false;'; } $completedHtml = '<a class="' . $completedClassName . '" title="' . $completedTitle . '" alt="' . $completedTitle . '" href="#" onclick="' . $completedOnClick . '"></a>'; $descriptionHtml = isset($item['DESCRIPTION_HTML']) ? $item['DESCRIPTION_HTML'] : ''; $enableDescriptionCut = isset($item['ENABLE_DESCRIPTION_CUT']) ? $item['ENABLE_DESCRIPTION_CUT'] : false; if ($enableDescriptionCut && strlen($descriptionHtml) > 64) { $descriptionHtml = substr($descriptionHtml, 0, 64) . '<a href="#" onclick="BX.CrmInterfaceGridManager.expandEllipsis(this); return false;">...</a><span class="bx-crm-text-cut-on">' . substr($descriptionHtml, 64) . '</span>'; } $arRowData = array('id' => $item['~ID'], 'actions' => $arActions, 'data' => $item, 'editable' => $isEditable, 'columnClasses' => array('COMPLETED' => 'bx-minimal'), 'columns' => array('SUBJECT' => $subjectHtml, 'RESPONSIBLE_FULL_NAME' => $item['~RESPONSIBLE_FULL_NAME'] !== '' ? '<a href="' . htmlspecialcharsbx($item['PATH_TO_RESPONSIBLE']) . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $item['ID'] . '">' . htmlspecialcharsbx($item['~RESPONSIBLE_FULL_NAME']) . '</a>' . '<script type="text/javascript">BX.tooltip(' . $item['RESPONSIBLE_ID'] . ', "balloon_' . $arResult['GRID_ID'] . '_' . $item['ID'] . '", "");</script>' : '', 'CREATED' => '<span class="crm-activity-date-time">' . FormatDate('SHORT', MakeTimeStamp($item['~CREATED'])) . '</span>', 'START_TIME' => isset($item['~START_TIME']) && $item['~START_TIME'] !== '' ? '<span class="crm-activity-date-time">' . CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($item['~START_TIME'])), $dateTimeOptions) . '</span>' : '', 'END_TIME' => isset($item['~END_TIME']) && $item['~END_TIME'] !== '' ? '<span class="crm-activity-date-time">' . CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($item['~END_TIME'])), $dateTimeOptions) . '</span>' : '', 'DEADLINE' => isset($item['~DEADLINE']) && $item['~DEADLINE'] !== '' ? '<span class="crm-activity-date-time">' . CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($item['~DEADLINE'])), $dateTimeOptions) . '</span>' : '', 'COMPLETED' => $completedHtml, 'DESCRIPTION' => $descriptionHtml)); $ownerTypeID = isset($item['OWNER_TYPE_ID']) ? intval($item['OWNER_TYPE_ID']) : 0; $ownerID = isset($item['OWNER_ID']) ? intval($item['OWNER_ID']) : 0; if ($ownerTypeID > 0 && $ownerID > 0) { $showPath = ''; $title = ''; if ($ownerTypeID === CCrmOwnerType::Lead) { $showPath = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_lead_show'), array('lead_id' => $ownerID)); } elseif ($ownerTypeID === CCrmOwnerType::Deal) { $showPath = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_deal_show'), array('deal_id' => $ownerID)); } $title = CCrmOwnerType::GetCaption($ownerTypeID, $ownerID); if ($showPath !== '' && $title !== '') { $arRowData['columns']['REFERENCE'] = '<a target="_blank" href="' . htmlspecialcharsbx($showPath) . '">' . htmlspecialcharsbx($title) . '</a>'; } }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } global $APPLICATION; CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/activity.js'); CCrmComponentHelper::RegisterScriptLink('/bitrix/js/crm/interface_grid.js'); if ($arResult['NEED_FOR_REBUILD_DUP_INDEX']) { ?> <div id="rebuildLeadDupIndexMsg" class="crm-view-message"> <?php echo GetMessage('CRM_LEAD_REBUILD_DUP_INDEX', array('#ID#' => 'rebuildLeadDupIndexLink', '#URL#' => '#')); ?> </div><?php } if ($arResult['NEED_FOR_REBUILD_LEAD_ATTRS']) { ?> <div id="rebuildLeadAttrsMsg" class="crm-view-message"> <?php echo GetMessage('CRM_LEAD_REBUILD_ACCESS_ATTRS', array('#ID#' => 'rebuildLeadAttrsLink', '#URL#' => $arResult['PATH_TO_PRM_LIST'])); ?> </div><?php } if (isset($arResult['ERROR_HTML'])) { ShowError($arResult['ERROR_HTML']); } $currentUserID = $arResult['CURRENT_USER_ID']; $isInternal = $arResult['INTERNAL']; $activityEditorID = ''; if (!$isInternal) {
<div id="<?php echo $prefix; ?> activities" class="crm-right-block"<?php echo empty($items) ? ' style="display:none;"' : ''; ?> > <div class="crm-right-block-title"><?php echo GetMessage('CRM_ENTITY_LF_ACTIVITY_LIST_TITLE'); ?> </div><?php foreach ($items as &$item) { $itemID = intval($item['~ID']); $typeID = isset($item['~TYPE_ID']) ? intval($item['~TYPE_ID']) : CCrmActivityType::Undefined; $direction = isset($item['~DIRECTION']) ? intval($item['~DIRECTION']) : CCrmActivityDirection::Undefined; $deadline = isset($item['~DEADLINE']) && $item['~DEADLINE'] !== '' ? CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($item['~DEADLINE']))) : ''; $completed = (isset($item['~COMPLETED']) ? $item['~COMPLETED'] : 'N') === 'Y'; $expired = !$completed && $deadline !== '' && MakeTimeStamp($deadline) <= ($now = time() + CTimeZone::GetOffset()); $subject = isset($item['~SUBJECT']) ? htmlspecialcharsbx($item['~SUBJECT']) : $itemID; $descr = isset($item['DESCRIPTION_HTML']) ? $item['DESCRIPTION_HTML'] : ''; $responsibleName = isset($item['RESPONSIBLE_FULL_NAME']) ? $item['RESPONSIBLE_FULL_NAME'] : ''; $responsibleUrl = isset($item['PATH_TO_RESPONSIBLE']) ? $item['PATH_TO_RESPONSIBLE'] : ''; $priority = isset($item['~PRIORITY']) ? intval($item['~PRIORITY']) : CCrmActivityPriority::None; $itemData[] = array('ID' => $itemID, 'typeID' => $typeID, 'direction' => $direction, 'completed' => $completed, 'deadline' => $deadline); $containerClassName = ''; if ($typeID === CCrmActivityType::Meeting) { $containerClassName = 'crm-right-block-meet'; } elseif ($typeID === CCrmActivityType::Call) { if ($direction === CCrmActivityDirection::Outgoing) { $containerClassName = 'crm-right-block-call-to'; } else {
if (isset($arSelectMap['COMPANY_ID'])) { $arSelectMap['COMPANY_TITLE'] = true; } else { // Required for construction of URLs $arSelectMap['COMPANY_ID'] = true; } if (isset($arSelectMap['FULL_ADDRESS'])) { $arSelectMap['ADDRESS'] = $arSelectMap['ADDRESS_2'] = $arSelectMap['ADDRESS_CITY'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_REGION'] = $arSelectMap['ADDRESS_PROVINCE'] = $arSelectMap['ADDRESS_COUNTRY'] = true; } // ID must present in select if (!isset($arSelectMap['ID'])) { $arSelectMap['ID'] = true; } } if ($isInExportMode) { CCrmComponentHelper::PrepareExportFieldsList($arSelectedHeaders, array('CONTACT_SUMMARY' => array('NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO', 'TYPE_ID'), 'CONTACT_COMPANY' => array('COMPANY_ID', 'POST'), 'ACTIVITY_ID' => array())); if (!in_array('ID', $arSelectedHeaders)) { $arSelectedHeaders[] = 'ID'; } $arResult['SELECTED_HEADERS'] = $arSelectedHeaders; } $nTopCount = false; if ($arResult['GADGET'] == 'Y') { $nTopCount = $arParams['CONTACT_COUNT']; } if ($nTopCount > 0 && !isset($arFilter['ID'])) { $arNavParams['nTopCount'] = $nTopCount; } if ($isInExportMode) { $arFilter['PERMISSION'] = 'EXPORT'; }
if (isset($arSelectMap['MODIFY_BY'])) { $arSelectMap['MODIFY_BY_LOGIN'] = $arSelectMap['MODIFY_BY_NAME'] = $arSelectMap['MODIFY_BY_LAST_NAME'] = $arSelectMap['MODIFY_BY_SECOND_NAME'] = true; } if (isset($arSelectMap['FULL_ADDRESS'])) { $arSelectMap['ADDRESS'] = $arSelectMap['ADDRESS_2'] = $arSelectMap['ADDRESS_CITY'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_POSTAL_CODE'] = $arSelectMap['ADDRESS_REGION'] = $arSelectMap['ADDRESS_PROVINCE'] = $arSelectMap['ADDRESS_COUNTRY'] = true; } if (isset($arSelectMap['FULL_REG_ADDRESS'])) { $arSelectMap['REG_ADDRESS'] = $arSelectMap['REG_ADDRESS_2'] = $arSelectMap['REG_ADDRESS_CITY'] = $arSelectMap['REG_ADDRESS_POSTAL_CODE'] = $arSelectMap['REG_ADDRESS_POSTAL_CODE'] = $arSelectMap['REG_ADDRESS_REGION'] = $arSelectMap['REG_ADDRESS_PROVINCE'] = $arSelectMap['REG_ADDRESS_COUNTRY'] = true; } // ID must present in select if (!isset($arSelectMap['ID'])) { $arSelectMap['ID'] = true; } } if ($isInExportMode) { CCrmComponentHelper::PrepareExportFieldsList($arSelectedHeaders, array('COMPANY_SUMMARY' => array('LOGO', 'TITLE', 'COMPANY_TYPE'), 'ACTIVITY_ID' => array())); if (!in_array('ID', $arSelectedHeaders)) { $arSelectedHeaders[] = 'ID'; } $arResult['SELECTED_HEADERS'] = $arSelectedHeaders; } $nTopCount = false; if ($arResult['GADGET'] == 'Y') { $nTopCount = $arParams['COMPANY_COUNT']; } if ($nTopCount > 0 && !isset($arFilter['ID'])) { $arNavParams['nTopCount'] = $nTopCount; } if ($isInExportMode) { $arFilter['PERMISSION'] = 'EXPORT'; }