Rerun en_US-demo.sql.
[fa-stable.git] / manufacturing / includes / manufacturing_ui.inc
index b903d2c8f500fb85254c9cf460a04a8bb68abb25..812590edd1a9f6a51884f7e5c1921e7cbd5a3867 100644 (file)
@@ -1,25 +1,32 @@
 <?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");
 
 //--------------------------------------------------------------------------------------
 
 function display_bom($item_check)
 {
-       global $table_style;
-
     $result = get_bom($item_check);
 
     if (db_num_rows($result) == 0)
     {
        display_note(_("The bill of material for this item is empty."), 0, 1);
-    } 
-    else 
+    }
+    else
     {
 
-        start_table($table_style);
+        start_table(TABLESTYLE);
         $th = array(_("Component"), _("Description"), _("Work Centre"),
-               _("From Location"), _("Quantity"), _("Unit Cost"), _("Total Cost"));
+               _("From Location"), _("Quantity"), _("Unit Cost"), _("Cost"));
 
         table_header($th);
 
@@ -28,7 +35,7 @@ function display_bom($item_check)
 
         $total_cost = 0;
 
-        while ($myrow = db_fetch($result)) 
+        while ($myrow = db_fetch($result))
         {
 
                        alt_table_row_color($k);
@@ -37,20 +44,37 @@ function display_bom($item_check)
                        label_cell($myrow["description"]);
                        label_cell($myrow["WorkCentreDescription"]);
                        label_cell($myrow["location_name"]);
-                       qty_cell($myrow["quantity"]);
-                       amount_cell($myrow["standard_cost"]);
+                       qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
+                       amount_cell($myrow["ProductCost"]);
                        amount_cell($myrow["ComponentCost"]);
                        end_row();
                $total_cost += $myrow["ComponentCost"];
 
                $j++;
-               If ($j == 12)
+               if ($j == 12)
                {
                        $j = 1;
                        table_header($th);
-               }//end of page full new headings if
-               }//end of while
+               }
+               }
 
+               $item = get_item($item_check);
+               if ($item['labour_cost'] != 0)
+               {
+                       $total_cost += $item['labour_cost'];
+                       alt_table_row_color($k);
+               label_cells(_("Standard Labour Cost"), number_format2($item['labour_cost'],user_price_dec()),
+               "colspan=6 align=left", "class=odd_row nowrap align=right");
+           end_row();
+               }
+               if ($item['overhead_cost'] != 0)
+               {
+                       $total_cost += $item['overhead_cost'];
+                       alt_table_row_color($k);
+               label_cells(_("Standard Overhead Cost"), number_format2($item['overhead_cost'],user_price_dec()),
+               "colspan=6 align=left", "nowrap align=right");
+           end_row();
+               }
         label_row("<b>" . _("Total Cost") . "</b>", "<b>" . number_format2($total_cost,user_price_dec()) ."</b>",
                "colspan=6 align=right", "nowrap align=right");
                end_table();
@@ -61,18 +85,18 @@ function display_bom($item_check)
 
 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
 {
-       global $table_style;
+       global $SysPrefs;
 
     $result = get_wo_requirements($woid);
 
     if (db_num_rows($result) == 0)
     {
        display_note(_("There are no Requirements for this Order."), 1, 0);
-    } 
-    else 
+    }
+    else
     {
 
-        start_table("$table_style width=80%");
+        start_table(TABLESTYLE, "width='80%'");
         $th = array(_("Component"), _("From Location"), _("Work Centre"),
                _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand"));
 
@@ -84,11 +108,11 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
                if ($date == null)
                        $date = Today();
 
-        while ($myrow = db_fetch($result)) 
+        while ($myrow = db_fetch($result))
         {
 
                        $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;
@@ -96,13 +120,13 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
                        if ($show_qoh)
                                $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()) 
+                       if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
+                               !$SysPrefs->allow_negative_stock())
                        {
                                // oops, we don't have enough of one of the component items
                                start_row("class='stockmankobg'");
                                $has_marked = true;
-                       } 
+                       }
                        else
                                alt_table_row_color($k);
 
