Changed Advanced Manufacturing payments to be more flexible and simpler. Removed...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 8 Jun 2009 20:10:09 +0000 (20:10 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 8 Jun 2009 20:10:09 +0000 (20:10 +0000)
Overhead costs in Manufacturing/Assembling wasn't added to stock overhead cost

15 files changed:
CHANGELOG.txt
gl/includes/db/gl_db_trans.inc
gl/includes/ui/gl_bank_ui.inc
includes/types.inc
includes/ui/ui_lists.inc
manufacturing/includes/db/work_order_produce_items_db.inc
manufacturing/includes/db/work_orders_db.inc
manufacturing/includes/db/work_orders_quick_db.inc
manufacturing/includes/manufacturing_ui.inc
manufacturing/search_work_orders.php
manufacturing/view/work_order_view.php
manufacturing/work_order_add_finished.php
manufacturing/work_order_entry.php
manufacturing/work_order_issue.php
manufacturing/work_order_release.php

index b74d579615560d5a76aea4f7b71044edd700f549..dd59d77f17c09575a3f65beca6040ee7ecb59cd3 100644 (file)
@@ -19,13 +19,24 @@ Legend:
 ! -> Note
 $ -> Affected files
 
-06-Jun-2009
+
+08-Jun-2009
+! Changed Advanced Manufacturing payments to be more flexible and simpler. Removed from Payment.
+$ /gl/includes/db/gl_db_trans.inc
+  /gl/includes/ui/gl_bank_ui.inc
+  /includes/types.inc
+  /includes/ui/ui_lists.inc
+  /manufacturing/search_work_orders.php
+  /manufacturing/work_order_costs.php (new file)
+  /manufacturing/work_order_entry.php
 # Overhead costs in Manufacturing/Assembling wasn't added to stock overhead cost
 $ /manufacturing/work_order_add_finished.php
   /manufacturing/work_order_issue.php
   /manufacturing/work_order_release.php
+  /manufacturing/includes/manufacturing_ui.inc
   /manufacturing/includes/db/work_orders_db.inc
   /manufacturing/includes/db/work_orders_quick_db.inc
+  /manufacturing/view/work_order_view.php
   
 05-Jun-2009 Joe Hunt
 # Missing underscore in gettext string
index 89eaa25243d6d1ace619fe56680326b4f0dfbbd6..3570f9c3a5974c3b510c00cb42cf446ee4082924 100644 (file)
@@ -138,6 +138,19 @@ function get_gl_trans($type, $trans_id)
 
 //--------------------------------------------------------------------------------
 
+function get_gl_wo_cost_trans($trans_id, $person_id=-1)
+{
+       $sql = "SELECT ".TB_PREF."gl_trans.*, ".TB_PREF."chart_master.account_name FROM ".TB_PREF."gl_trans, ".TB_PREF."chart_master
+               WHERE ".TB_PREF."chart_master.account_code=".TB_PREF."gl_trans.account
+               AND ".TB_PREF."gl_trans.type=".systypes::work_order()." AND ".TB_PREF."gl_trans.type_no=$trans_id
+               AND ".TB_PREF."gl_trans.person_type_id=".payment_person_types::WorkOrder();
+       if ($person_id != -1)
+               $sql .= " AND ".TB_PREF."gl_trans.person_id=$person_id";
+       $sql .= " AND amount < 0";      
+
+       return db_query($sql, "The gl transactions could not be retrieved");
+}
+
 function get_gl_balance_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0)
 {
        $from = date2sql($from_date);
index 507ff4cf4c779077fd71961744415be212f62c2a..ee3af8089a13ef184c36df2fcbeecc922a356cfc 100644 (file)
@@ -53,9 +53,9 @@ function display_bank_header(&$order)
                text_row_ex($payment ?_("To the Order of:"):_("Name:"),
                                 'person_id', 40, 50);
                break;
-               case payment_person_types::WorkOrder() :
-               workorders_list_row(_("Work Order:"), 'person_id', null);
-               break;
+               //case payment_person_types::WorkOrder() :
+       //      workorders_list_row(_("Work Order:"), 'person_id', null);
+       //      break;
                case payment_person_types::supplier() :
                supplier_list_row(_("Supplier:"), 'person_id', null, false, true);
                break;
@@ -223,8 +223,8 @@ function gl_edit_item_controls(&$order, $dim, $Index=null)
                        $acc = get_supplier_accounts($_POST['person_id']);
                        $_POST['code_id'] = $acc['payable_account'];
                }
