Merged changes up to 2.3.16 into unstable
[fa-stable.git] / includes / ui / ui_view.inc
index f578f5372ca38fea59eea8c54820f0556abc1a22..49315c02c894958b7cdf4841e9c17b81dd4dccfd 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);
 }
 
 //--------------------------------------------------------------------------------------
@@ -475,14 +475,14 @@ function display_footer_exit($space=2)
 
 //--------------------------------------------------------------------------------------
 
-function display_allocations($alloc_result, $total, $payments=false)
+function display_allocations($alloc_result, $total, $title, $show_summary=true)
 {
        global $systypes_array;
 
        if (!$alloc_result || db_num_rows($alloc_result) == 0)
                return;
 
-    display_heading2(($payments ? _("Payments") : _("Allocations")));
+    display_heading2($title);
 
     start_table(TABLESTYLE, "width=80%");
 
@@ -493,7 +493,6 @@ function display_allocations($alloc_result, $total, $payments=false)
 
     while ($alloc_row = db_fetch($alloc_result))
     {
-
        alt_table_row_color($k);
 
        label_cell($systypes_array[$alloc_row['type']]);
@@ -514,12 +513,14 @@ function display_allocations($alloc_result, $total, $payments=false)
        label_cell(_("Total Allocated:"), "align=right colspan=5");
        amount_cell($total_allocated);
        end_row();
-       start_row();
-    label_cell(_("Left to Allocate:"), "align=right colspan=5");
-    $total = round2($total, user_price_dec());
-    amount_cell($total - $total_allocated);
-    end_row();
-
+       if ($show_summary)
+       {
+               start_row();
+           label_cell(_("Left to Allocate:"), "align=right colspan=5");
+           $total = round2($total, user_price_dec());
+       amount_cell($total - $total_allocated);
+       end_row();
+       }
     end_table(1);
 }
 
@@ -531,11 +532,11 @@ function display_allocations_from($person_type, $person_id, $type, $type_no, $to
        {
                case PT_CUSTOMER :
                        $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
-                       display_allocations($alloc_result, $total);
+                       display_allocations($alloc_result, $total, _("Allocations"));
                        return;
                case PT_SUPPLIER :
                        $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
-                       display_allocations($alloc_result, $total);
+                       display_allocations($alloc_result, $total, _("Allocations"));
                        return;
        }
 }
@@ -548,11 +549,11 @@ function display_allocations_to($person_type, $person_id, $type, $type_no, $tota
        {
                case PT_CUSTOMER :
                        $alloc_result = get_allocatable_from_cust_transactions($person_id, $type_no, $type);
-                       display_allocations($alloc_result, $total, true);
+                       display_allocations($alloc_result, $total, $type == ST_SALESORDER ? _("Pre-Payments") : _("Payments"), false);
                        return;
                case PT_SUPPLIER :
                        $alloc_result = get_allocatable_from_supp_transactions($person_id, $type_no, $type);
-                       display_allocations($alloc_result, $total, true);
+                       display_allocations($alloc_result, $total, $type == ST_PURCHORDER ? _("Pre-Payments") : _("Payments"), false);
                        return;
        }
 }
@@ -588,9 +589,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);
@@ -599,7 +600,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))
                {
@@ -610,7 +611,7 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='')
                                case "t+": // ditto & increase base amount
                                case "t-": // ditto & reduce base amount
                                        if (substr($row['action'],0,1) != 'T') 
-                                               $totrate += get_tax_type_default_rate($row['dest_id']);
+                                               $totrate += get_tax_type_rate($row['dest_id']);
                        }
                }
                $first = true;
@@ -784,7 +785,7 @@ function price_in_words($amount, $document=0)
     else
        $frac = "";
     return _number_to_words(intval($amount)) . $frac;
-}    
+}
 
 function get_js_open_window($width, $height)
 {
@@ -1372,5 +1373,3 @@ function payment_link($name, $options)
 
        return strtr($link, $patterns);
 }
-
-?>
\ No newline at end of file