Exemplo n.º 1
0
 /**
  * Export a Base64 PDF Report
  * @param SugarBean report
  * @return file contents
  */
 protected function exportBase64(ServiceBase $api, SugarBean $report)
 {
     global $beanList, $beanFiles;
     global $sugar_config, $current_language;
     require_once 'modules/Reports/templates/templates_pdf.php';
     $contents = '';
     $report_filename = false;
     if ($report->id != null) {
         //Translate pdf to correct language
         $reporter = new Report(html_entity_decode($report->content), '', '');
         $reporter->layout_manager->setAttribute("no_sort", 1);
         $reporter->fromApi = true;
         //Translate pdf to correct language
         $mod_strings = return_module_language($current_language, 'Reports');
         //Generate actual pdf
         $report_filename = template_handle_pdf($reporter, false);
         sugar_cache_put($report->id . '-' . $GLOBALS['current_user']->id, $report_filename, $this->cacheLength * 60);
         $dl = new DownloadFile();
         $contents = $dl->getFileByFilename($report_filename);
     }
     if (empty($contents)) {
         throw new SugarApiException('File contents empty.');
     }
     // Reply is raw just pass back the base64 encoded contents
     return base64_encode($contents);
 }