[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Vtiger/dashboards/ -> KeyMetrics.php (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  class Vtiger_KeyMetrics_Dashboard extends Vtiger_IndexAjax_View {
  12      
  13  	public function process(Vtiger_Request $request) {
  14          $currentUser = Users_Record_Model::getCurrentUserModel();
  15          $viewer = $this->getViewer($request);
  16          $moduleName = $request->getModule();
  17          
  18          $linkId = $request->get('linkid');
  19          
  20          $widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
  21          
  22          // TODO move this to models
  23          $keyMetrics = $this->getKeyMetricsWithCount();
  24          
  25          $viewer->assign('WIDGET', $widget);
  26          $viewer->assign('MODULE_NAME', $moduleName);
  27          $viewer->assign('KEYMETRICS', $keyMetrics);
  28          
  29          $content = $request->get('content');
  30          if(!empty($content)) {
  31              $viewer->view('dashboards/KeyMetricsContents.tpl', $moduleName);
  32          } else {
  33              $viewer->view('dashboards/KeyMetrics.tpl', $moduleName);
  34          }
  35          
  36      }
  37      
  38      // NOTE: Move this function to appropriate model.
  39  	protected function getKeyMetricsWithCount() {
  40          global $current_user, $adb;
  41          $current_user = Users_Record_Model::getCurrentUserModel();
  42          
  43          require_once  'modules/CustomView/ListViewTop.php';
  44          $metriclists = getMetricList();
  45          
  46          foreach ($metriclists as $key => $metriclist) {
  47              
  48              $metricresult = NULL;
  49                  $queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
  50                  $queryGenerator->initForCustomViewById($metriclist['id']);
  51              if($metriclist['module'] == "Calendar") {
  52                  // For calendar we need to eliminate emails or else it will break in status empty condition
  53                  $queryGenerator->addCondition('activitytype', "Emails", 'n',  QueryGenerator::$AND);
  54              }
  55                  $metricsql = $queryGenerator->getQuery();
  56                  $metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
  57              if($metricresult) {
  58                      $rowcount = $adb->fetch_array($metricresult);
  59                      $metriclists[$key]['count'] = $rowcount['count'];
  60                  }
  61          }
  62          return $metriclists;
  63      }
  64      
  65  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1