From: Joe Hunt Date: Mon, 8 Jun 2009 20:10:09 +0000 (+0000) Subject: Changed Advanced Manufacturing payments to be more flexible and simpler. Removed... X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c1c7dd09f2670cc0ac1f1b058c3c231b9f6800ee;p=textcart.git Changed Advanced Manufacturing payments to be more flexible and simpler. Removed from Payment. Overhead costs in Manufacturing/Assembling wasn't added to stock overhead cost --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b74d579..dd59d77 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 89eaa25..3570f9c 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -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); diff --git a/gl/includes/ui/gl_bank_ui.inc b/gl/includes/ui/gl_bank_ui.inc index 507ff4c..ee3af80 100644 --- a/gl/includes/ui/gl_bank_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -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'); diff --git a/includes/types.inc b/includes/types.inc index d4f3c4a..38c3101 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -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 diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index e27d245..a1b65af 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -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']; } } diff --git a/manufacturing/includes/db/work_order_produce_items_db.inc b/manufacturing/includes/db/work_order_produce_items_db.inc index 5b2dad2..c9131df 100644 --- a/manufacturing/includes/db/work_order_produce_items_db.inc +++ b/manufacturing/includes/db/work_order_produce_items_db.inc @@ -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_) diff --git a/manufacturing/includes/db/work_orders_db.inc b/manufacturing/includes/db/work_orders_db.inc index 3150016..09a402c 100644 --- a/manufacturing/includes/db/work_orders_db.inc +++ b/manufacturing/includes/db/work_orders_db.inc @@ -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); } diff --git a/manufacturing/includes/db/work_orders_quick_db.inc b/manufacturing/includes/db/work_orders_quick_db.inc index 8bd0de2..3c9a49f 100644 --- a/manufacturing/includes/db/work_orders_quick_db.inc +++ b/manufacturing/includes/db/work_orders_quick_db.inc @@ -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); } diff --git a/manufacturing/includes/manufacturing_ui.inc b/manufacturing/includes/manufacturing_ui.inc index 6726fb3..e5eaf8c 100644 --- a/manufacturing/includes/manufacturing_ui.inc +++ b/manufacturing/includes/manufacturing_ui.inc @@ -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(); } diff --git a/manufacturing/search_work_orders.php b/manufacturing/search_work_orders.php index bc5c53f..ea3aae2 100644 --- a/manufacturing/search_work_orders.php +++ b/manufacturing/search_work_orders.php @@ -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) diff --git a/manufacturing/view/work_order_view.php b/manufacturing/view/work_order_view.php index 21d2e80..60daf02 100644 --- a/manufacturing/view/work_order_view.php +++ b/manufacturing/view/work_order_view.php @@ -64,7 +64,14 @@ else display_heading2(_("Productions")); display_wo_productions($woid); echo ""; - display_heading2(_("Payments")); + display_heading2(_("Additional Costs")); + display_wo_payments($woid); + echo ""; + } + else + { + echo "
"; + display_heading2(_("Additional Costs")); display_wo_payments($woid); echo "
"; } diff --git a/manufacturing/work_order_add_finished.php b/manufacturing/work_order_add_finished.php index 5afdd61..f94970b 100644 --- a/manufacturing/work_order_add_finished.php +++ b/manufacturing/work_order_add_finished.php @@ -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)); diff --git a/manufacturing/work_order_entry.php b/manufacturing/work_order_entry.php index c4d3dd5..b30209f 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -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 "
"; - 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']) diff --git a/manufacturing/work_order_issue.php b/manufacturing/work_order_issue.php index c6afb08..0a014d0 100644 --- a/manufacturing/work_order_issue.php +++ b/manufacturing/work_order_issue.php @@ -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 */ diff --git a/manufacturing/work_order_release.php b/manufacturing/work_order_release.php index e8efcfd..b6d518a 100644 --- a/manufacturing/work_order_release.php +++ b/manufacturing/work_order_release.php @@ -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');