2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 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/agpl-3.0.html>.
11 ***********************************************************************/
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 // trial_inquiry_controls();
30 print_bill_of_material();
32 function getTransactions($from, $to)
34 $sql = "SELECT ".TB_PREF."bom.parent,
35 ".TB_PREF."bom.component,
36 ".TB_PREF."stock_master.description as CompDescription,
37 ".TB_PREF."bom.quantity,
38 ".TB_PREF."bom.loc_code,
39 ".TB_PREF."bom.workcentre_added
41 ".TB_PREF."stock_master,
43 WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component
44 AND ".TB_PREF."bom.parent >= '$from'
45 AND ".TB_PREF."bom.parent <= '$to'
47 ".TB_PREF."bom.parent,
48 ".TB_PREF."bom.component";
50 return db_query($sql,"No transactions were returned");
53 //----------------------------------------------------------------------------------------------------
55 function print_bill_of_material()
59 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
61 $frompart = $_POST['PARAM_0'];
62 $topart = $_POST['PARAM_1'];
63 $comments = $_POST['PARAM_2'];
65 $cols = array(0, 50, 305, 375, 445, 515);
67 $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
69 $aligns = array('left', 'left', 'left', 'left', 'right');
71 $params = array( 0 => $comments,
72 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
74 $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize());
77 $rep->Info($params, $cols, $headers, $aligns);
80 $res = getTransactions($frompart, $topart);
82 while ($trans=db_fetch($res))
84 if ($parent != $trans['parent'])
88 $rep->Line($rep->row - 2);
91 $rep->TextCol(0, 1, $trans['parent']);
92 $desc = get_item($trans['parent']);
93 $rep->TextCol(1, 2, $desc['description']);
94 $parent = $trans['parent'];
99 $dec = get_qty_dec($trans['component']);
100 $rep->TextCol(0, 1, $trans['component']);
101 $rep->TextCol(1, 2, $trans['CompDescription']);
102 //$rep->TextCol(2, 3, $trans['loc_code']);
103 //$rep->TextCol(3, 4, $trans['workcentre_added']);
104 $wc = get_work_centre($trans['workcentre_added']);
105 $rep->TextCol(2, 3, get_location_name($trans['loc_code']));
106 $rep->TextCol(3, 4, $wc['name']);
107 $rep->TextCol(4, 5, number_format2($trans['quantity'], $dec));
109 $rep->Line($rep->row - 4);