add some time-worked reporting
[freeside.git] / sql-ledger / bin / mozilla / menu.pl
1 ######################################################################
2 # SQL-Ledger Accounting
3 # Copyright (c) 2001
4 #
5 #  Author: Dieter Simader
6 #   Email: dsimader@sql-ledger.org
7 #     Web: http://www.sql-ledger.org
8 #
9 #  Contributors: Christopher Browne
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #######################################################################
24 #
25 # two frame layout with refractured menu
26 #
27 #######################################################################
28
29 $menufile = "menu.ini";
30 use SL::Menu;
31
32
33 1;
34 # end of main
35
36
37 sub display {
38
39   $menuwidth = ($ENV{HTTP_USER_AGENT} =~ /links/i) ? "240" : "155";
40   $menuwidth = $myconfig{menuwidth} if $myconfig{menuwidth};
41
42   $form->header(1);
43
44   print qq|
45
46 <FRAMESET COLS="$menuwidth,*" BORDER="1">
47
48   <FRAME NAME="acc_menu" SRC="$form->{script}?login=$form->{login}&sessionid=$form->{sessionid}&action=acc_menu&path=$form->{path}">
49   <FRAME NAME="main_window" SRC="am.pl?login=$form->{login}&sessionid=$form->{sessionid}&action=company_logo&path=$form->{path}">
50
51 </FRAMESET>
52
53 </BODY>
54 </HTML>
55 |;
56
57 }
58
59
60
61 sub acc_menu {
62
63   my $menu = new Menu "$menufile";
64   $menu = new Menu "custom_$menufile" if (-f "custom_$menufile");
65   $menu = new Menu "$form->{login}_$menufile" if (-f "$form->{login}_$menufile");
66   
67   $form->{title} = $locale->text('Accounting Menu');
68   
69   $form->header;
70
71   print qq|
72 <body class=menu>
73
74 |;
75
76   &section_menu($menu);
77
78   print qq|
79 </body>
80 </html>
81 |;
82
83 }
84
85
86 sub section_menu {
87   my ($menu, $level) = @_;
88
89   # build tiered menus
90   my @menuorder = $menu->access_control(\%myconfig, $level);
91
92   while (@menuorder) {
93     $item = shift @menuorder;
94     $label = $item;
95     $label =~ s/$level--//g;
96
97     my $spacer = "&nbsp;" x (($item =~ s/--/--/g) * 2);
98
99     $label =~ s/.*--//g;
100     $label = $locale->text($label);
101     $label =~ s/ /&nbsp;/g if $label !~ /<img /i;
102
103     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
104     
105     if ($menu->{$item}{submenu}) {
106
107       $menu->{$item}{$item} = !$form->{$item};
108
109       if ($form->{level} && $item =~ $form->{level}) {
110
111         # expand menu
112         print qq|<br>\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
113
114         # remove same level items
115         map { shift @menuorder } grep /^$item/, @menuorder;
116         
117         &section_menu($menu, $item);
118
119         print qq|<br>\n|;
120
121       } else {
122
123         print qq|<br>\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label&nbsp;...</a>|;
124
125         # remove same level items
126         map { shift @menuorder } grep /^$item/, @menuorder;
127
128       }
129       
130     } else {
131     
132       if ($menu->{$item}{module}) {
133
134         print qq|<br>\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
135         
136       } else {
137
138         $form->{tag}++;
139         print qq|<a name="id$form->{tag}"></a>
140         <p><b>$label</b>|;
141         
142         &section_menu($menu, $item);
143
144         print qq|<br>\n|;
145
146       }
147     }
148   }
149 }
150
151
152 sub menubar {
153
154   1;
155
156 }
157
158