Cleanup: removed all closing tags in php files.
[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 page(_($help_context = "Inventory Item Status"), @$_GET['popup']);
17
18 if (isset($_GET['stock_id']))
19         $_POST['stock_id'] = $_GET['stock_id'];
20
21 include_once($path_to_root . "/includes/date_functions.inc");
22 include_once($path_to_root . "/includes/ui.inc");
23 include_once($path_to_root . "/includes/manufacturing.inc");
24 include_once($path_to_root . "/includes/data_checks.inc");
25
26 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
27
28 if (list_updated('stock_id')) 
29         $Ajax->activate('status_tbl');
30 //----------------------------------------------------------------------------------------------------
31
32 check_db_has_stock_items(_("There are no items defined in the system."));
33
34 start_form();
35
36 if (!isset($_POST['stock_id']))
37         $_POST['stock_id'] = get_global_stock_item();
38
39 if (!$page_nested)
40 {
41         echo "<center> " . _("Item:"). " ";
42         echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
43 }
44 echo "<br>";
45
46 echo "<hr></center>";
47
48 set_global_stock_item($_POST['stock_id']);
49
50 $mb_flag = get_mb_flag($_POST['stock_id']);
51 $kitset_or_service = false;
52
53 div_start('status_tbl');
54 if (is_service($mb_flag))
55 {
56         display_note(_("This is a service and cannot have a stock holding, only the total quantity on outstanding sales orders is shown."), 0, 1);
57         $kitset_or_service = true;
58 }
59
60 $loc_details = get_loc_details($_POST['stock_id']);
61
62 start_table(TABLESTYLE);
63
64 if ($kitset_or_service == true)
65 {
66         $th = array(_("Location"), _("Demand"));
67 }
68 else
69 {
70         $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"),
71                 _("Demand"), _("Available"), _("On Order"));
72 }
73 table_header($th);
74 $dec = get_qty_dec($_POST['stock_id']);
75 $j = 1;
76 $k = 0; //row colour counter
77
78 while ($myrow = db_fetch($loc_details))
79 {
80
81         alt_table_row_color($k);
82
83         $demand_qty = get_demand_qty($_POST['stock_id'], $myrow["loc_code"]);
84         $demand_qty += get_demand_asm_qty($_POST['stock_id'], $myrow["loc_code"]);
85
86         $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
87
88         if ($kitset_or_service == false)
89         {
90                 $qoo = get_on_porder_qty($_POST['stock_id'], $myrow["loc_code"]);
91                 $qoo += get_on_worder_qty($_POST['stock_id'], $myrow["loc_code"]);
92                 label_cell($myrow["location_name"]);
93                 qty_cell($qoh, false, $dec);
94         qty_cell($myrow["reorder_level"], false, $dec);
95         qty_cell($demand_qty, false, $dec);
96         qty_cell($qoh - $demand_qty, false, $dec);
97         qty_cell($qoo, false, $dec);
98         end_row();
99
100         }
101         else
102         {
103         /* It must be a service or kitset part */
104                 label_cell($myrow["location_name"]);
105                 qty_cell($demand_qty, false, $dec);
106                 end_row();
107
108         }
109         $j++;
110         If ($j == 12)
111         {
112                 $j = 1;
113                 table_header($th);
114         }
115 }
116
117 end_table();
118 div_end();
119 end_form();
120 end_page();
121