From 5d3fcb9c57e586c20651594edf91a2dccb08df00 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sat, 26 Jan 2013 15:29:51 +0100 Subject: [PATCH] Included Sales Pricing, Purchasing Prising, Cost update and Reorder Levels in tabs in Items form. --- inventory/cost_update.php | 48 +++++++++++++++------ inventory/includes/db/items_prices_db.inc | 10 +++++ inventory/includes/db/items_trans_db.inc | 2 +- inventory/manage/items.php | 28 ++++++++++++ inventory/prices.php | 42 +++++++++++++----- inventory/purchasing_data.php | 52 +++++++++++++++++------ inventory/reorder_level.php | 37 +++++++++++----- 7 files changed, 168 insertions(+), 51 deletions(-) diff --git a/inventory/cost_update.php b/inventory/cost_update.php index b5ee125d..e16594b3 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -10,20 +10,26 @@ See the License here . ***********************************************************************/ $page_security = 'SA_STANDARDCOST'; -$path_to_root = ".."; -include_once($path_to_root . "/includes/session.inc"); +if (!@$_GET['popup']) + $path_to_root = ".."; +else + $path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/banking.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); - include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -$js = ""; -if ($use_popup_windows) - $js .= get_js_open_window(900, 500); -page(_($help_context = "Inventory Item Cost Update"), false, false, "", $js); + +if (!@$_GET['popup']) +{ + $js = ""; + if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + page(_($help_context = "Inventory Item Cost Update"), false, false, "", $js); +} //-------------------------------------------------------------------------------------- @@ -68,8 +74,9 @@ if (isset($_POST['UpdateData'])) if ($update_no > 0) { - display_note(get_gl_view_str(ST_COSTUPDATE, $update_no, _("View the GL Journal Entries for this Cost Update")), 0, 1); + display_notification(get_gl_view_str(ST_COSTUPDATE, $update_no, _("View the GL Journal Entries for this Cost Update")), 0, 1); } + } } @@ -77,16 +84,25 @@ if (list_updated('stock_id')) $Ajax->activate('cost_table'); //----------------------------------------------------------------------------------------- -start_form(); +$action = $_SERVER['PHP_SELF']; +if (@$_GET['popup']) + $action .= "?stock_id=".get_post('stock_id'); +start_form(false, false, $action); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); -echo "
" . _("Item:"). " "; -//echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); -echo stock_items_list('stock_id', $_POST['stock_id'], false, true); +if (!@$_GET['popup']) +{ + echo "
" . _("Item:"). " "; + //echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); + echo stock_items_list('stock_id', $_POST['stock_id'], false, true); + + echo "

"; +} +else + br(2); -echo "

