Gettext switching clenaup.
[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 if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
13         die("Restricted access");
14         include_once($path_to_root . '/applications/application.php');
15         include_once($path_to_root . '/applications/customers.php');
16         include_once($path_to_root . '/applications/suppliers.php');
17         include_once($path_to_root . '/applications/inventory.php');
18         include_once($path_to_root . '/applications/manufacturing.php');
19         include_once($path_to_root . '/applications/dimensions.php');
20         include_once($path_to_root . '/applications/generalledger.php');
21         include_once($path_to_root . '/applications/setup.php');
22         include_once($path_to_root . '/installed_extensions.php');
23
24         foreach ($installed_extensions as $ext)
25         {
26                 if (@($ext['active'] && isset($ext['tabs']))) // supressed warnings before 2.2 upgrade
27                         foreach($ext['tabs'] as $tab) {
28                                 include_once($path_to_root.'/'.$ext['path'].'/'.$tab['url']);
29                         }
30         }
31
32         class front_accounting
33                 {
34                 var $user;
35                 var $settings;
36                 var $applications;
37                 var $selected_application;
38                 // GUI
39                 var $menu;
40                 //var $renderer;
41
42                 function front_accounting()
43                 {
44                         //$this->renderer =& new renderer();
45                 }
46                 function add_application(&$app)
47                                 {       
48                                         if ($app->enabled) // skip inactive modules
49                                                 $this->applications[$app->id] = &$app;
50                                 }
51                 function get_application($id)
52                                 {
53                                  if (isset($this->applications[$id]))
54                                         return $this->applications[$id];
55                                  return null;
56                                 }
57                 function get_selected_application()
58                 {
59                         if (isset($this->selected_application))
60                                  return $this->applications[$this->selected_application];
61                         foreach ($this->applications as $application)
62                                 return $application;
63                         return null;
64                 }
65                 function display()
66                 {
67                         global $path_to_root;
68                         
69                         include_once($path_to_root . "/themes/".user_theme()."/renderer.php");
70
71                         $this->init();
72                         $rend = new renderer();
73                         $rend->wa_header();
74                         //$rend->menu_header($this->menu);
75                         $rend->display_applications($this);
76                         //$rend->menu_footer($this->menu);
77                         $rend->wa_footer();
78                         $this->renderer =& $rend;
79                 }
80                 function init()
81                 {
82                         global $installed_extensions, $path_to_root;
83
84                         $this->menu = new menu(_("Main  Menu"));
85                         $this->menu->add_item(_("Main  Menu"), "index.php");
86                         $this->menu->add_item(_("Logout"), "/account/access/logout.php");
87                         $this->applications = array();
88                         $this->add_application(new customers_app());
89                         $this->add_application(new suppliers_app());
90                         $this->add_application(new inventory_app());
91                         $this->add_application(new manufacturing_app());
92                         $this->add_application(new dimensions_app());
93                         $this->add_application(new general_ledger_app());
94
95                         // Do not use global array directly here, or you suffer 
96                         // from buggy php behaviour (unexpected loop break 
97                         // because of same var usage in class constructor).
98                         $extensions = $installed_extensions;
99                         foreach ($extensions as $ext)
100                         {
101                                 if (@($ext['active'] && isset($ext['tabs']))) { // supressed warnings before 2.2 upgrade
102                                         set_ext_domain($ext['path']);
103                                         foreach($ext['tabs'] as $tab) {
104                                                 $class = $tab['tab_id']."_app";
105                                                 if (class_exists($class))
106                                                         $this->add_application(new $class());
107                                         }
108                                 }
109                         }
110                         set_ext_domain();
111                         $this->add_application(new setup_app());
112                 }
113 }
114 ?>