Option for saving report selections ($save_report_selection > 0 in config.php means...
[fa-stable.git] / reporting / prn_redirect.php
1 <?php
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 ***********************************************************************/
12 /*
13         Print request redirector. This file is fired via print link or 
14         print button in reporting module. 
15 */
16 $path_to_root = "..";
17 $page_security = 'SA_OPEN';     // this level is later overriden in rep file
18 include_once($path_to_root . "/includes/session.inc");
19
20 if (isset($save_report_selections) && $save_report_selections > 0 && isset($_POST['REP_ID'])) { // save parameters from Report Center
21         for($i=0; $i<10; $i++) { // 2010-10-06 Joe Hunt
22                 if (isset($_POST['PARAM_'.$i]) && !is_array($_POST['PARAM_'.$i])) {
23                         $rep = $_POST['REP_ID'];
24                         setcookie("select[$rep][$i]", $_POST['PARAM_'.$i], time()+60*60*24*$save_report_selections); // days from $save_report_selections
25                 }       
26         }
27 }       
28
29 if (isset($_GET['xls']))
30 {
31         $filename = $_GET['filename'];
32         $unique_name = $_GET['unique'];
33         $path =  company_path(). '/pdf_files/';
34         header("Content-type: application/vnd.ms-excel");
35         header("Content-Disposition: attachment; filename=$filename" );
36         header("Expires: 0");
37         header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
38         header("Pragma: public");
39         echo file_get_contents($path.$unique_name);
40         exit();
41 }
42 elseif (isset($_GET['xml']))
43 {
44         $filename = $_GET['filename'];
45         $unique_name = $_GET['unique'];
46         $path =  company_path(). '/pdf_files/';
47         header("content-type: text/xml");
48         header("Content-Disposition: attachment; filename=$filename");
49         header("Expires: 0");
50         header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
51         header("Pragma: public");
52         echo file_get_contents($path.$unique_name);
53         exit();
54 }
55         
56 if (!isset($_POST['REP_ID'])) { // print link clicked
57         $def_pars = array(0, 0, '', '', 0, '', '', 0); //default values
58         $rep = $_POST['REP_ID'] = $_GET['REP_ID'];
59         for($i=0; $i<8; $i++) {
60                 $_POST['PARAM_'.$i] = isset($_GET['PARAM_'.$i]) 
61                         ? $_GET['PARAM_'.$i] : $def_pars[$i];
62         }
63 }
64 $rep = $_POST['REP_ID'];
65
66 $rep_file = find_custom_file("/reporting/rep$rep.php");
67
68 if ($rep_file) {
69         require($rep_file);
70 } else
71         display_error("Cannot find report file '$rep'");
72 exit();
73
74 ?>