*** empty log message ***
[fa-stable.git] / reporting / rep702.php
1 <?php
2
3 $page_security = 2;
4 // ----------------------------------------------------------------
5 // $ Revision:  2.0 $
6 // Creator:     Joe Hunt
7 // date_:       2005-05-19
8 // Title:       List of Journal Entries
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 . "includes/ui/ui_view.inc");
17
18 //----------------------------------------------------------------------------------------------------
19
20 // trial_inquiry_controls();
21 print_list_of_journal_entries();
22
23 //----------------------------------------------------------------------------------------------------
24
25 function print_list_of_journal_entries()
26 {
27     global $path_to_root;
28
29     include_once($path_to_root . "reporting/includes/pdf_report.inc");
30
31     $from = $_POST['PARAM_0'];
32     $to = $_POST['PARAM_1'];
33     $systype = $_POST['PARAM_2'];
34     $comments = $_POST['PARAM_3'];
35     $dec = user_price_dec();
36
37     $cols = array(0, 100, 240, 300, 400, 460, 520, 580);
38
39     $headers = array(_('Type/Account'), _('Account Name'), _('Date/Dim.'), 
40         _('Person/Item/Memo'), _('Debit'), _('Credit'));
41     
42     $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
43     
44     $params =   array(  0 => $comments,
45                                     1 => array('text' => _('Period'), 'from' => $from,'to' => $to),
46                         2 => array('text' => _('Type'), 'from' => systypes::name($systype),
47                             'to' => ''));
48
49     $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries.pdf", user_pagesize());
50
51     $rep->Font();
52     $rep->Info($params, $cols, $headers, $aligns);
53     $rep->Header();
54
55     if ($systype == -1)
56         $systype = null;
57
58     $trans = get_gl_transactions($from, $to, -1, null, 0, $systype);
59
60     $typeno = 0;
61     while ($myrow=db_fetch($trans))
62     {
63         if ($typeno != $myrow['type_no'])
64         {
65             if ($typeno != 0)
66             {
67                 $rep->Line($rep->row  + 4);
68                 $rep->NewLine();
69             }
70             $typeno = $myrow['type_no'];
71             $TransName = systypes::name($myrow['type']);
72             $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']);
73             $rep->TextCol(2, 3, sql2date($myrow['tran_date']));
74             $coms =  payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]);    
75             $memo = get_comments_string($myrow['type'], $myrow['type_no']);
76             if ($memo != '')
77                 $coms .= ($coms!= "")?"/":"" . $memo;
78             $rep->TextCol(3, 6, $coms);
79             $rep->NewLine(2);
80         }
81         $rep->TextCol(0, 1, $myrow['account']);
82         $rep->TextCol(1, 2, $myrow['account_name']);
83         $dim_str = get_dimension_string($myrow['dimension_id']);
84         $dim_str2 = get_dimension_string($myrow['dimension2_id']);
85         if ($dim_str2 != "")
86                 $dim_str .= "/".$dim_str2;
87         $rep->TextCol(2, 3, $dim_str);
88         $rep->TextCol(3, 4, $myrow['memo_']);
89         if ($myrow['amount'] > 0.0)
90             $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec));
91         else
92             $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec));
93         $rep->NewLine(1, 2);    
94     }
95     $rep->Line($rep->row  + 4);
96     $rep->End();
97 }
98
99 ?>