0de4de7e2cd2ed2597056a1e39b16aec051faac5
[fa-stable.git] / manufacturing / inquiry / where_used_inquiry.php
1 <?php
2
3 $page_security = 2;
4 $path_to_root="../..";
5 include($path_to_root . "/includes/db_pager.inc");
6 include($path_to_root . "/includes/session.inc");
7
8 page(_("Inventory Item Where Used Inquiry"));
9
10 include($path_to_root . "/includes/ui.inc");
11
12 check_db_has_stock_items(_("There are no items defined in the system."));
13
14 start_form(false, true);
15
16 if (!isset($_POST['stock_id']))
17         $_POST['stock_id'] = get_global_stock_item();
18
19 echo "<center>" . _("Select an item to display its parent item(s).") . "&nbsp;";
20 stock_items_list('stock_id', $_POST['stock_id'], false, true);
21 echo "<hr></center>";
22
23 set_global_stock_item($_POST['stock_id']);
24 //-----------------------------------------------------------------------------
25 function select_link($row)
26 {
27         return  pager_link( $row["parent"]. " - " . $row["description"],
28                 "/manufacturing/manage/bom_edit.php?stock_id=" . $row["parent"]);
29 }
30
31 $sql = "SELECT 
32                 bom.parent,
33                 workcentre.name As WorkCentreName,
34                 location.location_name,
35                 bom.quantity,
36                 parent.description
37                 FROM ".TB_PREF."bom as bom, "
38                         .TB_PREF."stock_master as parent, "
39                         .TB_PREF."workcentres as workcentre, "
40                         .TB_PREF."locations as location
41                 WHERE bom.parent = parent.stock_id 
42                         AND bom.workcentre_added = workcentre.id
43                         AND bom.loc_code = location.loc_code
44                         AND bom.component='" . $_POST['stock_id'] . "'";
45
46    $cols = array(
47         _("Parent Item") => array('fun'=>'select_link'), 
48         _("Work Centre"), 
49         _("Location"), 
50         _("Quantity Required")
51         );
52
53 $table =& new_db_pager('usage_table', $sql, $cols);
54
55 if (list_updated('stock_id')) {
56         $table->set_sql($sql);
57         $table->set_columns($cols);
58         $Ajax->activate('usage_table');
59 }
60
61 display_db_pager($table);
62
63 end_form();
64 end_page();
65
66 ?>