Changed extension include to be outside function. Didn't work in submenus.
[fa-stable.git] / frontaccounting.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         include_once($path_to_root . '/applications/application.php');
13         include_once($path_to_root . '/applications/customers.php');
14         include_once($path_to_root . '/applications/suppliers.php');
15         include_once($path_to_root . '/applications/inventory.php');
16         include_once($path_to_root . '/applications/manufacturing.php');
17         include_once($path_to_root . '/applications/dimensions.php');
18         include_once($path_to_root . '/applications/generalledger.php');
19         include_once($path_to_root . '/applications/setup.php');
20         include_once($path_to_root . '/installed_extensions.php');
21         if (count($installed_extensions) > 0)
22         {
23                 foreach ($installed_extensions as $ext)
24                 {
25                         include_once($path_to_root."/".$ext['folder']."/".$ext['app_file']);
26                 }
27         }       
28
29         include_once($path_to_root . '/modules/installed_modules.php');
30
31         class front_accounting
32                 {
33                 var $user;
34                 var $settings;
35                 var $applications;
36                 var $selected_application;
37                 // GUI
38                 var $menu;
39                 //var $renderer;
40                 function front_accounting()
41                 {
42                         //$this->renderer =& new renderer();
43                 }
44                 function add_application($app)
45                                 {
46                                                         $this->applications[$app->id] = &$app;
47                                 }
48                 function get_application($id)
49                                 {
50                                  if (isset($this->applications[$id]))
51                                         return $this->applications[$id];
52                                  return null;
53                                 }
54                 function get_selected_application()
55                 {
56                         if (isset($this->selected_application))
57                                  return $this->applications[$this->selected_application];
58                         foreach ($this->applications as $application)
59                                 return $application;
60                         return null;
61                 }
62                 function display()
63                 {
64                         global $path_to_root;
65                         include($path_to_root . "/themes/".user_theme()."/renderer.php");
66                         $this->init();
67                         $rend = new renderer();
68                         $rend->wa_header();
69                         //$rend->menu_header($this->menu);
70                         $rend->display_applications($this);
71                         //$rend->menu_footer($this->menu);
72                         $rend->wa_footer();
73                 }
74                 function init()
75                 {
76                         global $installed_extensions, $path_to_root;
77                         $this->menu = new menu(_("Main  Menu"));
78                         $this->menu->add_item(_("Main  Menu"), "index.php");
79                         $this->menu->add_item(_("Logout"), "/account/access/logout.php");
80                         $this->applications = array();
81                         $this->add_application(new customers_app());
82                         $this->add_application(new suppliers_app());
83                         $this->add_application(new inventory_app());
84                         $this->add_application(new manufacturing_app());
85                         $this->add_application(new dimensions_app());
86                         $this->add_application(new general_ledger_app());
87                         if (count($installed_extensions) > 0)
88                         {
89                                 foreach ($installed_extensions as $ext)
90                                 {
91                                         get_text::add_domain($_SESSION['language']->code, 
92                                                 $ext['folder']."/lang");
93                                         $class = $ext['name']."_app";
94                                         $this->add_application(new $class());
95                                         get_text::add_domain($_SESSION['language']->code, 
96                                                 $path_to_root."/lang");
97                                 }
98                         }       
99                         
100                         $this->add_application(new setup_app());
101                         }
102 }
103 ?>