From 83640bde88f0114e162c509ed0b04cef9b4da64c Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Thu, 23 Oct 2008 17:23:08 +0000 Subject: [PATCH] Improved report module performance, usable also in non-js browsers. --- reporting/includes/class.pdf.inc | 6 +-- reporting/includes/header2.inc | 2 +- reporting/includes/pdf_report.inc | 8 +-- reporting/includes/reports_classes.inc | 67 ++++++++++++++------------ reporting/reports_main.php | 2 +- 5 files changed, 40 insertions(+), 45 deletions(-) diff --git a/reporting/includes/class.pdf.inc b/reporting/includes/class.pdf.inc index 7c182017..fe6011e1 100644 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@ -202,16 +202,12 @@ class Cpdf extends TCPDF { { TCPDF::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg); } + function Stream() { TCPDF::Output('', 'I'); } - function Output() - { - return TCPDF::Output('','S'); - } - function calcTextWrap($txt, $width, $spacebreak=false) { $ret = ""; diff --git a/reporting/includes/header2.inc b/reporting/includes/header2.inc index 07c73f96..34178804 100644 --- a/reporting/includes/header2.inc +++ b/reporting/includes/header2.inc @@ -148,7 +148,7 @@ // 2008-06-16. Added customer's reference $this->NewLine(); $this->Text($ccol, $doc_Customers_Ref, $ccol2); - if ($sales_order != NULL) + if (isset($sales_order["customer_ref"])) $this->Text($ccol2, $sales_order["customer_ref"], $mcol); $locale = $path_to_root . "lang/" . $_SESSION['language']->code . "/locale.inc"; if (file_exists($locale)) diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index b3fffbe4..115fa929 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -361,7 +361,7 @@ class FrontReport extends Cpdf if ($pdf_debug == 1) { - $pdfcode = $this->Output(); + $pdfcode = $this->Output('','S'); $pdfcode = str_replace("\n", "\n
", htmlspecialchars($pdfcode)); echo ''; 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)) @@ -388,9 +386,7 @@ class FrontReport extends Cpdf // do not use standard filenames or your sensitive company data // are world readable $fname = $dir.'/'.uniqid('').'.pdf'; - $fp = fopen($fname,'w'); - fwrite($fp,$buf); - fclose($fp); + $this->Output($fname, 'F'); if ($email == 1) { $emailtype = true; diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index e244b8ff..fd08842f 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -20,7 +20,7 @@ class BoxReports function getDisplay($class=null) { - global $table_style2, $comp_path, $path_to_root; + global $table_style2, $comp_path, $path_to_root, $pdf_debug, $Ajax; $temp = array_values($this->ar_classes); $display_class = $class==null ? $temp[0] : $this->ar_classes[$class]; @@ -31,44 +31,50 @@ class BoxReports $st_classes = "" . _("Report Classes:") . "
"; foreach($this->ar_classes as $key=>$value) { - $style = $class_counter==0 ? '' : $style = "style='display:none'"; + $style = $class_counter==$_REQUEST['Class'] ? '' : "style='display:none'"; $acc = access_string($key); - $st_classes .= "$acc[0]
"; - $st_reports .= ""; + $st_classes .= "$acc[0]
"; + $st_reports .= "
" . _("Reports For Class: ") . " $key
\n"; foreach($value as $report) - { $acc = access_string($report->name); - $st_reports .= ""; - - $action = $path_to_root.'/reporting/prn_redirect.php'; - - $st_params .= "
" . _("Reports For Class: ") . " $key
$acc[0]
\n" - . "
\n" - . $report->getDisplay() - . "\n
\n" - . "
"; + { + $acc = access_string($report->name); + $st_reports .= "id" + ."'$acc[1]>$acc[0]\n"; + if (isset($_REQUEST['rep_id']) && $_REQUEST['rep_id']==$report->id) { + $action = $path_to_root.'/reporting/prn_redirect.php'; + + $st_params = "
\n" + . "
\n"; + $st_params .= hidden('REP_ID', $report->id, false); + $st_params .= submit('Rep'.$report->id, + _("Display: ") . access_string($report->name,true), + false, '', $pdf_debug==0) . '

'; + $st_params .= $report->getDisplay() + . "\n
\n"; + $Ajax->addUpdate(true, 'rep_form', $st_params); + } } $st_reports .= ""; + $class_counter++; } + $st_params = "
". + "$st_params
"; + + $st = "