getModule(); $sp99f14b = $spb9aaa5->get('record'); if ($sp99f14b) { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); } else { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getCleanInstance($sp00497f); } $sp332727->set('id', $sp99f14b); $sp332727->set('name', $spb9aaa5->get('name')); $sp332727->set('isDuplicate', $spb9aaa5->get('isDuplicate')); $sp77da92 = array('success' => false); if ($sp332727->checkDuplicate()) { $sp77da92 = array('success' => true, 'message' => vtranslate('LBL_RECORD_WITH_NAME_EXISTS', $sp00497f)); } $sp9c1417 = new Vtiger_Response(); $sp9c1417->setResult($sp77da92); $sp9c1417->emit(); } } class SPFunnelChartsWidgetExtensions_DeleteAjax_Action extends Vtiger_Delete_Action { public function checkPermission(Vtiger_Request $spb9aaa5) { $spfd2a00 = $spb9aaa5->get('record'); $sp00497f = $spb9aaa5->getModule(); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($spfd2a00, $sp00497f); if ($sp332727 != null && !$sp332727->isDeletable()) { throw new AppException(vtranslate('LBL_PERMISSION_DENIED')); } return true; } public function process(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $spfd2a00 = $spb9aaa5->get('record'); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($spfd2a00, $sp00497f); $sp332727->delete(); $spc01d2b = $spb9aaa5->get('viewname'); $sp9c1417 = new Vtiger_Response(); $sp9c1417->setResult(array('viewname' => $spc01d2b, 'module' => $sp00497f)); $sp9c1417->emit(); } } class SPFunnelChartsWidgetExtensions_MassDelete_Action extends Vtiger_Mass_Action { public function checkPermission(Vtiger_Request $spb9aaa5) { return; } public function process(Vtiger_Request $spb9aaa5) { $sp01da60 = array(); $sp36a917 = Vtiger_Module_Model::getInstance($spb9aaa5->getModule()); $sp12ab23 = $sp36a917->getMassActionRecords($spb9aaa5->get('selected_ids')); foreach ($sp12ab23 as $sp332727) { if ($sp332727->isDeletable()) { $sp332727->delete(); } else { $sp01da60[] = $sp332727->getName(); } } $sp00497f = $spb9aaa5->getModule(); $sp9c1417 = new Vtiger_Response(); if (empty($sp01da60)) { $sp9c1417->setResult(array(vtranslate('LBL_RECORDS_DELETED_SUCCESSFULLY', $sp00497f))); } else { $sp9c1417->setError($sp01da60, vtranslate('LBL_DENIED_DELETE_RECORDS', $sp00497f)); } $sp9c1417->emit(); } } class SPFunnelChartsWidgetExtensions_Save_Action extends Vtiger_Save_Action { public function checkPermission(Vtiger_Request $spb9aaa5) { SPFunnelChartsWidgetExtensions_Module_Model::checkViewRecordAccess($spb9aaa5); } public function process(Vtiger_Request $spb9aaa5) { $sp99f14b = $spb9aaa5->get('record'); $sp00497f = $spb9aaa5->getModule(); $sp42da14 = SPFunnelChartsWidgetExtensions_Record_Model::getCleanInstance($sp00497f); if (!empty($sp99f14b) && !$spb9aaa5->get('isDuplicate')) { $sp42da14->setId($sp99f14b); } foreach ($sp42da14->getSaveFieldsNames() as $sp57ce0c) { $sp42da14->set($sp57ce0c, $spb9aaa5->get($sp57ce0c)); } $sp42da14->save(); $sp2e13eb = $sp42da14->getDetailViewUrl(); header("Location: {$sp2e13eb}"); } } abstract class SPFunnelChartsWidgetExtensions_SPFunnelChartsWidgetExtensions_Dashboard extends Vtiger_IndexAjax_View { public function process(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $spfd2a00 = $spb9aaa5->get('record'); $sp8464ee = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($spfd2a00, $sp00497f); $spce8310 = $sp8464ee->getBindedWidgetModel(); $sp1c01ff = new SPFunnelChartsPlotParams(); $sp1123a7 = $spb9aaa5->get('content'); $sp01fb3e = $spb9aaa5->get('isReportView'); $sp1c01ff->parsePlotParams($spb9aaa5); $spe45b5d = $this->getViewer($spb9aaa5); $spe45b5d->assign('WIDGET', $spce8310); $spe45b5d->assign('MODULE_NAME', $sp00497f); $spe45b5d->assign('DATA', $sp8464ee->getData($sp1c01ff)); $spe45b5d->assign('STYLES', $this->getAdditionalStyles($spb9aaa5)); $spe45b5d->assign('SCRIPTS', $this->getAdditionalScripts()); $spe45b5d->assign('CURRENTUSER', Users_Record_Model::getCurrentUserModel()); $spe45b5d->assign('DEFAULT_ASSIGNED_USER_FILTER', SPFunnelChartsPlotParams::DEFAULT_ASSIGNED_USER_FILTER); $spe45b5d->assign('IS_REPORT_VIEW', $sp01fb3e); if ($sp01fb3e) { $sp8464ee->applyReportViewModeToWidget($spce8310); if (!empty($sp1123a7)) { $spe45b5d->view($this->getReportViewWidgetContentsTPL(), $sp00497f); } else { $spe45b5d->view($this->getReportViewWidgetTPL(), $sp00497f); } } else { if (!empty($sp1123a7)) { $spe45b5d->view($this->getDashBoardWidgetContentsTPL(), $sp00497f); } else { $spe45b5d->view($this->getDashBoardWidgetTPL(), $sp00497f); } } } protected abstract function getAdditionalScripts(); protected abstract function getReportViewWidgetTPL(); protected abstract function getReportViewWidgetContentsTPL(); protected abstract function getDashBoardWidgetTPL(); protected function getDashBoardWidgetContentsTPL() { return 'dashboards/DashBoardWidgetContents.tpl'; } protected function getAdditionalStyles(Vtiger_Request $spb9aaa5) { global $default_layout; $sp00497f = $spb9aaa5->getModule(); $speed10a = $this->checkAndConvertCssStyles(array("~/layouts/{$default_layout}/modules/{$sp00497f}/resources/css/SPFunnelChartsWidgetExtensionsDashboard.css")); return array_merge($speed10a); } } class SPFunnelChartsWidgetExtensions_DetailView_Model extends Vtiger_DetailView_Model { public static function getInstance($sp00497f, $spfd2a00) { $spf512c1 = Vtiger_Loader::getComponentClassName('Model', 'DetailView', $sp00497f); $sp795104 = new $spf512c1(); $sp36a917 = Vtiger_Module_Model::getInstance($sp00497f); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($spfd2a00, $sp00497f); return $sp795104->setModule($sp36a917)->setRecord($sp332727); } public function getDetailViewLinks($spf4fc71 = '') { return array(); } public function getWidgets() { return array(); } public function getDetailBasicLinks() { $sp3a34f7 = array(); $sp3a34f7[] = Vtiger_Link_Model::getInstanceFromValues(array('linktype' => 'LISTVIEWBASIC', 'linklabel' => 'LBL_ADD_RECORD', 'linkurl' => $this->getModule()->getCreateRecordUrl(), 'linkicon' => 'fa-plus')); return $sp3a34f7; } } class SPFunnelChartsWidgetExtensions_ListView_Model extends Vtiger_ListView_Model { public static function getInstance($sp00497f) { $spf512c1 = Vtiger_Loader::getComponentClassName('Model', 'ListView', $sp00497f); $sp795104 = new $spf512c1(); $sp36a917 = Vtiger_Module_Model::getInstance($sp00497f); return $sp795104->set('module', $sp36a917); } public function getListViewLinks() { $sp3a34f7 = array(); $sp3a34f7['LISTVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues(array('linktype' => 'LISTVIEWBASIC', 'linklabel' => 'LBL_ADD_RECORD', 'linkurl' => $this->getModule()->getCreateRecordUrl(), 'linkicon' => '')); return $sp3a34f7; } public function getListBasicLinks() { $sp3a34f7 = array(); $sp3a34f7[] = Vtiger_Link_Model::getInstanceFromValues(array('linktype' => 'LISTVIEWBASIC', 'linklabel' => 'LBL_ADD_RECORD', 'linkurl' => $this->getModule()->getCreateRecordUrl(), 'linkicon' => 'fa-plus')); return $sp3a34f7; } public function getListViewMassActions($spf4fc71) { $sp36a917 = $this->getModule(); $sp3a34f7 = array(); $sp3a34f7['LISTVIEWMASSACTION'][] = Vtiger_Link_Model::getInstanceFromValues(array('linktype' => 'LISTVIEWMASSACTION', 'linklabel' => 'LBL_DELETE', 'linkurl' => 'javascript:Vtiger_List_Js.massDeleteRecords("index.php?module=' . $sp36a917->get('name') . '&action=MassDelete");', 'linkicon' => '')); return $sp3a34f7; } public function getListViewHeaders() { $sp48c88f = array(); $sp8b9d91 = array('Name' => 'name', 'Description' => 'description'); foreach ($sp8b9d91 as $spa97d30 => $sp57ce0c) { $spad0abe = new Vtiger_Field_Model(); $spad0abe->set('name', $sp57ce0c); $spad0abe->set('label', vtranslate($spa97d30, $this->getModule()->getName())); $spad0abe->set('column', $sp57ce0c); $sp48c88f[] = $spad0abe; } return $sp48c88f; } public function getListViewEntries($sp7643b2) { $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->query($this->sp6998b7($sp7643b2)); $spd9f271 = $sp829569->num_rows($sp77da92); $sp10aa25 = array(); for ($sp7085e5 = 0; $sp7085e5 < $spd9f271; $sp7085e5++) { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getCleanInstance($this->getModule()->getName()); $sp332727->setData($sp829569->query_result_rowdata($sp77da92, $sp7085e5)); $sp10aa25[$sp332727->getId()] = $sp332727; } $sp7643b2->calculatePageRange($sp10aa25); if ($spd9f271 > $sp7643b2->getPageLimit()) { array_pop($sp10aa25); $sp7643b2->set('nextPageExists', true); } else { $sp7643b2->set('nextPageExists', false); } return $sp10aa25; } public function getListViewCount() { $sp6039ae = 'SELECT count(*) AS count FROM ' . $this->getModule()->getMainTableName(); $sp6039ae .= $this->spe59602(); $sp829569 = PearDatabase::getInstance(); $sp3e7d1e = $sp829569->query($sp6039ae); return $sp829569->query_result($sp3e7d1e, 0, 'count'); } private function sp6998b7($sp7643b2) { $sp6039ae = 'SELECT * FROM ' . $this->getModule()->getMainTableName(); $sp1cceac = $sp7643b2->getStartIndex(); $sp34d4b8 = $sp7643b2->getPageLimit(); $sp95bf20 = $this->getForSql('orderby'); $spb13b85 = $this->getForSql('sortorder'); $sp6039ae .= $this->spe59602(); if (!empty($sp95bf20) && $sp95bf20 === 'smownerid') { $spad0abe = Vtiger_Field_Model::getInstance('assigned_user_id'); if ($spad0abe->getFieldDataType() == 'owner') { $sp95bf20 = 'COALESCE(CONCAT(vtiger_users.first_name, vtiger_users.last_name), vtiger_groups.groupname)'; } } if ($sp95bf20) { $sp6039ae .= " ORDER BY {$sp95bf20} {$spb13b85}"; } $sp6039ae .= " LIMIT {$sp1cceac}," . ($sp34d4b8 + 1); return $sp6039ae; } private function spe59602() { $sp6e9854 = ''; $spbd2fa8 = $this->get('search_key'); $sp4dcea5 = $this->get('search_value'); $spea9876 = Users_Record_Model::getCurrentUserModel(); if ($spea9876->isAdminUser()) { if (!empty($spbd2fa8) && !empty($sp4dcea5)) { $sp6e9854 .= " WHERE {$spbd2fa8} LIKE '{$sp4dcea5}%'"; } } else { $sp6b8a65 = array_keys($spea9876->getSubordinateUsers()); $sp6b8a65[] = $spea9876->getId(); $sp6e9854 .= ' WHERE owner IN (' . join(',', $sp6b8a65) . ')'; if (!empty($spbd2fa8) && !empty($sp4dcea5)) { $sp6e9854 .= " AND {$spbd2fa8} LIKE '{$sp4dcea5}%'"; } } return $sp6e9854; } } abstract class SPFunnelChartsWidgetExtensions_Module_Model extends Vtiger_Module_Model { public function isCustomizable() { return false; } public function isFilterColumnEnabled() { return false; } public function getAlphabetSearchField() { return 'name'; } public function getSideBarLinks($spf4fc71) { $sp3a34f7 = array(); $sp3a34f7['SIDEBARLINK'][] = Vtiger_Link_Model::getInstanceFromValues(array('linktype' => 'SIDEBARLINK', 'linklabel' => 'LBL_RECORDS_LIST', 'linkurl' => $this->getListViewUrl(), 'linkicon' => '')); return $sp3a34f7; } public function getMassActionRecords($spa3d4c5) { $spa94425 = array(); if (!empty($spa3d4c5)) { if ($spa3d4c5 == 'all') { $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->query('SELECT id FROM ' . $this->getMainTableName()); while ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { $spa94425[] = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp2b1f4d['id'], $this->getName()); } } else { foreach ($spa3d4c5 as $spfd2a00) { $spa94425[] = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($spfd2a00, $this->getName()); } } } return $spa94425; } public static function getRecordsCount() { $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->query('select count(*) AS totalrecords FROM ' . $this->getMainTableName()); $sp2b1f4d = $sp829569->fetchByAssoc($sp77da92); return $sp2b1f4d['totalrecords']; } public function deleteRecord($sp332727) { $sp829569 = PearDatabase::getInstance(); $sp829569->pquery('DELETE FROM ' . $this->getMainTableName() . ' WHERE id = ?', array($sp332727->getId())); $sp829569->pquery('DELETE FROM ' . $this->getReportsStagesTableName() . ' WHERE record_id = ?', array($sp332727->getId())); $spe4cb96 = $sp332727->findWidgetLinkModel(); if ($spe4cb96 != null) { $sp829569->pquery('DELETE FROM vtiger_module_dashboard_widgets WHERE linkid=?', $spe4cb96->getId()); $sp332727->removeWidgetLink(); } } public function isQuickSearchEnabled() { return false; } public static function checkViewRecordAccess($spb9aaa5) { $spa5ac7d = Users_Privileges_Model::getCurrentUserPrivilegesModel(); $sp36a917 = Vtiger_Module_Model::getInstance('Reports'); if (!$spa5ac7d->hasModulePermission($sp36a917->getId())) { throw new AppException(vtranslate('LBL_PERMISSION_DENIED')); } $sp00497f = $spb9aaa5->getModule(); $sp36a917 = Vtiger_Module_Model::getInstance($sp00497f); if (!$spa5ac7d->hasModulePermission($sp36a917->getId())) { throw new AppException(vtranslate('LBL_PERMISSION_DENIED')); } $sp99f14b = $spb9aaa5->get('record'); if ($sp99f14b) { SPFunnelChartsWidgetExtensions_Module_Model::checkRecordForAction($sp99f14b, $sp00497f); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); if (!$sp332727->isEditable()) { throw new AppException(vtranslate('LBL_PERMISSION_DENIED')); } } } public static function checkRecordForAction($sp99f14b, $sp00497f) { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); if ($sp332727 == null) { throw new AppException(vtranslate('LBL_RECORD_NOT_FOUND')); } } public abstract function getMainTableName(); public abstract function getReportsStagesTableName(); } class SPFunnelChartsWidgetExtensions_Record_Model extends Vtiger_Record_Model { const LINKS_DASHBOARD_VIEW_TYPE = 'DASHBOARDWIDGET'; public function getSaveFieldsNames() { return array('name', 'description', 'report_ids', 'reports_plot_by'); } public function getName() { return $this->get('name'); } public static function getInstanceById($spfd2a00, $sp00497f) { $sp36a917 = Vtiger_Module_Model::getInstance($sp00497f); $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->pquery('SELECT * FROM ' . $sp36a917->getMainTableName() . ' WHERE id=?', array($spfd2a00)); $sp332727 = null; if ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { $sp2b1f4d['label'] = $sp2b1f4d['name']; $spf512c1 = Vtiger_Loader::getComponentClassName('Model', 'Record', $sp00497f); $sp332727 = new $spf512c1(); $sp332727->setData($sp2b1f4d); $sp332727->setModuleFromInstance($sp36a917); } return $sp332727; } public function save() { $sp829569 = PearDatabase::getInstance(); $spea9876 = Users_Record_Model::getCurrentUserModel(); $sp36a917 = $this->getModule(); if ($this->getId() == null) { $this->setId($sp829569->getUniqueID($sp36a917->getMainTableName())); $sp829569->pquery('INSERT INTO ' . $sp36a917->getMainTableName() . ' VALUES(?,?,?,?)', array($this->getId(), $this->get('name'), $this->get('description'), $spea9876->getId())); $this->sp5ed55e(); } else { $this->sp5ed55e(); $sp829569->pquery('UPDATE ' . $sp36a917->getMainTableName() . ' SET name=?, description=? WHERE id=?', array($this->get('name'), $this->get('description'), $this->getId())); } $this->savePlotReports(); } protected function savePlotReports() { $sp829569 = PearDatabase::getInstance(); $sp36a917 = $this->getModule(); $sp829569->pquery('DELETE FROM ' . $sp36a917->getReportsStagesTableName() . ' WHERE record_id=?', array($this->getId())); $sp162a59 = $this->get('reports_plot_by'); $sp0f3a1d = $this->get('report_ids'); if (!empty($sp0f3a1d)) { $spca51ae = array(); $spe1f7a0 = 'INSERT INTO ' . $sp36a917->getReportsStagesTableName() . ' VALUES'; foreach ($sp0f3a1d as $spb701f5 => $sp72b306) { $spe1f7a0 .= '(?,?,?,?),'; $spca51ae[] = $this->getId(); $spca51ae[] = $sp72b306; $spca51ae[] = $sp162a59[$sp72b306]; $spca51ae[] = $spb701f5; } $sp829569->pquery(substr($spe1f7a0, 0, -1), $spca51ae); } } public function getReportsList() { $sp829569 = PearDatabase::getInstance(); $sp36a917 = $this->getModule(); $spd18c68 = array(); $sp77da92 = $sp829569->pquery('SELECT report_id FROM ' . $sp36a917->getReportsStagesTableName() . ' WHERE record_id=? ORDER BY sequence', array($this->getId())); while ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { $sp62c054 = Reports_Record_Model::getInstanceById($sp2b1f4d['report_id']); if ($sp62c054->getId() != null) { $spd18c68[] = Reports_Record_Model::getInstanceById($sp2b1f4d['report_id']); } } return $spd18c68; } public function getReportsPlotDependencies($spd18c68) { $spdcbab1 = array(); foreach ($spd18c68 as $spcd19d6) { $spdcbab1[$spcd19d6->getId()] = array('selectedPlotType' => $this->spbb8dfb($spcd19d6), 'selectablePlotTypes' => $this->sp6fb91a($spcd19d6)); } return $spdcbab1; } private function sp6fb91a($spcd19d6) { $sp81dbb1 = array(); $sp81dbb1[] = array(SPFunnelChartsPlotParams::DEFAULT_PLOT_BY, SPFunnelChartsPlotParams::translateReportAggregationKey(SPFunnelChartsPlotParams::DEFAULT_PLOT_BY)); $spf9d295 = $spcd19d6->getSelectedCalculationFields(); foreach ($spcd19d6->getCalculationFields() as $sp00497f => $spe3e4c4) { foreach ($spe3e4c4 as $sp4b3f3d => $spa64eca) { $spc0b9ba = explode(':', $sp4b3f3d); $sp83ae83 = $spc0b9ba[0]; $sp1cad50 = $spc0b9ba[1]; $sp2d3082 = explode('_', $spc0b9ba[2]); $spb75375 = array_slice($sp2d3082, 1); $sp57ce0c = implode('_', $spb75375); foreach (SPFunnelChartsPlotParams::getFieldsCalculationOperations() as $spbe8b90) { $sp66d8bc = 'cb:' . $sp83ae83 . ':' . $sp1cad50 . ':' . $sp57ce0c . '_' . $spbe8b90; if (in_array($sp66d8bc, $spf9d295)) { $sp61981a = vtranslate($sp00497f) . ' - ' . SPFunnelChartsPlotParams::translateReportAggregationKey($spbe8b90) . ' "' . vtranslate($spa64eca, $sp00497f) . '"'; $sp81dbb1[] = array($sp66d8bc, $sp61981a); } } } } return $sp81dbb1; } private function spbb8dfb($spcd19d6) { $sp829569 = PearDatabase::getInstance(); $sp36a917 = $this->getModule(); $sp77da92 = $sp829569->pquery('SELECT plot_field FROM ' . $sp36a917->getReportsStagesTableName() . ' WHERE record_id=? AND report_id=?', array($this->getId(), $spcd19d6->getId())); $spfc4fff = SPFunnelChartsPlotParams::DEFAULT_PLOT_BY; if ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { $spfc4fff = $sp2b1f4d['plot_field']; } return $spfc4fff; } public function getSortedAllReportsList() { $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->query('SELECT reportid FROM vtiger_report WHERE reporttype=\'summary\' OR reporttype=\'tabular\''); $spf8706f = $this->getReportsList(); while ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { if (!$this->sped74b7($spf8706f, $sp2b1f4d['reportid'])) { $spf8706f[] = Reports_Record_Model::getInstanceById($sp2b1f4d['reportid']); } } return $spf8706f; } private function sp43d51c($sp8d3022, $sp04b736) { $sp63d2d3 = $this->sp5fabc6($sp8d3022, $sp04b736); $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->query($sp63d2d3); $sp1fc890 = 0; if ($sp77da92) { $sp0653d2 = $sp829569->fetchByAssoc($sp77da92); $sp1fc890 = $sp0653d2['records_count']; } return $sp1fc890; } private function sp5fabc6($sp8d3022, $sp04b736) { $sp8383fc = $sp8d3022->getStdFilterList($sp8d3022->reportid); $sp0d2d98 = ''; if (isset($sp8383fc)) { $sp52bcb3 = implode(', ', $sp8383fc); } if ($sp52bcb3 != '') { $sp0d2d98 = ' and ' . $sp52bcb3; } $sp5af710 = $this->sp888cc3($sp8d3022, $sp04b736); if (isset($sp5af710) && $sp5af710 !== false && $sp5af710 != '') { $sp0d2d98 .= ' and ' . $sp5af710; } $sp09c0ae = 'SELECT count(*) AS records_count ' . $sp8d3022->getReportsQuery($sp8d3022->primarymodule, 'COLUMNSTOTOTAL') . ' ' . $sp0d2d98; $spacc6fb = array(); preg_match('/&/', $sp09c0ae, $spacc6fb); if (!empty($spacc6fb)) { $sp09c0ae = str_replace('&', '&', $sp09c0ae); $sp09c0ae = $sp8d3022->replaceSpecialChar($sp09c0ae); } $sp8d3022->queryPlanner->initializeTempTables(); return $sp09c0ae; } private function sp888cc3($sp8d3022, $sp04b736) { $sp5af710 = $sp8d3022->getAdvFilterSql($sp8d3022->reportid); if (isset($sp04b736) && $sp04b736 !== false && $sp04b736 != '') { if ($sp5af710 != null) { $sp5af710 .= ' and ' . $sp04b736; } else { $sp5af710 = $sp04b736; } } return $sp5af710; } public function getData($sp192f8d) { $spde0ea5 = array(); foreach ($this->getReportsList() as $sp62c054) { $sp8d3022 = ReportRun::getInstance($sp62c054->getId()); $sp04b736 = ''; if ($sp192f8d->getAssignedUserId() !== SPFunnelChartsPlotParams::DEFAULT_ASSIGNED_USER_FILTER) { $sp04b736 = $sp8d3022->getAdvFilterSql($sp62c054->getId()); if ($sp04b736 == '') { $sp04b736 = 'vtiger_crmentity.smownerid=' . $sp192f8d->getAssignedUserId(); } else { $sp04b736 .= ' AND vtiger_crmentity.smownerid=' . $sp192f8d->getAssignedUserId(); } } $sp42f506 = $this->sp43d51c($sp8d3022, $sp04b736); $spe3e4c4 = $sp8d3022->GenerateReport('TOTALXLS', $this->sp888cc3($sp8d3022, $sp04b736), true); $sp316a75 = array(); $sp316a75[SPFunnelChartsPlotParams::DEFAULT_PLOT_BY] = array('calculationFieldName' => SPFunnelChartsPlotParams::getTranslatedPlotParamName(SPFunnelChartsPlotParams::DEFAULT_PLOT_BY), 'value' => $sp42f506); $sp43ce7e = $sp42f506; $speb9c7d = $this->sp772901($sp62c054); foreach ($spe3e4c4 as $spa64eca) { foreach ($spa64eca as $sp01cf27 => $sp40e666) { if ($sp40e666 != '') { $sp8841eb = explode('_', $sp01cf27); $sp00497f = $sp8841eb[0]; $sp689212 = end($sp8841eb); $sp3a35c5 = join(' ', array_slice($sp8841eb, 1, -1)); $sp316a75[] = array('calculationFieldName' => vtranslate($sp00497f) . ' - ' . vtranslate($sp3a35c5, $sp00497f) . ' ' . vtranslate('LBL_' . $sp689212, 'Reports'), 'value' => $sp40e666); if ($speb9c7d['moduleName'] == $sp00497f && $speb9c7d['plotByField'] == $sp3a35c5 && $speb9c7d['aggregationKey'] == $sp689212) { $sp43ce7e = $sp40e666; } } } } $spde0ea5[] = array('label' => $sp62c054->getName(), 'detail' => $sp62c054->getDetailViewUrl(), 'count' => $this->sp34ea44($sp43ce7e), 'summary' => array_values($sp316a75), 'reportId' => $sp62c054->getId()); } $sp2b0977 = true; foreach ($spde0ea5 as $sp17886c) { if ($sp17886c['count'] != 0) { $sp2b0977 = false; } } if ($sp2b0977) { $spde0ea5 = array(); } return $spde0ea5; } private function sp34ea44($sp43ce7e) { $spea9876 = Users_Record_Model::getCurrentUserModel(); $sp43ce7e = str_replace($spea9876->get('currency_symbol'), '', $sp43ce7e); $sp43ce7e = str_replace($spea9876->get('currency_grouping_separator'), '', $sp43ce7e); if ($spea9876->get('currency_decimal_separator') != '.') { $sp43ce7e = str_replace($spea9876->get('currency_decimal_separator'), '.', $sp43ce7e); } return (double) $sp43ce7e; } private function sp772901($sp62c054) { $speb9c7d = array(); $sp702630 = $this->spbb8dfb($sp62c054); foreach ($sp62c054->getCalculationFields() as $sp00497f => $spe3e4c4) { foreach ($spe3e4c4 as $sp4b3f3d => $spa64eca) { $sp86955c = explode(':', $sp4b3f3d); $sp83ae83 = $sp86955c[0]; $sp1cad50 = $sp86955c[1]; $spd24164 = explode('_', $sp86955c[2]); $spa5ba54 = array_slice($spd24164, 1); $sp57ce0c = implode('_', $spa5ba54); foreach (SPFunnelChartsPlotParams::getFieldsCalculationOperations() as $spa28268) { $sp66d8bc = 'cb:' . $sp83ae83 . ':' . $sp1cad50 . ':' . $sp57ce0c . '_' . $spa28268; if ($sp66d8bc == $sp702630) { $sp17eb77 = explode(':', $spa28268); $speb9c7d['moduleName'] = $sp00497f; $speb9c7d['plotByField'] = $spa64eca; $speb9c7d['aggregationKey'] = $sp17eb77[0]; return $speb9c7d; } } } } return $speb9c7d; } public function getWidgetLinkId() { $spe4cb96 = $this->findWidgetLinkModel(); if ($spe4cb96 != null) { return $spe4cb96->getId(); } return null; } public function getWidgetReportURL() { return 'index.php?module=' . $this->getModuleName() . '&view=ShowWidget&name=' . $this->getFrontEndWidgetName() . '&record=' . $this->getId(); } protected function getFrontEndWidgetName() { return 'SPFunnelChartsWidgetExtensions'; } public function checkDuplicate() { $sp829569 = PearDatabase::getInstance(); $sp36a917 = $this->getModule(); $sp63d2d3 = 'SELECT * FROM ' . $sp36a917->getMainTableName() . ' WHERE name = ?'; $spca51ae = array($this->getName()); $sp99f14b = $this->getId(); if ($sp99f14b && !$this->get('isDuplicate')) { $sp63d2d3 .= ' AND id != ?'; array_push($spca51ae, $sp99f14b); } $sp77da92 = $sp829569->pquery($sp63d2d3, $spca51ae); return $sp829569->num_rows($sp77da92) > 0; } public static function getCleanInstance($sp00497f) { $spf512c1 = Vtiger_Loader::getComponentClassName('Model', 'Record', $sp00497f); $sp332727 = new $spf512c1(); $sp332727->setModule($sp00497f); return $sp332727; } public function isEditable() { return $this->sp5c5953(); } public function isDeletable() { return $this->sp5c5953(); } public function getBindedWidgetModel() { $spf12723 = $this->findWidgetLinkModel(); $spe414e5 = new Vtiger_Widget_Model(); if ($spf12723 != null) { $spe414e5->setData($this->sp917d53($spf12723)); } return $spe414e5; } private function sp917d53($spf12723) { $sp6b93e0 = array(); $sp6b93e0['tabid'] = $spf12723->tabid; $sp6b93e0['linkid'] = $spf12723->linkid; $sp6b93e0['linktype'] = $spf12723->linktype; $sp6b93e0['linklabel'] = $spf12723->linklabel; $sp6b93e0['linkurl'] = $spf12723->linkurl; $sp6b93e0['linkicon'] = $spf12723->linkicon; $sp6b93e0['sequence'] = $spf12723->sequence; $sp6b93e0['status'] = $spf12723->status; $sp6b93e0['handler_path'] = $spf12723->handler_path; $sp6b93e0['handler_class'] = $spf12723->handler_class; $sp6b93e0['handler'] = $spf12723->handler; return $sp6b93e0; } public function addWidgetLink() { Vtiger_Link_Model::addLink(getTabid('Home'), SPFunnelChartsWidgetExtensions_Record_Model::LINKS_DASHBOARD_VIEW_TYPE, $this->getName(), $this->getWidgetReportURL()); } public function removeWidgetLink() { Vtiger_Link_Model::deleteLink(getTabid('Home'), SPFunnelChartsWidgetExtensions_Record_Model::LINKS_DASHBOARD_VIEW_TYPE, $this->getName(), $this->getWidgetReportURL()); } public function findWidgetLinkModel() { $spa72554 = getTabid('Home'); $sp082075 = Vtiger_Link_Model::getAllByType($spa72554, array(SPFunnelChartsWidgetExtensions_Record_Model::LINKS_DASHBOARD_VIEW_TYPE)); foreach ($sp082075[SPFunnelChartsWidgetExtensions_Record_Model::LINKS_DASHBOARD_VIEW_TYPE] as $spf12723) { if ($this->spe7fd36($spf12723)) { return $spf12723; } } return null; } private function spe7fd36($spf12723) { return decode_html($spf12723->getLabel()) == decode_html($this->getName()) && decode_html($spf12723->getUrl()) == decode_html($this->getWidgetReportURL()); } public function applyReportViewModeToWidget($spce8310) { $spce8310->set('linkurl', $spce8310->get('linkurl') . '&isReportView=true'); } private function sped74b7($spd18c68, $sp72b306) { foreach ($spd18c68 as $spcd19d6) { if ($spcd19d6->getId() == $sp72b306) { return true; } } return false; } private function sp5ed55e() { $sp3369ba = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($this->getId(), $this->getModuleName()); $sp3369ba->removeWidgetLink(); $this->addWidgetLink(); } private function sp5c5953() { $spea9876 = Users_Record_Model::getCurrentUserModel(); if ($spea9876->isAdminUser()) { return true; } $spca51ae = array($this->get('owner')); $spffdb63 = 'SELECT vtiger_users.id AS id FROM vtiger_users ' . 'INNER JOIN vtiger_user2role ON vtiger_user2role.userid=vtiger_users.id ' . 'INNER JOIN vtiger_role ON vtiger_role.roleid=vtiger_user2role.roleid ' . 'WHERE vtiger_users.status=\'Active\' AND vtiger_users.deleted=0 AND ' . '(vtiger_users.id=?'; $sp85cd10 = Users_Privileges_Model::getInstanceById($this->get('owner')); $spd63434 = $sp85cd10->get('parent_roles'); if (!empty($spd63434)) { foreach ($spd63434 as $sp43ae2a => $sp4575b6) { $spd63434[$sp43ae2a] = '\'' . $sp4575b6 . '\''; } $spffdb63 .= ' OR vtiger_role.roleid IN (' . join(',', $spd63434) . ')'; } $spffdb63 .= ')'; $sp829569 = PearDatabase::getInstance(); $sp77da92 = $sp829569->pquery($spffdb63, $spca51ae); $sp0d5afc = array(); while ($sp2b1f4d = $sp829569->fetchByAssoc($sp77da92)) { $sp0d5afc[] = $sp2b1f4d['id']; } return in_array($spea9876->getId(), $sp0d5afc); } } class SPFunnelChartsWidgetExtensions_Detail_View extends Vtiger_Index_View { public function checkPermission(Vtiger_Request $spb9aaa5) { SPFunnelChartsWidgetExtensions_Module_Model::checkViewRecordAccess($spb9aaa5); } public function preProcess(Vtiger_Request $spb9aaa5) { global $default_layout; $spa9a73c = !($default_layout == 'v7'); parent::preProcess($spb9aaa5, $spa9a73c); $sp00497f = $spb9aaa5->getModule(); $sp297ee1 = SPFunnelChartsWidgetExtensions_DetailView_Model::getInstance($sp00497f, $spb9aaa5->get('record')); $sp332727 = $sp297ee1->getRecord(); $spe45b5d = $this->getViewer($spb9aaa5); $spe45b5d->assign('RECORD', $sp332727); $spe45b5d->assign('MODEL', $sp332727); $spe45b5d->assign('MODULE', $sp00497f); if ($default_layout == 'v7') { $sp62a832 = $sp297ee1->getDetailBasicLinks(); foreach ($sp62a832 as $sp7fa569) { $spdc4078[] = $sp7fa569; } $spe45b5d->assign('MODULE_BASIC_ACTIONS', $spdc4078); } $spe45b5d->view('DetailHeader.tpl', $sp00497f); } public function process(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $sp99f14b = $spb9aaa5->get('record'); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); $spce8310 = $sp332727->getBindedWidgetModel(); $sp332727->applyReportViewModeToWidget($spce8310); $spe45b5d = $this->getViewer($spb9aaa5); $spe45b5d->assign('RECORD', $sp332727); $spe45b5d->assign('WIDGET', $spce8310); $spe45b5d->assign('MODULE', $sp00497f); $spe45b5d->view('Detail.tpl', $sp00497f); } function getHeaderScripts(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $sp7dadff = array('~/libraries/jquery/gridster/jquery.gridster.min.js', '~/libraries/jquery/jqplot/jquery.jqplot.js', '~/libraries/jquery/jqplot/plugins/jqplot.canvasTextRenderer.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.categoryAxisRenderer.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.logAxisRenderer.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.pointLabels.min.js', '~/libraries/jquery/jqplot/plugins/jqplot.highlighter.min.js', 'modules.Vtiger.resources.DashBoard', 'modules.Vtiger.resources.dashboards.Widget', "modules.{$sp00497f}.resources.Detail"); $sp518c5a = $this->checkAndConvertJsScripts($sp7dadff); return array_merge(parent::getHeaderScripts($spb9aaa5), $sp518c5a); } public function getHeaderCss(Vtiger_Request $spb9aaa5) { global $default_layout; $sp00497f = $spb9aaa5->getModule(); $spdd885d = array('~/libraries/jquery/jqplot/jquery.jqplot.min.css', "~/layouts/{$default_layout}/modules/{$sp00497f}/resources/css/SPFunnelChartsWidgetExtensionsDetail.css"); $speed10a = $this->checkAndConvertCssStyles($spdd885d); return array_merge(parent::getHeaderCss($spb9aaa5), $speed10a); } } class SPFunnelChartsWidgetExtensions_Edit_View extends Vtiger_Edit_View { public function checkPermission(Vtiger_Request $spb9aaa5) { SPFunnelChartsWidgetExtensions_Module_Model::checkViewRecordAccess($spb9aaa5); } public function preProcess(Vtiger_Request $spb9aaa5) { parent::preProcess($spb9aaa5); $sp00497f = $spb9aaa5->getModule(); $sp99f14b = $spb9aaa5->get('record'); $sp332727 = null; if ($sp99f14b != null) { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); } else { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getCleanInstance($sp00497f); } $spe45b5d = $this->getViewer($spb9aaa5); if ($spb9aaa5->get('isDuplicate')) { $spe45b5d->assign('IS_DUPLICATE', true); } $spe45b5d->assign('MODEL', $sp332727); $spe45b5d->assign('MODULE', $sp00497f); $spe45b5d->view('EditHeader.tpl', $sp00497f); } public function process(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $sp99f14b = $spb9aaa5->get('record'); $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getCleanInstance($sp00497f); if ($sp99f14b != null) { $sp332727 = SPFunnelChartsWidgetExtensions_Record_Model::getInstanceById($sp99f14b, $sp00497f); } $spe45b5d = $this->getViewer($spb9aaa5); if ($spb9aaa5->get('isDuplicate')) { $spe45b5d->assign('IS_DUPLICATE', true); $sp332727->set('name', ''); } $spe45b5d->assign('MODE', ''); if (!empty($sp99f14b)) { $spe45b5d->assign('MODE', 'edit'); } $spce0887 = $sp332727->getSortedAllReportsList(); $spe45b5d->assign('MODEL', $sp332727); $spe45b5d->assign('RECORD_ID', $sp99f14b); $spe45b5d->assign('SELECTED_REPORTS', $sp332727->getReportsList()); $spe45b5d->assign('REPORTS_PLOT_DEPENDENCIES', $sp332727->getReportsPlotDependencies($spce0887)); $spe45b5d->assign('ALL_REPORTS', $spce0887); $spe45b5d->view('Edit.tpl', $sp00497f); } public function getHeaderCss(Vtiger_Request $spb9aaa5) { global $default_layout; $sp00497f = $spb9aaa5->getModule(); $sp156197 = array("~/layouts/{$default_layout}/modules/{$sp00497f}/resources/css/SPFunnelChartsWidgetExtensionsEdit.css", '~/libraries/jquery/posabsolute-jQuery-Validation-Engine/css/validationEngine.jquery.css'); $sp3a07fd = $this->checkAndConvertCssStyles($sp156197); return array_merge(parent::getHeaderCss($spb9aaa5), $sp3a07fd); } public function getHeaderScripts(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $sp518c5a = $this->checkAndConvertJsScripts(array("modules.{$sp00497f}.resources.Edit", '~layouts/v7/modules/Vtiger/resources/validation.js')); return array_merge(parent::getHeaderScripts($spb9aaa5), $sp518c5a); } } class SPFunnelChartsWidgetExtensions_List_View extends Vtiger_Index_View { public function preProcess(Vtiger_Request $spb9aaa5, $spa9a73c = true) { parent::preProcess($spb9aaa5, false); $sp00497f = $spb9aaa5->getModule(); $sp07b66c = SPFunnelChartsWidgetExtensions_ListView_Model::getInstance($sp00497f); $spf4fc71 = array('MODULE' => $sp00497f, 'ACTION' => $spb9aaa5->get('view')); $spe45b5d = $this->getViewer($spb9aaa5); $spe45b5d->assign('QUICK_LINKS', $sp07b66c->getSideBarLinks($spf4fc71)); $sp62a832 = $sp07b66c->getListBasicLinks(); foreach ($sp62a832 as $sp7fa569) { $spdc4078[] = $sp7fa569; } $spe45b5d->assign('MODULE_BASIC_ACTIONS', $spdc4078); $this->initializeListViewContents($spb9aaa5, $spe45b5d); if ($spa9a73c) { $this->preProcessDisplay($spb9aaa5); } } public function preProcessTplName(Vtiger_Request $spb9aaa5) { return 'ListViewPreProcess.tpl'; } public function process(Vtiger_Request $spb9aaa5) { global $default_layout; $spe45b5d = $this->getViewer($spb9aaa5); $sp00497f = $spb9aaa5->getModule(); $sp36a917 = Vtiger_Module_Model::getInstance($sp00497f); $this->initializeListViewContents($spb9aaa5, $spe45b5d); if ($default_layout == 'v7') { $this->assignCustomViews($spb9aaa5, $spe45b5d); } $spe45b5d->assign('VIEW', $spb9aaa5->get('view')); $spe45b5d->assign('MODULE_MODEL', $sp36a917); $spe45b5d->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel()); $spe45b5d->view('ListViewContents.tpl', $sp00497f); } public function postProcess(Vtiger_Request $spb9aaa5) { $spe45b5d = $this->getViewer($spb9aaa5); $sp00497f = $spb9aaa5->getModule(); $spe45b5d->view('ListViewPostProcess.tpl', $sp00497f); parent::postProcess($spb9aaa5); } public function assignCustomViews($spb9aaa5, $spe45b5d) { $sp85d922 = CustomView_Record_Model::getAllByGroup($spb9aaa5->getModule()); if (!empty($sp85d922)) { $spe45b5d->assign('CUSTOM_VIEWS', $sp85d922); $sp2f854c = $spe45b5d->get_template_vars('VIEWID'); $spc81878 = new CustomView_Record_Model(); $spe45b5d->assign('CURRENT_CV_MODEL', $spc81878); } } public function initializeListViewContents(Vtiger_Request $spb9aaa5, Vtiger_Viewer $spe45b5d) { $sp00497f = $spb9aaa5->getModule(); $spc01d2b = $spb9aaa5->get('viewname'); $sp95bf20 = $spb9aaa5->get('orderby'); $spb13b85 = $spb9aaa5->get('sortorder'); if ($spb13b85 == 'ASC') { $sp1a4777 = 'DESC'; $spd81f73 = 'icon-chevron-down'; } else { $sp1a4777 = 'ASC'; $spd81f73 = 'icon-chevron-up'; } $sp7643b2 = new Vtiger_Paging_Model(); $sp87f5ca = $spb9aaa5->get('page'); if (empty($sp87f5ca)) { $sp87f5ca = 1; } $sp07b66c = SPFunnelChartsWidgetExtensions_ListView_Model::getInstance($sp00497f); $spf4fc71 = array('MODULE' => $sp00497f, 'ACTION' => $spb9aaa5->get('view'), 'CVID' => $spc01d2b); $sp26a3a7 = $sp07b66c->getListViewMassActions($spf4fc71); if (!empty($sp95bf20)) { $sp07b66c->set('orderby', $sp95bf20); $sp07b66c->set('sortorder', $spb13b85); } $spbd2fa8 = $spb9aaa5->get('search_key'); $sp4dcea5 = $spb9aaa5->get('search_value'); $sp206fc1 = $spb9aaa5->get('operator'); if (!empty($sp206fc1)) { $sp07b66c->set('operator', $sp206fc1); $spe45b5d->assign('OPERATOR', $sp206fc1); $spe45b5d->assign('ALPHABET_VALUE', $sp4dcea5); } if (!empty($spbd2fa8) && !empty($sp4dcea5)) { $sp07b66c->set('search_key', $spbd2fa8); $sp07b66c->set('search_value', $sp4dcea5); } if (!$this->listViewHeaders) { $this->listViewHeaders = $sp07b66c->getListViewHeaders(); } if (!$this->listViewEntries) { $this->listViewEntries = $sp07b66c->getListViewEntries($sp7643b2); } $sp70e567 = count($this->listViewEntries); $spe45b5d->assign('MODULE', $sp00497f); $spe45b5d->assign('LISTVIEW_ENTRIES_COUNT', $sp70e567); $spe45b5d->assign('LISTVIEW_ENTRIES', $this->listViewEntries); $spe45b5d->assign('VIEWID', $spc01d2b); $spe45b5d->assign('MODULE', $sp00497f); if (!$this->listViewLinks) { $this->listViewLinks = $sp07b66c->getListViewLinks($spf4fc71); } $spe45b5d->assign('LISTVIEW_LINKS', $this->listViewLinks); $spe45b5d->assign('LISTVIEW_MASSACTIONS', $sp26a3a7['LISTVIEWMASSACTION']); $spe45b5d->assign('ORDER_BY', $sp95bf20); $spe45b5d->assign('SORT_ORDER', $spb13b85); $spe45b5d->assign('NEXT_SORT_ORDER', $sp1a4777); $spe45b5d->assign('SORT_IMAGE', $spd81f73); $spe45b5d->assign('COLUMN_NAME', $sp95bf20); $sp7643b2->calculatePageRange($this->listViewEntries); $spe45b5d->assign('PAGING_MODEL', $sp7643b2); $spe45b5d->assign('PAGE_NUMBER', $sp87f5ca); $spe45b5d->assign('LISTVIEW_HEADERS', $this->listViewHeaders); if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) { if (!$this->listViewCount) { $this->listViewCount = $sp07b66c->getListViewCount(); } $spe45b5d->assign('LISTVIEW_COUNT', $this->listViewCount); } $spe45b5d->assign('IS_MODULE_EDITABLE', $sp07b66c->getModule()->isPermitted('EditView')); $spe45b5d->assign('IS_MODULE_DELETABLE', $sp07b66c->getModule()->isPermitted('Delete')); } public function getRecordsCount(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $sp52adc6 = $this->getListViewCount($spb9aaa5); $sp77da92 = array(); $sp77da92['module'] = $sp00497f; $sp77da92['count'] = $sp52adc6; $sp9c1417 = new Vtiger_Response(); $sp9c1417->setEmitType(Vtiger_Response::$EMIT_JSON); $sp9c1417->setResult($sp77da92); $sp9c1417->emit(); } public function getListViewCount(Vtiger_Request $spb9aaa5) { $sp00497f = $spb9aaa5->getModule(); $spbd2fa8 = $spb9aaa5->get('search_key'); $sp4dcea5 = $spb9aaa5->get('search_value'); $sp07b66c = SPFunnelChartsWidgetExtensions_ListView_Model::getInstance($sp00497f); $sp07b66c->set('search_key', $spbd2fa8); $sp07b66c->set('search_value', $sp4dcea5); $sp07b66c->set('operator', $spb9aaa5->get('operator')); return $sp07b66c->getListViewCount(); } public function getPageCount(Vtiger_Request $spb9aaa5) { $space03d = $this->getListViewCount($spb9aaa5); $sp7643b2 = new Vtiger_Paging_Model(); $sp34d4b8 = $sp7643b2->getPageLimit(); $sp52dc92 = ceil((int) $space03d / (int) $sp34d4b8); $sp77da92 = array(); $sp77da92['page'] = $sp52dc92; $sp77da92['numberOfRecords'] = $space03d; $sp9c1417 = new Vtiger_Response(); $sp9c1417->setResult($sp77da92); $sp9c1417->emit(); } function getHeaderScripts(Vtiger_Request $spb9aaa5) { $spf502b8 = parent::getHeaderScripts($spb9aaa5); $sp7dadff = array('modules.Vtiger.resources.List'); $sp518c5a = $this->checkAndConvertJsScripts($sp7dadff); return array_merge($spf502b8, $sp518c5a); } } class SPFunnelChartsWidgetExtensions_ListAjax_View extends SPFunnelChartsWidgetExtensions_List_View { function __construct() { parent::__construct(); $this->exposeMethod('getRecordsCount'); $this->exposeMethod('getPageCount'); } function preProcess(Vtiger_Request $spb9aaa5) { return true; } function postProcess(Vtiger_Request $spb9aaa5) { return true; } function process(Vtiger_Request $spb9aaa5) { $sp1e8d35 = $spb9aaa5->get('mode'); if (!empty($sp1e8d35)) { $this->invokeExposedMethod($sp1e8d35, $spb9aaa5); return; } } } class SPFunnelChartsPlotParams { const DEFAULT_PLOT_BY = 'count'; const SUM_PLOT_BY = 'sum'; const AVERAGE_PLOT_BY = 'average'; const MAX_PLOT_BY = 'max'; const MIN_PLOT_BY = 'min'; const DEFAULT_ASSIGNED_USER_FILTER = 'all'; private static $fieldsCalculationOperations = array('SUM:2', 'AVG:3', 'MIN:4', 'MAX:5'); private static $reportAggregateLabelsMap = array('count' => 'count', 'sum' => 'LBL_SUM', 'average' => 'LBL_AVG', 'max' => 'LBL_MAX', 'min' => 'LBL_MIN'); private static $reportsAggregationKeysMapping = array('count' => 'LBL_RECORD_COUNT', 'SUM:2' => 'LBL_SUM_VALUE', 'AVG:3' => 'LBL_AVERAGE', 'MIN:4' => 'LBL_LOWEST_VALUE', 'MAX:5' => 'LBL_HIGHEST_VALUE'); private static $plotTypesMap = array(SPFunnelChartsPlotParams::DEFAULT_PLOT_BY => 'LBL_RECORD_COUNT', SPFunnelChartsPlotParams::SUM_PLOT_BY => 'LBL_SUM_VALUE', SPFunnelChartsPlotParams::AVERAGE_PLOT_BY => 'LBL_AVERAGE', SPFunnelChartsPlotParams::MAX_PLOT_BY => 'LBL_HIGHEST_VALUE', SPFunnelChartsPlotParams::MIN_PLOT_BY => 'LBL_LOWEST_VALUE'); private $assignedUserId; public function __construct() { $this->assignedUserId = SPFunnelChartsPlotParams::DEFAULT_ASSIGNED_USER_FILTER; } public function parsePlotParams($spb9aaa5) { $this->assignedUserId = $spb9aaa5->get('assigned_user_id', SPFunnelChartsPlotParams::DEFAULT_ASSIGNED_USER_FILTER); } public function getAssignedUserId() { return $this->assignedUserId; } public static function getFieldsCalculationOperations() { return self::$fieldsCalculationOperations; } public static function getTranslatedPlotParamName($sp3f847f) { if (array_key_exists($sp3f847f, self::$plotTypesMap)) { $sp3f847f = vtranslate(self::$plotTypesMap[$sp3f847f], 'Reports'); } return $sp3f847f; } public static function getPlotTypesMap() { $sp452809 = array(); foreach (self::$plotTypesMap as $spa97d30 => $sp82bfd5) { $sp452809[$spa97d30] = vtranslate($sp82bfd5, 'Reports'); } return $sp452809; } public function getCurrentPlotParamAggregateLabel() { if (array_key_exists($this->plotBy, self::$reportAggregateLabelsMap)) { return self::$reportAggregateLabelsMap[$this->plotBy]; } return self::$reportAggregateLabelsMap[SPFunnelChartsPlotParams::DEFAULT_PLOT_BY]; } public static function translateReportAggregationKey($sp689212) { return vtranslate(self::$reportsAggregationKeysMapping[$sp689212], 'Reports'); } }