From 6b724fc86f632fd277f7fbc330cd748fc019afd3 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Wed, 6 Oct 2010 10:44:26 +0000 Subject: [PATCH] Option for saving report selections ($save_report_selection > 0 in config.php means days to save) Excel reports were missing their headers (due to change in report system) --- CHANGELOG.txt | 8 ++++ config.default.php | 3 ++ reporting/includes/excel_report.inc | 12 +++++- reporting/includes/reports_classes.inc | 53 +++++++++++++++----------- reporting/prn_redirect.php | 10 ++++- 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6581fb03..8f226755 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,14 @@ Legend: ! -> Note $ -> Affected files +06-Oct-2010 Joe Hunt +! Option for saving report selections ($save_report_selection > 0 in config.php means days to save) +$ /reporting/includes/reports_classes.inc + /reporting/prn_redirect.php + config.default.php +# Excel reports were missing their headers (due to change in report system). +$ /reporting/includes/excel_report.inc + 05-Oct-2010 Jusz Dobrowolski # [0000258] Broken src_id fields after sales document edition. $ /sales/includes/cart_class.inc diff --git a/config.default.php b/config.default.php index e7a1eaee..e69595f3 100644 --- a/config.default.php +++ b/config.default.php @@ -64,6 +64,9 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ $power_by = "FrontAccounting"; $power_url = "http://frontaccounting.com"; + /* Save Report selections (a value > 0 means days to save. 0 = no save) */ + $save_report_selections = 0; + /* use popup windows for views */ $use_popup_windows = 1; diff --git a/reporting/includes/excel_report.inc b/reporting/includes/excel_report.inc index ecffc7d3..7356da84 100644 --- a/reporting/includes/excel_report.inc +++ b/reporting/includes/excel_report.inc @@ -53,6 +53,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook var $formatHeaderRight; var $formatFooter; var $formatAmount = array(); + var $headerFunc; var $sheet; @@ -166,9 +167,16 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->formatFooter =& $this->addFormat(); $this->formatFooter->setTop(2); $this->formatFooter->setTopColor('gray'); + $this->SetHeaderType("header"); } + /* + Set header handler + */ + function SetHeaderType($name) { + $this->headerFunc = $name; + } // Check a given name to see if it's a valid Excel worksheet name, // and fix if necessary function worksheetNameGenerator($name) @@ -634,7 +642,8 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook function NewPage() { - return; + if (method_exists($this, $this->headerFunc)) // draw predefined page layout if any + $this->{$this->headerFunc}(); } function ymd2Date($year, $mon, $day) // XLS internal date representation is a number between 1900-01-01 and 2078-12-31 @@ -679,6 +688,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook function End($email=0, $subject=null, $myrow=null, $doctype = 0) { + ++$this->y; for ($i = 0; $i < $this->numcols; $i++) $this->sheet->writeBlank($this->y, $i, $this->formatFooter); $this->sheet->mergeCells($this->y, 0, $this->y, $this->numcols - 1); diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index cffe6cb3..dd0bc82b 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -82,7 +82,7 @@ class BoxReports $st_params .= submit('Rep'.$report->id, _("Display: ") . access_string($report->name, true), false, '', $pdf_debug ? false : 'default process') . hidden('REP_ID', $report->id, false).'

'; - $st_params .= $this->getOptions($report->get_controls()); + $st_params .= $this->getOptions($report->get_controls(), $report->id); $st_params .= "\n\n"; set_focus('Rep'.$report->id); $Ajax->addUpdate(true, 'rep_form', $st_params); @@ -124,7 +124,7 @@ class BoxReports return $st; } - function getOptions($controls) + function getOptions($controls, $id = 0) { $st = ''; if ($controls == null) @@ -139,6 +139,8 @@ class BoxReports if ($ctrl) break; } if ($ctrl == '') { + if (isset($_COOKIE['select'][$id][$cnt])) // saved parameters 2010-10-06 Joe Hunt + $_POST['PARAM_'.$cnt] = $_COOKIE['select'][$id][$cnt]; $ctrl = $this->get_ctrl('PARAM_'.$cnt, $type); } if ($ctrl != '') { @@ -180,31 +182,35 @@ class BoxReports case 'DATEENDM': case 'DATEBEGINTAX': case 'DATEENDTAX': - if ($type == 'DATEBEGIN') - $date = begin_fiscalyear(); - elseif ($type == 'DATEEND') - $date = end_fiscalyear(); - else - $date = Today(); - if ($type == 'DATEBEGINM') - $date = begin_month($date); - elseif ($type == 'DATEENDM') - $date = end_month($date); - elseif ($type == 'DATEBEGINTAX' || $type == 'DATEENDTAX') + if (!isset($_POST[$name])) { - $row = get_company_prefs(); - $edate = add_months($date, -$row['tax_last']); - $edate = end_month($edate); - if ($type == 'DATEENDTAX') - $date = $edate; + if ($type == 'DATEBEGIN') + $date = begin_fiscalyear(); + elseif ($type == 'DATEEND') + $date = end_fiscalyear(); else + $date = Today(); + if ($type == 'DATEBEGINM') + $date = begin_month($date); + elseif ($type == 'DATEENDM') + $date = end_month($date); + elseif ($type == 'DATEBEGINTAX' || $type == 'DATEENDTAX') { - $bdate = begin_month($edate); - $bdate = add_months($bdate, -$row['tax_prd'] + 1); - $date = $bdate; + $row = get_company_prefs(); + $edate = add_months($date, -$row['tax_last']); + $edate = end_month($edate); + if ($type == 'DATEENDTAX') + $date = $edate; + else + { + $bdate = begin_month($edate); + $bdate = add_months($bdate, -$row['tax_prd'] + 1); + $date = $bdate; + } } } - + else // saved parameters 2010-10-16 Joe Hunt + $date = $_POST[$name]; $st = ""; if ($use_date_picker) $st .= "" @@ -245,7 +251,8 @@ class BoxReports return ""; case 'TEXTBOX': - return ""; + $value = (isset($_POST[$name]) ? $_POST[$name] : ""); + return ""; case 'ACCOUNTS': // not used return gl_account_types_list($name, null, _("No Account Group Filter"), true); diff --git a/reporting/prn_redirect.php b/reporting/prn_redirect.php index ce525ea1..8a64ea39 100644 --- a/reporting/prn_redirect.php +++ b/reporting/prn_redirect.php @@ -17,6 +17,15 @@ $path_to_root = ".."; $page_security = 'SA_OPEN'; // this level is later overriden in rep file include_once($path_to_root . "/includes/session.inc"); +if (isset($save_report_selections) && $save_report_selections > 0 && isset($_POST['REP_ID'])) { // save parameters from Report Center + for($i=0; $i<10; $i++) { // 2010-10-06 Joe Hunt + if (isset($_POST['PARAM_'.$i]) && !is_array($_POST['PARAM_'.$i])) { + $rep = $_POST['REP_ID']; + setcookie("select[$rep][$i]", $_POST['PARAM_'.$i], time()+60*60*24*$save_report_selections); // days from $save_report_selections + } + } +} + if (isset($_GET['xls'])) { $filename = $_GET['filename']; @@ -52,7 +61,6 @@ if (!isset($_POST['REP_ID'])) { // print link clicked ? $_GET['PARAM_'.$i] : $def_pars[$i]; } } - $rep = $_POST['REP_ID']; $rep_file = find_custom_file("/reporting/rep$rep.php"); -- 2.30.2