Adde integration of custom/extended reports; optimizations.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 15 Nov 2009 20:55:06 +0000 (20:55 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 15 Nov 2009 20:55:06 +0000 (20:55 +0000)
reporting/includes/reports_classes.inc
reporting/prn_redirect.php
reporting/reports_main.php

index 51f19fbea5e768cabb30996c3998abf4cd286a1b..4069c873b9c8f30bf881bc75f70f70c420058b87 100644 (file)
@@ -25,13 +25,15 @@ class BoxReports
 
        function addReport($class_name, $id, $rep_name, $params=null)
        {
-               $this->ar_classes[$class_name][] = new Report($id,$rep_name,$params);
+               unset($this->ar_classes[$class_name][$id]); // unset std report if any
+               $this->ar_classes[$class_name][$id] = new Report($id, $rep_name, $params);
        }
 
        function getDisplay($class=null)
        {
                global $table_style2, $comp_path, $path_to_root, $pdf_debug, $Ajax;
 
+
                $temp = array_values($this->ar_classes);
                $display_class = $class==null ? $temp[0] : $this->ar_classes[$class];
                $class_counter = 0;
@@ -65,8 +67,8 @@ class BoxReports
                                        $st_params .= submit('Rep'.$report->id,  
                                                _("Display: ") . access_string($report->name, true),
                                                false, '', $pdf_debug ? false : 'default') . '<br><br>';
-                                       $st_params .= $report->getDisplay() 
-                                               . "\n</form></td></tr></table>\n";
+                                       $st_params .= $this->getOptions($report->get_controls());
+                                       $st_params .= "\n</form></td></tr></table>\n";
                                        set_focus('Rep'.$report->id);
                                        $Ajax->addUpdate(true, 'rep_form', $st_params);
                                }
@@ -105,38 +107,56 @@ class BoxReports
 
                return $st;
        }
