Implemented Selectable Print Orientation (Portrait, Landscape) for all reports in...
[fa-stable.git] / reporting / rep201.php
index 1c1ee43839ef40cc80b831805a6d3a0222a61af6..ee2bbcbcd40e4bc13c054c040e7ebaee31cc7417 100644 (file)
@@ -90,13 +90,15 @@ function print_supplier_balances()
        $currency = $_POST['PARAM_3'];
        $no_zeros = $_POST['PARAM_4'];
        $comments = $_POST['PARAM_5'];
-       $destination = $_POST['PARAM_6'];
+       $orientation = $_POST['PARAM_6'];
+       $destination = $_POST['PARAM_7'];
        if ($destination)
                include_once($path_to_root . "/reporting/includes/excel_report.inc");
        else
                include_once($path_to_root . "/reporting/includes/pdf_report.inc");
 
-       if ($fromsupp == ALL_NUMERIC)
+       $orientation = ($orientation ? 'L' : 'P');
+       if ($fromsupp == ALL_TEXT)
                $supp = _('All');
        else
                $supp = get_supplier_name($fromsupp);
@@ -126,7 +128,9 @@ function print_supplier_balances()
                        3 => array(  'text' => _('Currency'),'from' => $currency, 'to' => ''),
                        4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
 
-    $rep = new FrontReport(_('Supplier Balances'), "SupplierBalances", user_pagesize());
+    $rep = new FrontReport(_('Supplier Balances'), "SupplierBalances", user_pagesize(), 9, $orientation);
+    if ($orientation == 'L')
+       $rep->recalculate_cols($cols);
 
     $rep->Font();
     $rep->Info($params, $cols, $headers, $aligns);
@@ -136,7 +140,7 @@ function print_supplier_balances()
        $grandtotal = array(0,0,0,0);
 
        $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers";
-       if ($fromsupp != ALL_NUMERIC)
+       if ($fromsupp != ALL_TEXT)
                $sql .= " WHERE supplier_id=".db_escape($fromsupp);
        $sql .= " ORDER BY supp_name";
        $result = db_query($sql, "The customers could not be retrieved");
@@ -175,7 +179,7 @@ function print_supplier_balances()
                $rep->Line($rep->row + 4);
                while ($trans=db_fetch($res))
                {
-                       if ($no_zeros && $trans['TotalAmount'] == 0 && $trans['Allocated'] == 0) continue;
+                       if ($no_zeros && floatcmp(abs($trans['TotalAmount']), $trans['Allocated']) == 0) continue;
                        $rep->NewLine(1, 2);
                        $rep->TextCol(0, 1, $systypes_array[$trans['type']]);
                        $rep->TextCol(1, 2,     $trans['reference']);