Beispiel #1
0
 protected function action_changeReportPage()
 {
     $tableId = !empty($_REQUEST['table_id']) ? $_REQUEST['table_id'] : '';
     $group = !empty($_REQUEST['group']) ? $_REQUEST['group'] : '';
     $offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
     if (!empty($this->bean->id)) {
         $this->bean->user_parameters = requestToUserParameters();
         echo $this->bean->build_report_html($offset, true, $group, $tableId);
     }
     die;
 }
Beispiel #2
0
 public function preDisplay()
 {
     global $app_list_strings;
     parent::preDisplay();
     $this->ss->assign('report_module', $this->bean->report_module);
     $this->bean->user_parameters = requestToUserParameters();
     $reportHTML = $this->bean->build_group_report(0, true) . '<br />';
     $reportHTML .= $this->bean->build_report_chart(null, AOR_Report::CHART_TYPE_CHARTJS);
     $this->ss->assign('report_content', $reportHTML);
     echo "<input type='hidden' name='report_module' id='report_module' value='{$this->bean->report_module}'>";
     if (!is_file('cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js')) {
         require_once 'include/language/jsLanguage.php';
         jsLanguage::createModuleStringsCache('AOR_Conditions', $GLOBALS['current_language']);
     }
     echo '<script src="cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js"></script>';
     $params = $this->getReportParameters();
     echo "<script>var reportParameters = " . json_encode($params) . ";</script>";
 }
Beispiel #3
0
    public function preDisplay()
    {
        global $app_list_strings;
        parent::preDisplay();
        $this->ss->assign('report_module', $this->bean->report_module);
        $this->bean->user_parameters = requestToUserParameters();
        //$reportHTML = $this->bean->build_group_report(0,true);
        $reportHTML = $this->bean->buildMultiGroupReport(0, true);
        $chartsHTML = $this->bean->build_report_chart(null, AOR_Report::CHART_TYPE_RGRAPH);
        $chartsPerRow = $this->bean->graphs_per_row;
        $this->ss->assign('charts_content', $chartsHTML);
        $this->ss->assign('report_content', $reportHTML);
        echo "<input type='hidden' name='report_module' id='report_module' value='{$this->bean->report_module}'>";
        if (!is_file('cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js')) {
            require_once 'include/language/jsLanguage.php';
            jsLanguage::createModuleStringsCache('AOR_Conditions', $GLOBALS['current_language']);
        }
        echo '<script src="cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js"></script>';
        $params = $this->getReportParameters();
        echo "<script>var reportParameters = " . json_encode($params) . ";</script>";
        $resizeGraphsPerRow = <<<EOD

       <script>
        function resizeGraphsPerRow()
        {
                var maxWidth = 900;
                var maxHeight = 500;
                var maxTextSize = 10;
                var divWidth = \$("#detailpanel_report").width();

                var graphWidth = Math.floor(divWidth / {$chartsPerRow});

                var graphs = document.getElementsByClassName('resizableCanvas');
                for(var i = 0; i < graphs.length; i++)
                {
                    if(graphWidth * 0.9 > maxWidth)
                    graphs[i].width  = maxWidth;
                else
                    graphs[i].width = graphWidth * 0.9;
                if(graphWidth * 0.9 > maxHeight)
                    graphs[i].height = maxHeight;
                else
                    graphs[i].height = graphWidth * 0.9;


                /*
                var text_size = Math.min(12, (graphWidth / 1000) * 12 );
                if(text_size < 6)text_size=6;
                if(text_size > maxTextSize) text_size = maxTextSize;

                if(     graphs[i] !== undefined
                    &&  graphs[i].__object__ !== undefined
                    &&  graphs[i].__object__["properties"] !== undefined
                    &&  graphs[i].__object__["properties"]["chart.text.size"] !== undefined
                    &&  graphs[i].__object__["properties"]["chart.key.text.size"] !== undefined)
                 {
                    graphs[i].__object__["properties"]["chart.text.size"] = text_size;
                    graphs[i].__object__["properties"]["chart.key.text.size"] = text_size;
                 }
                //http://www.rgraph.net/docs/issues.html
                //As per Google Chrome not initially drawing charts
                RGraph.redrawCanvas(graphs[i]);
                */
                }
                if (typeof RGraph !== 'undefined') {
                    RGraph.redraw();
                }
        }
        </script>

EOD;
        echo $resizeGraphsPerRow;
        echo "<script> \$(document).ready(function(){resizeGraphsPerRow();}); </script>";
        echo "<script> \$(window).resize(function(){resizeGraphsPerRow();}); </script>";
    }