-}
-
-class Report
-{
-       var $id;
-       var $name;
-       var $ar_params;
 
-       function Report($id, $name, $ar_params)
+       function getOptions($controls)
        {
-               $this->id                       = $id;
-               $this->name             = $name;
-               $this->ar_params        = $ar_params;
+               $st = '';
+               if ($controls == null)
+                       return "";
+
+               $cnt = 0;
+               foreach($controls as $title => $type)
+               {
+                       $ctrl = '';
+                       foreach($this->ctrl_handlers as $fun) { // first check for non-standard controls
+                               $ctrl = $fun('PARAM_'.$cnt, $type);
+                               if ($ctrl) break;
+                       }
+                       if ($ctrl == '') {
+                               $ctrl = $this->get_ctrl('PARAM_'.$cnt, $type);
+                       }
+                       if ($ctrl != '')  {
+                               $st .= $title . ':<br>';
+                               $st .= $ctrl;
+                               $st .= "<br><br>";
+                       } else {
+                               display_error(_('Unknown report parameter type:').$type);
+                       }
+                       $cnt++;
+               }
+               return $st;
        }
-       
-       function getDisplay()
+
+       //
+       //      Register additional control handler
+       // $handle - name of global function f($name, $type) returning html code for control
+       function register_controls($handler) {
+               $this->ctrl_handlers[] = $handler;
+       }
+       //
+       //      Returns html code for input control $name of type $type 
+       //
+       function get_ctrl($name, $type)
        {
                global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no;
 
                $st = '';
-               $dummy = "";
-               if ($this->ar_params==null)
-                       return "";
-               foreach($this->ar_params as $index=>$param)
-               {
-                       $st .= $param->param_name . ':<br>';
-                       switch ($param->param_type)
+                       switch ($type)
                        {
                                case 'CURRENCY':
                                        $sql = "SELECT curr_abrev, concat(curr_abrev,' - ', currency) AS name FROM ".TB_PREF."currencies";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'curr_abrev', 'name',array('spec_option'=>_("No Currency Filter"),'spec_id'=>ALL_TEXT,'order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'curr_abrev', 'name',array('spec_option'=>_("No Currency Filter"),'spec_id'=>ALL_TEXT,'order'=>false));
+
                                case 'DATE':
                                case 'DATEBEGIN':
                                case 'DATEEND':
@@ -144,22 +164,22 @@ class Report
                                case 'DATEENDM':
                                case 'DATEBEGINTAX':
                                case 'DATEENDTAX':
-                                       if ($param->param_type == 'DATEBEGIN')
+                                       if ($type == 'DATEBEGIN')
                                                $date = begin_fiscalyear();
-                                       elseif ($param->param_type == 'DATEEND')
+                                       elseif ($type == 'DATEEND')
                                                $date = end_fiscalyear();
                                        else
                                                $date = Today();
-                                       if ($param->param_type == 'DATEBEGINM')
+                                       if ($type == 'DATEBEGINM')
                                                $date = begin_month($date);
-                                       elseif ($param->param_type == 'DATEENDM')
+                                       elseif ($type == 'DATEENDM')
                                                $date = end_month($date);
-                                       elseif ($param->param_type == 'DATEBEGINTAX' || $param->param_type == 'DATEENDTAX')
+                                       elseif ($type == 'DATEBEGINTAX' || $type == 'DATEENDTAX')
                                        {
                                                $row = get_company_prefs();
                                                $edate = add_months($date, -$row['tax_last']);
                                                $edate = end_month($edate);
-                                               if ($param->param_type == 'DATEENDTAX')
+                                               if ($type == 'DATEENDTAX')
                                                        $date = $edate;
                                                else
                                                {
@@ -168,102 +188,100 @@ class Report
                                                        $date = $bdate;
                                                }
                                        }
-                                       $name = "PARAM_$index";
 
-                                       $st .= "<input type='text' name='$name' value='$date'>";
+                                       $st = "<input type='text' name='$name' value='$date'>";
                                        if ($use_date_picker)
                                                $st .= "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
                                                . "     <img src='$path_to_root/themes/default/images/cal.gif' width='16' height='16' border='0' alt='"._('Click Here to Pick up the date')."'></a>\n";
-
+                                       return $st;
                                        break;
+
                                case 'YES_NO':
-                                       $sel = array(_('No'), _("Yes"));
-                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
-                                       break;
+                                       return yesno_list($name);
+
                                case 'PAYMENT_LINK':
-                                       $sel = array(_("No Payment Link"), "PayPal");
-                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
-                                       break;
+                                       $sel = array(_("No payment Link"), "PayPal");
+                                       return array_selector($name, null, $sel);
+
                                case 'DESTINATION':
                                        $sel = array(_("PDF/Printer"), "Excel");
-                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
-                                       break;
+                                       return array_selector($name, null, $sel);
+
                                case 'COMPARE':
                                        $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget"));
-                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
-                                       break;
+                                       return array_selector($name, null, $sel);
+
                                case 'GRAPHIC':
-                                       $sel = array(_("No Graphics"), _("Vertical bars"), _("Horizontal bars"), _("Dots"), _("Lines"), _("Pie"), _("Donut"));
-                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
-                                       break;
+                                       $sel = array(_("No Graphics"), _("Vertical bars"), _("Horizontal bars"), 
+                                                               _("Dots"), _("Lines"), _("Pie"), _("Donut"));
+                                       return array_selector($name, null, $sel);
+
                                case 'SYS_TYPES':
+                                       return gl_systypes_list($name, null, _("No Type Filter"));
+
                                case 'SYS_TYPES_ALL':
-                                       $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), ($param->param_type=='SYS_TYPES_ALL'));
-                                       break;
+                                       return systypes_list($name, null, _("No Type Filter"));
+
                                case 'TEXT':
-                                       $st .= "<input type='text' name='PARAM_$index'>";
-                                       break;
+                                       return "<input type='text' name='$name'>";
+
                                case 'TEXTBOX':
-                                       $st .= "<textarea rows=4 cols=30 name='PARAM_$index'></textarea>";
-                                       break;
-                               case 'ACCOUNTS':
-                                       $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('spec_option'=>_("No Account Group Filter"),'spec_id'=>ALL_NUMERIC));
-                                       break;
-                               case 'ACCOUNTS_NO_FILTER':
-                                       $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name', null);
-                                       break;
+                                       return "<textarea rows=4 cols=30 name='$name'></textarea>";
+
+                               case 'ACCOUNTS': // not used
+//                                     $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
+//                                     return combo_input($name, '', $sql, 'id', 'name',array('spec_option'=>_("No Account Group Filter"),'spec_id'=>ALL_NUMERIC));
+                                       return gl_account_types_list($name, null, _("No Account Group Filter"), true);
+
+                               case 'ACCOUNTS_NO_FILTER': // not used
+                                       return gl_account_types_list($name);
+
                                case 'GL_ACCOUNTS':
-                                       $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
-                                               FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type WHERE chart.account_type=type.id";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'chart.account_code', 'chart.account_name',
-                                               array('format' => '_format_account','order' => array('type.id','account_code'),'async' => false,'category' => 2));
-                                       break;
+                                       return gl_all_accounts_list($name);
+
                                case 'BANK_ACCOUNTS':
-                                       $sql = "SELECT ".TB_PREF."bank_accounts.id, concat(bank_account_name, if (bank_curr_code=curr_default,'', concat(' - ', bank_curr_code))) AS name FROM ".TB_PREF."bank_accounts, ".TB_PREF."company";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('order'=>array('id')));
-                                       break;
+                                       return bank_accounts_list($name);
+                                       
                                case 'DIMENSION':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, false, ' ', false, true, 0);
+                                       
                                case 'DIMENSIONS':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, true, _("No Dimension Filter"), false, true, 0);
+
                                case 'DIMENSION1':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, false, ' ', false, true, 1);
+
                                case 'DIMENSIONS1':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, true, _("No Dimension Filter"), false, true, 1);
