Changed popup to tabs in customers, suppliers, items for transactions.
[fa-stable.git] / inventory / inquiry / stock_status.php
1 <?php
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");
15
16 if (!@$_GET['popup'])
17 {
18         if (isset($_GET['stock_id'])){
19                 page(_($help_context = "Inventory Item Status"), true);
20         } else {
21                 page(_($help_context = "Inventory Item Status"));
22         }
23 }
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");
30
31 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
32
33 if (list_updated('stock_id')) 
34         $Ajax->activate('status_tbl');
35 //----------------------------------------------------------------------------------------------------
36
37 check_db_has_stock_items(_("There are no items defined in the system."));
38
39 if (!@$_GET['popup'])
40         start_form();
41
42 if (!isset($_POST['stock_id']))
43         $_POST['stock_id'] = get_global_stock_item();
44
45 echo "<center> " . _("Item:"). " ";
46 if (!@$_GET['popup'])
47         echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
48 echo "<br>";
49
50 echo "<hr></center>";
51
52 set_global_stock_item($_POST['stock_id']);
53
54 $mb_flag = get_mb_flag($_POST['stock_id']);
55 $kitset_or_service = false;
56
57 div_start('status_tbl');
58 if (is_service($mb_flag))
59 {
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;
62 }
63
64 $loc_details = get_loc_details($_POST['stock_id']);
65
66 start_table(TABLESTYLE);
67
68 if ($kitset_or_service == true)
69 {
70         $th = array(_("Location"), _("Demand"));
71 }
72 else
73 {
74         $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"),
75                 _("Demand"), _("Available"), _("On Order"));
76 }
77 table_header($th);
78 $dec = get_qty_dec($_POST['stock_id']);
79 $j = 1;
80 $k = 0; //row colour counter
81
82 while ($myrow = db_fetch($loc_details))
83 {
84
85         alt_table_row_color($k);
86
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"]);
89
90         $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
91
92         if ($kitset_or_service == false)
93         {
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);
102         end_row();
103
104         }
105         else
106         {
107         /* It must be a service or kitset part */
108                 label_cell($myrow["location_name"]);
109                 qty_cell($demand_qty, false, $dec);
110                 end_row();
111
112         }
113         $j++;
114         If ($j == 12)
115         {
116                 $j = 1;
117                 table_header($th);
118         }
119 }
120
121 end_table();
122 div_end();
123 if (!@$_GET['popup'])
124 {
125         end_form();
126         end_page(@$_GET['popup'], false, false);
127 }       
128
129 ?>