Changed license type to GPLv3 in top of files
[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 = 2;
13 $path_to_root="../..";
14 include($path_to_root . "/includes/db_pager.inc");
15 include($path_to_root . "/includes/session.inc");
16
17 page(_("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 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 = "SELECT 
41                 bom.parent,
42                 workcentre.name As WorkCentreName,
43                 location.location_name,
44                 bom.quantity,
45                 parent.description
46                 FROM ".TB_PREF."bom as bom, "
47                         .TB_PREF."stock_master as parent, "
48                         .TB_PREF."workcentres as workcentre, "
49                         .TB_PREF."locations as location
50                 WHERE bom.parent = parent.stock_id 
51                         AND bom.workcentre_added = workcentre.id
52                         AND bom.loc_code = location.loc_code
53                         AND bom.component='" . $_POST['stock_id'] . "'";
54
55    $cols = array(
56         _("Parent Item") => array('fun'=>'select_link'), 
57         _("Work Centre"), 
58         _("Location"), 
59         _("Quantity Required")
60         );
61
62 $table =& new_db_pager('usage_table', $sql, $cols);
63
64 if (get_post('_stock_id_update'))
65         $table->set_sql($sql);
66
67 $table->width = "80%";
68 display_db_pager($table);
69
70 end_form();
71 end_page();
72
73 ?>