This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / sql-ledger / bin / mozilla / menu.pl
1 ######################################################################
2 # SQL-Ledger Accounting
3 # Copyright (c) 1998-2002
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 # CHANGE LOG:
28 #   DS. 2002-03-25  Created
29 #######################################################################
30
31 $menufile = "menu.ini";
32 use SL::Menu;
33
34
35 1;
36 # end of main
37
38
39 sub display {
40
41   $framesize = ($ENV{HTTP_USER_AGENT} =~ /links/i) ? "240" : "135";
42
43   $form->header;
44
45   print qq|
46
47 <FRAMESET COLS="$framesize,*" BORDER="1">
48
49   <FRAME NAME="acc_menu" SRC="$form->{script}?login=$form->{login}&password=$form->{password}&action=acc_menu&path=$form->{path}">
50   <FRAME NAME="main_window" SRC="login.pl?login=$form->{login}&password=$form->{password}&action=company_logo&path=$form->{path}">
51
52 </FRAMESET>
53
54 </BODY>
55 </HTML>
56 |;
57
58 }
59
60
61
62 sub acc_menu {
63
64   my $menu = new Menu "$menufile";
65   $menu = new Menu "custom_$menufile" if (-f "custom_$menufile");
66   $menu = new Menu "$form->{login}_$menufile" if (-f "$form->{login}_$menufile");
67   
68   $form->{title} = $locale->text('Accounting Menu');
69   
70   $form->header;
71
72   print qq|
73 <body class=menu>
74
75 |;
76
77   &section_menu($menu);
78
79   print qq|
80 </body>
81 </html>
82 |;
83
84 }
85
86
87 sub section_menu {
88   my ($menu, $level) = @_;
89
90   # build tiered menus
91   my @menuorder = $menu->access_control(\%myconfig, $level);
92
93   while (@menuorder) {
94     $item = shift @menuorder;
95     $label = $item;
96     $label =~ s/$level--//g;
97
98     my $spacer = "&nbsp;" x (($item =~ s/--/--/g) * 2);
99
100     $label =~ s/.*--//g;
101     $label = $locale->text($label);
102     $label =~ s/ /&nbsp;/g;
103
104     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
105     
106     if ($menu->{$item}{submenu}) {
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       
131     } else {
132     
133       if ($menu->{$item}{module}) {
134         if ($form->{$item} && $form->{level} eq $item) {
135           $menu->{$item}{$item} = !$form->{$item};
136           print qq|<br>\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
137           
138           # remove same level items
139           map { shift @menuorder } grep /^$item/, @menuorder;
140           
141           &section_menu($menu, $item);
142
143         } else {
144           print qq|<br>\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
145         }
146         
147       } else {
148         
149         print qq|<br><b>$label</b>|;
150         
151         &section_menu($menu, $item);
152
153         print qq|<br>\n|;
154         
155       }
156     }
157   }
158 }
159
160