Option for saving report selections ($save_report_selection > 0 in config.php means...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 6 Oct 2010 10:44:26 +0000 (10:44 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 6 Oct 2010 10:44:26 +0000 (10:44 +0000)
Excel reports were missing their headers (due to change in report system)

CHANGELOG.txt
config.default.php
reporting/includes/excel_report.inc
reporting/includes/reports_classes.inc
reporting/prn_redirect.php

index 6581fb03234d0f3f134dcd1979def90dcc5d240d..8f22675535ad6ba78b011e5464586749b3b8f5c9 100644 (file)
@@ -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
index e7a1eaee621e274e422b5a1dd314ec5006662864..e69595f31d4cd44c390d7e5b48760d4295eb92f5 100644 (file)
@@ -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;
 
index ecffc7d3bba2401636e441d2cb46a76cb8c162ed..7356da84c3188944cd321901d7a9f496ca59512c 100644 (file)
@@ -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);
index cffe6cb3e793f6fab0f85100fb0a51bcf7171fc0..dd0bc82bfeaa0341800f966086bda7701825b9cd 100644 (file)
@@ -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).'<br><br>';
-                                       $st_params .= $this->getOptions($report->get_controls());
+                                       $st_params .= $this->getOptions($report->get_controls(), $report->id);
                                        $st_params .= "\n</form></td></tr></table>\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 = "<input type='text' name='$name' value='$date'>";
                                        if ($use_date_picker)
                                                $st .= "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
@@ -245,7 +251,8 @@ class BoxReports
                                        return "<input type='text' name='$name'>";
 
                                case 'TEXTBOX':
-                                       return "<textarea rows=4 cols=30 name='$name'></textarea>";
+                                       $value = (isset($_POST[$name]) ? $_POST[$name] : "");
+                                       return "<textarea rows=4 cols=30 name='$name'>$value</textarea>";
 
                                case 'ACCOUNTS': // not used
                                        return gl_account_types_list($name, null, _("No Account Group Filter"), true);
index ce525ea1ff788253acabaf994fdb5f8a644013f1..8a64ea397e65dc13c98720d5bd63ae42adfc1cb7 100644 (file)
@@ -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");