From 7d9150f4f6ba547f19c789abb7a506bbd4c2bdf4 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 17 Oct 2008 11:10:20 +0000 Subject: [PATCH] Added optional popup for pdf reports display. --- admin/db/users_db.inc | 17 ++++++++++------- admin/display_prefs.php | 5 ++++- admin/users.php | 9 +++++++-- includes/current_user.inc | 20 ++++++++++++++------ includes/prefs/userprefs.inc | 7 +++++++ reporting/includes/pdf_report.inc | 9 +++++---- sql/alter2.1.sql | 1 + 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/admin/db/users_db.inc b/admin/db/users_db.inc index 7b82e609..32f7c88c 100644 --- a/admin/db/users_db.inc +++ b/admin/db/users_db.inc @@ -1,13 +1,13 @@ username, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, - $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $profile); + function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, + $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, + $theme, $pagesize, $show_hints, $profile, $rep_popup) { + update_user_display_prefs($this->username, $price_dec, + $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, + $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, + $show_hints, $profile, $rep_popup); // re-read the prefs $user = get_user($this->username); @@ -252,14 +255,19 @@ function user_print_profile() return $_SESSION["wa_current_user"]->prefs->print_profile(); } +function user_rep_popup() +{ + return $_SESSION["wa_current_user"]->prefs->rep_popup(); +} + function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, - $print_profile) + $print_profile, $rep_popup) { $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, - $print_profile); + $print_profile, $rep_popup); } function add_user_js_data() { diff --git a/includes/prefs/userprefs.inc b/includes/prefs/userprefs.inc index 6dd37663..f48fef0e 100644 --- a/includes/prefs/userprefs.inc +++ b/includes/prefs/userprefs.inc @@ -19,6 +19,7 @@ class user_prefs var $dec_sep; var $theme; var $print_profile; + var $rep_popup; var $pagesize; // for printing var $show_hints; @@ -43,6 +44,7 @@ class user_prefs $this->pagesize = $user["page_size"]; $this->show_hints = $user["show_hints"]; $this->print_profile = $user["print_profile"]; + $this->rep_popup = $user["rep_popup"]; } function language() @@ -132,6 +134,11 @@ class user_prefs return $this->print_profile; } + function rep_popup() + { + return $this->rep_popup; + } + function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) { $this->price_dec = $price_dec; diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index b9ae9410..e3d84a19 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -361,9 +361,7 @@ class FrontReport extends Cpdf if ($pdf_debug == 1) { - $buf = $this->Output(); - $len = strlen($buf); - $pdfcode = $buf; + $pdfcode = $this->Output(); $pdfcode = str_replace("\n", "\n
", htmlspecialchars($pdfcode)); echo ''; echo trim($pdfcode); @@ -474,7 +472,10 @@ class FrontReport extends Cpdf $fname = substr(realpath($fname), strlen($_SERVER['DOCUMENT_ROOT'])); if (substr($fname,0,1) != '/') $fname = '/'.$fname; - $Ajax->redirect($fname); + if (user_rep_popup()) + $Ajax->popup($fname); + else + $Ajax->redirect($fname); } else { //echo ' // diff --git a/sql/alter2.1.sql b/sql/alter2.1.sql index 8ae7a66c..d2d381b4 100644 --- a/sql/alter2.1.sql +++ b/sql/alter2.1.sql @@ -1,5 +1,6 @@ ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) DEFAULT '' AFTER `show_hints` ; +ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1' AFTER `print_profile` ; DROP TABLE IF EXISTS `0_print_profiles`; CREATE TABLE `0_print_profiles` ( -- 2.30.2