Fixes in sales reports to use debtor_trans.tax_included field instead of trans_tax_de...
[fa-stable.git] / includes / ui / ui_view.inc
index 00c0cd0c9d64f3ad4f20d5b80c8beb47621e342d..938f0a33768292029ec17229134f21c74b218268 100644 (file)
@@ -50,11 +50,11 @@ function get_gl_view_str($type, $trans_no, $label="", $force=false, $class='', $
        {
                $label = _("GL");
                $icon = ICON_GL;
-       }       
+       }
+       $url = ($type == ST_WORKORDER && !work_order_is_closed($trans_no)) ? "manufacturing/view/wo_costs_view.php?trans_no=$trans_no"
+               : "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no";
 
-       return viewer_link($label, 
-               "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no", 
-               $class, $id, $icon);
+       return viewer_link($label, $url, $class, $id, $icon);
 }
 
 //--------------------------------------------------------------------------------------
@@ -586,9 +586,9 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='')
                                        $begin = "";
                                else
                                        $begin = begin_fiscalyear(); // from fiscalyear begin
-                       }               
+                       }
                        $base = get_gl_trans_from_to($begin, $cart->tran_date, $qe['base_desc']);
-                               
+
                }
                if ($descr != '') $qe['description'] .= ': '.$descr;
                $result = get_quick_entry_lines($id);
@@ -597,7 +597,7 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='')
                        display_error( _("No Quick Entry lines are defined."));
                        set_focus('totamount');
                        return 0;
-               }       
+               }
                $totrate = 0;
                while ($row = db_fetch($result))
                {
@@ -774,21 +774,15 @@ function price_in_words($amount, $document=0)
        if ($dec > 0)
        {
                $divisor = pow(10, $dec);
-               // algorithm rewritten due to a bug in sprintf (wrong with frac, 29, 57 and more).
         $frac = round2($amount - floor($amount), $dec) * $divisor;
-        for ($div = $divisor / 10; $div > 1; $div /= 10)
-        {
-               if ($frac < $div)
-                       $frac = "0" . $frac;
-        }              
-               //$frac = sprintf("%0{$dec}d", $frac);
+               $frac = sprintf("%0{$dec}d", round2($frac, 0));
                $and = _("and");
        $frac = " $and $frac/$divisor";
     }
     else
        $frac = "";
     return _number_to_words(intval($amount)) . $frac;
-}    
+}
 
 function get_js_open_window($width, $height)
 {
@@ -1350,5 +1344,3 @@ function payment_link($name, $options)
 
        return strtr($link, $patterns);
 }
-
-?>
\ No newline at end of file