function preProcess(Vtiger_Request $request) { parent::preProcess($request); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $recordId = $request->get('record'); $page = $request->get('page'); $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId); $reportModel = $detailViewModel->getRecord(); $reportModel->setModule('Reports'); $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('page', $page); $pagingModel->set('limit', self::REPORT_LIMIT); $this->reportData = $reportModel->getReportData($pagingModel); $this->calculationFields = $reportModel->getReportCalulationData(); $primaryModule = $reportModel->getPrimaryModule(); $secondaryModules = $reportModel->getSecondaryModules(); $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule); $currentUser = Users_Record_Model::getCurrentUserModel(); $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId()); $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId()); if (!$permission) { $viewer->assign('MODULE', $primaryModule); $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED'); $viewer->view('OperationNotPermitted.tpl', $primaryModule); exit; } $detailViewLinks = $detailViewModel->getDetailViewLinks(); // Advanced filter conditions $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter()); $viewer->assign('PRIMARY_MODULE', $primaryModule); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel); $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure(); $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure(); $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure); $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures); $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar'); if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter(false)); $viewer->assign('DETAILVIEW_LINKS', $detailViewLinks); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('RECORD_ID', $recordId); $viewer->assign('COUNT', count($this->reportData)); $viewer->assign('MODULE', $moduleName); $viewer->view('ReportHeader.tpl', $moduleName); }
function preProcess(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $recordId = $request->get('record'); $this->record = $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId); parent::preProcess($request); $reportModel = $detailViewModel->getRecord(); $reportModel->setModule('Reports'); $primaryModule = $reportModel->getPrimaryModule(); $secondaryModules = $reportModel->getSecondaryModules(); $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule); $currentUser = Users_Record_Model::getCurrentUserModel(); $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId()); $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId()); if (!$permission) { $viewer->assign('MODULE', $primaryModule); $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED'); $viewer->view('OperationNotPermitted.tpl', $primaryModule); exit; } $isAdmin = $currentUser->isAdminUser(); $viewer->assign('isAdmin', $isAdmin); // Advanced filter conditions $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter()); $viewer->assign('PRIMARY_MODULE', $primaryModule); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel); $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure(); $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure(); $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure); $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures); $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar'); if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName); $dateFilters[$comparatorKey] = $comparatorInfo; } $reportChartModel = Reports_Chart_Model::getInstanceById($reportModel); $viewer->assign('PRIMARY_MODULE_FIELDS', $reportModel->getPrimaryModuleFieldsForAdvancedReporting()); $viewer->assign('SECONDARY_MODULE_FIELDS', $reportModel->getSecondaryModuleFieldsForAdvancedReporting()); $viewer->assign('CALCULATION_FIELDS', $reportModel->getModuleCalculationFieldsForReport()); $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('RECORD', $recordId); $viewer->assign('MODULE', $moduleName); $viewer->assign('CHART_MODEL', $reportChartModel); $viewer->view('ChartReportHeader.tpl', $moduleName); }
function preProcess(Vtiger_Request $request) { parent::preProcess($request); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $recordId = $request->get('record'); $page = $request->get('page'); $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId); $reportModel = $detailViewModel->getRecord(); $reportModel->setModule('Reports'); $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('page', $page); $pagingModel->set('limit', self::REPORT_LIMIT); $reportData = $reportModel->getReportData($pagingModel); $this->reportData = $reportData['data']; $this->calculationFields = $reportModel->getReportCalulationData(); $count = $reportData['count']; if ($count < 1000) { $this->count = $count; } else { $query = $reportModel->getReportSQL(false, 'PDF'); $countQuery = $reportModel->generateCountQuery($query); $this->count = $reportModel->getReportsCount($countQuery); } $primaryModule = $reportModel->getPrimaryModule(); $secondaryModules = $reportModel->getSecondaryModules(); $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule); $currentUser = Users_Record_Model::getCurrentUserModel(); $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId()); $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId()); if (!$permission) { $viewer->assign('MODULE', $primaryModule); $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED'); $viewer->view('OperationNotPermitted.tpl', $primaryModule); exit; } $detailViewLinks = $detailViewModel->getDetailViewLinks(); // Advanced filter conditions $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter()); $viewer->assign('PRIMARY_MODULE', $primaryModule); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel); $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure(); $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure(); //TODO : We need to remove "update_log" field from "HelpDesk" module in New Look // after removing old look we need to remove this field from crm if ($primaryModule == 'HelpDesk') { foreach ($primaryModuleRecordStructure as $blockLabel => $blockFields) { foreach ($blockFields as $field => $object) { if ($field == 'update_log') { unset($primaryModuleRecordStructure[$blockLabel][$field]); } } } } if (!empty($secondaryModuleRecordStructures)) { foreach ($secondaryModuleRecordStructures as $module => $structure) { if ($module == 'HelpDesk') { foreach ($structure as $blockLabel => $blockFields) { foreach ($blockFields as $field => $object) { if ($field == 'update_log') { unset($secondaryModuleRecordStructures[$module][$blockLabel][$field]); } } } } } } // End $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure); $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures); $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar'); if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter(false)); $viewer->assign('DETAILVIEW_LINKS', $detailViewLinks); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('RECORD_ID', $recordId); $viewer->assign('COUNT', $this->count); $viewer->assign('MODULE', $moduleName); // SalesPlatform.ru begin // If it is a custom report if (in_array($reportModel->getReportType(), getCustomReportsList())) { // Only equals filter $customAdvanceFilterOpsByFieldType = array('V' => array('e'), 'N' => array('e'), 'T' => array('e'), 'I' => array('e'), 'C' => array('e'), 'D' => array('e'), 'DT' => array('e'), 'I' => array('e'), 'NN' => array('e'), 'E' => array('e')); $spPaymentsRecordStructure = $recordStructureInstance->getStructure('SPPayments'); foreach ($spPaymentsRecordStructure as $blockLabel => $blockFields) { foreach ($blockFields as $field => $object) { if ($field != 'pay_date' && $field != 'assigned_user_id' && $field != 'payer') { unset($spPaymentsRecordStructure[$blockLabel][$field]); } } } $customBlockName = 'CUSTOM_BLOCK'; $customRecordStructure[$customBlockName] = $spPaymentsRecordStructure['LBL_PAYMENT_DETAILS']; // Check date filter for custom report if (!in_array($reportModel->getReportType(), getCustomReportsListWithDateFilter())) { unset($customRecordStructure[$customBlockName]['pay_date']); } // Check owner filter for custom report if (!in_array($reportModel->getReportType(), getCustomReportsListWithOwnerFilter())) { unset($customRecordStructure[$customBlockName]['assigned_user_id']); } // Check account filter for custom report if (!in_array($reportModel->getReportType(), getCustomReportsListWithAccountFilter())) { unset($customRecordStructure[$customBlockName]['payer']); } $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $customRecordStructure); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $customAdvanceFilterOpsByFieldType); $viewer->view('SPReportHeader.tpl', $moduleName); } else { $viewer->view('ReportHeader.tpl', $moduleName); } // SalesPlatform.ru end }