+
                                case 'DIMENSION2':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, false, ' ', false, true, 2);
+
                                case 'DIMENSIONS2':
-                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
-                                       break;
+                                       return dimensions_list($name, null, true, _("No Dimension Filter"), false, true, 2);
+
                                case 'CUSTOMERS_NO_FILTER':
                                case 'CUSTOMERS':
                                        $sql = "SELECT debtor_no, name FROM ".TB_PREF."debtors_master";
-                                       if ($param->param_type == 'CUSTOMERS_NO_FILTER')
-                                               $st .= combo_input("PARAM_$index", '', $sql, 'debtor_no', 'name',array('spec_option'=>_("No Customer Filter"),'spec_id'=>ALL_NUMERIC));
+                                       if ($type == 'CUSTOMERS_NO_FILTER')
+                                               return combo_input($name, '', $sql, 'debtor_no', 'name',array('spec_option'=>_("No Customer Filter"),'spec_id'=>ALL_NUMERIC));
+// FIX allitems numeric!
+//                                             return customer_list($name, null, _("No Customer Filter"));
                                        else
-                                               $st .= combo_input("PARAM_$index", '', $sql, 'debtor_no', 'name', null);
-                                       break;
+                                               return combo_input($name, '', $sql, 'debtor_no', 'name', null);
+//                                             return customer_list($name);
+
                                case 'SUPPLIERS_NO_FILTER':
                                case 'SUPPLIERS':
                                        $sql = "SELECT supplier_id, supp_name FROM ".TB_PREF."suppliers";
-                                       if ($param->param_type == 'SUPPLIERS_NO_FILTER')
-                                               $st .= combo_input("PARAM_$index", '', $sql, 'supplier_id', 'supp_name',array('spec_option'=>_("No Supplier Filter"),'spec_id'=>ALL_NUMERIC));
+                                       if ($type == 'SUPPLIERS_NO_FILTER')
+                                               return combo_input($name, '', $sql, 'supplier_id', 'supp_name',array('spec_option'=>_("No Supplier Filter"),'spec_id'=>ALL_NUMERIC));
+// FIX allitems numeric!
+//                                             return supplier_list($name, null, _("No Supplier Filter"));
                                        else
-                                               $st .= combo_input("PARAM_$index", '', $sql, 'supplier_id', 'supp_name', null);
-                                       break;
+                                               return combo_input($name, '', $sql, 'supplier_id', 'supp_name', null);
+//                                             return supplier_list($name);
+
                                case 'INVOICE':
                                        $IV = _("IV");
                                        $CN = _("CN");
@@ -271,8 +289,8 @@ class Report
                                        $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
                                                ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, if (type=".ST_SALESINVOICE.", ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'TNO', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
+
                                case 'DELIVERY':
                                        $DN = _("DN");
                                        $sql = "SELECT
@@ -281,135 +299,141 @@ class Report
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans
                                                WHERE type=".ST_CUSTDELIVERY." AND ".TB_PREF."debtors_master.debtor_no=".
                                                TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'TNO', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
+
                                case 'ORDERS':
                                        $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
                                        $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.$ref, '-',
                                                ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no 
                                                AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." ORDER BY ".TB_PREF."sales_orders.order_no DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
+
                                case 'QUOTATIONS':
                                        $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
                                        $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.$ref, '-',
                                                ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no 
                                                AND ".TB_PREF."sales_orders.trans_type=".ST_SALESQUOTE." ORDER BY ".TB_PREF."sales_orders.order_no DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
+
                                case 'PO':
                                        $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
                                        $sql = "SELECT ".TB_PREF."purch_orders.order_no, concat(".TB_PREF."purch_orders.$ref, '-',
                                                ".TB_PREF."suppliers.supp_name) as IName
                                                FROM ".TB_PREF."suppliers, ".TB_PREF."purch_orders WHERE ".TB_PREF."suppliers.supplier_id=".TB_PREF."purch_orders.supplier_id ORDER BY ".TB_PREF."purch_orders.order_no DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
+
                                case 'ITEMS':
-                                       $sql = "SELECT stock_id, concat(stock_id, '-', description) as name FROM ".TB_PREF."stock_master WHERE (mb_flag='A' OR mb_flag='M')";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'stock_id', 'name',array('order'=>array('stock_id')));
-                                       break;
+                                       return stock_manufactured_items_list($name);
+
                                case 'WORKORDER':
                                        $sql = "SELECT ".TB_PREF."workorders.id, concat(".TB_PREF."workorders.id, '-',
                                                ".TB_PREF."stock_master.description) as IName
                                                FROM ".TB_PREF."stock_master, ".TB_PREF."workorders WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id ORDER BY ".TB_PREF."workorders.id DESC";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'IName',array('order'=>false));
-                                       break;
+                                       return combo_input($name, '', $sql, 'id', 'IName',array('order'=>false));
+
                                case 'LOCATIONS':
