Added Print of Work Order
[fa-stable.git] / reporting / includes / reports_classes.inc
index 0dabe11ca676661ab3d027d91873501709b355d9..69597924d89a7dda3eb1c062ae2a1d2e281c8088 100644 (file)
@@ -1,4 +1,14 @@
 <?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 class BoxReports
 {
        var $ar_classes;
@@ -20,7 +30,8 @@ class BoxReports
 
        function getDisplay($class=null)
        {
-               global $table_style2;
+               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;
@@ -30,34 +41,59 @@ class BoxReports
                $st_classes = "<b>" . _("Report Classes:") . "</b><br>";
                foreach($this->ar_classes as $key=>$value)
                {
-                       $style = $class_counter==0 ? '' : $style = "style='display:none'";
-                       $st_classes .= "<a href='javascript:showClass($class_counter)'>$key</a> <br>";
-                       $st_reports .= "<table id='TAB_" . $class_counter++ ."' $style cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$key</b></td></tr>";
+                       $style = $class_counter==$_REQUEST['Class'] ? '' : "style='display:none'";
+                       $acc = access_string($key);
+                       $st_classes .= "<a href='"
+                               .$_SERVER['PHP_SELF']."?Class=$class_counter'"
+                               ." class='menu_option' id='".default_focus()."'"
+                               ." onclick='return showClass($class_counter);'$acc[1]>$acc[0]</a> <br>";
+                       $st_reports .= "<table id='TAB_" . $class_counter ."' $style cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$key</b></td></tr>\n";
                        foreach($value as $report)
                        {
-                               $st_reports .= "<tr><td><a href='javascript:showReport($rep_counter)'>" . $report->name . "</a></td></tr>";
-                               $st_params .= "<table border=0 id='REP_" . $rep_counter++ . "' style='display:none'>";
-                               $st_params .= "<tr><td>" . $report->getDisplay() . "</td></tr></table>";
+                               $acc = access_string($report->name);
+                               $st_reports .= "<tr><td><a class='printlink' href='"
+                                       .$_SERVER['PHP_SELF']."?Class=$class_counter&rep_id=$report->id'"
+                                       ." id='".default_focus()."'"
+                                       ."$acc[1]>$acc[0]</a><tr><td>\n";
+                               if (isset($_REQUEST['rep_id']) && $_REQUEST['rep_id']==$report->id) {
+
+                                       $action = $path_to_root.'/reporting/prn_redirect.php';
+       
+                                       $st_params = "<table border=0><tr><td>\n"
+                                               . "<form method='POST' action='$action' target='_blank'>\n";
+                                       $st_params .= hidden('REP_ID', $report->id, false);
+                                       $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";
+                                       set_focus('Rep'.$report->id);
+                                       $Ajax->addUpdate(true, 'rep_form', $st_params);
+                               }
                        }
                        $st_reports .= "</table>";
+                       $class_counter++;
                }
 
+               $st_params = "<div id='rep_form'>".
+                       "$st_params</div>";
+               
+
                $st =   "<script language='javascript'>
                                        function showClass(pClass) {
                                                for(i=0; i<$class_counter; i++) {
-                                                       eval('document.getElementById(\"TAB_\" + i).style.display=\"none\"')
-                                               }
-                                               eval('document.getElementById(\"TAB_\" + pClass).style.display=\"block\"')
-                                               for (i=0; i<$rep_counter; i++) {
-                                                       eval('document.getElementById(\"REP_\" + i).style.display=\"none\"')
+                                                       document.getElementById(\"TAB_\" + i).style.display=
+                                                       i==pClass ? \"block\" : \"none\";
                                                }
+                                               document.getElementById('rep_form').innerHTML = '';
+//                                             document.getElementById('rep_form').style.display = 'none';
+                                               return false;
                                        }
-                                       function showReport(pId) {
-                                               var tab;
-                                               for(i=0; i<$rep_counter; i++) {
-                                                       eval('document.getElementById(\"REP_\" + i).style.display=\"none\"')
+                                       function checkDate(pObj) {
+                                               var re = /^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/\d{4}/;
+                                               if (re.test(pObj.value)==false) {
+                                                       alert('" . _("Invalid date format") . "')
                                                }
-                                               eval('document.getElementById(\"REP_\" + pId).style.display=\"block\"')
                                        }
                                </script>
                                ";
@@ -83,39 +119,12 @@ class Report
                $this->name             = $name;
                $this->ar_params        = $ar_params;
        }
+       
        function getDisplay()
        {
-               global $comp_path, $path_to_root, $use_date_picker;
-
-               $rep_file = $comp_path.'/'.user_company().
-                    "/reporting/rep".$this->id.".php";
-               if (!file_exists($rep_file))
-                   $rep_file = $path_to_root ."/reporting/rep".$this->id.".php";
-
-               $st = "
-<script language='javascript'>
-       function displayReport_" . $this->id . "() {
-               pParamCount = " . count($this->ar_params) . ";
-               document.forms[0].REP_ID.value = " . $this->id . ";
-               document.forms[0].PARAM_COUNT.value = pParamCount;
-               for (i=0; i<pParamCount; i++) {
-                       eval('document.forms[0].PARAM_' + i + '.value=document.forms[0].RP_" . $this->id . "_' + i + '.value');
-               }
+               global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no;
 
-               window.open('','REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');
-               document.forms[0].target='REP_WINDOW';
-               document.forms[0].action= '$rep_file';
-               document.forms[0].submit();
-       }
-       function checkDate(pObj) {
-               var re = /^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/\d{4}/;
-               if (re.test(pObj.value)==false) {
-                       alert('" . _("Invalid date format") . "')
-               }
-       }
-</script>
-                       ";
-               $st .= "<input type='button' onclick='javascript:displayReport_" . $this->id ."()' value='" . _("Display: ") . $this->name . "'><br><br>";
+               $st = '';
                $dummy = "";
                if ($this->ar_params==null)
                        return "";
@@ -126,7 +135,7 @@ class Report
                        {
                                case 'CURRENCY':
                                        $sql = "SELECT curr_abrev, concat(curr_abrev,' - ', currency) FROM ".TB_PREF."currencies";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Currency Filter"));
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Currency Filter"));
                                        break;
                                case 'DATE':
                                case 'DATEBEGIN':
@@ -154,12 +163,13 @@ class Report
                                                        $date = $edate;
                                                else
                                                {
-                                                       $bdate = add_months($edate, -$row['tax_prd'] + 1);
-                                                       $date = begin_month($bdate);
+                                                       $bdate = begin_month($edate);
+                                                       $bdate = add_months($bdate, -$row['tax_prd'] + 1);
+                                                       $date = $bdate;
                                                }
                                        }
-                                       $name = "RP_" . $this->id . "_$index";
-                                       //$st .= "<input type='text' name='$name' value='$date' onblur='javascript:checkDate(this)'>";
+                                       $name = "PARAM_$index";
+
                                        $st .= "<input type='text' name='$name' value='$date'>";
                                        if ($use_date_picker)
                                                $st .= "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
@@ -168,89 +178,97 @@ class Report
                                        break;
                                case 'YES_NO':
                                        $sel = array(_('No'), _("Yes"));
-                                       $st .= dup_simple_name_list("RP_" . $this->id . "_$index", $sel);
+                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
                                        break;
                                case 'PAYMENT_LINK':
                                        $sel = array(_("No Payment Link"), "PayPal");
-                                       $st .= dup_simple_name_list("RP_" . $this->id . "_$index", $sel);
+                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
+                                       break;
+                               case 'DESTINATION':
+                                       $sel = array(_("PDF/Printer"), "Excel");
+                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
                                        break;
                                case 'COMPARE':
                                        $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget"));
-                                       $st .= dup_simple_name_list("RP_" . $this->id . "_$index", $sel);
+                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
                                        break;
                                case 'GRAPHIC':
                                        $sel = array(_("No Graphics"), _("Vertical bars"), _("Horizontal bars"), _("Dots"), _("Lines"), _("Pie"), _("Donut"));
-                                       $st .= dup_simple_name_list("RP_" . $this->id . "_$index", $sel);
+                                       $st .= dup_simple_name_list("PARAM_$index", $sel);
                                        break;
                                case 'SYS_TYPES':
-                                       $st .= dup_systypes_list("RP_" . $this->id . "_$index", $dummy, true, _("No Type Filter"), true);
+                                       $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), true);
                                        break;
                                case 'TEXT':
-                                       $st .= "<input type='text' name='RP_" . $this->id . "_$index'>";
+                                       $st .= "<input type='text' name='PARAM_$index'>";
                                        break;
                                case 'TEXTBOX':
-                                       $st .= "<textarea rows=4 cols=30 name='RP_" . $this->id . "_$index'></textarea>";
+                                       $st .= "<textarea rows=4 cols=30 name='PARAM_$index'></textarea>";
                                        break;
                                case 'ACCOUNTS':
                                        $sql = "SELECT id, name FROM ".TB_PREF."chart_types ORDER BY name";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Account Group Filter"), true);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Account Group Filter"), true);
                                        break;
                                case 'GL_ACCOUNTS':
                                        $sql = "SELECT account_code, concat(account_code, ' - ', account_name) as account_name FROM ".TB_PREF."chart_master ORDER BY account_code";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'BANK_ACCOUNTS':
-                                       $sql = "SELECT ".TB_PREF."bank_accounts.account_code, concat(bank_account_name, if (bank_curr_code=curr_default,'', concat(' - ', bank_curr_code))) FROM ".TB_PREF."bank_accounts, ".TB_PREF."chart_master, ".TB_PREF."company
-                                               WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $sql = "SELECT ".TB_PREF."bank_accounts.id, concat(bank_account_name, if (bank_curr_code=curr_default,'', concat(' - ', bank_curr_code))) FROM ".TB_PREF."bank_accounts, ".TB_PREF."company";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'DIMENSION':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'DIMENSIONS':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Dimension Filter"), true);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
                                        break;
                                case 'DIMENSION1':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index". "_$index", $dummy);
                                        break;
                                case 'DIMENSIONS1':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Dimension Filter"), true);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
                                        break;
                                case 'DIMENSION2':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'DIMENSIONS2':
-                                       $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Dimension Filter"), true);
+                                       $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
                                        break;
                                case 'CUSTOMERS_NO_FILTER':
                                case 'CUSTOMERS':
                                        $sql = "SELECT debtor_no, name FROM ".TB_PREF."debtors_master ORDER BY name";
                                        if ($param->param_type == 'CUSTOMERS_NO_FILTER')
-                                               $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Customer Filter"), true);
+                                               $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Customer Filter"), true);
                                        else
-                                               $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                               $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'SUPPLIERS_NO_FILTER':
                                case 'SUPPLIERS':
                                        $sql = "SELECT supplier_id, supp_name FROM ".TB_PREF."suppliers ORDER BY supp_name";
                                        if ($param->param_type == 'SUPPLIERS_NO_FILTER')
-                                               $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Supplier Filter"), true);
+                                               $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Supplier Filter"), true);
                                        else
-                                               $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                               $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'INVOICE':
                                        $IV = _("IV");
                                        $CN = _("CN");
-                                       $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
-                                               ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
-                                               FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       if ($print_invoice_no == 1)
+                                               $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+                                                       ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+                                                       FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+                                       else            
+                                               $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+                                                       ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+                                                       FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'DELIVERY':
                                        $DN = _("DN");
@@ -260,51 +278,57 @@ class Report
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans
                                                WHERE type=13 AND ".TB_PREF."debtors_master.debtor_no=".
                                                TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'ORDERS':
                                        $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-',
                                                ".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 ORDER BY ".TB_PREF."sales_orders.order_no DESC";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'PO':
                                        $sql = "SELECT ".TB_PREF."purch_orders.order_no, concat(".TB_PREF."purch_orders.order_no, '-',
                                                ".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 .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                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') ORDER BY stock_id";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+                                       break;
+                               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 .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'LOCATIONS':
                                        $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations ORDER BY location_name";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Location Filter"), false);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Location Filter"), false);
                                        break;
                                case 'CATEGORIES':
                                        $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category ORDER BY description";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Category Filter"), true);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Category Filter"), true);
                                        break;
                                case 'SALESTYPES':
                                        $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types ORDER BY sales_type";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'AREAS':
                                        $sql = "SELECT area_code, description FROM ".TB_PREF."areas ORDER BY description";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Area Filter"), true);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Area Filter"), true);
                                        break;
                                case 'SALESMEN':
                                        $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman ORDER BY salesman_name";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy, true, _("No Sales Folk Filter"), true);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Sales Folk Filter"), true);
                                        break;
                                case 'TRANS_YEARS':
                                        $sql = "SELECT DISTINCT YEAR(tran_date), YEAR(tran_date) FROM ".TB_PREF."gl_trans";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
                                case 'ACCOUNTS_NO_FILTER':
                                        $sql = "SELECT id, name FROM ".TB_PREF."chart_types ORDER BY name";
-                                       $st .= dup_simple_codeandname_list($sql, "RP_" . $this->id . "_$index", $dummy);
+                                       $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
                                        break;
 
                        }