[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / applications / application.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
13 define('MENU_ENTRY', 'menu_entry');
14 define('MENU_TRANSACTION', 'menu_transaction');
15 define('MENU_INQUIRY', 'menu_inquiry');
16 define('MENU_REPORT', 'menu_report');
17 define('MENU_MAINTENANCE', 'menu_maintenance');
18 define('MENU_UPDATE', 'menu_update');
19 define('MENU_SETTINGS', 'menu_settings');
20 define('MENU_SYSTEM', 'menu_system');
21
22     class menu_item
23         {
24                 var $label;
25                 var $link;
26                 
27                 function __construct($label, $link) 
28                 {
29                         $this->label = $label;
30                         $this->link = $link;
31                 }
32         }
33
34         class menu 
35         {
36                 var $title;
37                 var $items;
38                 
39                 function __construct($title) 
40                 {
41                         $this->title = $title;
42                         $this->items = array();
43                 }
44                 
45                 function add_item($label, $link) 
46                 {
47                         $item = new menu_item($label,$link);
48                         array_push($this->items,$item);
49                         return $item;
50                 }
51                 
52         }
53
54         class app_function 
55         {
56                 var $label;
57                 var $link;
58                 var $access;
59         var $category;
60                 
61                 function __construct($label,$link,$access='SA_OPEN',$category='')
62                 {
63                         $this->label = $label;
64                         $this->link = $link;
65                         $this->access = $access;
66             $this->category = $category;
67                 }
68         }
69
70         class module 
71         {
72                 var $name;
73                 var $icon;
74                 var $lappfunctions;
75                 var $rappfunctions;
76                 
77                 function __construct($name,$icon = null) 
78                 {
79                         $this->name = $name;
80                         $this->icon = $icon;
81                         $this->lappfunctions = array();
82                         $this->rappfunctions = array();
83                 }
84                 
85                 function add_lapp_function($label,$link="",$access='SA_OPEN',$category='')
86                 {
87                         $appfunction = new app_function($label,$link,$access,$category);
88                         $this->lappfunctions[] = $appfunction;
89                         return $appfunction;
90                 }
91
92                 function add_rapp_function($label,$link="",$access='SA_OPEN',$category='')
93                 {
94                         $appfunction = new app_function($label,$link,$access,$category);
95                         $this->rappfunctions[] = $appfunction;
96                         return $appfunction;
97                 }
98                 
99                 
100         }
101
102         class application 
103         {
104                 var $id;
105                 var $name;
106                 var $help_context;
107                 var $modules;
108                 var $enabled;
109                 
110                 function __construct($id, $name, $enabled=true) 
111                 {
112                         $this->id = $id;
113                         $this->name = $name;
114                         $this->enabled = $enabled;
115                         $this->modules = array();
116                 }
117                 
118                 function add_module($name, $icon = null) 
119                 {
120                         $module = new module($name,$icon);
121                         $this->modules[] = $module;
122                         return $module;
123                 }
124                 
125                 function add_lapp_function($level, $label,$link="",$access='SA_OPEN',$category='')
126                 {
127                         $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access, $category);
128                 }
129                 
130                 function add_rapp_function($level, $label,$link="",$access='SA_OPEN',$category='')
131                 {
132                         $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access, $category);
133                 }
134                 
135                 function add_extensions()
136                 {
137                         hook_invoke_all('install_options', $this);
138                 }
139                 //
140                 // Helper returning link to report class added by extension module.
141                 //
142                 function report_class_url($class)
143                 {
144                         return "reporting/reports_main.php?Class=".$class;
145                 }
146         }
147
148