[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / manufacturing / inquiry / where_used_inquiry.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_WORKORDERANALYTIC';
13 $path_to_root = "../..";
14 include($path_to_root . "/includes/db_pager.inc");
15 include($path_to_root . "/includes/session.inc");
16
17 page(_($help_context = "Inventory Item Where Used Inquiry"));
18
19 include($path_to_root . "/includes/ui.inc");
20
21 check_db_has_stock_items(_("There are no items defined in the system."));
22
23 start_form(false, true);
24
25 if (!isset($_POST['stock_id']))
26         $_POST['stock_id'] = get_global_stock_item();
27
28 echo "<center>" . _("Select an item to display its parent item(s).") . "&nbsp;";
29 echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
30 echo "<hr></center>";
31
32 set_global_stock_item($_POST['stock_id']);
33 //-----------------------------------------------------------------------------
34 function select_link($row)
35 {
36         return  pager_link( $row["parent"]. " - " . $row["description"],
37                 "/manufacturing/manage/bom_edit.php?stock_id=" . $row["parent"]);
38 }
39
40 $sql = get_sql_for_where_used(get_post('stock_id'));
41
42    $cols = array(
43         _("Parent Item") => array('fun'=>'select_link'), 
44         _("Work Centre"), 
45         _("Location"), 
46         _("Quantity Required")
47         );
48
49 $table =& new_db_pager('usage_table', $sql, $cols);
50
51 $table->width = "80%";
52 display_db_pager($table);
53
54 end_form();
55 end_page();
56