Sending location email when below reorder also in Itmes Transfer and Adjustment
[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 if (!@$_GET['popup'])
46 {
47         echo "<center> " . _("Item:"). " ";
48         echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
49 }       
50 echo "<br>";
51
52 echo "<hr></center>";
53
54 set_global_stock_item($_POST['stock_id']);
55
56 $mb_flag = get_mb_flag($_POST['stock_id']);
57 $kitset_or_service = false;
58
59 div_start('status_tbl');
60 if (is_service($mb_flag))
61 {
62         display_note(_("This is a service and cannot have a stock holding, only the total quantity on outstanding sales orders is shown."), 0, 1);
63         $kitset_or_service = true;
64 }
65
66 $loc_details = get_loc_details($_POST['stock_id']);
67
68 start_table(TABLESTYLE);
69
70 if ($kitset_or_service == true)
71 {
72         $th = array(_("Location"), _("Demand"));
73 }
74 else
75 {
76         $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"),
77                 _("Demand"), _("Available"), _("On Order"));
78 }
79 table_header($th);
80 $dec = get_qty_dec($_POST['stock_id']);
81 $j = 1;
82 $k = 0; //row colour counter
83
84 while ($myrow = db_fetch($loc_details))
85 {
86
87         alt_table_row_color($k);
88
89         $demand_qty = get_demand_qty($_POST['stock_id'], $myrow["loc_code"]);
90         $demand_qty += get_demand_asm_qty($_POST['stock_id'], $myrow["loc_code"]);
91
92         $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
93
94         if ($kitset_or_service == false)
95         {
96                 $qoo = get_on_porder_qty($_POST['stock_id'], $myrow["loc_code"]);
97                 $qoo += get_on_worder_qty($_POST['stock_id'], $myrow["loc_code"]);
98                 label_cell($myrow["location_name"]);
99                 qty_cell($qoh, false, $dec);
100         qty_cell($myrow["reorder_level"], false, $dec);
101         qty_cell($demand_qty, false, $dec);
102         qty_cell($qoh - $demand_qty, false, $dec);
103         qty_cell($qoo, false, $dec);
104         end_row();
105
106         }
107         else
108         {
109         /* It must be a service or kitset part */
110                 label_cell($myrow["location_name"]);
111                 qty_cell($demand_qty, false, $dec);
112                 end_row();
113
114         }
115         $j++;
116         If ($j == 12)
117         {
118                 $j = 1;
119                 table_header($th);
120         }
121 }
122
123 end_table();
124 div_end();
125 if (!@$_GET['popup'])
126 {
127         end_form();
128         end_page(@$_GET['popup'], false, false);
129 }       
130
131 ?>