5 include($path_to_root . "/includes/session.inc");
7 page(_("Inventory Item Where Used Inquiry"));
9 //include($path_to_root . "/includes/date_functions.inc");
10 include($path_to_root . "/includes/ui.inc");
12 check_db_has_stock_items(_("There are no items defined in the system."));
14 start_form(false, true);
16 if (!isset($_POST['stock_id']))
17 $_POST['stock_id'] = get_global_stock_item();
19 echo "<center>" . _("Select an item to display its parent item(s).") . " ";
20 stock_items_list('stock_id', $_POST['stock_id'], false, true);
23 set_global_stock_item($_POST['stock_id']);
25 if (isset($_POST['_stock_id_update']))
26 $Ajax->activate('usage_table');
28 if (isset($_POST['stock_id']))
30 $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description,".TB_PREF."workcentres.name As WorkCentreName, ".TB_PREF."locations.location_name
31 FROM ".TB_PREF."bom, ".TB_PREF."stock_master, ".TB_PREF."workcentres, ".TB_PREF."locations
32 WHERE ".TB_PREF."bom.parent = ".TB_PREF."stock_master.stock_id AND ".TB_PREF."bom.workcentre_added = ".TB_PREF."workcentres.id
33 AND ".TB_PREF."bom.loc_code = ".TB_PREF."locations.loc_code
34 AND ".TB_PREF."bom.component='" . $_POST['stock_id'] . "'";
36 $result = db_query($sql,"No parent items were returned");
38 div_start('usage_table');
39 if (db_num_rows($result) == 0)
41 display_note(_("The selected item is not used in any BOMs."));
46 start_table("$table_style width=80%");
48 $th = array(_("Parent Item"), _("Work Centre"), _("Location"), _("Quantity Required"));
52 while ($myrow = db_fetch($result))
55 alt_table_row_color($k);
57 $select_item = $path_to_root . "/manufacturing/manage/bom_edit.php?" . SID . "stock_id=" . $myrow["parent"];
59 label_cell("<a href='$select_item'>" . $myrow["parent"]. " - " . $myrow["description"]. "</a>");
60 label_cell($myrow["WorkCentreName"]);
61 label_cell($myrow["location_name"]);
62 label_cell(qty_format($myrow["quantity"], $_POST['stock_id']));
71 //end of page full new headings if