f01628f8bd367ea3c7324f648262e76dc5a14629
[fa-stable.git] / reporting / rep701.php
1 <?php
2
3 $page_security = 2;
4 // ----------------------------------------------------------------
5 // $ Revision:  2.0 $
6 // Creator:     Joe Hunt
7 // date_:       2005-05-19
8 // Title:       Chart of GL Accounts
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
17 //----------------------------------------------------------------------------------------------------
18
19 // trial_inquiry_controls();
20 print_Chart_of_Accounts();
21
22 //----------------------------------------------------------------------------------------------------
23
24 function print_Chart_of_Accounts()
25 {
26         global $path_to_root;
27
28         include_once($path_to_root . "reporting/includes/pdf_report.inc");
29
30         $showbalance = $_POST['PARAM_0'];
31         $comments = $_POST['PARAM_1'];
32         $dec = 0;
33
34         $cols = array(0, 50, 300, 425, 500);
35
36         $headers = array(_('Account'), _('Account Name'), _('Account Code'), _('Balance'));
37         
38         $aligns = array('left', 'left', 'left', 'right');
39         
40         $params = array(0 => $comments);
41
42         $rep = new FrontReport(_('Chart of Accounts'), "ChartOfAccounts.pdf", user_pagesize());
43         
44         $rep->Font();
45         $rep->Info($params, $cols, $headers, $aligns);
46         $rep->Header();
47
48         $classname = '';
49         $group = '';
50
51         $accounts = get_gl_accounts_all();
52
53         while ($account=db_fetch($accounts))
54         {
55                 if ($showbalance == 1)
56                 {
57                         $begin = begin_fiscalyear();
58                         if (is_account_balancesheet($account["account_code"]))
59                                 $begin = "";
60                         $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
61                 }
62                 if ($account['AccountTypeName'] != $group)
63                 {
64                         if ($classname != '')
65                                 $rep->row -= 4;
66                         if ($account['AccountClassName'] != $classname)
67                         {
68                                 $rep->Font('bold');
69                                 $rep->TextCol(0, 4, $account['AccountClassName']);
70                                 $rep->Font();
71                                 $rep->row -= ($rep->lineHeight + 4);
72                         }
73                         $group = $account['AccountTypeName'];
74                         $rep->TextCol(0, 4, $account['AccountTypeName']);
75                         //$rep->Line($rep->row - 4);
76                         $rep->row -= ($rep->lineHeight + 4);
77                 }
78                 $classname = $account['AccountClassName'];
79
80                 $rep->TextCol(0, 1,     $account['account_code']);
81                 $rep->TextCol(1, 2,     $account['account_name']);
82                 $rep->TextCol(2, 3,     $account['account_code2']);
83                 if ($showbalance == 1)  
84                         $rep->TextCol(3, 4,     number_format2($balance, $dec));
85
86                 $rep->NewLine();
87                 if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
88                 {
89                         $rep->Line($rep->row - 2);
90                         $rep->Header();
91                 }
92         }
93         $rep->Line($rep->row);
94         $rep->End();
95 }
96
97 ?>