4 // ----------------------------------------------------------------
8 // Title: Bill Of Material
9 // ----------------------------------------------------------------
12 include_once($path_to_root . "includes/session.inc");
13 include_once($path_to_root . "includes/date_functions.inc");
14 include_once($path_to_root . "includes/data_checks.inc");
15 include_once($path_to_root . "gl/includes/gl_db.inc");
16 include_once($path_to_root . "inventory/includes/db/items_db.inc");
18 //----------------------------------------------------------------------------------------------------
20 // trial_inquiry_controls();
21 print_bill_of_material();
23 function getTransactions($from, $to)
25 $sql = "SELECT ".TB_PREF."bom.parent,
26 ".TB_PREF."bom.component,
27 ".TB_PREF."stock_master.description as CompDescription,
28 ".TB_PREF."bom.quantity,
29 ".TB_PREF."bom.loc_code,
30 ".TB_PREF."bom.workcentre_added
32 ".TB_PREF."stock_master,
34 WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component
35 AND ".TB_PREF."bom.parent >= '$from'
36 AND ".TB_PREF."bom.parent <= '$to'
38 ".TB_PREF."bom.parent,
39 ".TB_PREF."bom.component";
41 return db_query($sql,"No transactions were returned");
44 //----------------------------------------------------------------------------------------------------
46 function print_bill_of_material()
50 include_once($path_to_root . "reporting/includes/pdf_report.inc");
52 $frompart = $_POST['PARAM_0'];
53 $topart = $_POST['PARAM_1'];
54 $comments = $_POST['PARAM_2'];
56 $dec = user_qty_dec();
58 $cols = array(0, 50, 305, 375, 445, 515);
60 $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
62 $aligns = array('left', 'left', 'left', 'left', 'right');
64 $params = array( 0 => $comments,
65 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
67 $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize());
70 $rep->Info($params, $cols, $headers, $aligns);
73 $res = getTransactions($frompart, $topart);
75 while ($trans=db_fetch($res))
77 if ($parent != $trans['parent'])
81 $rep->Line($rep->row - 2);
84 $rep->TextCol(0, 1, $trans['parent']);
85 $desc = get_item($trans['parent']);
86 $rep->TextCol(1, 2, $desc['description']);
87 $parent = $trans['parent'];
92 $rep->TextCol(0, 1, $trans['component']);
93 $rep->TextCol(1, 2, $trans['CompDescription']);
94 $rep->TextCol(2, 3, $trans['loc_code']);
95 $rep->TextCol(3, 4, $trans['workcentre_added']);
96 $rep->TextCol(4, 5, number_format2($trans['quantity'], $dec));
98 $rep->Line($rep->row - 4);