-                                       $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'loc_code', 'location_name',array('spec_option'=>_("No Location Filter"),'spec_id'=>ALL_TEXT));
-                                       break;
+                                       return  locations_list($name, null, _("No Location Filter"));
+
                                case 'CATEGORIES':
-                                       $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'category_id', 'description',array('spec_option'=>_("No Category Filter"),'spec_id'=>ALL_NUMERIC));
-                                       break;
+                                       return stock_categories_list($name, null, _("No Category Filter"));
+
                                case 'SALESTYPES':
-                                       $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'sales_type', null);
-                                       break;
+                                       return sales_types_list($name);
+
                                case 'AREAS':
-                                       $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'area_code', 'description',array('spec_option'=>_("No Area Filter"),'spec_id'=>ALL_NUMERIC));
-                                       break;
+                                       return sales_areas_list($name);
+
                                case 'SALESMEN':
-                                       $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'salesman_code', 'salesman_name',array('spec_option'=>_("No Sales Folk Filter"),'spec_id'=>ALL_NUMERIC));
-                                       break;
+                                       return sales_persons_list($name, null, _("No Sales Folk Filter"));
+                                       
                                case 'TRANS_YEARS':
                                        $sql = "SELECT DISTINCT YEAR(tran_date) AS tran_date, YEAR(tran_date) AS tran_date2 FROM ".TB_PREF."gl_trans";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'tran_date', 'tran_date2',array('order'=>array('tran_date')));
-                                       break;
+                                       return combo_input($name, '', $sql, 'tran_date', 'tran_date2',array('order'=>array('tran_date')));
+// FIX shouldn't it be fiscal year selector?
+//                                     return fiscalyears_list($name);
+
                                case 'USERS':
                                        $sql = "SELECT id, user_id FROM ".TB_PREF."users";
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'user_id',array('spec_option'=>_("No Users Filter"),'spec_id'=>ALL_NUMERIC));
-                                       break;
+                                       return combo_input($name, '', $sql, 'id', 'user_id',array('spec_option'=>_("No Users Filter"),'spec_id'=>ALL_NUMERIC));
+
                                case 'ACCOUNTTAGS':
                                case 'DIMENSIONTAGS':
-                                       if ($param->param_type == 'ACCOUNTTAGS')
-                                               $type = TAG_ACCOUNT;
+                                       if ($type == 'ACCOUNTTAGS')
+                                               $tag_type = TAG_ACCOUNT;
                                        else
-                                               $type = TAG_DIMENSION;
-                                       $sql = "SELECT id, name FROM ".TB_PREF."tags WHERE type=$type"; 
-                                       $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('spec_option'=>_("No tags"),'spec_id' => ALL_NUMERIC,'multi'=>true,'height'=>5));
-                                       break;
+                                               $tag_type = TAG_DIMENSION;
+                                       return tag_list($name, 5, $tag_type, true, _("No tags"));
 
                        }
-                       $st .= "<br><br>";
-               }
-               return $st;
+               return '';
        }
 }
 
-class ReportParam
+class Report
 {
-       var $param_name;
-       var $param_type;
-
-       function ReportParam($param_name, $param_type)
+       var $id;
+       var $name;
+       var $ar_params;
+       var $controls;
+       var $ctrl_handlers = array();
+       
+       function Report($id, $name, $ar_params = null)
        {
-               $this->param_name = $param_name;
-               $this->param_type = $param_type;
+               $this->id = $id;
+               $this->name = $name;
+               if ($ar_params) $this->set_controls($ar_params);
        }
-}
-
-function dup_simple_name_list($name, $selections)
-{
-       $st = "<select name='$name'>";
-       for ($i = 0; $i < count($selections); $i++)
-               $st .= "<option value='" . $i . "'>" . $selections[$i] . "</option>\n";
-       $st .= "</select>";
-       return $st;
+       
+       function set_controls($ar_params) {
+               $this->controls = $ar_params;
+       }
+       
+       function get_controls() {
+               return $this->controls;
+       }
+       
 }
 
 //------------------------------------------------------------------------------------------------
-
-function dup_systypes_list($name, &$selected_id, $all_option=false, $all_option_name=null, $all_types=false)
+function gl_systypes_list($name, $value=null, $spec_opt=false)
 {
        global $systypes_array;
+       
+       $types = $systypes_array;
+       
+       foreach(array(ST_LOCTRANSFER, ST_PURCHORDER, ST_SUPPRECEIVE, ST_MANUISSUE,
+                               ST_MANURECEIVE, ST_SALESORDER, ST_SALESQUOTE, ST_DIMENSION) as $type)
+               unset($types[$type]);
 
-       $st = "<select name='$name'>";
-       if ($all_option == true)
-       {
-               $reserved_word = ALL_NUMERIC;
-       if ($reserved_word == $selected_id)
-            $st .= "<option selected value='" . $reserved_word . "'>" . $all_option_name . "</option>\n";
-       else
-            $st .= "<option value='" . $reserved_word . "'>" . $all_option_name . "</option>\n";
-               if ($selected_id == "")
-                       $selected_id = $reserved_word;
-       }
+       return array_selector($name, $value, $types, 
+               array( 
+                       'spec_option'=> $spec_opt,
+                       'spec_id' => ALL_NUMERIC,
+                       'async' => false,
+                       )
+       );
+}
 