-               elseif ($_POST['PayType'] == payment_person_types::WorkOrder())
-                       $_POST['code_id'] = get_company_pref('default_assembly_act');
+               //elseif ($_POST['PayType'] == payment_person_types::WorkOrder())
+               //      $_POST['code_id'] = get_company_pref('default_assembly_act');
                else {
                        $_POST['code_id'] =
                                get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act');
index d4f3c4a17bc4c676203a302cb6cadb718c8c2663..38c3101b39009e04d9247cf99647ce98abe25059 100644 (file)
@@ -216,8 +216,8 @@ class payment_person_types
                        $qe = get_quick_entry($person_id);
                        return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"];
                case payment_person_types::WorkOrder() :
-                       $wo = get_work_order($person_id);
-                       return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
+                       global $wo_cost_types;
+                       return $wo_cost_types[$person_id];
                case payment_person_types::customer() :
                        return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
                case payment_person_types::supplier() :
@@ -309,6 +309,14 @@ class wo_types
        }
 }
 
+define('WO_LABOUR', 0);
+define('WO_OVERHEAD', 1);
+
+$wo_cost_types = array(
+               WO_LABOUR => _("Labour Cost"),
+               WO_OVERHEAD => _("Overhead Cost"),
+);
+
 $quick_actions = array(
        '=' => _('Remainder'), // post current base amount to GL account
        'a' => _('Amount'), // post amount to GL account
@@ -337,6 +345,4 @@ $quick_entry_types = array(
                QE_SUPPINV => _("Supplier Invoice/Credit")
 );
 
-
-
 ?>
\ No newline at end of file
index e27d245ecaea5675654fb772aed1a604694d3786..a1b65af1bc4472cd0f1c15fc0f40ce5277347726 100644 (file)
@@ -1699,7 +1699,8 @@ function payment_person_types_list($name, $selected_id=null, $submit_on_change=f
        {
                if (payment_person_types::has_items($type['id']))
                {
-                       $items[$type['id']] = $type['name'];
+                       if ($type['id'] != payment_person_types::WorkOrder())
+                               $items[$type['id']] = $type['name'];
                }
        }
        
index 5b2dad2dbaba4f60b3d8e0192d910c8c9a3418dd..c9131df8ba586d790c3fc6a4d187238e14a5d73c 100644 (file)
@@ -47,7 +47,7 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo)
 
        // -------------------------------------------------------------------------
 
-       work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, 0, true);
+       work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, true);
 
        // -------------------------------------------------------------------------
        if ($memo_)
index 3150016165da215cb1d09dce07b8b7b3bbb631b7..09a402c85d0b949a05803a3a35ba07cda77f4fb7 100644 (file)
@@ -34,7 +34,7 @@ function add_material_cost($stock_id, $qty, $date_)
        db_query($sql,"The cost details for the inventory item could not be updated");
 }
 
-function add_additional_cost($stock_id, $qty, $date_, $costs)
+function add_overhead_cost($stock_id, $qty, $date_, $costs)
 {
        if ($qty != 0)
                $costs /= $qty;
@@ -52,6 +52,24 @@ function add_additional_cost($stock_id, $qty, $date_, $costs)
        db_query($sql,"The cost details for the inventory item could not be updated");
 }
 
+function add_labour_cost($stock_id, $qty, $date_, $costs)
+{
+       if ($qty != 0)
+               $costs /= $qty;
+       $sql = "SELECT labour_cost FROM ".TB_PREF."stock_master WHERE stock_id = '$stock_id'";
+       $result = db_query($sql);
+       $myrow = db_fetch($result);
+       $labour_cost =  $myrow['labour_cost'];
+       $qoh = get_qoh_on_date($stock_id, null, $date_);
+       if ($qoh + $qty <= 0)
+               $labour_cost = 0;
+       else
+               $labour_cost = ($qoh * $labour_cost + $qty * $costs) /  ($qoh + $qty);
+       $sql = "UPDATE ".TB_PREF."stock_master SET labour_cost=$labour_cost
+               WHERE stock_id='$stock_id'";
+       db_query($sql,"The cost details for the inventory item could not be updated");
+}
+
 function add_issue_cost($stock_id, $qty, $date_, $costs)
 {
        if ($qty != 0)
@@ -71,10 +89,10 @@ function add_issue_cost($stock_id, $qty, $date_, $costs)
 }
 
 function add_work_order($wo_ref, $loc_code, $units_reqd, $stock_id,
-       $type, $date_, $required_by, $costs, $memo_)
+       $type, $date_, $required_by, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc)
 {
        if (!($type == wo_types::advanced()))
-               return add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $costs, $memo_);
+               return add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc);
 
        begin_transaction();
 
