Switch to new access levels system
[fa-stable.git] / reporting / rep701.php
index 12bea194cccc7c882f880bb5838641a37a1a4f83..847fb04e7371d6f1f4fe9fb35d3d263a296e3c85 100644 (file)
@@ -9,7 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$page_security = 2;
+$page_security = 'SA_GLREP';
 // ----------------------------------------------------------------
 // $ Revision: 2.0 $
 // Creator:    Joe Hunt
@@ -25,7 +25,6 @@ include_once($path_to_root . "/gl/includes/gl_db.inc");
 
 //----------------------------------------------------------------------------------------------------
 
-// trial_inquiry_controls();
 print_Chart_of_Accounts();
 
 //----------------------------------------------------------------------------------------------------
@@ -37,16 +36,11 @@ function print_Chart_of_Accounts()
        $showbalance = $_POST['PARAM_0'];
        $comments = $_POST['PARAM_1'];
        $destination = $_POST['PARAM_2'];
-       if (isset($destination) && $destination)
-       {
+       if ($destination)
                include_once($path_to_root . "/reporting/includes/excel_report.inc");
-               $filename = "ChartOfAccounts.xml";
-       }       
        else
-       {
                include_once($path_to_root . "/reporting/includes/pdf_report.inc");
-               $filename = "ChartOfAccounts.pdf";
-       }
+
        $dec = 0;
 
        $cols = array(0, 50, 300, 425, 500);
@@ -57,7 +51,7 @@ function print_Chart_of_Accounts()
        
        $params = array(0 => $comments);
 
-       $rep = new FrontReport(_('Chart of Accounts'), $filename, user_pagesize());
+       $rep = new FrontReport(_('Chart of Accounts'), "ChartOfAccounts", user_pagesize());
        
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns);
@@ -70,13 +64,6 @@ function print_Chart_of_Accounts()
 
        while ($account=db_fetch($accounts))
        {
-               if ($showbalance == 1)
-               {
-                       $begin = begin_fiscalyear();
-                       if (is_account_balancesheet($account["account_code"]))
-                               $begin = "";
-                       $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
-               }
                if ($account['AccountTypeName'] != $group)
                {
                        if ($classname != '')
@@ -96,19 +83,29 @@ function print_Chart_of_Accounts()
                        $rep->NewLine();
                }
                $classname = $account['AccountClassName'];
-
-               $rep->TextCol(0, 1,     $account['account_code']);
-               $rep->TextCol(1, 2,     $account['account_name']);
-               $rep->TextCol(2, 3,     $account['account_code2']);
-               if ($showbalance == 1)  
-                       $rep->AmountCol(3, 4, $balance, $dec);
-
-               $rep->NewLine();
-               if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+               
+               if ($account['account_code'] != null)
                {
-                       $rep->Line($rep->row - 2);
-                       $rep->Header();
-               }
+                       if ($showbalance == 1)
+                       {
+                               $begin = begin_fiscalyear();
+                               if (is_account_balancesheet($account["account_code"]))
+                                       $begin = "";
+                               $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
+                       }
+                       $rep->TextCol(0, 1,     $account['account_code']);
+                       $rep->TextCol(1, 2,     $account['account_name']);
+                       $rep->TextCol(2, 3,     $account['account_code2']);
+                       if ($showbalance == 1)  
+                               $rep->AmountCol(3, 4, $balance, $dec);
+
+                       $rep->NewLine();
+                       if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight)
+                       {
+                               $rep->Line($rep->row - 2);
+                               $rep->Header();
+                       }
+               }       
        }
        $rep->Line($rep->row);
        $rep->End();