From: Janusz Dobrowolski Date: Thu, 26 Jun 2008 14:47:00 +0000 (+0000) Subject: Ajax additions X-Git-Tag: v2.4.2~19^2~1969 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=5cae8206ae7eaf4df4b95b7f2184e2332f85ec8d;p=fa-stable.git Ajax additions --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7290c5a2..f1d9676b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,22 @@ Legend: ! -> Note $ -> Affected files +26-Jun-2008 Janusz Dobrowolski ++ Ajax additions +$ /includes/ui/ui_lists.inc + /inventory/adjustments.php + /inventory/cost_update.php + /inventory/prices.php + /inventory/transfers.php + /inventory/includes/item_adjustments_ui.inc + /inventory/includes/stock_transfers_ui.inc + /inventory/inquiry/stock_movements.php + /inventory/manage/items.php + /manufacturing/work_order_entry.php + /purchasing/po_entry_items.php +! Changes to items_cart API (line_items indexed by line# instead of stock_id) +$ /includes/ui/items_cart.inc + 25-Jun-2008 Joe Hunt # Fixed 'div end out of order' in invoice_ui.inc causing the newwave bug with missing menu $ /purchasing/includes/ui/invoice_ui.inc diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 300efd41..3bdd6d88 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -540,7 +540,7 @@ function stock_items_list_cells($label, $name, $selected_id, $all_option=false, if ($label != null) echo "$label\n"; $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change, - array('cells'=>true)); + array('cells'=>true)); return $str; } /* @@ -642,8 +642,18 @@ function stock_component_items_list($name, $parent_stock_id, $selected_id, function stock_costable_items_list($name, $selected_id, $all_option=false, $submit_on_change=false) { - return base_stock_items_list("mb_flag!='D'", $name, $selected_id, - $all_option, $submit_on_change); + $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change, + array('where'=>array("mb_flag!='D'"))); + return $str; +} + +function stock_costable_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false) +{ + if ($label != null) + echo "$label\n"; + $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change, + array('where'=>array("mb_flag!='D'"), 'cells'=>true)); + return $str; } //------------------------------------------------------------------------------------ @@ -1466,8 +1476,8 @@ function wo_types_list($name, $selected_id) { $types = wo_types::get_all(); - default_focus($name); // FIX ajax - echo ""; if ($selected_id == null) $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]); diff --git a/inventory/adjustments.php b/inventory/adjustments.php index 1f9d04a5..2f837fa0 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -40,7 +40,14 @@ if (isset($_GET['AddedID'])) display_footer_exit(); } +//-------------------------------------------------------------------------------------------------- + +function line_start_focus() { + global $Ajax; + $Ajax->activate('items_table'); + set_focus('_stock_id_edit'); +} //-------------------------------------------------------------------------------------------------- function copy_to_st() @@ -51,7 +58,6 @@ function copy_to_st() $_SESSION['adj_items']->increase = $_POST['Increase']; $_SESSION['adj_items']->memo_ = $_POST['memo_']; } - //-------------------------------------------------------------------------------------------------- function copy_from_st() @@ -86,6 +92,13 @@ function handle_new_order() function can_process() { + $adj = &$_SESSION['adj_items']; + + if (count($adj->line_items) == 0) { + display_error(_("You must enter at least one non empty item line.")); + set_focus('stock_id'); + return false; + } if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); @@ -111,15 +124,18 @@ function can_process() display_error(_("The entered date is not in fiscal year.")); set_focus('AdjDate'); return false; - } - $failed_item = $_SESSION['adj_items']->check_qoh($_POST['StockLocation'], $_POST['AdjDate'], !$_POST['Increase']); - if ($failed_item != null) - { - display_error(_("The adjustment cannot be processed because an adjustment item would cause a negative inventory balance :") . - " " . $failed_item->stock_id . " - " . $failed_item->item_description); + } else { + $failed_item = $adj->check_qoh($_POST['StockLocation'], $_POST['AdjDate'], !$_POST['Increase']); + if ($failed_item >= 0) + { + $line = $adj->line_items[$failed_item]; + display_error(_("The adjustment cannot be processed because an adjustment item would cause a negative inventory balance :") . + " " . $line->stock_id . " - " . $line->item_description); + $_POST['Edit'.$failed_item] = 1; // enter edit mode + unset($_POST['Process']); return false; + } } - return true; } @@ -133,6 +149,7 @@ if (isset($_POST['Process']) && can_process()){ $_SESSION['adj_items']->clear_items(); unset($_SESSION['adj_items']); + meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); } /*end of process credit note */ @@ -163,16 +180,19 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { - $_SESSION['adj_items']->update_cart_item($_POST['stock_id'], - input_num('qty'), input_num('std_cost')); + $id = $_POST['LineNo']; + $_SESSION['adj_items']->update_cart_item($id, input_num('qty'), + input_num('std_cost')); } + line_start_focus(); } //----------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($id) { - $_SESSION['adj_items']->remove_from_cart($_GET['Delete']); + $_SESSION['adj_items']->remove_from_cart($id); + line_start_focus(); } //----------------------------------------------------------------------------------------------- @@ -184,25 +204,28 @@ function handle_new_item() add_to_order($_SESSION['adj_items'], $_POST['stock_id'], input_num('qty'), input_num('std_cost')); + line_start_focus(); } //----------------------------------------------------------------------------------------------- +$id = find_submit('Delete'); +if ($id != -1) + handle_delete_item($id); -if (isset($_GET['Delete']) || isset($_GET['Edit'])) - copy_from_st(); - -if (isset($_GET['Delete'])) - handle_delete_item(); - -if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) +if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) { copy_to_st(); - + line_start_focus(); +} + if (isset($_POST['AddItem'])) handle_new_item(); if (isset($_POST['UpdateItem'])) handle_update_item(); +if (isset($_POST['CancelItemChanges'])) { + line_start_focus(); +} //----------------------------------------------------------------------------------------------- if (isset($_GET['NewAdjustment']) || !isset($_SESSION['adj_items'])) @@ -211,7 +234,6 @@ if (isset($_GET['NewAdjustment']) || !isset($_SESSION['adj_items'])) } //----------------------------------------------------------------------------------------------- - start_form(false, true); display_order_header($_SESSION['adj_items']); @@ -225,15 +247,8 @@ echo ""; end_row(); end_table(1); -start_table(); -start_row(); -submit_cells('Update', _("Update")); -if ($_SESSION['adj_items']->count_items() >= 1) -{ - submit_cells('Process', _("Process Adjustment")); -} -end_row(); -end_table(); +submit_center_first('Update', _("Update"), '', true); +submit_center_last('Process', _("Process Transfer"), '', true); end_form(); end_page(); diff --git a/inventory/cost_update.php b/inventory/cost_update.php index 82dfb0db..ff58f9eb 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -26,7 +26,6 @@ if (isset($_GET['stock_id'])) } //-------------------------------------------------------------------------------------- - if (isset($_POST['UpdateData'])) { @@ -80,11 +79,11 @@ stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); echo "
"; set_global_stock_item($_POST['stock_id']); -$sql = "SELECT description, units, last_cost, actual_cost, material_cost, labour_cost, +$sql = "SELECT description, units, material_cost, labour_cost, overhead_cost, mb_flag FROM ".TB_PREF."stock_master WHERE stock_id='" . $_POST['stock_id'] . "' - GROUP BY description, units, last_cost, actual_cost, material_cost, labour_cost, overhead_cost, mb_flag"; + GROUP BY description, units, material_cost, labour_cost, overhead_cost, mb_flag"; $result = db_query($sql); check_db_error("The cost details for the item could not be retrieved", $sql); @@ -95,18 +94,20 @@ hidden("OldLabourCost", $myrow["labour_cost"]); hidden("OldOverheadCost", $myrow["overhead_cost"]); start_table($table_style2); -label_row(_("Last Cost"), price_format($myrow["last_cost"]), - "class='tableheader2'", "nowrap align=right"); + +$_POST['material_cost'] = price_format($myrow["material_cost"]); +$_POST['labour_cost'] = price_format($myrow["labour_cost"]); +$_POST['overhead_cost'] = price_format($myrow["overhead_cost"]); amount_row(_("Standard Material Cost Per Unit"), "material_cost", - price_format($myrow["material_cost"]), "class='tableheader2'"); + null, "class='tableheader2'"); if ($myrow["mb_flag"]=='M') { amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", - price_format($myrow["labour_cost"]), "class='tableheader2'"); + null, "class='tableheader2'"); amount_row(_("Standard Overhead Cost Per Unit"), "overhead_cost", - price_format($myrow["overhead_cost"]), "class='tableheader2'"); + null, "class='tableheader2'"); } else { diff --git a/inventory/includes/item_adjustments_ui.inc b/inventory/includes/item_adjustments_ui.inc index b4d8edd5..e52395b2 100644 --- a/inventory/includes/item_adjustments_ui.inc +++ b/inventory/includes/item_adjustments_ui.inc @@ -7,21 +7,10 @@ include_once($path_to_root . "/includes/ui/items_cart.inc"); function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost) { - $allready_on_order = 0; - - foreach ($order->line_items as $order_item) - { - if (strcasecmp($order_item->stock_id, $new_item) == 0) - { - $allready_on_order = 1; - display_error(_("For Part :") . $new_item . " " . "This item is already on this order. You can change the quantity ordered of the existing line if necessary."); - } - } - - if ($allready_on_order != 1) - { - $order->add_to_cart ($new_item, $new_item_qty, $standard_cost); - } /* end of if not already on the order */ + if ($order->find_cart_item($new_item)) + display_error(_("For Part :") . $new_item . " " . "This item is already on this order. You can change the quantity ordered of the existing line if necessary."); + else + $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost); } //-------------------------------------------------------------------------------- @@ -70,6 +59,7 @@ function display_adjustment_items($title, &$order) global $table_style, $path_to_root; display_heading($title); + div_start('items_table'); start_table("$table_style width=80%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Unit Cost"), _("Total")); @@ -79,68 +69,73 @@ function display_adjustment_items($title, &$order) $total = 0; $k = 0; //row colour counter - foreach ($order->line_items as $stock_item) + $id = find_submit('Edit'); + foreach ($order->line_items as $line_no=>$stock_item) { - $quantity = number_format2($stock_item->quantity,user_qty_dec()); - $total += ($stock_item->standard_cost * $stock_item->quantity); - if (!isset($_GET['Edit']) || $_GET['Edit'] != $stock_item->stock_id) + if ($id != $line_no) { alt_table_row_color($k); label_cell("$stock_item->stock_id"); label_cell($stock_item->item_description); - label_cell($quantity, "nowrap align=right"); + qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id)); label_cell($stock_item->units); amount_cell($stock_item->standard_cost); amount_cell($stock_item->standard_cost * $stock_item->quantity); - edit_link_cell(SID . "Edit=$stock_item->stock_id"); - delete_link_cell(SID . "Delete=$stock_item->stock_id"); + edit_button_cell("Edit$line_no", _("Edit"), + _('Edit document line')); + edit_button_cell("Delete$line_no", _("Delete"), + _('Remove line from document')); end_row(); } else { - adjustment_edit_item_controls($order, $stock_item->stock_id); + adjustment_edit_item_controls($order, $line_no); } } - if (!isset($_GET['Edit'])) + if ($id == -1) adjustment_edit_item_controls($order); label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right"); end_table(); + div_end(); } //--------------------------------------------------------------------------------- -function adjustment_edit_item_controls(&$order, $stock_id=null) +function adjustment_edit_item_controls(&$order, $line_no=-1) { + global $Ajax; start_row(); - if (isset($_GET['Edit']) and $stock_id!=null) + $id = find_submit('Edit'); + if ($line_no != -1 && $line_no == $id) { - if (!isset($_POST['stock_id'])) - $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id; - if (!isset($_POST['qty']) OR ($_POST['qty']=="")) - $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity, $order->line_items[$stock_id]->stock_id, $dec); - if (!isset($_POST['std_cost']) OR ($_POST['std_cost']=="")) - $_POST['std_cost'] = price_format($order->line_items[$stock_id]->standard_cost); - - $_POST['units'] = $order->line_items[$stock_id]->units; + $_POST['stock_id'] = $order->line_items[$id]->stock_id; + $_POST['qty'] = qty_format($order->line_items[$id]->quantity, + $order->line_items[$id]->stock_id, $dec); + $_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost); + $_POST['units'] = $order->line_items[$id]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); - label_cell($order->line_items[$stock_id]->item_description); + label_cell($order->line_items[$id]->item_description); + $Ajax->activate('items_table'); } else { - echo ""; - stock_costable_items_list('stock_id', null, false, true); - echo ""; + stock_costable_items_list_cells(null, 'stock_id', null, false, true); + if(isset($_POST['_stock_id_update'])) { + $Ajax->activate('units'); + $Ajax->activate('qty'); + $Ajax->activate('std_cost'); + } $item_info = get_item_edit_info($_POST['stock_id']); @@ -150,19 +145,24 @@ function adjustment_edit_item_controls(&$order, $stock_id=null) } qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); + label_cell($_POST['units'], '', 'units'); - label_cell($_POST['units']); amount_cells(null, 'std_cost', $_POST['std_cost']); label_cell(" "); - if (isset($_GET['Edit'])) + if ($id != -1) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); + edit_button_cell('UpdateItem', _("Update"), + _('Confirm changes')); + edit_button_cell('CancelItemChanges', _("Cancel"), + _('Cancel changes')); + hidden('LineNo', $line_no); + set_focus('qty'); } else { - submit_cells('AddItem', _("Add Item"), "colspan=2"); + submit_cells('AddItem', _("Add Item"), "colspan=2", + _('Add new item to document'), true); } end_row(); diff --git a/inventory/includes/stock_transfers_ui.inc b/inventory/includes/stock_transfers_ui.inc index 48182ed8..eb68bc47 100644 --- a/inventory/includes/stock_transfers_ui.inc +++ b/inventory/includes/stock_transfers_ui.inc @@ -7,21 +7,10 @@ include_once($path_to_root . "/includes/ui/items_cart.inc"); function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost) { - $already_on_order = 0; - - foreach ($order->line_items as $order_item) - { - if (strcasecmp($order_item->stock_id, $new_item) == 0) - { - $already_on_order = 1; - display_error(_("For Part :") . $new_item . " " . "This item is already on this order. You can change the quantity ordered of the existing line if necessary."); - } - } - - if ($already_on_order != 1) - { - $order->add_to_cart ($new_item, $new_item_qty, $standard_cost); - } /* end of if not already on the order */ + if ($order->find_cart_item($new_item)) + display_error(_("For Part :") . $new_item . " " . "This item is already on this order. You can change the quantity ordered of the existing line if necessary."); + else + $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost); } //-------------------------------------------------------------------------------- @@ -66,18 +55,18 @@ function display_transfer_items($title, &$order) global $table_style, $path_to_root; display_heading($title); + div_start('items_table'); start_table("$table_style width=80%"); - $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),''); + $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), ''); table_header($th); $subtotal = 0; $k = 0; //row colour counter - foreach ($order->line_items as $stock_item) + $id = find_submit('Edit'); + foreach ($order->line_items as $line_no=>$stock_item) { - $quantity = number_format2($stock_item->quantity,user_qty_dec()); - - if (!isset($_GET['Edit']) || $_GET['Edit'] != $stock_item->stock_id) + if ($id != $line_no) { alt_table_row_color($k); @@ -86,46 +75,51 @@ function display_transfer_items($title, &$order) qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id)); label_cell($stock_item->units); - edit_link_cell(SID . "Edit=$stock_item->stock_id"); - delete_link_cell(SID . "Delete=$stock_item->stock_id"); + edit_button_cell("Edit$line_no", _("Edit"), + _('Edit document line')); + edit_button_cell("Delete$line_no", _("Delete"), + _('Remove line from document')); end_row(); } else { - transfer_edit_item_controls($order, $stock_item->stock_id); + transfer_edit_item_controls($order, $line_no); } } - if (!isset($_GET['Edit'])) + if ($id == -1) transfer_edit_item_controls($order); end_table(); + div_end(); } //--------------------------------------------------------------------------------- -function transfer_edit_item_controls(&$order, $stock_id=null) +function transfer_edit_item_controls(&$order, $line_no=-1) { + global $Ajax; start_row(); - if (isset($_GET['Edit']) and $stock_id!=null) + $id = find_submit('Edit'); + if ($line_no != -1 && $line_no == $id) { - if (!isset($_POST['stock_id'])) - $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id; - if (!isset($_POST['qty']) || $_POST['qty'] == '') - $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity, $order->line_items[$stock_id]->stock_id, $dec); - - $_POST['units'] = $order->line_items[$stock_id]->units; + $_POST['stock_id'] = $order->line_items[$id]->stock_id; + $_POST['qty'] = qty_format($order->line_items[$id]->quantity, $order->line_items[$id]->stock_id, $dec); + $_POST['units'] = $order->line_items[$id]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); - label_cell($order->line_items[$stock_id]->item_description); + label_cell($order->line_items[$id]->item_description); + $Ajax->activate('items_table'); } else { - echo ""; - stock_costable_items_list('stock_id', null, false, true); - echo ""; + stock_costable_items_list_cells(null, 'stock_id', null, false, true); + if(isset($_POST['_stock_id_update'])) { + $Ajax->activate('units'); + $Ajax->activate('qty'); + } $item_info = get_item_edit_info($_POST['stock_id']); @@ -133,18 +127,22 @@ function transfer_edit_item_controls(&$order, $stock_id=null) $_POST['units'] = $item_info["units"]; } - small_qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); - label_cell($_POST['units']); + label_cell($_POST['units'], '', 'units'); - if (isset($_GET['Edit'])) + if ($id != -1) { - submit_cells('UpdateItem', _("Update")); - submit_cells('CancelItemChanges', _("Cancel")); + edit_button_cell('UpdateItem', _("Update"), + _('Confirm changes')); + edit_button_cell('CancelItemChanges', _("Cancel"), + _('Cancel changes')); + hidden('LineNo', $line_no); + set_focus('qty'); } else { - submit_cells('AddItem', _("Add Item"), "colspan=2"); + submit_cells('AddItem', _("Add Item"), "colspan=2", + _('Add new item to document'), true); } end_row(); diff --git a/inventory/inquiry/stock_movements.php b/inventory/inquiry/stock_movements.php index 944cb437..0f4b21da 100644 --- a/inventory/inquiry/stock_movements.php +++ b/inventory/inquiry/stock_movements.php @@ -17,6 +17,12 @@ if ($use_date_picker) $js .= get_js_date_picker(); page(_("Inventory Item Movement"), false, false, "", $js); +//------------------------------------------------------------------------------------------------ + +if(get_post('ShowMoves')) +{ + $Ajax->activate('doc_tbl'); +} if (isset($_GET['stock_id'])) { @@ -37,7 +43,7 @@ locations_list_cells(_("From Location:"), 'StockLocation', null); date_cells(_("From:"), 'AfterDate', '', null, -30); date_cells(_("To:"), 'BeforeDate'); -submit_cells('ShowMoves',_("Show Movements")); +submit_cells('ShowMoves',_("Show Movements"),'',_('Refresh Inquiry'), true); end_table(); end_form(); @@ -56,6 +62,7 @@ $result = db_query($sql, "could not query stock moves"); check_db_error("The stock movements for the selected criteria could not be retrieved",$sql); +div_start('doc_tbl'); start_table("$table_style width=70%"); $th = array(_("Type"), _("#"), _("Reference"), _("Date"), _("Detail"), _("Quantity In"), _("Quantity Out"), _("Quantity On Hand")); @@ -114,7 +121,6 @@ while ($myrow = db_fetch($result)) label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"], $myrow["reference"])); - label_cell($trandate); $person = $myrow["person_id"]; @@ -179,7 +185,7 @@ while ($myrow = db_fetch($result)) //} end_table(1); - +div_end(); end_page(); ?> diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 967cb5e6..24335def 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -13,6 +13,7 @@ include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); $user_comp = user_company(); +$new_item = (!isset($_POST['stock_id']) || $_POST['stock_id'] == ""); //------------------------------------------------------------------------------------ if (isset($_GET['stock_id'])) @@ -24,15 +25,17 @@ else if (isset($_POST['stock_id'])) $stock_id = strtoupper($_POST['stock_id']); } -if (isset($_GET['New']) || !isset($_POST['NewStockID'])) -{ - $_POST['New'] = "1"; -} - -if (isset($_POST['SelectStockItem'])) -{ +if(get_post('_stock_id_update')) { $_POST['NewStockID'] = $_POST['stock_id']; - unset($_POST['New']); + if ($new_item) { + clear_data(); + set_focus('NewStockID'); + } else { + set_focus('description'); + } + $Ajax->activate('details'); + $Ajax->activate('controls'); +// unset($_POST['New']); } $upload_file = ""; if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '') @@ -88,6 +91,8 @@ check_db_has_item_tax_types(_("There are no item tax types defined in the system function clear_data() { + global $new_item; + unset($_POST['long_description']); unset($_POST['description']); unset($_POST['category_id']); @@ -97,7 +102,7 @@ function clear_data() unset($_POST['NewStockID']); unset($_POST['dimension_id']); unset($_POST['dimension2_id']); - $_POST['New'] = "1"; + $new_item = true; } //------------------------------------------------------------------------------------ @@ -133,7 +138,7 @@ if (isset($_POST['addupdate'])) if ($input_error != 1) { - if (!isset($_POST['New'])) + if (!$new_item) { /*so its an existing one */ update_item($_POST['NewStockID'], $_POST['description'], @@ -142,6 +147,9 @@ if (isset($_POST['addupdate'])) $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id']); + display_notification(_("Item has been updated.")); + set_focus('stock_id'); + $Ajax->activate('details'); //update image if any } else { //it is a NEW part @@ -152,8 +160,13 @@ if (isset($_POST['addupdate'])) $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id']); + + display_notification(_("A new item has been added.")); + $_POST['stock_id'] = $_POST['NewStockID']; + $new_item = false; + set_focus('stock_id'); + $Ajax->activate('_page_body'); } - meta_forward($_SERVER['PHP_SELF']); } } @@ -212,7 +225,13 @@ if (isset($_POST['delete']) && strlen($_POST['delete']) > 1) $filename = $comp_path . "/$user_comp/images/$stock_id.jpg"; if (file_exists($filename)) unlink($filename); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_("Selected item has been deleted.")); + $new_item = true; + $_POST['stock_id'] = ''; + clear_data(); + set_focus('stock_id'); + $Ajax->activate('_page_body'); +// meta_forward($_SERVER['PHP_SELF']); } } @@ -224,28 +243,28 @@ if (db_has_stock_items()) { start_table("class='tablestyle_noborder'"); start_row(); - stock_items_list_cells(_("Select an item:"), 'stock_id', null); - submit_cells('SelectStockItem', _("Edit Item")); + stock_items_list_cells(_("Select an item:"), 'stock_id', null, + _('New item'), true); +// submit_cells('SelectStockItem', _("Edit Item")); end_row(); end_table(); } -hyperlink_params($_SERVER['PHP_SELF'], _("Enter a new item"), "New=1"); -echo "
"; +//hyperlink_params($_SERVER['PHP_SELF'], _("Enter a new item"), "New=1"); +//echo "
"; +div_start('details'); start_table("$table_style2 width=40%"); table_section_title(_("Item")); //------------------------------------------------------------------------------------ -if (!isset($_POST['NewStockID']) || isset($_POST['New'])) +if (!isset($_POST['NewStockID']) || $new_item) { /*If the page was called without $_POST['NewStockID'] passed to page then assume a new item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden stock_id field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ - hidden('New', 'Yes'); - text_row(_("Item Code:"), 'NewStockID', null, 21, 20); $company_record = get_company_prefs(); @@ -269,7 +288,7 @@ if (!isset($_POST['NewStockID']) || isset($_POST['New'])) else { // Must be modifying an existing item - if (!isset($_POST['New'])) + if (!$new_item) { $myrow = get_item($_POST['NewStockID']); @@ -320,10 +339,10 @@ stock_categories_list_row(_("Category:"), 'category_id', null); item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null); stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, - (!isset($_POST['NewStockID']) || isset($_POST['New']))); + (!isset($_POST['NewStockID']) || $new_item)); stock_units_list_row(_('Units of Measure:'), 'units', null, - (!isset($_POST['NewStockID']) || isset($_POST['New']))); + (!isset($_POST['NewStockID']) || $new_item)); end_table(); start_table("$table_style2 width=40%"); @@ -364,20 +383,20 @@ if ($dim < 2) hidden('dimension2_id', 0); end_table(1); - -if (!isset($_POST['NewStockID']) || (isset($_POST['New']) && $_POST['New'] != "")) +div_end(); +div_start('controls'); +if (!isset($_POST['NewStockID']) || $new_item) { - submit_center('addupdate', _("Insert New Item")); - + submit_center('addupdate', _("Insert New Item"), true, '', true); } else { - submit_center_first('addupdate', _("Update Item")); + submit_center_first('addupdate', _("Update Item"), '', true); - submit_center_last('delete', _("Delete This Item")); + submit_center_last('delete', _("Delete This Item"), '', true); } - +div_end(); end_form(); //------------------------------------------------------------------------------------ diff --git a/inventory/prices.php b/inventory/prices.php index 7a8e53e1..fd74e70a 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -108,8 +108,10 @@ if (isset($_GET['delete'])) echo _("The selected price has been deleted."); } -if (isset($_POST['_stock_id_update'])) +if (isset($_POST['_stock_id_update'])) { $Ajax->activate('price_table'); + $Ajax->activate('price'); +} //--------------------------------------------------------------------------------------------------- $mb_flag = get_mb_flag($_POST['stock_id']); diff --git a/inventory/transfers.php b/inventory/transfers.php index c28604c0..b76557a0 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -18,7 +18,6 @@ if ($use_date_picker) $js .= get_js_date_picker(); page(_("Inventory Location Transfers"), false, false, "", $js); - //----------------------------------------------------------------------------------------------- check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items).")); @@ -39,7 +38,14 @@ if (isset($_GET['AddedID'])) display_footer_exit(); } +//-------------------------------------------------------------------------------------------------- + +function line_start_focus() { + global $Ajax; + $Ajax->activate('items_table'); + set_focus('_stock_id_edit'); +} //-------------------------------------------------------------------------------------------------- function copy_to_st() @@ -50,7 +56,6 @@ function copy_to_st() $_SESSION['transfer_items']->transfer_type = $_POST['type']; $_SESSION['transfer_items']->memo_ = $_POST['memo_']; } - //-------------------------------------------------------------------------------------------------- function copy_from_st() @@ -86,8 +91,14 @@ function handle_new_order() if (isset($_POST['Process'])) { + $tr = &$_SESSION['transfer_items']; $input_error = 0; + if (count($tr->line_items) == 0) { + display_error(_("You must enter at least one non empty item line.")); + set_focus('stock_id'); + return false; + } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); @@ -120,12 +131,14 @@ if (isset($_POST['Process'])) } else { - $failed_item = $_SESSION['transfer_items']->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true); - if ($failed_item != null) + $failed_item = $tr->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true); + if ($failed_item >= 0) { + $line = $tr->line_items[$failed_item]; display_error(_("The quantity entered is greater than the available quantity for this item at the source location :") . - " " . $failed_item->stock_id . " - " . $failed_item->item_description); + " " . $line->stock_id . " - " . $line->item_description); echo "
"; + $_POST['Edit'.$failed_item] = 1; // enter edit mode $input_error = 1; } } @@ -153,20 +166,12 @@ if (isset($_POST['Process'])) function check_item_data() { - if (!check_num('qty')) - { - display_error( _("The quantity entered is not a valid number.")); - set_focus('qty'); - return false; - } - if (!check_num('qty', 0)) { display_error(_("The quantity entered must be a positive number.")); set_focus('qty'); return false; } - return true; } @@ -176,17 +181,20 @@ function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { + $id = $_POST['LineNo']; if (!isset($_POST['std_cost'])) - $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$_POST['stock_id']]->standard_cost; - $_SESSION['transfer_items']->update_cart_item($_POST['stock_id'], input_num('qty'), $_POST['std_cost']); + $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$id]->standard_cost; + $_SESSION['transfer_items']->update_cart_item($id, input_num('qty'), $_POST['std_cost']); } + line_start_focus(); } //----------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($id) { - $_SESSION['transfer_items']->remove_from_cart($_GET['Delete']); + $_SESSION['transfer_items']->remove_from_cart($id); + line_start_focus(); } //----------------------------------------------------------------------------------------------- @@ -198,18 +206,21 @@ function handle_new_item() if (!isset($_POST['std_cost'])) $_POST['std_cost'] = 0; add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], input_num('qty'), $_POST['std_cost']); + line_start_focus(); } //----------------------------------------------------------------------------------------------- +$id = find_submit('Delete'); +if ($id != -1) + handle_delete_item($id); -if (isset($_GET['Delete']) || isset($_GET['Edit'])) - copy_from_st(); - -if (isset($_GET['Delete'])) - handle_delete_item(); +//if (isset($_GET['Delete']) || isset($_GET['Edit'])) +// copy_from_st(); -if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) - copy_to_st(); +if (isset($_POST['AddItem']) || isset($_POST['UpdateItem'])) { + copy_to_st(); + line_start_focus(); +} if (isset($_POST['AddItem'])) handle_new_item(); @@ -217,6 +228,9 @@ if (isset($_POST['AddItem'])) if (isset($_POST['UpdateItem'])) handle_update_item(); +if (isset($_POST['CancelItemChanges'])) { + line_start_focus(); +} //----------------------------------------------------------------------------------------------- if (isset($_GET['NewTransfer']) || !isset($_SESSION['transfer_items'])) @@ -225,7 +239,6 @@ if (isset($_GET['NewTransfer']) || !isset($_SESSION['transfer_items'])) } //----------------------------------------------------------------------------------------------- - start_form(false, true); display_order_header($_SESSION['transfer_items']); @@ -239,16 +252,9 @@ echo ""; end_row(); end_table(1); -if (!isset($_POST['Process'])) -{ - if ($_SESSION['transfer_items']->count_items() >= 1) - { - submit_center_first('Update', _("Update")); - submit_center_last('Process', _("Process Transfer")); - } - else - submit_center('Update', _("Update")); -} +submit_center_first('Update', _("Update"), '', true); +submit_center_last('Process', _("Process Transfer"), '', true); + end_form(); end_page(); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 74469db9..6d950dbb 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -412,9 +412,9 @@ div_start('controls', 'items_table'); if ($_SESSION['PO']->order_has_items()) { if ($_SESSION['PO']->order_no) - submit_center_first('Commit', _("Update Order")); + submit_center_first('Commit', _("Update Order"), '', true); else - submit_center_first('Commit', _("Place Order")); + submit_center_first('Commit', _("Place Order"), '', true); submit_center_last('CancelOrder', _("Cancel Order")); } else