Security update merged from 2.1.
[fa-stable.git] / manufacturing / includes / manufacturing_ui.inc
index eb14c8a11c64dcd3309d2e873845beda9fcc7769..426356d9c61a4efa053edd055dba260cb2717772 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 include_once($path_to_root . "/includes/ui.inc");
 
 //--------------------------------------------------------------------------------------
@@ -37,7 +46,7 @@ function display_bom($item_check)
                        label_cell($myrow["description"]);
                        label_cell($myrow["WorkCentreDescription"]);
                        label_cell($myrow["location_name"]);
-                       qty_cell($myrow["quantity"]);
+                       qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
                        amount_cell($myrow["standard_cost"]);
                        amount_cell($myrow["ComponentCost"]);
                        end_row();
@@ -61,7 +70,7 @@ function display_bom($item_check)
 
 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
 {
-       global $table_style;
+       global $table_style, $SysPrefs;
 
     $result = get_wo_requirements($woid);
 
@@ -88,7 +97,7 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
         {
 
                        $qoh = 0;
-
+                       $show_qoh = true;
                        // if it's a non-stock item (eg. service) don't show qoh
                        if (!has_stock_holding($myrow["mb_flag"]))
                                $show_qoh = false;
@@ -97,7 +106,7 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
                                $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date);
 
                        if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
-                               !sys_prefs::allow_negative_stock())
+                               !$SysPrefs->allow_negative_stock())
                        {
                                // oops, we don't have enough of one of the component items
                                start_row("class='stockmankobg'");
@@ -113,11 +122,12 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
 
                        label_cell($myrow["location_name"]);
                        label_cell($myrow["WorkCentreDescription"]);
-            qty_cell($myrow["units_req"]);
-                       qty_cell($myrow["units_req"] * $quantity);
-            qty_cell($myrow["units_issued"]);
+                       $dec = get_qty_dec($myrow["stock_id"]);
+            qty_cell($myrow["units_req"], false, $dec);
+                       qty_cell($myrow["units_req"] * $quantity, false, $dec);
+            qty_cell($myrow["units_issued"], false, $dec);
                        if ($show_qoh)
-                               qty_cell($qoh);
+                               qty_cell($qoh, false, $dec);
                        else
                                label_cell("");
                        end_row();
@@ -163,7 +173,7 @@ function display_wo_productions($woid)
                label_cell(get_trans_view_str(29, $myrow["id"]));
                        label_cell($myrow['reference']);
                        label_cell(sql2date($myrow["date_"]));
-                       qty_cell($myrow['quantity']);
+                       qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference']));
                        end_row();
                }//end of while
 
@@ -214,33 +224,34 @@ function display_wo_issues($woid)
 
 function display_wo_payments($woid)
 {
-       global $path_to_root, $table_style;
+       global $path_to_root, $table_style, $wo_cost_types;
 
-    $result = get_bank_trans(null, null, payment_person_types::WorkOrder(), $woid);
+    //$result = get_bank_trans(null, null, PT_WORKORDER, $woid);
+    $result = get_gl_wo_cost_trans($woid);
 
     if (db_num_rows($result) == 0)
     {
-       display_note(_("There are no Payments for this Order."), 0, 1);
+       display_note(_("There are no additional costs for this Order."), 0, 1);
     }
     else
     {
         start_table($table_style);
-        $th = array(_("#"), _("Reference"), _("Date"), _("Amount"));
+        $th = array(_("#"), _("Type"), _("Date"), _("Amount"));
 
         table_header($th);
 
         $k = 0; //row colour counter
-
+               
         while ($myrow = db_fetch($result))
         {
 
                        alt_table_row_color($k);
 
-               label_cell(get_trans_view_str(1, $myrow["trans_no"]));
-                       label_cell($myrow['ref']);
-                       label_cell(sql2date($myrow["trans_date"]));
+               label_cell(get_gl_view_str(ST_WORKORDER, $myrow["type_no"], $myrow["type_no"]));
+               label_cell($wo_cost_types[$myrow['person_id']]);
+               $date = sql2date($myrow["tran_date"]);
+               label_cell($date);
                        amount_cell(-($myrow['amount']));
-                       label_cell($myrow['bank_curr_code']);
                        end_row();
                }
 
@@ -252,7 +263,7 @@ function display_wo_payments($woid)
 
 function display_wo_details($woid, $suppress_view_link=false)
 {
-       global $table_style;
+       global $table_style, $wo_types_array;
 
        $myrow = get_work_order($woid);
 
@@ -277,24 +288,24 @@ function display_wo_details($woid, $suppress_view_link=false)
        if ($suppress_view_link)
                label_cell($myrow["id"]);
        else
-               label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"]));
+               label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
        label_cell($myrow["wo_ref"]);
-       label_cell(wo_types::name($myrow["type"]));
+       label_cell($wo_types_array[$myrow["type"]]);
        view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
        label_cell($myrow["location_name"]);
        label_cell(sql2date($myrow["date_"]));
        label_cell(sql2date($myrow["required_by"]));
-
-       qty_cell($myrow["units_reqd"]);
+       $dec = get_qty_dec($myrow["stock_id"]);
+       qty_cell($myrow["units_reqd"], false, $dec);
 
        if ($myrow["released"] == true)
        {
                label_cell(sql2date($myrow["released_date"]));
-               qty_cell($myrow["units_issued"]);
+               qty_cell($myrow["units_issued"], false, $dec);
        }
        end_row();
 
-       comments_display_row(systypes::work_order(), $woid);
+       comments_display_row(ST_WORKORDER, $woid);
 
        end_table();
 
@@ -308,7 +319,7 @@ function display_wo_details($woid, $suppress_view_link=false)
 
 function display_wo_details_quick($woid, $suppress_view_link=false)
 {
-       global $table_style;
+       global $table_style, $wo_types_array;
 
        $myrow = get_work_order($woid);
 
@@ -328,18 +339,18 @@ function display_wo_details_quick($woid, $suppress_view_link=false)
        if ($suppress_view_link)
                label_cell($myrow["id"]);
        else
-               label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"]));
+               label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
        label_cell($myrow["wo_ref"]);
-       label_cell(wo_types::name($myrow["type"]));
+       label_cell($wo_types_array[$myrow["type"]]);
        view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
        label_cell($myrow["location_name"]);
        label_cell(sql2date($myrow["date_"]));
 
-       qty_cell($myrow["units_issued"]);
+       qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"]));
 
        end_row();
 
-       comments_display_row(systypes::work_order(), $woid);
+       comments_display_row(ST_WORKORDER, $woid);
 
        end_table();