@@ -191,7 +209,7 @@ function work_order_has_issues($woid)
 
 function work_order_has_payments($woid)
 {
-    $result = get_bank_trans(null, null, payment_person_types::WorkOrder(), $woid);
+       $result = get_gl_wo_cost_trans($woid);
 
     return (db_num_rows($result) != 0);
 }
index 8bd0de2869e8fb942350be55e6a7990a6cf55fff..3c9a49fe82079befd6da63a92743bef76f2f9a44 100644 (file)
@@ -11,7 +11,7 @@
 ***********************************************************************/
 //--------------------------------------------------------------------------------------
 
-function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $additional_costs, $memo_)
+function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc)
 {
        begin_transaction();
 
@@ -22,15 +22,19 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
        add_material_cost($stock_id, $units_reqd, $date_);
 
        $date = date2sql($date_);
-       if (!isset($additional_costs) || ($additional_costs == ""))
-               $additional_costs = 0;
-       if ($additional_costs != 0)
-               add_additional_cost($stock_id, $units_reqd, $date_, $additional_costs);
+       if (!isset($costs) || ($costs == ""))
+               $costs = 0;
+       if ($costs != 0)
+               add_overhead_cost($stock_id, $units_reqd, $date_, $costs);
+       if (!isset($labour) || ($labour == ""))
+               $labour = 0;
+       if ($labour != 0)
+               add_labour_cost($stock_id, $units_reqd, $date_, $labour);
                
        $sql = "INSERT INTO ".TB_PREF."workorders (wo_ref, loc_code, units_reqd, units_issued, stock_id,
                type, additional_costs, date_, released_date, required_by, released, closed)
        VALUES (".db_escape($wo_ref).", ".db_escape($loc_code).", $units_reqd, $units_reqd, '$stock_id',
-               $type, $additional_costs, '$date', '$date', '$date', 1, 1)";
+               $type, $costs, '$date', '$date', '$date', 1, 1)";
        db_query($sql, "could not add work order");
 
        $woid = db_insert_id();
@@ -68,7 +72,7 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
 
        // -------------------------------------------------------------------------
 
-       work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $additional_costs);
+       work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, false, $costs, $cr_acc, $labour, $cr_lab_acc);
 
        // -------------------------------------------------------------------------
 
@@ -82,8 +86,9 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
 
 //--------------------------------------------------------------------------------------
 
