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_BOMREP';
13 // ----------------------------------------------------------------
17 // Title: Bill Of Material
18 // ----------------------------------------------------------------
21 include_once($path_to_root . "/includes/session.inc");
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24 include_once($path_to_root . "/gl/includes/gl_db.inc");
25 include_once($path_to_root . "/inventory/includes/db/items_db.inc");
27 //----------------------------------------------------------------------------------------------------
29 print_bill_of_material();
31 function getTransactions($from, $to)
33 $sql = "SELECT ".TB_PREF."bom.parent,
34 ".TB_PREF."bom.component,
35 ".TB_PREF."stock_master.description as CompDescription,
36 ".TB_PREF."bom.quantity,
37 ".TB_PREF."bom.loc_code,
38 ".TB_PREF."bom.workcentre_added
40 ".TB_PREF."stock_master,
42 WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component
43 AND ".TB_PREF."bom.parent >= ".db_escape($from)."
44 AND ".TB_PREF."bom.parent <= ".db_escape($to)."
46 ".TB_PREF."bom.parent,
47 ".TB_PREF."bom.component";
49 return db_query($sql,"No transactions were returned");
52 //----------------------------------------------------------------------------------------------------
54 function print_bill_of_material()
58 $frompart = $_POST['PARAM_0'];
59 $topart = $_POST['PARAM_1'];
60 $comments = $_POST['PARAM_2'];
61 $destination = $_POST['PARAM_3'];
63 include_once($path_to_root . "/reporting/includes/excel_report.inc");
65 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
67 $cols = array(0, 50, 305, 375, 445, 515);
69 $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
71 $aligns = array('left', 'left', 'left', 'left', 'right');
73 $params = array( 0 => $comments,
74 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
76 $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial", user_pagesize());
79 $rep->Info($params, $cols, $headers, $aligns);
82 $res = getTransactions($frompart, $topart);
84 while ($trans=db_fetch($res))
86 if ($parent != $trans['parent'])
90 $rep->Line($rep->row - 2);
93 $rep->TextCol(0, 1, $trans['parent']);
94 $desc = get_item($trans['parent']);
95 $rep->TextCol(1, 2, $desc['description']);
96 $parent = $trans['parent'];
101 $dec = get_qty_dec($trans['component']);
102 $rep->TextCol(0, 1, $trans['component']);
103 $rep->TextCol(1, 2, $trans['CompDescription']);
104 //$rep->TextCol(2, 3, $trans['loc_code']);
105 //$rep->TextCol(3, 4, $trans['workcentre_added']);
106 $wc = get_work_centre($trans['workcentre_added']);
107 $rep->TextCol(2, 3, get_location_name($trans['loc_code']));
108 $rep->TextCol(3, 4, $wc['name']);
109 $rep->AmountCol(4, 5, $trans['quantity'], $dec);
111 $rep->Line($rep->row - 4);