-       foreach ($systypes_array as $i => $value)
+function add_custom_reports(&$reports)
+{
+       global $installed_extensions, $path_to_root, $comp_path;
+       
+       // include reports installed inside extension modules
+       if (count($installed_extensions) > 0)
        {
-               if (!$all_types && ($i == ST_LOCTRANSFER || $i == ST_PURCHORDER || $i == ST_SUPPRECEIVE || ($i >= ST_MANUISSUE && $i <= ST_SALESQUOTE) || 
-                       $i >= ST_DIMENSION))
-                       continue;
-       $st .= "<option" . ($selected_id == $i ? " selected" : "") . " value='$i'>" . $value . "</option>\n";
+               $extensions = $installed_extensions;
+               foreach ($extensions as $ext)
+                       if (($ext['active'] && $ext['type'] == 'module')) {
+                               $file = $path_to_root.'/'.$ext['path']."/reporting/reports_custom.php";
+                               if (file_exists($file))
+                                       include_once($file);
+                       }
        }
-    $st .= "</select>";
-       return $st;
+       $file = $comp_path.'/'.user_company()."/reporting/reports_custom.php";
+       if (file_exists($file))
+               include_once($file);
 }
 
-
 ?>
\ No newline at end of file
index 3d985ec87ec44a59d9db45587e56f440d386f788..9018e0fd424be98585075561fb44a8f02b3d4fea 100644 (file)
@@ -17,6 +17,37 @@ $path_to_root = "..";
 $page_security = 'SA_OPEN';    // this level is later overriden in rep file
 include_once($path_to_root . "/includes/session.inc");
 
+/*
+       Find report definition file.
+       Standard reports can be superseded by report with the same id
+       included in active extension, or company customized report.
+*/
+function find_report_file($rep) {
+       global $installed_extensions, $comp_path, $path_to_root;
+
+       // customized per company versions 
+       $rep_file = $comp_path.'/'.user_company()."/reporting/rep$rep.php";
+       if (file_exists($rep_file)) 
+               return $rep_file;
+       // reports added by active extension modules
+       if (count($installed_extensions) > 0)
+       {
+               $extensions = $installed_extensions;
+               foreach ($extensions as $ext)
+                       if (($ext['active'] && $ext['type'] == 'module')) {
+                               $rep_file = $path_to_root.'/'.$ext['path']."/reporting/rep$rep.php";
+                               if (file_exists($rep_file))
+                                       return $rep_file;
+                       }
+       }
+       // standard reports
+       $rep_file = $path_to_root ."/reporting/rep$rep.php";
+       if (file_exists($rep_file))
+               return $rep_file;
+
+       return null;
+}
+
 if (isset($_GET['xls']))
 {
        $filename = $_GET['filename'];
@@ -53,10 +84,8 @@ if (!isset($_POST['REP_ID'])) {      // print link clicked
        }
 }
 $rep = $_POST['REP_ID'];
-$rep_file = $comp_path.'/'.user_company()."/reporting/rep$rep.php";
-if (!file_exists($rep_file)) {
-    $rep_file = $path_to_root ."/reporting/rep$rep.php";
-}
+
+$rep_file = find_report_file($rep);
 require($rep_file);
 exit();
 