-function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $additional_costs, $advanced=false)
+function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=false, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="")
 {
+       global $wo_cost_types;
        $result = get_bom($stock_id);
 
        // credit all the components
@@ -93,7 +98,7 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $addition
 
                $bom_accounts = get_stock_gl_code($bom_item["component"]);
 
-               $bom_cost = $bom_item["standard_cost"] * $bom_item["quantity"] * $units_reqd;
+               $bom_cost = $bom_item["ComponentCost"] * $units_reqd;
 
                if ($advanced)
                {
@@ -110,11 +115,12 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $addition
        {
                // also take the additional issues
                $res = get_additional_issues($woid);
+               $wo = get_work_order($woid);
                $issue_total = 0;
                while ($item = db_fetch($res))
                {
                        $standard_cost = get_standard_cost($item['stock_id']);
-                       $issue_cost = $standard_cost * $item['qty_issued'];
+                       $issue_cost = $standard_cost * $item['qty_issued'] * $units_reqd / $wo['units_reqd'];
                        $issue = get_stock_gl_code($item['stock_id']);
                        add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $issue["inventory_account"], 0, 0,
                                null, -$issue_cost);
@@ -122,20 +128,55 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $addition
                }
                add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
                $total_cost += $issue_total;
-               $pcost = 0; // fix bank payments as additional cost.
-               $result = get_bank_trans(null, null, payment_person_types::WorkOrder(), $woid);
-               while ($row = db_fetch($result))
-                       $pcost += -$row['amount'];
-               if ($pcost != 0)        
-                       add_additional_cost($stock_id, $units_reqd, $date_, $pcost);
+               $result = get_gl_wo_cost_trans($woid, WO_LABOUR);
+               $lcost = 0;
+               while ($row = db_fetch_row($result))
+                       $lcost += -$row['amount'];
+               if ($lcost != 0)        
+                       add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']);
+               $result = get_gl_wo_cost_trans($woid, WO_OVERHEAD);
+               $ocost = 0;
+               while ($row = db_fetch_row($result))
+                       $ocost += -$row['amount'];
+               if ($ocost != 0)        
+                       add_overhead_cost($stock_id, $units_reqd, $date_, $ocost * $units_reqd / $wo['units_reqd']);
        }
        // credit additional costs
        $item_accounts = get_stock_gl_code($stock_id);
-       add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $item_accounts["assembly_account"],
-               $item_accounts["dimension_id"], $item_accounts["dimension2_id"], null, -$additional_costs);
-
-       // debit total components + additional
-       $total_cost += $additional_costs;
+       if ($costs != 0.0)
+       {
+               add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $cr_acc,
+                       0, 0, $wo_cost_types[WO_OVERHEAD], -$costs, payment_person_types::WorkOrder(), WO_OVERHEAD);
+               $is_bank_to = is_bank_account($cr_acc);
+       if ($is_bank_to)
+       {
+               add_bank_trans(systypes::work_order(), $woid, $is_bank_to, "",
+                       $date_, -$costs, payment_person_types::WorkOrder(), WO_OVERHEAD, get_company_currency(),
+                       "Cannot insert a destination bank transaction");
+       }
+                       
+               add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $item_accounts["assembly_account"],
+                       $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_OVERHEAD], $costs, 
+                       payment_person_types::WorkOrder(), WO_OVERHEAD);
+       }
+       if ($labour != 0.0)
+       {
+               add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $cr_lab_acc,
+                       0, 0, $wo_cost_types[WO_LABOUR], -$labour, payment_person_types::WorkOrder(), WO_LABOUR);
+               $is_bank_to = is_bank_account($cr_lab_acc);
+       if ($is_bank_to)
+       {
+               add_bank_trans(systypes::work_order(), $woid, $is_bank_to, "",
+                       $date_, -$labour, payment_person_types::WorkOrder(), WO_LABOUR, get_company_currency(),
+                       "Cannot insert a destination bank transaction");
+       }
+                       
+               add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $item_accounts["assembly_account"],
+                       $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_LABOUR], $labour, 
+                       payment_person_types::WorkOrder(), WO_LABOUR);
+       }
+       // debit total components
+       //$total_cost += $additional_costs;
        add_gl_trans_std_cost(systypes::work_order(), $woid, $date_, $item_accounts["inventory_account"],
                0, 0, null, $total_cost);
 }
index 6726fb34c958c2813aae1e82acc77374edf4a582..e5eaf8ccf3fdf439fce442b932507adc1fb51704 100644 (file)
@@ -224,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, payment_person_types::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(systypes::work_order(), $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();
                }
 
index bc5c53f475aadfa5a437dd7fdd841ec41f081245..ea3aae225683a22587d6e307bf4457dfc6687276 100644 (file)
@@ -130,10 +130,15 @@ function produce_link($row)
 
 function costs_link($row)
 {
+/*
        return $row["closed"] || !$row["released"] ? '' :
                pager_link(_('Costs'),
                        "/gl/gl_bank.php?NewPayment=1&PayType=" 
                        .payment_person_types::WorkOrder(). "&PayPerson=" .$row["id"]);
+*/                     
+       return $row["closed"] || !$row["released"] ? '' :
+               pager_link(_('Costs'),
+                       "/manufacturing/work_order_costs.php?trans_no=" .$row["id"]);
 }
 
 function view_gl_link($row)
index 21d2e80ba4489ead70205c528cf0f8ba34b44b64..60daf0280f555559118d2ecb7df5c85e32cf3108 100644 (file)
@@ -64,7 +64,14 @@ else
        display_heading2(_("Productions"));
        display_wo_productions($woid);
        echo "</td><td>";
-       display_heading2(_("Payments"));
+       display_heading2(_("Additional Costs"));
+       display_wo_payments($woid);
+       echo "</td></tr></table>";
+       }
+       else
+       {
+       echo "<br><table cellspacing=7><tr valign=top><td>";
+       display_heading2(_("Additional Costs"));
        display_wo_payments($woid);
        echo "</td></tr></table>";
        }
