263672f215d0ec4d8a78c56418d72d0fe77f27e8
[fa-stable.git] / reporting / rep702.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         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/gpl-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     $from = $_POST['PARAM_0'];
39     $to = $_POST['PARAM_1'];
40     $systype = $_POST['PARAM_2'];
41     $comments = $_POST['PARAM_3'];
42         $destination = $_POST['PARAM_4'];
43         if (isset($destination) && $destination)
44         {
45                 include_once($path_to_root . "/reporting/includes/excel_report.inc");
46                 $filename = "JournalEntries.xml";
47         }       
48         else
49         {
50                 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
51                 $filename = "JournalEntries.pdf";
52         }
53
54     $dec = user_price_dec();
55
56     $cols = array(0, 100, 240, 300, 400, 460, 520, 580);
57
58     $headers = array(_('Type/Account'), _('Account Name'), _('Date/Dim.'),
59         _('Person/Item/Memo'), _('Debit'), _('Credit'));
60
61     $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
62
63     $params =   array(  0 => $comments,
64                                     1 => array('text' => _('Period'), 'from' => $from,'to' => $to),
65                         2 => array('text' => _('Type'), 'from' => systypes::name($systype),
66                             'to' => ''));
67
68     $rep = new FrontReport(_('List of Journal Entries'), $filename, user_pagesize());
69
70     $rep->Font();
71     $rep->Info($params, $cols, $headers, $aligns);
72     $rep->Header();
73
74     if ($systype == -1)
75         $systype = null;
76
77     $trans = get_gl_transactions($from, $to, -1, null, 0, 0, $systype);
78
79     $typeno = 0;
80     while ($myrow=db_fetch($trans))
81     {
82         if ($typeno != $myrow['type_no'])
83         {
84             if ($typeno != 0)
85             {
86                 $rep->Line($rep->row  + 4);
87                 $rep->NewLine();
88             }
89             $typeno = $myrow['type_no'];
90             $TransName = systypes::name($myrow['type']);
91             $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']);
92             $rep->DateCol(2, 3, $myrow['tran_date'], true);
93             $coms =  payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]);
94             $memo = get_comments_string($myrow['type'], $myrow['type_no']);
95             if ($memo != '')
96                 $coms .= ($coms!= "")?"/":"" . $memo;
97             $rep->TextCol(3, 6, $coms);
98             $rep->NewLine(2);
99         }
100         $rep->TextCol(0, 1, $myrow['account']);
101         $rep->TextCol(1, 2, $myrow['account_name']);
102         $dim_str = get_dimension_string($myrow['dimension_id']);
103         $dim_str2 = get_dimension_string($myrow['dimension2_id']);
104         if ($dim_str2 != "")
105                 $dim_str .= "/".$dim_str2;
106         $rep->TextCol(2, 3, $dim_str);
107         $rep->TextCol(3, 4, $myrow['memo_']);
108         if ($myrow['amount'] > 0.0)
109             $rep->AmountCol(4, 5, abs($myrow['amount']), $dec);
110         else
111             $rep->AmountCol(5, 6, abs($myrow['amount']), $dec);
112         $rep->NewLine(1, 2);
113     }
114     $rep->Line($rep->row  + 4);
115     $rep->End();
116 }
117
118 ?>