"; set_global_stock_item($_POST['stock_id']); $myrow = get_item($_POST['stock_id']); @@ -100,6 +116,9 @@ $_POST['labour_cost'] = price_decimal_format($myrow["labour_cost"], $dec2); $_POST['overhead_cost'] = price_decimal_format($myrow["overhead_cost"], $dec3); amount_row(_("Standard Material Cost Per Unit"), "material_cost", null, "class='tableheader2'", null, $dec1); + +if (@$_GET['popup']) + hidden('_tabs_sel', get_post('_tabs_sel')); if ($myrow["mb_flag"]=='M') { amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", null, "class='tableheader2'", null, $dec2); @@ -116,6 +135,7 @@ div_end(); submit_center('UpdateData', _("Update"), true, false, 'default'); end_form(); -end_page(); +if (!@$_GET['popup']) + end_page(@$_GET['popup'], false, false); ?> diff --git a/inventory/includes/db/items_prices_db.inc b/inventory/includes/db/items_prices_db.inc index 9b670d24..bcf734b8 100644 --- a/inventory/includes/db/items_prices_db.inc +++ b/inventory/includes/db/items_prices_db.inc @@ -53,4 +53,14 @@ function get_stock_price($price_id) return db_fetch($result); } +function get_stock_price_type_currency($stock_id, $type, $currency) +{ + $sql = "SELECT * FROM ".TB_PREF."prices WHERE stock_id=".db_escape($stock_id)." + AND sales_type_id=".db_escape($type)." + AND curr_abrev=".db_escape($currency); + + $result = db_query($sql,"price could not be retreived"); + + return db_fetch($result); +} ?> \ No newline at end of file diff --git a/inventory/includes/db/items_trans_db.inc b/inventory/includes/db/items_trans_db.inc index 3b71bf56..0a17b66e 100644 --- a/inventory/includes/db/items_trans_db.inc +++ b/inventory/includes/db/items_trans_db.inc @@ -58,7 +58,7 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co $stock_gl_code = get_stock_gl_code($stock_id); $update_no = get_next_trans_no(ST_COSTUPDATE); $memo_ = sprintf(_("Cost was %s changed to %s x quantity on hand for item '%s'"), - number_format2($last_cost, 2), number_format2($new_cost, 2), $$stock_id); + number_format2($last_cost, 2), number_format2($new_cost, 2), $stock_id); add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["adjustment_account"], $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change)); diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 666486f0..7e5bb7ae 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -452,6 +452,10 @@ if (!$stock_id) tabbed_content_start('tabs', array( 'settings' => array(_('&General settings'), $stock_id), + 'sales_pricing' => array(_('S&ales Pricing'), $stock_id), + 'purchase_pricing' => array(_('&Purchasing Pricing'), $stock_id), + 'standard_cost' => array(_('Standard &Costs'), $stock_id), + 'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) ? $stock_id : null)), 'movement' => array(_('&Transactions'), $stock_id), 'status' => array(_('&Status'), $stock_id), )); @@ -461,6 +465,30 @@ tabbed_content_start('tabs', array( case 'settings': item_settings($stock_id); break; + case 'sales_pricing': + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/prices.php"); + break; + case 'purchase_pricing': + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/purchasing_data.php"); + break; + case 'standard_cost': + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/cost_update.php"); + break; + case 'reorder_level': + if (!is_inventory_item($stock_id)) + { + break; + } + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/reorder_level.php"); + break; case 'movement': $_GET['stock_id'] = $stock_id; $_GET['popup'] = 1; diff --git a/inventory/prices.php b/inventory/prices.php index dfac2aa5..123c4bd0 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -10,18 +10,21 @@ See the License here . ***********************************************************************/ $page_security = 'SA_SALESPRICE'; -$path_to_root = ".."; -include_once($path_to_root . "/includes/session.inc"); - -page(_($help_context = "Inventory Item Sales prices")); +if (!@$_GET['popup']) + $path_to_root = ".."; +else + $path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/sales/includes/db/sales_types_db.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); - include_once($path_to_root . "/inventory/includes/inventory_db.inc"); +if (!@$_GET['popup']) + page(_($help_context = "Inventory Item Sales prices")); + //--------------------------------------------------------------------------------------------------- check_db_has_stock_items(_("There are no items defined in the system.")); @@ -48,15 +51,22 @@ if (!isset($_POST['curr_abrev'])) //--------------------------------------------------------------------------------------------------- -start_form(); +$action = $_SERVER['PHP_SELF']; +if (@$_GET['popup']) + $action .= "?stock_id=".get_post('stock_id'); +start_form(false, false, $action); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); -echo "
" . _("Item:"). " "; -echo sales_items_list('stock_id', $_POST['stock_id'], false, true, '', array('editable' => false)); -echo "
"; - +if (!@$_GET['popup']) +{ + echo "
" . _("Item:"). " "; + echo sales_items_list('stock_id', $_POST['stock_id'], false, true, '', array('editable' => false)); + echo "
"; +} +else + br(2); set_global_stock_item($_POST['stock_id']); //---------------------------------------------------------------------------------------------------- @@ -70,6 +80,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') display_error( _("The price entered must be numeric.")); set_focus('price'); } + elseif ($Mode == 'ADD_ITEM' && get_stock_price_type_currency($_POST['stock_id'], $_POST['sales_type_id'], $_POST['curr_abrev'])) + { + $input_error = 1; + display_error( _("The sales pricing for this item, sales type and currency has already been added.")); + set_focus('supplier_id'); + } if ($input_error != 1) { @@ -168,6 +184,9 @@ if ($Mode == 'Edit') } hidden('selected_id', $selected_id); +if (@$_GET['popup']) + hidden('_tabs_sel', get_post('_tabs_sel')); + div_start('price_details'); start_table(TABLESTYLE2); @@ -191,5 +210,6 @@ submit_add_or_update_center($selected_id == -1, '', 'both'); div_end(); end_form(); -end_page(); +if (!@$_GET['popup']) + end_page(@$_GET['popup'], false, false); ?> diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 0a7a01c3..3f85c037 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -10,21 +10,29 @@ See the License here . ***********************************************************************/ $page_security = 'SA_PURCHASEPRICING'; -$path_to_root = ".."; -include_once($path_to_root . "/includes/session.inc"); - -page(_($help_context = "Supplier Purchasing Data")); +if (!@$_GET['popup']) + $path_to_root = ".."; +else + $path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); +if (!@$_GET['popup']) + page(_($help_context = "Supplier Purchasing Data")); + check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system.")); check_db_has_suppliers(_("There are no suppliers defined in the system.")); //---------------------------------------------------------------------------------------- simple_page_mode(true); +if (isset($_GET['stock_id'])) +{ + $_POST['stock_id'] = $_GET['stock_id']; +} //-------------------------------------------------------------------------------------------------- @@ -36,7 +44,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $input_error = 1; display_error( _("There is no item selected.")); - set_focus('stock_id'); + set_focus('stock_id'); } elseif (!check_num('price', 0)) { @@ -50,7 +58,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure.")); set_focus('conversion_factor'); } - + elseif ($Mode == 'ADD_ITEM' && get_item_purchasing_data($_POST['supplier_id'], $_POST['stock_id'])) + { + $input_error = 1; + display_error( _("The purchasing data for this supplier has already been added.")); + set_focus('supplier_id'); + } if ($input_error == 0) { if ($Mode == 'ADD_ITEM') @@ -93,17 +106,24 @@ if (list_updated('stock_id')) $Ajax->activate('price_table'); //-------------------------------------------------------------------------------------------------- -start_form(); +$action = $_SERVER['PHP_SELF']; +if (@$_GET['popup']) + $action .= "?stock_id=".get_post('stock_id'); +start_form(false, false, $action); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); -echo "
" . _("Item:"). " "; -//Chaitanya : All items can be purchased -echo stock_items_list('stock_id', $_POST['stock_id'], false, true); -//echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true); - -echo "
"; +if (!@$_GET['popup']) +{ + echo "
" . _("Item:"). " "; + //Chaitanya : All items can be purchased + echo stock_items_list('stock_id', $_POST['stock_id'], false, true); + //echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true); + echo "
"; +} +else + br(2); set_global_stock_item($_POST['stock_id']); @@ -176,6 +196,9 @@ if ($Mode =='Edit') br(); hidden('selected_id', $selected_id); +if (@$_GET['popup']) + hidden('_tabs_sel', get_post('_tabs_sel')); + start_table(TABLESTYLE2); if ($Mode == 'Edit') @@ -204,6 +227,7 @@ end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); -end_page(); +if (!@$_GET['popup']) + end_page(@$_GET['popup'], false, false); ?> diff --git a/inventory/reorder_level.php b/inventory/reorder_level.php index 4e8f02c4..e2ace58a 100644 --- a/inventory/reorder_level.php +++ b/inventory/reorder_level.php @@ -10,17 +10,20 @@ See the License here . ***********************************************************************/ $page_security = 'SA_REORDER'; -$path_to_root = ".."; -include_once($path_to_root . "/includes/session.inc"); - -page(_($help_context = "Reorder Levels")); +if (!@$_GET['popup']) + $path_to_root = ".."; +else + $path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); - include_once($path_to_root . "/inventory/includes/inventory_db.inc"); +if (!@$_GET['popup']) + page(_($help_context = "Reorder Levels")); + check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items).")); //------------------------------------------------------------------------------------ @@ -35,20 +38,28 @@ if (list_updated('stock_id')) } //------------------------------------------------------------------------------------ -start_form(); +$action = $_SERVER['PHP_SELF']; +if (@$_GET['popup']) + $action .= "?stock_id=".get_post('stock_id'); +start_form(false, false, $action); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); -echo "
" . _("Item:"). " "; -echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); - -echo "
"; +if (!@$_GET['popup']) +{ + echo "
" . _("Item:"). " "; + echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); + echo "
"; +} +else + br(2); div_start('show_heading'); stock_item_heading($_POST['stock_id']); br(); div_end(); + set_global_stock_item($_POST['stock_id']); div_start('reorders'); @@ -62,6 +73,9 @@ $k=0; //row colour counter $result = get_loc_details($_POST['stock_id']); +if (@$_GET['popup']) + hidden('_tabs_sel', get_post('_tabs_sel')); + while ($myrow = db_fetch($result)) { @@ -97,6 +111,7 @@ div_end(); submit_center('UpdateData', _("Update"), true, false, 'default'); end_form(); -end_page(); +if (!@$_GET['popup']) + end_page(@$_GET['popup'], false, false); ?> -- 2.30.2