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 bom.parent,
35 item.description as CompDescription,
40 .TB_PREF."stock_master item,"
42 WHERE item.stock_id=bom.component
43 AND bom.parent >= ".db_escape($from)."
44 AND bom.parent <= ".db_escape($to)."
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 $orientation = $_POST['PARAM_3'];
62 $destination = $_POST['PARAM_4'];
64 include_once($path_to_root . "/reporting/includes/excel_report.inc");
66 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
68 $orientation = ($orientation ? 'L' : 'P');
69 $cols = array(0, 50, 305, 375, 445, 515);
71 $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
73 $aligns = array('left', 'left', 'left', 'left', 'right');
75 $params = array( 0 => $comments,
76 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
78 $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial", user_pagesize(), 9, $orientation);
79 if ($orientation == 'L')
80 recalculate_cols($cols);
83 $rep->Info($params, $cols, $headers, $aligns);
86 $res = getTransactions($frompart, $topart);
88 while ($trans=db_fetch($res))
90 if ($parent != $trans['parent'])
94 $rep->Line($rep->row - 2);
97 $rep->TextCol(0, 1, $trans['parent']);
98 $desc = get_item($trans['parent']);
99 $rep->TextCol(1, 2, $desc['description']);
100 $parent = $trans['parent'];
105 $dec = get_qty_dec($trans['component']);
106 $rep->TextCol(0, 1, $trans['component']);
107 $rep->TextCol(1, 2, $trans['CompDescription']);
108 $wc = get_work_centre($trans['workcentre_added']);
109 $rep->TextCol(2, 3, get_location_name($trans['loc_code']));
110 $rep->TextCol(3, 4, $wc['name']);
111 $rep->AmountCol(4, 5, $trans['quantity'], $dec);
113 $rep->Line($rep->row - 4);