index 5afdd61f5af6920f86e62fc024179328e12ff013..f94970ba4f24bc55e25211e8cdb06db9eb9d3e51 100644 (file)
@@ -37,8 +37,17 @@ if (isset($_GET['trans_no']) && $_GET['trans_no'] != "")
 
 if (isset($_GET['AddedID']))
 {
+       include_once($path_to_root . "/reporting/includes/reporting.inc");
+       $id = $_GET['AddedID'];
+       $stype = systypes::work_order();
 
        display_notification(_("The manufacturing process has been entered."));
+       
+    display_note(get_trans_view_str($stype, $id, _("View this Work Order")));
+
+       display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1);
+       $ar = array('PARAM_0' => $_GET['date'], 'PARAM_1' => $_GET['date'], 'PARAM_2' => $stype); 
+       display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1);
 
        hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
 
@@ -158,7 +167,7 @@ if ((isset($_POST['Process']) || isset($_POST['ProcessAndClose'])) && can_proces
         $id = work_order_produce($_POST['selected_id'], $_POST['ref'], $_POST['quantity'],
                        $_POST['date_'], $_POST['memo_'], $close_wo);
 
-       meta_forward($_SERVER['PHP_SELF'], "AddedID=$id");
+       meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']."&date=".$_POST['date_']);
 }
 
 //-------------------------------------------------------------------------------------
@@ -177,7 +186,8 @@ if (!isset($_POST['quantity']) || $_POST['quantity'] == '')
        $_POST['quantity'] = max($wo_details["units_reqd"] - $wo_details["units_issued"], 0);
 }
 
-start_table();
+start_table($table_style2);
+br();
 
 ref_row(_("Reference:"), 'ref', '', references::get_next(29));
 
index c4d3dd5d1a64054dc5d6db0589ee7921faee10f2..b30209fc984fca9f5bcc04172c8ce828fd366583 100644 (file)
@@ -22,6 +22,8 @@ include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
 
 $js = "";
+if ($use_popup_windows)
+       $js .= get_js_open_window(900, 500);
 if ($use_date_picker)
        $js .= get_js_date_picker();
 page(_("Work Order Entry"), false, false, "", $js);
@@ -47,9 +49,20 @@ elseif(isset($_POST['selected_id']))
 if (isset($_GET['AddedID']))
 {
        $id = $_GET['AddedID'];
+       $stype = systypes::work_order();
 
        display_notification_centered(_("The work order been added."));
 
+    display_note(get_trans_view_str($stype, $id, _("View this Work Order")));
+
+       if ($_GET['type'] != wo_types::advanced())
+       {
+               include_once($path_to_root . "/reporting/includes/reporting.inc");
+       display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1);
+       $ar = array('PARAM_0' => $_GET['date'], 'PARAM_1' => $_GET['date'], 'PARAM_2' => $stype); 
+       display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1);
+       }
+       
        safe_exit();
 }
 
@@ -91,10 +104,8 @@ function safe_exit()
 
        hyperlink_no_params("", _("Enter a new work order"));
        hyperlink_no_params("search_work_orders.php", _("Select an existing work order"));
-       echo "<br>";
-       end_form();
-       end_page();
-       exit;
+       
+       display_footer_exit();
 }
 
 //-------------------------------------------------------------------------------------
@@ -114,14 +125,14 @@ function can_process()
        if (!references::is_valid($_POST['wo_ref']))
        {
                display_error(_("You must enter a reference."));
-               set_focus('wo_ref');
+                       set_focus('wo_ref');
                return false;
        }
 
        if (!is_new_reference($_POST['wo_ref'], systypes::work_order()))
        {
                display_error(_("The entered reference is already in use."));
-               set_focus('wo_ref');
+                       set_focus('wo_ref');
                return false;
        }
        }
@@ -151,16 +162,24 @@ function can_process()
         if (!has_bom($_POST['stock_id']))
         {
                display_error(_("The selected item to manufacture does not have a bom."));
-               set_focus('stock_id');
+                       set_focus('stock_id');
                return false;
         }
 
+               if ($_POST['Labour'] == "")
+                       $_POST['Labour'] = price_format(0);
+       if (!check_num('Labour', 0))
+       {
+               display_error( _("The labour cost entered is invalid or less than zero."));
+                       set_focus('Labour');
+               return false;
+       }
                if ($_POST['Costs'] == "")
                        $_POST['Costs'] = price_format(0);
        if (!check_num('Costs', 0))
        {
                display_error( _("The cost entered is invalid or less than zero."));
-               set_focus('Costs');
+                       set_focus('Costs');
                return false;
        }
 