Beispiel #4
0
 protected function action_downloadPDF()
 {
     error_reporting(0);
     require_once 'modules/AOS_PDF_Templates/PDF_Lib/mpdf.php';
     $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
     $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
             <tbody style="text-align: left;">
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <p><img src="' . $d_image[0] . '" style="float: left;"/>&nbsp;</p>
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
              <tr style="text-align: left;">
             <td style="text-align: left;">
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <b>' . strtoupper($this->bean->name) . '</b>
             </td>
             </tr>
             </tbody>
             </table><br />';
     $this->bean->user_parameters = requestToUserParameters();
     $printable = $this->bean->build_group_report(-1, false);
     $stylesheet = file_get_contents('themes/Suite7/css/style.css');
     ob_clean();
     try {
         $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed');
         $pdf->setAutoFont();
         $pdf->WriteHTML($stylesheet, 1);
         $pdf->WriteHTML($head, 2);
         $pdf->WriteHTML($printable, 3);
         $pdf->Output($this->bean->name . '.pdf', "D");
     } catch (mPDF_exception $e) {
         echo $e;
     }
     die;
 }
Beispiel #5
0
 protected function action_downloadPDF()
 {
     error_reporting(0);
     require_once 'modules/AOS_PDF_Templates/PDF_Lib/mpdf.php';
     $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
     $graphs = $_POST["graphsForPDF"];
     $graphHtml = "<div class='reportGraphs' style='width:100%; text-align:center;'>";
     $chartsPerRow = $this->bean->graphs_per_row;
     $countOfCharts = count($graphs);
     if ($countOfCharts > 0) {
         $width = (int) 100 / $chartsPerRow;
         $modulusRemainder = $countOfCharts % $chartsPerRow;
         if ($modulusRemainder > 0) {
             $modulusWidth = (int) 100 / $modulusRemainder;
             $itemsWithModulus = $countOfCharts - $modulusRemainder;
         }
         for ($x = 0; $x < $countOfCharts; $x++) {
             if (is_null($itemsWithModulus) || $x < $itemsWithModulus) {
                 $graphHtml .= "<img src='.{$graphs[$x]}.' style='width:{$width}%;' />";
             } else {
                 $graphHtml .= "<img src='.{$graphs[$x]}.' style='width:{$modulusWidth}%;' />";
             }
         }
         /*            foreach($graphs as $g)
                     {
                         $graphHtml.="<img src='.$g.' style='width:$width%;' />";
                     }*/
         $graphHtml .= "</div>";
     }
     $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
             <tbody style="text-align: left;">
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <p><img src="' . $d_image[0] . '" style="float: left;"/>&nbsp;</p>
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
              <tr style="text-align: left;">
             <td style="text-align: left;">
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <b>' . strtoupper($this->bean->name) . '</b>
             </td>
             </tr>
             </tbody>
             </table><br />' . $graphHtml;
     $this->bean->user_parameters = requestToUserParameters();
     $printable = $this->bean->build_group_report(-1, false);
     $stylesheet = file_get_contents('themes/Suite7/css/style.css');
     ob_clean();
     try {
         $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed');
         $pdf->setAutoFont();
         $pdf->WriteHTML($stylesheet, 1);
         $pdf->WriteHTML($head, 2);
         $pdf->WriteHTML($printable, 3);
         $pdf->Output($this->bean->name . '.pdf', "D");
     } catch (mPDF_exception $e) {
         echo $e;
     }
     die;
 }