Ejemplo n.º 1
0
 public function OutputReport($szOutputBuffer, &$szErrorStr)
 {
     global $gl_root_path;
     // Helper variable, init with buffer
     $szFinalOutput = $szOutputBuffer;
     $res = SUCCESS;
     // Simple HTML Output!
     if ($this->_outputFormat == REPORT_OUTPUT_HTML) {
         // do nothing
     } else {
         if ($this->_outputFormat == REPORT_OUTPUT_PDF) {
             // Convert into PDF!
             include_once $gl_root_path . 'classes/html2fpdf/html2fpdf.php';
             //			$pdf=new HTML2FPDF('landscape');
             $pdf = new HTML2FPDF();
             $pdf->UseCss(true);
             $pdf->AddPage();
             //			$pdf->SetFontSize(12);
             $pdf->WriteHTML($szOutputBuffer);
             $szFinalOutput = $pdf->Output('', 'S');
             // Output to STANDARD Input!
         }
     }
     // Simple HTML Output!
     if ($this->_outputTarget == REPORT_TARGET_STDOUT) {
         // Check if we need another header
         if ($this->_outputFormat == REPORT_OUTPUT_PDF) {
             Header('Content-Type: application/pdf');
         }
         // Kindly output to browser
         echo $szFinalOutput;
         $res = SUCCESS;
     } else {
         if ($this->_outputTarget == REPORT_TARGET_FILE) {
             // Get Filename first
             if (isset($this->_arrOutputTargetDetails['filename'])) {
                 // Get Filename property
                 $szFilename = $this->_arrOutputTargetDetails['filename'];
                 // Create file and Write Report into it!
                 $handle = @fopen($szFilename, "w");
                 if ($handle === false) {
                     $szErrorStr = "Could not create '" . $szFilename . "'!";
                     $res = ERROR;
                 } else {
                     fwrite($handle, $szFinalOutput);
                     fflush($handle);
                     fclose($handle);
                     // For result
                     $szErrorStr = "Results were saved into '" . $szFilename . "'";
                     $res = SUCCESS;
                 }
             } else {
                 $szErrorStr = "The parameter 'filename' was missing.";
                 $res = ERROR;
             }
         }
     }
     // return result
     return $res;
 }