*** empty log message ***
[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/session.inc");
6
7 page(_("Inventory Item Where Used Inquiry"));
8
9 //include($path_to_root . "/includes/date_functions.inc");
10 include($path_to_root . "/includes/ui.inc");
11 include($path_to_root . "/includes/data_checks.inc");
12
13 check_db_has_stock_items(_("There are no items defined in the system."));
14
15 start_form(false, true);
16
17 if (!isset($_POST['stock_id']))
18         $_POST['stock_id'] = get_global_stock_item();
19
20 echo "<center>" . _("Select an item to display its parent item(s).") . "&nbsp;";
21 stock_items_list('stock_id', $_POST['stock_id'], false, true);
22 echo "<hr><center>";
23
24 set_global_stock_item($_POST['stock_id']);
25
26 if (isset($_POST['stock_id'])) 
27 {
28     $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description,".TB_PREF."workcentres.name As WorkCentreName, ".TB_PREF."locations.location_name
29                 FROM ".TB_PREF."bom, ".TB_PREF."stock_master, ".TB_PREF."workcentres, ".TB_PREF."locations
30                 WHERE ".TB_PREF."bom.parent = ".TB_PREF."stock_master.stock_id AND ".TB_PREF."bom.workcentre_added = ".TB_PREF."workcentres.id
31                 AND ".TB_PREF."bom.loc_code = ".TB_PREF."locations.loc_code
32                 AND ".TB_PREF."bom.component='" . $_POST['stock_id'] . "'";
33
34     $result = db_query($sql,"No parent items were returned");
35
36         if (db_num_rows($result) == 0) 
37         {
38                 display_note(_("The selected item is not used in any BOMs."));
39         } 
40         else 
41         {
42
43         start_table("$table_style width=80%");
44
45         $th = array(_("Parent Item"), _("Work Centre"), _("Location"), _("Quantity Required"));
46         table_header($th);
47
48                 $k = $j = 0;
49         while ($myrow = db_fetch($result)) 
50         {
51
52                         alt_table_row_color($k);
53
54                 $select_item = $path_to_root . "/manufacturing/manage/bom_edit.php?" . SID . "stock_id=" . $myrow["parent"];
55
56                 label_cell("<a href='$select_item'>" . $myrow["parent"]. " - " . $myrow["description"]. "</a>");
57                 label_cell($myrow["WorkCentreName"]);
58                 label_cell($myrow["location_name"]);
59                 label_cell($myrow["quantity"]);
60                         end_row();
61                         
62                 $j++;
63                 If ($j == 12)
64                 {
65                         $j = 1;
66                         table_header($th);
67                 }
68         //end of page full new headings if
69         }
70
71         end_table();
72         }
73 }
74
75 end_form();
76 end_page();
77
78 ?>