! -> 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
if ($label != null)
echo "<td>$label</td>\n";
$str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
- array('cells'=>true));
+ array('cells'=>true));
return $str;
}
/*
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 "<td>$label</td>\n";
+ $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
+ array('where'=>array("mb_flag!='D'"), 'cells'=>true));
+ return $str;
}
//------------------------------------------------------------------------------------
{
$types = wo_types::get_all();
- default_focus($name); // FIX ajax
- echo "<select name='$name' onchange='this.form.submit();'>";
+ default_focus($name);
+ echo "<select name='$name' onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>";
if ($selected_id == null)
$selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
display_footer_exit();
}
+//--------------------------------------------------------------------------------------------------
+
+function line_start_focus() {
+ global $Ajax;
+ $Ajax->activate('items_table');
+ set_focus('_stock_id_edit');
+}
//--------------------------------------------------------------------------------------------------
function copy_to_st()
$_SESSION['adj_items']->increase = $_POST['Increase'];
$_SESSION['adj_items']->memo_ = $_POST['memo_'];
}
-
//--------------------------------------------------------------------------------------------------
function copy_from_st()
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."));
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;
}
$_SESSION['adj_items']->clear_items();
unset($_SESSION['adj_items']);
+
meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no");
} /*end of process credit note */
{
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();
}
//-----------------------------------------------------------------------------------------------
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']))
}
//-----------------------------------------------------------------------------------------------
-
start_form(false, true);
display_order_header($_SESSION['adj_items']);
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();
}
//--------------------------------------------------------------------------------------
-
if (isset($_POST['UpdateData']))
{
echo "</center><hr>";
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);
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
{
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);
}
//--------------------------------------------------------------------------------
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"));
$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("<a target='_blank' href='$path_to_root/inventory/inquiry/stock_status.php?" . SID . "stock_id=" . $stock_item->stock_id . "'>$stock_item->stock_id</a>");
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 "<td colspan=2>";
- stock_costable_items_list('stock_id', null, false, true);
- echo "</td>";
+ 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']);
}
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();
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);
}
//--------------------------------------------------------------------------------
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);
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 "<TD colspan=2>";
- stock_costable_items_list('stock_id', null, false, true);
- echo "</TD>";
+ 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']);
$_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();
$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']))
{
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();
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"));
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"];
//}
end_table(1);
-
+div_end();
end_page();
?>
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']))
$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'] != '')
function clear_data()
{
+ global $new_item;
+
unset($_POST['long_description']);
unset($_POST['description']);
unset($_POST['category_id']);
unset($_POST['NewStockID']);
unset($_POST['dimension_id']);
unset($_POST['dimension2_id']);
- $_POST['New'] = "1";
+ $new_item = true;
}
//------------------------------------------------------------------------------------
if ($input_error != 1)
{
- if (!isset($_POST['New']))
+ if (!$new_item)
{ /*so its an existing one */
update_item($_POST['NewStockID'], $_POST['description'],
$_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
$_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']);
}
}
$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']);
}
}
{
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 "<br>";
+//hyperlink_params($_SERVER['PHP_SELF'], _("Enter a new item"), "New=1");
+//echo "<br>";
+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();
else
{ // Must be modifying an existing item
- if (!isset($_POST['New']))
+ if (!$new_item)
{
$myrow = get_item($_POST['NewStockID']);
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%");
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();
//------------------------------------------------------------------------------------
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']);
$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)."));
display_footer_exit();
}
+//--------------------------------------------------------------------------------------------------
+
+function line_start_focus() {
+ global $Ajax;
+ $Ajax->activate('items_table');
+ set_focus('_stock_id_edit');
+}
//--------------------------------------------------------------------------------------------------
function copy_to_st()
$_SESSION['transfer_items']->transfer_type = $_POST['type'];
$_SESSION['transfer_items']->memo_ = $_POST['memo_'];
}
-
//--------------------------------------------------------------------------------------------------
function copy_from_st()
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."));
}
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 "<br>";
+ $_POST['Edit'.$failed_item] = 1; // enter edit mode
$input_error = 1;
}
}
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;
}
{
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();
}
//-----------------------------------------------------------------------------------------------
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();
if (isset($_POST['UpdateItem']))
handle_update_item();
+if (isset($_POST['CancelItemChanges'])) {
+ line_start_focus();
+}
//-----------------------------------------------------------------------------------------------
if (isset($_GET['NewTransfer']) || !isset($_SESSION['transfer_items']))
}
//-----------------------------------------------------------------------------------------------
-
start_form(false, true);
display_order_header($_SESSION['transfer_items']);
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();
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