[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Reports/ -> ReportChartRun.php_deprecated (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  global $theme;
  12  $theme_path="themes/".$theme."/";
  13  $image_path=$theme_path."images/";
  14  require_once ('modules/CustomView/CustomView.php');
  15  require_once ("config.php");
  16  require_once ('modules/Reports/Reports.php');
  17  require_once ('include/logging.php');
  18  require_once ("modules/Reports/ReportRun.php");
  19  require_once ('include/utils/utils.php');
  20  require_once('Smarty_setup.php');
  21  
  22  global $adb,$mod_strings,$app_strings;
  23  
  24  $reportid = vtlib_purify($_REQUEST["record"]);
  25  $folderid = vtlib_purify($_REQUEST["folderid"]);
  26  
  27  $sql = "select * from vtiger_report where reportid=?";
  28  $res = $adb->pquery($sql, array($reportid));
  29  
  30  $numOfRows = $adb->num_rows($res);
  31  
  32  if($numOfRows > 0) {
  33  
  34      $Report_ID = $adb->query_result($res,0,'reportid');
  35      if(empty($folderid)) {
  36          $folderid = $adb->query_result($res,0,'folderid');
  37      }
  38      $reporttype = $adb->query_result($res,0,'reporttype');
  39  
  40      $showCharts = false;
  41      if($reporttype == 'summary'){
  42          $showCharts = true;
  43      }
  44  
  45      global $primarymodule,$secondarymodule,$orderbylistsql,$orderbylistcolumns,$ogReport;
  46      //added to fix the ticket #5117
  47      global $current_user;
  48      require('user_privileges/user_privileges_'.$current_user->id.'.php');
  49  
  50      $ogReport = new Reports($reportid);
  51      $primarymodule = $ogReport->primodule;
  52      $restrictedmodules = array();
  53      if($ogReport->secmodule!='')
  54          $rep_modules = split(":",$ogReport->secmodule);
  55      else
  56          $rep_modules = array();
  57  
  58      array_push($rep_modules,$primarymodule);
  59      $modules_permitted = true;
  60      $modules_export_permitted = true;
  61      foreach($rep_modules as $mod){
  62          if(isPermitted($mod,'index')!= "yes" || vtlib_isModuleActive($mod)==false){
  63              $modules_permitted = false;
  64              $restrictedmodules[] = $mod;
  65          }
  66          if(isPermitted("$mod",'Export','')!='yes')
  67              $modules_export_permitted = false;
  68      }
  69  
  70      if(isPermitted($primarymodule,'index') == "yes" && $modules_permitted == true) {
  71          $oReportRun = ReportRun::getInstance($reportid);
  72  
  73          $advft_criteria = $_REQUEST['advft_criteria'];
  74          if(!empty($advft_criteria)) $advft_criteria = Zend_Json::decode($advft_criteria);
  75          $advft_criteria_groups = $_REQUEST['advft_criteria_groups'];
  76          if(!empty($advft_criteria_groups)) $advft_criteria_groups = Zend_Json::decode($advft_criteria_groups);
  77  
  78          $filtersql = $oReportRun->RunTimeAdvFilter($advft_criteria,$advft_criteria_groups);
  79  
  80          $smarty = new vtigerCRM_Smarty;
  81          $smarty->assign("MOD", $mod_strings);
  82          $smarty->assign("APP", $app_strings);
  83          $smarty->assign("IMAGE_PATH", $image_path);
  84          $smarty->assign("REPORTID", $reportid);
  85          
  86          if($showCharts == true){
  87              require_once 'modules/Reports/CustomReportUtils.php';
  88              require_once  'include/ChartUtils.php';
  89  
  90              $groupBy = $oReportRun->getGroupingList($reportid);
  91              if(!empty($groupBy)){
  92                  foreach ($groupBy as $key => $value) {
  93                      //$groupByConditon = explode(" ",$value);
  94                      //$groupByNew = explode("'",$groupByConditon[0]);
  95                      list($tablename,$colname,$module_field,$fieldname,$single) = split(":",$key);
  96                      list($module,$field)= split("_",$module_field);
  97                      $fieldDetails = $key;
  98                      break;
  99                  }
 100                  //$groupByField = $oReportRun->GetFirstSortByField($reportid);
 101                  $queryReports = CustomReportUtils::getCustomReportsQuery($Report_ID,$filtersql);
 102                  $queryResult = $adb->pquery($queryReports,array());
 103                  //ChartUtils::generateChartDataFromReports($queryResult, strtolower($groupByNew[1]));
 104                  if($adb->num_rows($queryResult)){
 105                      $pieChart = ChartUtils::getReportPieChart($queryResult, strtolower($module_field),$fieldDetails,$reportid);
 106                      $barChart = ChartUtils::getReportBarChart($queryResult, strtolower($module_field),$fieldDetails,$reportid);
 107                      $smarty->assign("PIECHART",$pieChart);
 108                      $smarty->assign("BARCHART",$barChart);
 109                  }
 110                  $smarty->assign('HASGROUPBY', true);
 111              } else {
 112                  $smarty->assign('HASGROUPBY', false);
 113              }
 114              $smarty->display('ReportChartRun.tpl');
 115          }
 116      }
 117  }
 118  // To abort any extra output emits.
 119  exit;
 120  ?>


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