Example #1
0
 /**
  * Displays the dashlet
  * 
  * @return string html to display dashlet
  */
 function display()
 {
     require_once "modules/Reports/Report.php";
     //		ini_set('display_errors', 'false');
     $chartReport = new SavedReport();
     $chartExists = $chartReport->retrieve($this->report_id, false);
     if (!is_null($chartExists)) {
         $title = getReportNameTranslation($chartReport->name);
         $this->title = $title;
         $reporter = new Report($chartReport->content);
         $reporter->is_saved_report = true;
         $reporter->saved_report_id = $chartReport->id;
         $reporter->get_total_header_row();
         $reporter->run_chart_queries();
         require_once "modules/Reports/templates/templates_chart.php";
         ob_start();
         template_chart($reporter, true, true, $this->id);
         $str = ob_get_contents();
         ob_end_clean();
         $xmlFile = get_cache_file_name($reporter);
         $html = parent::display() . "<div align='center'>" . $str . "</div>" . "<br />";
         // return parent::display for title and such
         $ss = new Sugar_Smarty();
         $ss->assign('chartName', $this->id);
         $ss->assign('chartXMLFile', $xmlFile);
         $script = $ss->fetch('modules/Home/Dashlets/ChartsDashlet/ChartsDashletScript.tpl');
         $json = getJSONobj();
         return parent::display() . "<div align='center'>" . $str . "</div>" . "<br />";
         // return parent::display for title and such
     }
 }
Example #2
0
 function getReportCharts($category)
 {
     global $current_user;
     $chartsList = array();
     require_once 'modules/Reports/SavedReport.php';
     $sq = new SugarQuery();
     $savedReportBean = BeanFactory::getBean('Reports');
     $sq->from($savedReportBean);
     // Make sure the user isn't seeing reports they don't have access to
     $modules = array_keys(getACLDisAllowedModules());
     if (count($modules)) {
         $sq->where()->notIn('module', $modules);
     }
     //create the $where statement(s)
     $sq->where()->notEquals('chart_type', 'none');
     switch ($category) {
         case 'global':
             // build global where string
             $sq->where()->equals('saved_reports.team_set_id', '1');
             break;
         case 'myTeams':
             // build myTeams where string
             $myTeams = $current_user->get_my_teams();
             $teamWhere = '';
             foreach ($myTeams as $team_id => $team_name) {
                 if ($team_id != '1' && $team_id != $current_user->getPrivateTeamID()) {
                     if ($teamWhere == '') {
                         $teamWhere .= ' ';
                     } else {
                         $teamWhere .= 'OR ';
                     }
                     $teamWhere .= "saved_reports.team_set_id='" . $team_id . "' ";
                 }
             }
             $sq->whereRaw($teamWhere);
             break;
         case 'mySaved':
             // build mySaved where string
             $sq->where()->equals('saved_reports.team_set_id', $current_user->getPrivateTeamID());
             break;
         case 'myFavorites':
             global $current_user;
             $sugaFav = BeanFactory::getBean('SugarFavorites');
             $current_favorites_beans = $sugaFav->getUserFavoritesByModule('Reports', $current_user);
             $current_favorites = array();
             foreach ((array) $current_favorites_beans as $key => $val) {
                 array_push($current_favorites, $val->record_id);
             }
             if (is_array($current_favorites) && !empty($current_favorites)) {
                 $sq->where()->in('saved_reports.id', array_values($current_favorites));
             } else {
                 $sq->where()->in('saved_reports.id', array('-1'));
             }
             break;
         default:
             break;
     }
     //retrieve array of reports
     $savedReports = $savedReportBean->fetchFromQuery($sq);
     $chartsList = array();
     if (!empty($savedReports)) {
         foreach ($savedReports as $savedReport) {
             // clint - fixes bug #20398
             // only display dashlets that are from visibile modules and that the user has permission to list
             require_once 'include/MySugar/MySugar.php';
             $myDashlet = new MySugar($savedReport->module);
             $displayDashlet = $myDashlet->checkDashletDisplay();
             if ($displayDashlet) {
                 $title = getReportNameTranslation($savedReport->name);
                 $report_def = array('title' => $title, 'onclick' => 'return SUGAR.mySugar.addDashlet(\'' . $savedReport->id . '\', \'chart\', \'' . $savedReport->module . '\');');
                 array_push($chartsList, $report_def);
             }
         }
     }
     asort($chartsList);
     $this->dashlets[$category] = $chartsList;
 }
Example #3
-1
 /**
  * Displays the dashlet
  *
  * @return string html to display dashlet
  */
 function display()
 {
     require_once "modules/Reports/Report.php";
     $chartReport = BeanFactory::getBean('Reports', $this->report_id, array('encode' => false, 'strict_retrieve' => true));
     if (!empty($chartReport)) {
         $title = getReportNameTranslation($chartReport->name);
         $this->title = $title;
         $reporter = new Report($chartReport->content);
         $reporter->is_saved_report = true;
         $reporter->saved_report_id = $chartReport->id;
         $reporter->get_total_header_row();
         $reporter->run_chart_queries();
         ob_start();
         require_once "include/SugarCharts/ChartDisplay.php";
         $chartDisplay = new ChartDisplay();
         $chartDisplay->setReporter($reporter);
         echo $chartDisplay->legacyDisplay($this->id, true);
         $str = ob_get_contents();
         ob_end_clean();
         $xmlFile = $chartDisplay->get_cache_file_name($reporter);
         $html = parent::display() . "<div align='center'>" . $str . "</div>" . "<br />";
         // return parent::display for title and such
         $ss = new Sugar_Smarty();
         $ss->assign('chartName', $this->id);
         $ss->assign('chartXMLFile', $xmlFile);
         $script = $ss->fetch('modules/Home/Dashlets/ChartsDashlet/ChartsDashletScript.tpl');
         $json = getJSONobj();
         return parent::display() . "<div align='center'>" . $str . "</div>" . "<br />";
         // return parent::display for title and such
     }
 }