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 $page_security = 'SA_OPEN'; // this level is later overriden in rep file
18 include_once($path_to_root . "/includes/session.inc");
21 Find report definition file.
22 Standard reports can be superseded by report with the same id
23 included in active extension, or company customized report.
25 function find_report_file($rep) {
26 global $installed_extensions, $comp_path, $path_to_root;
28 // customized per company versions
29 $rep_file = $comp_path.'/'.user_company()."/reporting/rep$rep.php";
30 if (file_exists($rep_file))
32 // reports added by active extension modules
33 if (count($installed_extensions) > 0)
35 $extensions = $installed_extensions;
36 foreach ($extensions as $ext)
37 if (($ext['active'] && $ext['type'] == 'module')) {
38 $rep_file = $path_to_root.'/'.$ext['path']."/reporting/rep$rep.php";
39 if (file_exists($rep_file))
44 $rep_file = $path_to_root ."/reporting/rep$rep.php";
45 if (file_exists($rep_file))
51 if (isset($_GET['xls']))
53 $filename = $_GET['filename'];
54 $unique_name = $_GET['unique'];
55 $path = $comp_path.'/'.user_company(). '/pdf_files/';
56 header("Content-type: application/vnd.ms-excel");
57 header("Content-Disposition: attachment; filename=$filename" );
59 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
60 header("Pragma: public");
61 echo file_get_contents($path.$unique_name);
64 elseif (isset($_GET['xml']))
66 $filename = $_GET['filename'];
67 $unique_name = $_GET['unique'];
68 $path = $comp_path.'/'.user_company(). '/pdf_files/';
69 header("content-type: text/xml");
70 header("Content-Disposition: attachment; filename=$filename");
72 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
73 header("Pragma: public");
74 echo file_get_contents($path.$unique_name);
78 if (!isset($_POST['REP_ID'])) { // print link clicked
79 $def_pars = array(0, 0, '', '', 0, '', '', 0); //default values
80 $rep = $_POST['REP_ID'] = $_GET['REP_ID'];
81 for($i=0; $i<8; $i++) {
82 $_POST['PARAM_'.$i] = isset($_GET['PARAM_'.$i])
83 ? $_GET['PARAM_'.$i] : $def_pars[$i];
86 $rep = $_POST['REP_ID'];
88 $rep_file = find_report_file($rep);