Merged changes from stable branch up to 2.3.23.
[fa-stable.git] / reporting / includes / reports_classes.inc
index 1ba0b1b1ff46096ad4a049bd20b73b73cd848d2e..db333a0d0279cf9b71020e823f8386bf8e857f0a 100644 (file)
@@ -47,7 +47,7 @@ class BoxReports
 
        function getDisplay($class=null)
        {
-               global $path_to_root, $pdf_debug, $Ajax;
+               global $path_to_root, $SysPrefs, $Ajax;
 
                if (find_submit('Rep') != -1) {
                        include($path_to_root.'/reporting/prn_redirect.php');
@@ -78,7 +78,7 @@ class BoxReports
                                ."$acc[1]>$acc[0]</a> <br>";
 
                        $style = $class_id==$cur_class ? '' : "style='display:none'";
-                       $st_reports .= "<table class='repclass' id='TAB_" . $class_id ."' $style cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$name</b></td></tr>\n";
+                       $st_reports .= "<table class='repclass' id='TAB_" . $class_id ."' $style cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$name</b></td></tr>\n";
                        foreach($this->ar_reports[$class_id] as $rep_id => $report)
                        {
                                $acc = access_string($report->name);
@@ -99,7 +99,7 @@ class BoxReports
                                                . "<form method='POST' action='$action' target='_blank'>\n";
                                        $st_params .= submit('Rep'.$report->id,  
                                                _("Display: ") . access_string($report->name, true),
-                                               false, '', $pdf_debug ? false : 'default process') . hidden('REP_ID', $report->id, false).'<br><br>';
+                                               false, '', $SysPrefs->pdf_debug ? false : 'default process') . hidden('REP_ID', $report->id, false).'<br><br>';
                                        $st_params .= $this->getOptions($report->get_controls(), $report->id);
                                        $st_params .= "\n<input type=hidden name='Class' value=".$cur_class.">"
                                                ."\n</form></td></tr></table>\n";
@@ -137,6 +137,9 @@ class BoxReports
                                if ($ctrl) break;
                        }
                        if ($ctrl == '') {
+                               if (($id == 102 || $id == 202) && $cnt == 3) // set default Show Also Allocated to Yes in aged reports 2014-09-19 Joe Hunt
+                                       $_POST['PARAM_'.$cnt] = 1;
+                               
                                if (isset($_COOKIE['select'][$id][$cnt])) // saved parameters 2010-10-06 Joe Hunt
                                        $_POST['PARAM_'.$cnt] = $_COOKIE['select'][$id][$cnt];
                                $ctrl = $this->get_ctrl('PARAM_'.$cnt, $type);
@@ -164,8 +167,8 @@ class BoxReports
        //
        function get_ctrl($name, $type)
        {
-               global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no,
-                       $def_print_destination, $type_shortcuts;
+               global $path_to_root, $SysPrefs,
+                       $type_shortcuts;
 
                $st = '';
                        switch ($type)
@@ -211,7 +214,7 @@ class BoxReports
                                        else // saved parameters 2010-10-16 Joe Hunt
                                                $date = $_POST[$name];
                                        $st = "<input type='text' name='$name' value='$date'>";
-                                       if ($use_date_picker)
+                                       if (user_use_date_picker())
                                        {
                                                $calc_image = (file_exists("$path_to_root/themes/".user_theme()."/images/cal.gif")) ? 
                                                        "$path_to_root/themes/".user_theme()."/images/cal.gif" : "$path_to_root/themes/default/images/cal.gif";
@@ -230,7 +233,14 @@ class BoxReports
                                case 'DESTINATION':
                                        $sel = array(_("PDF/Printer"), "Excel");
                                        $def = 0;
-                                       if (isset($def_print_destination) && $def_print_destination == 1)
+                                       if (user_def_print_destination() == 1)
+                                               $def = 1;
+                                       return array_selector($name, $def, $sel);
+
+                               case 'ORIENTATION':
+                                       $sel = array(_("Portrait"), _("Landscape"));
+                                       $def = 0;
+                                       if (user_def_print_orientation() == 1)
                                                $def = 1;
                                        return array_selector($name, $def, $sel);
 
@@ -304,7 +314,7 @@ class BoxReports
 
                                case 'INVOICE':
                                        $IV = $type_shortcuts[ST_SALESINVOICE];
-                                       $ref = ($print_invoice_no == 1 ? "trans_no" : "reference");
+                                       $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                                        $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
                                                ".TB_PREF."debtor_trans.type) AS TNO, concat('$IV ', ".TB_PREF."debtor_trans.$ref,' ', ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE type=".ST_SALESINVOICE." AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
@@ -312,7 +322,7 @@ class BoxReports
 
                                case 'CREDIT':
                                        $CN = $type_shortcuts[ST_CUSTCREDIT];
-                                       $ref = ($print_invoice_no == 1 ? "trans_no" : "reference");
+                                       $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                                        $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
                                                ".TB_PREF."debtor_trans.type) AS TNO, concat('$CN ', ".TB_PREF."debtor_trans.$ref,' ', ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE 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";
@@ -329,7 +339,7 @@ class BoxReports
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
 
                                case 'ORDERS':
-                                       $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
+                                       $ref = ($SysPrefs->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 
@@ -337,7 +347,7 @@ class BoxReports
                                        return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
 
                                case 'QUOTATIONS':
-                                       $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
+                                       $ref = ($SysPrefs->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 
@@ -345,7 +355,7 @@ class BoxReports
                                        return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
 
                                case 'PO':
-                                       $ref = ($print_invoice_no == 1 ? "order_no" : "reference");
+                                       $ref = ($SysPrefs->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";
@@ -364,7 +374,7 @@ class BoxReports
                                case 'RECEIPT':
                                        $BD = $type_shortcuts[ST_BANKDEPOSIT];
                                        $CP = $type_shortcuts[ST_CUSTPAYMENT];
-                                       $ref = ($print_invoice_no == 1 ? "trans_no" : "reference");
+                                       $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                                        $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_BANKDEPOSIT.", ' $BD ', ' $CP '), ".TB_PREF."debtors_master.name) as IName
                                                FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_BANKDEPOSIT." OR type=".ST_CUSTPAYMENT." 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";
@@ -373,6 +383,9 @@ class BoxReports
                                case 'ITEMS':
                                        return stock_manufactured_items_list($name);
 
+                               case 'ITEMS_ALL':
+                                       return stock_manufactured_items_list($name, null, true);
+
                                case 'ITEMS_P':
                                        return stock_purchasable_items_list($name, null, true);
                                
@@ -487,4 +500,3 @@ function add_custom_reports(&$reports)
                include_once($file);
 }
 
-?>
\ No newline at end of file