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