@@ -113,11 +137,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();
@@ -135,17 +160,17 @@ function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
 
 function display_wo_productions($woid)
 {
-       global $path_to_root, $table_style;
+       global $path_to_root;
 
     $result = get_work_order_productions($woid);
 
     if (db_num_rows($result) == 0)
     {
        display_note(_("There are no Productions for this Order."), 1, 1);
-    } 
-    else 
+    }
+    else
     {
-        start_table($table_style);
+        start_table(TABLESTYLE);
         $th = array(_("#"), _("Reference"), _("Date"), _("Quantity"));
 
         table_header($th);
@@ -153,21 +178,21 @@ function display_wo_productions($woid)
         $k = 0; //row colour counter
                $total_qty = 0;
 
-        while ($myrow = db_fetch($result)) 
+        while ($myrow = db_fetch($result))
         {
 
                        alt_table_row_color($k);
 
                        $total_qty += $myrow['quantity'];
 
-               label_cell(get_trans_view_str(29, $myrow["id"]));
+               label_cell(get_trans_view_str(ST_MANURECEIVE, $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
 
-               label_row(_("Total"), number_format2($total_qty,user_qty_dec()), 
+               label_row(_("Total"), number_format2($total_qty,user_qty_dec()),
                        "colspan=3", "nowrap align=right");
 
                end_table();
@@ -178,29 +203,29 @@ function display_wo_productions($woid)
 
 function display_wo_issues($woid)
 {
-       global $path_to_root, $table_style;
+       global $path_to_root;
 
     $result = get_work_order_issues($woid);
 
     if (db_num_rows($result) == 0)
     {
        display_note(_("There are no Issues for this Order."), 0, 1);
-    } 
-    else 
+    }
+    else
     {
-        start_table($table_style);
+        start_table(TABLESTYLE);
         $th = array(_("#"), _("Reference"), _("Date"));
 
         table_header($th);
 
         $k = 0; //row colour counter
 
-        while ($myrow = db_fetch($result)) 
+        while ($myrow = db_fetch($result))
         {
 
                        alt_table_row_color($k);
 
-               label_cell(get_trans_view_str(28, $myrow["issue_no"]));
+               label_cell(get_trans_view_str(ST_MANUISSUE, $myrow["issue_no"]));
                        label_cell($myrow['reference']);
                        label_cell(sql2date($myrow["issue_date"]));
                        end_row();
@@ -214,33 +239,31 @@ function display_wo_issues($woid)
 
 function display_wo_payments($woid)
 {
-       global $path_to_root, $table_style;
+       global $path_to_root, $wo_cost_types;
 
-    $result = get_bank_trans(null, null, payment_person_types::WorkOrder(), $woid);
+    $result = get_wo_costing($woid);
 
     if (db_num_rows($result) == 0)
     {
-       echo _("There are no Payments for this Order.") . "<br>";
-    } 
-    else 
+       display_note(_("There are no additional costs for this Order."), 0, 1);
+    }
+    else
     {
-        start_table($table_style);
-        $th = array(_("#"), _("Reference"), _("Date"), _("Amount"));
+        start_table(TABLESTYLE);
+        $th = array(_("#"), _("Type"), _("Date"), _("Amount"));
 
         table_header($th);
 
-        $k = 0; //row colour counter
-
-        while ($myrow = db_fetch($result)) 
+        $k = 0;
+        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"]));
-                       amount_cell(-($myrow['amount']));
-                       label_cell($myrow['bank_curr_code']);
+               label_cell(get_gl_view_str( $myrow["trans_type"], $myrow["trans_no"], $myrow["trans_no"]));
+               label_cell($wo_cost_types[$myrow['cost_type']]);
+               $date = sql2date($myrow["tran_date"]);
+               label_cell($date);
+                       amount_cell($myrow['amount']);
                        end_row();
                }
 
@@ -252,23 +275,23 @@ function display_wo_payments($woid)
 
 function display_wo_details($woid, $suppress_view_link=false)
 {
-       global $table_style;
+       global $wo_types_array;
 
        $myrow = get_work_order($woid);
 
-    if (strlen($myrow[0]) == 0) 
+    if (strlen($myrow[0]) == 0)
     {
        display_note(_("The work order number sent is not valid."));
        exit;
     }
 
-       start_table("$table_style width=80%");
+       start_table(TABLESTYLE, "width='80%'");
 
-       if ($myrow["released"] == true) 
+       if ($myrow["released"] == true)
                $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
                        _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"),
                        _("Released Date"), _("Manufactured"));
-       else            
+       else
                $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
                        _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"));
 
@@ -277,28 +300,28 @@ 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"]));
+       $dec = get_qty_dec($myrow["stock_id"]);
+       qty_cell($myrow["units_reqd"], false, $dec);
 
-       qty_cell($myrow["units_reqd"]);
-
-       if ($myrow["released"] == true) 
+       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();
 
-    if ($myrow["closed"] == true) 
+    if ($myrow["closed"] == true)
     {
        display_note(_("This work order is closed."));
     }
@@ -308,45 +331,44 @@ function display_wo_details($woid, $suppress_view_link=false)
 
 function display_wo_details_quick($woid, $suppress_view_link=false)
 {
-       global $table_style;
+       global $wo_types_array;
 
        $myrow = get_work_order($woid);
 
-    if (strlen($myrow[0]) == 0) 
+    if (strlen($myrow[0]) == 0)
     {
        display_note(_("The work order number sent is not valid."));
        exit;
     }
 
-       start_table("$table_style width=80%");
+       start_table(TABLESTYLE, "width='80%'");
 
        $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
                _("Into Location"), _("Date"), _("Quantity"));
-       table_header($th);      
+       table_header($th);
 
        start_row();
        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();
 
-    if ($myrow["closed"] == true) 
+    if ($myrow["closed"] == true)
     {
        display_note(_("This work order is closed."));
     }
 }
 
-?>
\ No newline at end of file