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