[0003733] Fixed php7 compatibility issue.
[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/fixed_assets.php');
19         include_once($path_to_root . '/applications/manufacturing.php');
20         include_once($path_to_root . '/applications/dimensions.php');
21         include_once($path_to_root . '/applications/generalledger.php');
22         include_once($path_to_root . '/applications/setup.php');
23         include_once($path_to_root . '/installed_extensions.php');
24
25         class front_accounting
26         {
27                 var $user;
28                 var $settings;
29                 var $applications;
30                 var $selected_application;
31
32                 var $menu;
33
34                 function front_accounting()
35                 {
36                 }
37                 function add_application($app)
38                 {       
39                         if ($app->enabled) // skip inactive modules
40                                 $this->applications[$app->id] = $app;
41                 }
42                 function get_application($id)
43                 {
44                          if (isset($this->applications[$id]))
45                                 return $this->applications[$id];
46                          return null;
47                 }
48                 function get_selected_application()
49                 {
50                         if (isset($this->selected_application))
51                                  return $this->applications[$this->selected_application];
52                         foreach ($this->applications as $application)
53                                 return $application;
54                         return null;
55                 }
56                 function display()
57                 {
58                         global $path_to_root;
59                         
60                         include_once($path_to_root . "/themes/".user_theme()."/renderer.php");
61
62                         $this->init();
63                         $rend = new renderer();
64                         $rend->wa_header();
65
66                         $rend->display_applications($this);
67
68                         $rend->wa_footer();
69                         $this->renderer =& $rend;
70                 }
71                 function init()
72                 {
73                         global $SysPrefs;
74
75                         $this->menu = new menu(_("Main  Menu"));
76                         $this->menu->add_item(_("Main  Menu"), "index.php");
77                         $this->menu->add_item(_("Logout"), "/account/access/logout.php");
78                         $this->applications = array();
79                         $this->add_application(new customers_app());
80                         $this->add_application(new suppliers_app());
81                         $this->add_application(new inventory_app());
82                         if (get_company_pref('use_manufacturing'))
83                                 $this->add_application(new manufacturing_app());
84                         if (get_company_pref('use_fixed_assets'))
85                             $this->add_application(new assets_app());
86                         $this->add_application(new dimensions_app());
87                         $this->add_application(new general_ledger_app());
88
89                         hook_invoke_all('install_tabs', $this);
90
91                         $this->add_application(new setup_app());
92                 }
93         }