@@ -184,7 +203,7 @@ function can_process()
                                {
                                        display_error(_("The work order cannot be processed because there is an insufficient quantity for component:") .
                                                " " . $bom_item["component"] . " - " .  $bom_item["description"] . ".  " . _("Location:") . " " . $bom_item["location_name"]);
-                                               set_focus('quantity');
+                                                       set_focus('quantity');
                                                return false;
                                }
                        }
@@ -206,7 +225,7 @@ function can_process()
      {
        if (!is_date($_POST['RequDate']))
        {
-               set_focus('RequDate');
+                       set_focus('RequDate');
                display_error( _("The date entered is in an invalid format."));
                return false;
                }
@@ -221,7 +240,7 @@ function can_process()
 
                if ($_POST['units_issued'] > input_num('quantity'))
                {
-                       set_focus('quantity');
+                               set_focus('quantity');
                        display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order."));
                        return false;
                }
@@ -238,9 +257,9 @@ if (isset($_POST['ADD_ITEM']) && can_process())
 
        $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'),
                $_POST['stock_id'],  $_POST['type'], $_POST['date_'],
-               $_POST['RequDate'], input_num('Costs'), $_POST['memo_']);
+               $_POST['RequDate'], $_POST['memo_'], input_num('Costs'), $_POST['cr_acc'], input_num('Labour'), $_POST['cr_lab_acc']);
 
-       meta_forward($_SERVER['PHP_SELF'], "AddedID=$id");
+       meta_forward($_SERVER['PHP_SELF'], "AddedID=$id&type=".$_POST['type']."&date=".$_POST['date_']);
 }
 
 //-------------------------------------------------------------------------------------
@@ -391,10 +410,24 @@ else
     date_row(_("Date") . ":", 'date_');
        hidden('RequDate', '');
 
+       $sql = "SELECT DISTINCT account_code FROM ".TB_PREF."bank_accounts";
+       $rs = db_query($sql,"could not get bank accounts");
+       $r = db_fetch_row($rs);
+       if (!isset($_POST['Labour']))
+       {
+               $_POST['Labour'] = price_format(0);
+               $_POST['cr_lab_acc'] = $r[0];
+       }
+       amount_row($wo_cost_types[WO_LABOUR], 'Labour');
+       gl_all_accounts_list_row(_("Credit Labour Account"), 'cr_lab_acc', null);
        if (!isset($_POST['Costs']))
+       {
                $_POST['Costs'] = price_format(0);
-
-       amount_row(_("Total Additional Costs:"), 'Costs');
+               $_POST['cr_acc'] = $r[0];
+       }
+       amount_row($wo_cost_types[WO_OVERHEAD], 'Costs');
+       gl_all_accounts_list_row(_("Credit Overhead Account"), 'cr_acc', null);
+       
 }
 
 if ($_POST['released'])
index c6afb08b2ec7fa92e3ba06d4a8f6d89029376eff..0a014d066eda77f4cc1fd4ccfaea79e29ef8ca67 100644 (file)
@@ -34,6 +34,8 @@ if (isset($_GET['AddedID']))
 {
        display_notification(_("The work order issue has been entered."));
 
+    display_note(get_trans_view_str(systypes::work_order(), $_GET['AddedID'], _("View this Work Order")));
+
        hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
 
        display_footer_exit();
@@ -120,7 +122,7 @@ if (isset($_POST['Process']) && can_process())
        } 
        else 
        {
-               meta_forward($_SERVER['PHP_SELF'], "AddedID=1");
+               meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_SESSION['issue_items']->order_id);
        }
 
 } /*end of process credit note */
index e8efcfd8b70ce222f3ac8d01f679784327be6bfc..b6d518aeb77a5484710896e37d55be1dbd8f3ade 100644 (file)
@@ -20,6 +20,8 @@ include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
 
 $js = "";
+if ($use_popup_windows)
+       $js .= get_js_open_window(800, 500);
 if ($use_date_picker)
        $js .= get_js_date_picker();
 page(_("Work Order Release to Manufacturing"), false, false, "", $js);
@@ -67,6 +69,8 @@ if (isset($_POST['release']))
 
        display_notification(_("The work order has been released to manufacturing."));
 
+    display_note(get_trans_view_str(systypes::work_order(), $selected_id, _("View this Work Order")));
+
        hyperlink_no_params("search_work_orders.php", _("Select another &work order"));
 
        $Ajax->activate('_page_body');