49f5f5ca12f5abc8f0e41aa9817c2f4955de914d
[fa-stable.git] / inventory / reorder_level.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_REORDER';
13 $path_to_root = "..";
14 include_once($path_to_root . "/includes/session.inc");
15
16 page(_($help_context = "Reorder Levels"));
17
18 include_once($path_to_root . "/includes/date_functions.inc");
19 include_once($path_to_root . "/includes/ui.inc");
20 include_once($path_to_root . "/includes/data_checks.inc");
21
22 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
23
24 check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items)."));
25
26 //------------------------------------------------------------------------------------
27
28 if (isset($_GET['stock_id']))
29         $_POST['stock_id'] = $_GET['stock_id'];
30
31 if (list_updated('stock_id')) 
32 {
33         $Ajax->activate('show_heading');
34         $Ajax->activate('reorders');
35 }
36 //------------------------------------------------------------------------------------
37
38 start_form();
39
40 if (!isset($_POST['stock_id']))
41         $_POST['stock_id'] = get_global_stock_item();
42
43 echo "<center>" . _("Item:"). "&nbsp;";
44 stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
45
46 echo "<hr></center>";
47
48 div_start('show_heading');
49 stock_item_heading($_POST['stock_id']);
50 br();
51 div_end();
52 set_global_stock_item($_POST['stock_id']);
53
54 div_start('reorders');
55 start_table("$table_style width=30%");
56
57 $th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"));
58 table_header($th);
59
60 $j = 1;
61 $k=0; //row colour counter
62
63 $result = get_loc_details($_POST['stock_id']);
64
65 while ($myrow = db_fetch($result))
66 {
67
68         alt_table_row_color($k);
69
70         if (isset($_POST['UpdateData']) && check_num($myrow["loc_code"]))
71         {
72
73                 $myrow["reorder_level"] = input_num($myrow["loc_code"]);
74                 set_reorder_level($_POST['stock_id'], $myrow["loc_code"], input_num($myrow["loc_code"]));
75         }
76
77         $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
78
79         label_cell($myrow["location_name"]);
80
81         $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"], $_POST['stock_id'], $dec);
82
83         qty_cell($qoh, false, $dec);
84         qty_cells(null, $myrow["loc_code"], null, null, null, $dec);
85         end_row();
86         $j++;
87         If ($j == 12)
88         {
89                 $j = 1;
90                 table_header($th);
91         }
92 }
93
94 end_table(1);
95 div_end();
96 submit_center('UpdateData', _("Update"), true, false, 'default');
97
98 end_form();
99 end_page();
100
101 ?>