Changes in POS extension related to bank account structure change.
[fa-stable.git] / reporting / includes / pdf_report.inc
index e3d84a1914e94c8dfda83a6cb954534bab8cfc0f..115fa929d24ab9a34469ed9bffab0707fba42b7d 100644 (file)
@@ -361,7 +361,7 @@ class FrontReport extends Cpdf
 
                if ($pdf_debug == 1)
                {
-                       $pdfcode = $this->Output();
+                       $pdfcode = $this->Output('','S');
                        $pdfcode = str_replace("\n", "\n<br>", htmlspecialchars($pdfcode));
                        echo '<html><body>';
                        echo trim($pdfcode);
@@ -377,8 +377,6 @@ class FrontReport extends Cpdf
                else
                {
 
-                       $buf = $this->Output();
-                       $len = strlen($buf);
                        $dir =  $comp_path.'/'.user_company(). '/pdf_files';
                        //save the file
                        if (!file_exists($dir))
@@ -387,13 +385,8 @@ class FrontReport extends Cpdf
                        }
                        // do not use standard filenames or your sensitive company data 
                        // are world readable
-//                     $fname = $dir . '/' . $this->filename;
-                       $fname = tempnam($dir, 'xx');
-                       rename($fname, $fname.'.pdf');
-                       $fname .= '.pdf';
-                       $fp = fopen($fname,'w');
-                       fwrite($fp,$buf);
-                       fclose($fp);
+                       $fname = $dir.'/'.uniqid('').'.pdf';
+                       $this->Output($fname, 'F');
                        if ($email == 1)
                        {
                                $emailtype = true;
@@ -456,26 +449,13 @@ class FrontReport extends Cpdf
                        {
                                $printer = get_report_printer(user_print_profile(), $_POST['REP_ID']);
                                if ($printer == false) {
-                                       if(in_Ajax()) {
+                                       if(in_ajax()) {
                                                global $Ajax;
-                                               // in case of ajax call non-ajax page reload is forced.
-                                               // the alternative is to differ browser support from 
-                                               // call to remote printing by some attribute of print links,
-                                               // but in this case we should check related printer target 
-                                               // for any link on the page, even if never used.
-
-                                               // display in popup window ...
-//                                             $Ajax->popup($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
-                                               // ... or fire browser download popup
-                                               //      $Ajax->redirect($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
-// strip document root from file path
-                                               $fname = substr(realpath($fname), strlen($_SERVER['DOCUMENT_ROOT']));
-                                               if (substr($fname,0,1) != '/') $fname = '/'.$fname;
 
                                                if (user_rep_popup()) 
-                                                       $Ajax->popup($fname);
+                                                       $Ajax->popup($fname); // when embeded pdf viewer used
                                                else
-                                                       $Ajax->redirect($fname);
+                                                       $Ajax->redirect($fname); // otherwise use faster method
                                        } else {
                                        //echo '<html>
                                        //              <head>