2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
13 Print request redirector. This file is fired via print link or
14 print button in reporting module.
17 global $page_security, $save_report_selections;
18 $page_security = 'SA_OPEN'; // this level is later overriden in rep file
19 include_once($path_to_root . "/includes/session.inc");
21 if (isset($save_report_selections) && $save_report_selections > 0 && isset($_POST['REP_ID'])) { // save parameters from Report Center
22 for($i=0; $i<12; $i++) { // 2013-01-16 Joe Hunt
23 if (isset($_POST['PARAM_'.$i]) && !is_array($_POST['PARAM_'.$i])) {
24 $rep = $_POST['REP_ID'];
25 setcookie("select[$rep][$i]", $_POST['PARAM_'.$i], time()+60*60*24*$save_report_selections); // days from $save_report_selections
30 if (isset($_GET['xls']))
32 $filename = $_GET['filename'];
33 $unique_name = preg_replace('/[^0-9a-z.]/i', '', $_GET['unique']);
34 $path = company_path(). '/pdf_files/';
35 header("Content-type: application/vnd.ms-excel");
36 header("Content-Disposition: attachment; filename=$filename" );
38 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
39 header("Pragma: public");
40 echo file_get_contents($path.$unique_name);
43 elseif (isset($_GET['xml']))
45 $filename = $_GET['filename'];
46 $unique_name = preg_replace('/[^0-9a-z.]/i', '', $_GET['unique']);
47 $path = company_path(). '/pdf_files/';
48 header("content-type: text/xml");
49 header("Content-Disposition: attachment; filename=$filename");
51 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
52 header("Pragma: public");
53 echo file_get_contents($path.$unique_name);
57 if (!isset($_POST['REP_ID'])) { // print link clicked
58 $def_pars = array(0, 0, '', '', 0, '', '', 0); //default values
59 $rep = $_POST['REP_ID'] = $_GET['REP_ID'];
60 for($i=0; $i<8; $i++) {
61 $_POST['PARAM_'.$i] = isset($_GET['PARAM_'.$i])
62 ? $_GET['PARAM_'.$i] : $def_pars[$i];
66 $rep = preg_replace('/[^a-z_0-9]/i', '', $_POST['REP_ID']);
68 $rep_file = find_custom_file("/reporting/rep$rep.php");
73 display_error("Cannot find report file '$rep'");