2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_ITEMSSTATVIEW';
13 $path_to_root = "../..";
14 include_once($path_to_root . "/includes/session.inc");
18 if (isset($_GET['stock_id'])){
19 page(_($help_context = "Inventory Item Status"), true);
21 page(_($help_context = "Inventory Item Status"));
24 if (isset($_GET['stock_id']))
25 $_POST['stock_id'] = $_GET['stock_id'];
26 include_once($path_to_root . "/includes/date_functions.inc");
27 include_once($path_to_root . "/includes/ui.inc");
28 include_once($path_to_root . "/includes/manufacturing.inc");
29 include_once($path_to_root . "/includes/data_checks.inc");
31 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
33 if (list_updated('stock_id'))
34 $Ajax->activate('status_tbl');
35 //----------------------------------------------------------------------------------------------------
37 check_db_has_stock_items(_("There are no items defined in the system."));
42 if (!isset($_POST['stock_id']))
43 $_POST['stock_id'] = get_global_stock_item();
45 echo "<center> " . _("Item:"). " ";
47 echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
52 set_global_stock_item($_POST['stock_id']);
54 $mb_flag = get_mb_flag($_POST['stock_id']);
55 $kitset_or_service = false;
57 div_start('status_tbl');
58 if (is_service($mb_flag))
60 display_note(_("This is a service and cannot have a stock holding, only the total quantity on outstanding sales orders is shown."), 0, 1);
61 $kitset_or_service = true;
64 $loc_details = get_loc_details($_POST['stock_id']);
66 start_table(TABLESTYLE);
68 if ($kitset_or_service == true)
70 $th = array(_("Location"), _("Demand"));
74 $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"),
75 _("Demand"), _("Available"), _("On Order"));
78 $dec = get_qty_dec($_POST['stock_id']);
80 $k = 0; //row colour counter
82 while ($myrow = db_fetch($loc_details))
85 alt_table_row_color($k);
87 $demand_qty = get_demand_qty($_POST['stock_id'], $myrow["loc_code"]);
88 $demand_qty += get_demand_asm_qty($_POST['stock_id'], $myrow["loc_code"]);
90 $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
92 if ($kitset_or_service == false)
94 $qoo = get_on_porder_qty($_POST['stock_id'], $myrow["loc_code"]);
95 $qoo += get_on_worder_qty($_POST['stock_id'], $myrow["loc_code"]);
96 label_cell($myrow["location_name"]);
97 qty_cell($qoh, false, $dec);
98 qty_cell($myrow["reorder_level"], false, $dec);
99 qty_cell($demand_qty, false, $dec);
100 qty_cell($qoh - $demand_qty, false, $dec);
101 qty_cell($qoo, false, $dec);
107 /* It must be a service or kitset part */
108 label_cell($myrow["location_name"]);
109 qty_cell($demand_qty, false, $dec);
123 if (!@$_GET['popup'])
126 end_page(@$_GET['popup'], false, false);