Four minor bug fixes
[fa-stable.git] / reporting / rep209.php
index 947dd64d325cf762e8610ae5d8b50241e2445d90..c2c3c0fe58ca988492bcae63f57f59527c4e81ad 100644 (file)
@@ -5,7 +5,7 @@ $page_security = 2;
 // $ Revision: 2.0 $
 // Creator:    Joe Hunt
 // date_:      2005-05-19
-// Title:      Print Invoices
+// Title:      Purchase Orders
 // ----------------------------------------------------------------
 $path_to_root="../";
 
@@ -23,7 +23,8 @@ print_po();
 function get_po($order_no)
 {
        $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, 
-               ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name 
+               ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name,
+               ".TB_PREF."suppliers.email, ".TB_PREF."suppliers.address 
                FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations 
                WHERE ".TB_PREF."purch_orders.supplier_id = ".TB_PREF."suppliers.supplier_id
                AND ".TB_PREF."locations.loc_code = into_stock_location 
@@ -60,7 +61,7 @@ function print_po()
                $from = 0;
        if ($to == null)
                $to = 0;
-       $dec =user_price_dec();
+       $dec = user_price_dec();
        
        $cols = array(4, 60, 225, 300, 325, 385, 450, 515);
 
@@ -90,7 +91,7 @@ function print_po()
                        $rep = new FrontReport("", "", user_pagesize());
                        $rep->currency = $cur;
                        $rep->Font();
-                       $rep->title = _('PURCHASE_ORDER');
+                       $rep->title = _('PURCHASE ORDER');
                        $rep->filename = "PurchaseOrder" . $i . ".pdf";
                        $rep->Info($params, $cols, null, $aligns);
                }
@@ -102,7 +103,8 @@ function print_po()
                $SubTotal = 0;
                while ($myrow2=db_fetch($result))
                {
-                       $Net = ($myrow2["unit_price"] * $myrow2["quantity_ordered"]);
+                       $Net = round(($myrow2["unit_price"] * $myrow2["quantity_ordered"]),
+                         user_price_dec());
                        $SubTotal += $Net;
                        $DisplayPrice = number_format2($myrow2["unit_price"],$dec);
                        $DisplayQty = number_format2($myrow2["quantity_ordered"],user_qty_dec());
@@ -147,12 +149,10 @@ function print_po()
                $rep->Font();   
                if ($email == 1)
                {
-                       if ($myrow['contact_email'] == '')
-                       {
-                               $myrow['contact_email'] = $branch['email'];
-                               $myrow['DebtorName'] = $branch['br_name'];
-                       }
-                       $rep->End($email, $doc_Invoice_no . " " . $myrow['reference'], $myrow);
+                       $myrow['contact_email'] = $myrow['email'];
+                       $myrow['DebtorName'] = $myrow['supp_name'];
+                       $myrow['reference'] = $myrow['order_no'];
+                       $rep->End($email, $doc_Order_no . " " . $myrow['reference'], $myrow);
                }       
        }
        if ($email == 0)