- //echo '<html>
- // <head>
- // <SCRIPT LANGUAGE="JavaScript"><!--
- // function go_now () { window.location.href = "'.$fname.'"; }
- // //--></SCRIPT>
- // </head>
- // <body onLoad="go_now()"; >
- // <a href="'.$fname.'">click here</a> if you are not re-directed.
- // </body>
- // </html>';
- header('Content-type: application/pdf');
- header("Content-Disposition: inline; filename=$this->filename");
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- $this->Stream();
-
+ $printer = get_report_printer(user_print_profile(), $_POST['REP_ID']);
+ if ($printer == false) {
+ if(in_ajax()) {
+ global $Ajax;
+
+ if (user_rep_popup())
+ $Ajax->popup($fname); // when embeded pdf viewer used
+ else
+ $Ajax->redirect($fname); // otherwise use faster method
+ } else {
+ //echo '<html>
+ // <head>
+ // <SCRIPT LANGUAGE="JavaScript"><!--
+ // function go_now () { window.location.href = "'.$fname.'"; }
+ // //--></SCRIPT>
+ // </head>
+ // <body onLoad="go_now()"; >
+ // <a href="'.$fname.'">click here</a> if you are not re-directed.
+ // </body>
+ // </html>';
+ header('Content-type: application/pdf');
+ header("Content-Disposition: inline; filename=$this->filename");
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+
+ $this->Stream();
+ }
+ } else { // send report to network printer
+ $prn = new remote_printer($printer['queue'],$printer['host'],
+ $printer['port'], $printer['timeout']);
+ $error = $prn->print_file($fname);
+ if ($error)
+ display_error($error);
+ else
+ display_notification(_('Report has been sent to network printer ').$printer['name']);
+ }