Costed Inventory Movement Report: fixed regression after changes in stock_moves.
[fa-stable.git] / reporting / rep209.php
index c1632dfd1f1745f869ddff7d90c467af7055bbd8..c3246a626cc78ef179886d670771bfebba0fb760 100644 (file)
@@ -58,7 +58,7 @@ function get_po_details($order_no)
 
 function print_po()
 {
-       global $path_to_root, $show_po_item_codes;
+       global $path_to_root, $SysPrefs;
 
        include_once($path_to_root . "/reporting/includes/pdf_report.inc");
 
@@ -91,6 +91,9 @@ function print_po()
        for ($i = $from; $i <= $to; $i++)
        {
                $myrow = get_po($i);
+               if ($currency != ALL_TEXT && $myrow['curr_code'] != $currency) {
+                       continue;
+               }
                $baccount = get_default_bank_account($myrow['curr_code']);
                $params['bankaccount'] = $baccount['id'];
 
@@ -100,13 +103,13 @@ function print_po()
                        $rep->title = _('PURCHASE ORDER');
                        $rep->filename = "PurchaseOrder" . $i . ".pdf";
                }       
-               $rep->SetHeaderType('Header2');
                $rep->currency = $cur;
                $rep->Font();
                $rep->Info($params, $cols, null, $aligns);
 
                $contacts = get_supplier_contacts($myrow['supplier_id'], 'order');
                $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_PURCHORDER, $contacts);
+               $rep->SetHeaderType('Header2');
                $rep->NewPage();
 
                $result = get_po_details($i);
@@ -135,7 +138,7 @@ function print_po()
                        $DisplayPrice = price_decimal_format($myrow2["unit_price"],$dec2);
                        $DisplayQty = number_format2($myrow2["quantity_ordered"],get_qty_dec($myrow2['item_code']));
                        $DisplayNet = number_format2($Net,$dec);
-                       if ($show_po_item_codes) {
+                       if ($SysPrefs->show_po_item_codes()) {
                                $rep->TextCol(0, 1,     $myrow2['item_code'], -2);
                                $rep->TextCol(1, 2,     $myrow2['description'], -2);
                        } else
@@ -164,7 +167,7 @@ function print_po()
                $rep->NewLine();
 
                $tax_items = get_tax_for_items($items, $prices, 0,
-                 $myrow['tax_group_id'], $myrow['tax_included'],  null);
+                 $myrow['tax_group_id'], $myrow['tax_included'],  null, TCA_LINES);
                $first = true;
                foreach($tax_items as $tax_item)
                {
@@ -172,11 +175,14 @@ function print_po()
                                continue;
                        $DisplayTax = number_format2($tax_item['Value'], $dec);
 
-                       $tax_type_name = $tax_item['tax_type_name'];
+                       if ($SysPrefs->suppress_tax_rates() == 1)
+                               $tax_type_name = $tax_item['tax_type_name'];
+                       else
+                               $tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) ";
 
                        if ($myrow['tax_included'])
                        {
-                               if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1)
+                               if ($SysPrefs->alternative_tax_include_on_docs() == 1)
                                {
                                        if ($first)
                                        {
@@ -225,4 +231,3 @@ function print_po()
                $rep->End();
 }
 
-?>
\ No newline at end of file