*** empty log message ***
[fa-stable.git] / reporting / rep401.php
1 <?php
2
3 $page_security = 2;
4 // ----------------------------------------------------------------
5 // $ Revision:  2.0 $
6 // Creator:     Joe Hunt
7 // date_:       2005-05-19
8 // Title:       Bill Of Material
9 // ----------------------------------------------------------------
10 $path_to_root="../";
11
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");
17
18 //----------------------------------------------------------------------------------------------------
19
20 // trial_inquiry_controls();
21 print_bill_of_material();
22
23 function getTransactions($from, $to)
24 {
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
31                 FROM
32                         ".TB_PREF."stock_master,
33                         ".TB_PREF."bom
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'
37                 ORDER BY
38                         ".TB_PREF."bom.parent,
39                         ".TB_PREF."bom.component";
40
41     return db_query($sql,"No transactions were returned");
42 }
43
44 //----------------------------------------------------------------------------------------------------
45
46 function print_bill_of_material()
47 {
48     global $path_to_root;
49
50     include_once($path_to_root . "reporting/includes/pdf_report.inc");
51
52     $frompart = $_POST['PARAM_0'];
53     $topart = $_POST['PARAM_1'];
54     $comments = $_POST['PARAM_2'];
55     
56     $dec = user_qty_dec();
57
58         $cols = array(0, 50, 305, 375, 445,     515);
59
60         $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
61
62         $aligns = array('left', 'left', 'left', 'left', 'right');
63
64     $params =   array(  0 => $comments,
65                                     1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
66
67     $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize());
68
69     $rep->Font();
70     $rep->Info($params, $cols, $headers, $aligns);
71     $rep->Header();
72
73         $res = getTransactions($frompart, $topart);
74         $parent = '';
75         while ($trans=db_fetch($res))
76         {
77                 if ($parent != $trans['parent'])
78                 {
79                         if ($parent != '')
80                         {
81                                 $rep->Line($rep->row - 2);
82                                 $rep->NewLine(2, 3);
83                         }
84                         $rep->TextCol(0, 1, $trans['parent']);
85                         $desc = get_item($trans['parent']);
86                         $rep->TextCol(1, 2, $desc['description']);
87                         $parent = $trans['parent'];
88                         $rep->NewLine();
89                 }
90                 
91                 $rep->NewLine();
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));
97         }
98         $rep->Line($rep->row - 4);
99     $rep->End();
100 }
101
102 ?>