index 8babc61a5c7cc08d0cabb72b500a261141cff994..650f0dba39e091ffee83b247ab1189e8da524da6 100644 (file)
@@ -28,323 +28,326 @@ $dim = get_company_pref('use_dimension');
 
 $reports->addReportClass(_('Customer'));
 $reports->addReport(_('Customer'),101,_('Customer &Balances'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGIN'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Customer'),'CUSTOMERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGIN',
+                       _('End Date') => 'DATEENDM',
+                       _('Customer') => 'CUSTOMERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),102,_('&Aged Customer Analysis'),
-       array(  new ReportParam(_('End Date'),'DATE'),
-                       new ReportParam(_('Customer'),'CUSTOMERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Summary Only'),'YES_NO'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('End Date') => 'DATE',
+                       _('Customer') => 'CUSTOMERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Summary Only') => 'YES_NO',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),103,_('Customer &Detail Listing'),
-       array(  new ReportParam(_('Activity Since'),'DATEBEGIN'),
-                       new ReportParam(_('Sales Areas'),'AREAS'),
-                       new ReportParam(_('Sales Folk'),'SALESMEN'), 
-                       new ReportParam(_('Activity Greater Than'),'TEXT'), 
-                       new ReportParam(_('Activity Less Than'),'TEXT'), 
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Activity Since') => 'DATEBEGIN',
+                       _('Sales Areas') => 'AREAS',
+                       _('Sales Folk') => 'SALESMEN',
+                       _('Activity Greater Than') => 'TEXT',
+                       _('Activity Less Than') => 'TEXT',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),104,_('&Price Listing'),
-       array(  new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Sales Types'),'SALESTYPES'),
-                       new ReportParam(_('Show Pictures'),'YES_NO'),
-                       new ReportParam(_('Show GP %'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Currency Filter') => 'CURRENCY',
+                       _('Inventory Category') => 'CATEGORIES',
+                       _('Sales Types') => 'SALESTYPES',
+                       _('Show Pictures') => 'YES_NO',
+                       _('Show GP %') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),105,_('&Order Status Listing'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Stock Location'),'LOCATIONS'),
-                       new ReportParam(_('Back Orders Only'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Inventory Category') => 'CATEGORIES',
+                       _('Stock Location') => 'LOCATIONS',
+                       _('Back Orders Only') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),106,_('&Salesman Listing'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Summary Only'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Summary Only') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Customer'),107,_('Print &Invoices/Credit Notes'),
-       array(  new ReportParam(_('From'),'INVOICE'),
-                       new ReportParam(_('To'),'INVOICE'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('email Customers'),'YES_NO'),
-                       new ReportParam(_('Payment Link'),'PAYMENT_LINK'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'INVOICE',
+                       _('To') => 'INVOICE',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('email Customers') => 'YES_NO',
+                       _('Payment Link') => 'PAYMENT_LINK',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReport(_('Customer'),110,_('Print &Deliveries'),
-       array(  new ReportParam(_('From'),'DELIVERY'),
-                       new ReportParam(_('To'),'DELIVERY'),
-                       new ReportParam(_('email Customers'),'YES_NO'),
-                       new ReportParam(_('Print as Packing Slip'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'DELIVERY',
+                       _('To') => 'DELIVERY',
+                       _('email Customers') => 'YES_NO',
+                       _('Print as Packing Slip') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReport(_('Customer'),108,_('Print &Statements'),
-       array(  new ReportParam(_('Customer'),'CUSTOMERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Email Customers'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('Customer') => 'CUSTOMERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Email Customers') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReport(_('Customer'),109,_('&Print Sales Orders'),
-       array(  new ReportParam(_('From'),'ORDERS'),
-                       new ReportParam(_('To'),'ORDERS'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Email Customers'),'YES_NO'),
-                       new ReportParam(_('Print as Quote'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'ORDERS',
+                       _('To') => 'ORDERS',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Email Customers') => 'YES_NO',
+                       _('Print as Quote') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReport(_('Customer'),111,_('&Print Sales Quotations'),
-       array(  new ReportParam(_('From'),'QUOTATIONS'),
-                       new ReportParam(_('To'),'QUOTATIONS'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Email Customers'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'QUOTATIONS',
+                       _('To') => 'QUOTATIONS',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Email Customers') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 
 $reports->addReportClass(_('Supplier'));
 $reports->addReport(_('Supplier'),201,_('Supplier &Balances'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGIN'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Supplier'),'SUPPLIERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGIN',
+                       _('End Date') => 'DATEENDM',
+                       _('Supplier') => 'SUPPLIERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Supplier'),202,_('&Aged Supplier Analyses'),
-       array(  new ReportParam(_('End Date'),'DATE'),
-                       new ReportParam(_('Supplier'),'SUPPLIERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Summary Only'),'YES_NO'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('End Date') => 'DATE',
+                       _('Supplier') => 'SUPPLIERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Summary Only') => 'YES_NO',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Supplier'),203,_('&Payment Report'),
-       array(  new ReportParam(_('End Date'),'DATE'),
-                       new ReportParam(_('Supplier'),'SUPPLIERS_NO_FILTER'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('End Date') => 'DATE',
+                       _('Supplier') => 'SUPPLIERS_NO_FILTER',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Supplier'),204,_('Outstanding &GRNs Report'),
-       array(  new ReportParam(_('Supplier'),'SUPPLIERS_NO_FILTER'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Supplier') => 'SUPPLIERS_NO_FILTER',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Supplier'),209,_('Print Purchase &Orders'),
-       array(  new ReportParam(_('From'),'PO'),
-                       new ReportParam(_('To'),'PO'),
-                       new ReportParam(_('Currency Filter'),'CURRENCY'),
-                       new ReportParam(_('Email Customers'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'PO',
+                       _('To') => 'PO',
+                       _('Currency Filter') => 'CURRENCY',
+                       _('Email Customers') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 
 $reports->addReportClass(_('Inventory'));
 $reports->addReport(_('Inventory'),301,_('Inventory &Valuation Report'),
-       array(  new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Location'),'LOCATIONS'),
-                       new ReportParam(_('Summary Only'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Inventory Category') => 'CATEGORIES',
+                       _('Location') => 'LOCATIONS',
+                       _('Summary Only') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Inventory'),302,_('Inventory &Planning Report'),
-       array(  new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Location'),'LOCATIONS'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Inventory Category') => 'CATEGORIES',
+                       _('Location') => 'LOCATIONS',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Inventory'),303,_('Stock &Check Sheets'),
-       array(  new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Location'),'LOCATIONS'),
-                       new ReportParam(_('Show Pictures'),'YES_NO'),
-                       new ReportParam(_('Inventory Column'),'YES_NO'),
-                       new ReportParam(_('Show Shortage'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Inventory Category') => 'CATEGORIES',
+                       _('Location') => 'LOCATIONS',
+                       _('Show Pictures') => 'YES_NO',
+                       _('Inventory Column') => 'YES_NO',
+                       _('Show Shortage') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Inventory'),304,_('Inventory &Sales Report'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Inventory Category'),'CATEGORIES'),
-                       new ReportParam(_('Location'),'LOCATIONS'),
-                       new ReportParam(_('Customer'),'CUSTOMERS_NO_FILTER'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Inventory Category') => 'CATEGORIES',
+                       _('Location') => 'LOCATIONS',
+                       _('Customer') => 'CUSTOMERS_NO_FILTER',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Inventory'),305,_('&GRN Valuation Report'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 
 $reports->addReportClass(_('Manufacturing'));
 $reports->addReport(_('Manufacturing'),401,_('&Bill of Material Listing'),
-       array(  new ReportParam(_('From component'),'ITEMS'),
-                       new ReportParam(_('To component'),'ITEMS'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('From product') => 'ITEMS',
+                       _('To product') => 'ITEMS',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('Manufacturing'),409,_('Print &Work Orders'),
-       array(  new ReportParam(_('From'),'WORKORDER'),
-                       new ReportParam(_('To'),'WORKORDER'),
-                       new ReportParam(_('Email Locations'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('From') => 'WORKORDER',
+                       _('To') => 'WORKORDER',
+                       _('Email Locations') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReportClass(_('Dimensions'));
 if ($dim > 0)
 {
        $reports->addReport(_('Dimensions'),501,_('Dimension &Summary'),
-       array(  new ReportParam(_('From Dimension'),'DIMENSION'),
-                       new ReportParam(_('To Dimension'),'DIMENSION'),
-                       new ReportParam(_('Show Balance'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('From Dimension') => 'DIMENSION',
+                       _('To Dimension') => 'DIMENSION',
+                       _('Show Balance') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        //$reports->addReport(_('Dimensions'),502,_('Dimension Details'),
-       //array(        new ReportParam(_('Dimension'),'DIMENSIONS'),
-       //              new ReportParam(_('Comments'),'TEXTBOX')));
+       //array(        _('Dimension'),'DIMENSIONS'),
+       //              _('Comments'),'TEXTBOX')));
 }
 $reports->addReportClass(_('Banking'));
        $reports->addReport(_('Banking'),601,_('Bank &Statement'),
-       array(  new ReportParam(_('Bank Accounts'),'BANK_ACCOUNTS'),
-                       new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Bank Accounts') => 'BANK_ACCOUNTS',
+                       _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 
 $reports->addReportClass(_('General Ledger'));
 $reports->addReport(_('General Ledger'),701,_('Chart of &Accounts'),
-       array(  new ReportParam(_('Show Balances'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Show Balances') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 $reports->addReport(_('General Ledger'),702,_('List of &Journal Entries'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Type'),'SYS_TYPES'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Type') => 'SYS_TYPES',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 //$reports->addReport(_('General Ledger'),703,_('GL Account Group Summary'),
-//     array(  new ReportParam(_('Comments'),'TEXTBOX')));
+//     array(  _('Comments'),'TEXTBOX')));
+
 if ($dim == 2)
 {
        $reports->addReport(_('General Ledger'),704,_('GL Account &Transactions'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('From Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('To Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('Dimension')." 1", 'DIMENSIONS1'),
-                       new ReportParam(_('Dimension')." 2", 'DIMENSIONS2'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('From Account') => 'GL_ACCOUNTS',
+                       _('To Account') => 'GL_ACCOUNTS',
+                       _('Dimension')." 1" =>  'DIMENSIONS1',
+                       _('Dimension')." 2" =>  'DIMENSIONS2',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),705,_('Annual &Expense Breakdown'),
-       array(  new ReportParam(_('Year'),'TRANS_YEARS'),
-                       new ReportParam(_('Dimension')." 1", 'DIMENSIONS1'),
-                       new ReportParam(_('Dimension')." 2", 'DIMENSIONS2'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Year') => 'TRANS_YEARS',
+                       _('Dimension')." 1" =>  'DIMENSIONS1',
+                       _('Dimension')." 2" =>  'DIMENSIONS2',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),706,_('&Balance Sheet'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGIN'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Dimension')." 1", 'DIMENSIONS1'),
-                       new ReportParam(_('Dimension')." 2", 'DIMENSIONS2'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGIN',
+                       _('End Date') => 'DATEENDM',
+                       _('Dimension')." 1" => 'DIMENSIONS1',
+                       _('Dimension')." 2" => 'DIMENSIONS2',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),707,_('&Profit and Loss Statement'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Compare to'),'COMPARE'),
-                       new ReportParam(_('Dimension')." 1", 'DIMENSIONS1'),
-                       new ReportParam(_('Dimension')." 2", 'DIMENSIONS2'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Compare to') => 'COMPARE',
+                       _('Dimension')." 1" =>  'DIMENSIONS1',
+                       _('Dimension')." 2" =>  'DIMENSIONS2',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),708,_('Trial &Balance'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Zero values'),'YES_NO'),
-                       new ReportParam(_('Only balances'),'YES_NO'),
-                       new ReportParam(_('Dimension')." 1", 'DIMENSIONS1'),
-                       new ReportParam(_('Dimension')." 2", 'DIMENSIONS2'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Zero values') => 'YES_NO',
+                       _('Only balances') => 'YES_NO',
+                       _('Dimension')." 1" =>  'DIMENSIONS1',
+                       _('Dimension')." 2" =>  'DIMENSIONS2',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 }
 else if ($dim == 1)
 {
        $reports->addReport(_('General Ledger'),704,_('GL Account &Transactions'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('From Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('To Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('Dimension'), 'DIMENSIONS1'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('From Account') => 'GL_ACCOUNTS',
+                       _('To Account') => 'GL_ACCOUNTS',
+                       _('Dimension') =>  'DIMENSIONS1',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),705,_('Annual &Expense Breakdown'),
-       array(  new ReportParam(_('Year'),'TRANS_YEARS'),
-                       new ReportParam(_('Dimension'), 'DIMENSIONS1'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Year') => 'TRANS_YEARS',
+                       _('Dimension') =>  'DIMENSIONS1',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),706,_('&Balance Sheet'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGIN'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Dimension'), 'DIMENSIONS1'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGIN',
+                       _('End Date') => 'DATEENDM',
+                       _('Dimension') => 'DIMENSIONS1',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),707,_('&Profit and Loss Statement'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Compare to'),'COMPARE'),
-                       new ReportParam(_('Dimension'), 'DIMENSIONS1'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Compare to') => 'COMPARE',
+                       _('Dimension') => 'DIMENSIONS1',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),708,_('Trial &Balance'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Zero values'),'YES_NO'),
-                       new ReportParam(_('Only balances'),'YES_NO'),
-                       new ReportParam(_('Dimension'), 'DIMENSIONS1'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Zero values') => 'YES_NO',
+                       _('Only balances') => 'YES_NO',
+                       _('Dimension') => 'DIMENSIONS1',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 }
 else
 {
        $reports->addReport(_('General Ledger'),704,_('GL Account &Transactions'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('From Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('To Account'),'GL_ACCOUNTS'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('From Account') => 'GL_ACCOUNTS',
+                       _('To Account') => 'GL_ACCOUNTS',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),705,_('Annual &Expense Breakdown'),
-       array(  new ReportParam(_('Year'),'TRANS_YEARS'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Year') => 'TRANS_YEARS',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),706,_('&Balance Sheet'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGIN'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGIN',
+                       _('End Date') => 'DATEENDM',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),707,_('&Profit and Loss Statement'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Compare to'),'COMPARE'),
-                       new ReportParam(_('Graphics'),'GRAPHIC'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Compare to') => 'COMPARE',
+                       _('Graphics') => 'GRAPHIC',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
        $reports->addReport(_('General Ledger'),708,_('Trial &Balance'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Zero values'),'YES_NO'),
-                       new ReportParam(_('Only balances'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Zero values') => 'YES_NO',
+                       _('Only balances') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
 }
 $reports->addReport(_('General Ledger'),709,_('Ta&x Report'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINTAX'),
-                       new ReportParam(_('End Date'),'DATEENDTAX'),
-                       new ReportParam(_('Summary Only'),'YES_NO'),
-                       new ReportParam(_('Comments'),'TEXTBOX')));
+       array(  _('Start Date') => 'DATEBEGINTAX',
+                       _('End Date') => 'DATEENDTAX',
+                       _('Summary Only') => 'YES_NO',
+                       _('Comments') => 'TEXTBOX'));
 $reports->addReport(_('General Ledger'),710,_('Audit Trail'),
-       array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
-                       new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Type'),'SYS_TYPES_ALL'),
-                       new ReportParam(_('User'),'USERS'),
-                       new ReportParam(_('Comments'),'TEXTBOX'),
-                       new ReportParam(_('Destination'),'DESTINATION')));
+       array(  _('Start Date') => 'DATEBEGINM',
+                       _('End Date') => 'DATEENDM',
+                       _('Type') => 'SYS_TYPES_ALL',
+                       _('User') => 'USERS',
+                       _('Comments') => 'TEXTBOX',
+                       _('Destination') => 'DESTINATION'));
+
+add_custom_reports($reports);
 
 echo "<script language='javascript'>
                function onWindowLoad() {