Fenster und Tabtitle im XUL MenĂ¼ gefixt.
[kivitendo-erp.git] / bin / mozilla / menu.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 ######################################################################
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #  Contributors: Christopher Browne
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #######################################################################
30 #
31 # thre frame layout with refractured menu
32 #
33 # CHANGE LOG:
34 #   DS. 2002-03-25  Created
35 #  2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
36 #######################################################################
37
38 $menufile = "menu.ini";
39 use SL::Menu;
40 use Data::Dumper;
41
42 1;
43
44 # end of main
45
46 $framesize = ($ENV{HTTP_USER_AGENT} =~ /links/i) ? "240" : "190";
47
48 sub display {
49   $lxdebug->enter_sub();
50
51   $form->{callback}   = $form->unescape($form->{callback});
52   $form->{callback} ||= "login.pl?action=company_logo";
53
54   $form->header;
55
56   print qq|
57 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
58   <frame  src="kopf.pl" name="kopf"  scrolling="NO">
59   <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" >
60     <frame src="$form->{script}?action=acc_menu" name="acc_menu"  scrolling="auto" noresize marginwidth="0">
61     <frame src="$form->{callback}" name="main_window" scrolling="auto">
62   </frameset>
63   <noframes>
64   You need a browser that can read frames to see this page.
65   </noframes>
66 </frameset>
67 </HTML>
68 |;
69
70   $lxdebug->leave_sub();
71 }
72
73 sub acc_menu {
74   $lxdebug->enter_sub();
75   $mainlevel = $form->{level};
76   $mainlevel =~ s/\Q$mainlevel\E--//g;
77   my $menu = new Menu "$menufile";
78
79   $form->{title} = $locale->text('Accounting Menu');
80
81   $form->header;
82
83   print qq|
84 <body class="menu">
85
86 |;
87   print qq|<div align="left">\n<table width="|
88     . $framesize
89     . qq|" border=0>\n|;
90
91   &section_menu($menu);
92
93   print qq|</table></div>|;
94   print qq|
95 </body>
96 </html>
97 |;
98
99   $lxdebug->leave_sub();
100 }
101
102 sub section_menu {
103   $lxdebug->enter_sub();
104   my ($menu, $level) = @_;
105
106   # build tiered menus
107   my @menuorder = $menu->access_control(\%myconfig, $level);
108   while (@menuorder) {
109     $item  = shift @menuorder;
110     $label = $item;
111     $ml    = $item;
112     $label =~ s/\Q$level\E--//g;
113     $ml    =~ s/--.*//;
114     if ($ml eq $mainlevel) { $zeige = 1; }
115     else { $zeige = 0; }
116     my $spacer = "&nbsp;" x (($item =~ s/--/--/g) * 1);
117     $label =~ s/.*--//g;
118     $label_icon = $label . ".gif";
119     $mlab       = $label;
120     $label      = $locale->text($label);
121
122     # multi line hack, sschoeling jul06
123     # if a label is too long, try to split it at whitespaces, then join it to chunks of less
124     # than 20 chars and store it in an array.
125     # use this array later instead of the &nbsp;-ed label
126     @chunks = ();
127     my ($i,$l) = (-1, 20);
128     map {
129       if (($l += length $_) < 20) {
130         $chunks[$i] .= " $_";
131       } else {
132         $l = length $_;
133         $chunks[++$i] = $_;
134
135       }
136     } split / /, $label;
137     map { s/ /&nbsp;/ } @chunks;
138     # end multi line
139
140     $label =~ s/ /&nbsp;/g;
141     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
142
143     if ($menu->{$item}{submenu}) {
144       $menu->{$item}{$item} = !$form->{$item};
145       if ($form->{level} && $item =~ /^\Q$form->{level}\E/) {
146
147         # expand menu
148         if ($zeige) {
149           print
150             qq|<tr><td valign=bottom><b>$spacer<img src="image/unterpunkt.png">$label</b></td></tr>\n|;
151         }
152
153         # remove same level items
154         map { shift @menuorder } grep /^$item/, @menuorder;
155         &section_menu($menu, $item);
156       } else {
157         if ($zeige) {
158           print qq|<tr><td>|
159             . $menu->menuitem(\%myconfig, \%$form, $item, $level)
160             . qq|$label&nbsp;...</a></td></tr>\n|;
161         }
162
163         # remove same level items
164         map { shift @menuorder } grep /^$item/, @menuorder;
165       }
166     } else {
167       if ($menu->{$item}{module}) {
168         if ($form->{$item} && $form->{level} eq $item) {
169           $menu->{$item}{$item} = !$form->{$item};
170           if ($zeige) {
171             print
172               qq|<tr><td valign=bottom>$spacer<img src="image/unterpunkt.png">|
173               . $menu->menuitem(\%myconfig, \%$form, $item, $level)
174               . qq|$label</a></td></tr>\n|;
175           }
176
177           # remove same level items
178           map { shift @menuorder } grep /^$item/, @menuorder;
179           &section_menu($menu, $item);
180         } else {
181           if ($zeige) {
182             if (scalar @chunks <= 1) {
183               print
184                 qq|<tr><td class="hover" height="13" >$spacer<img src="image/unterpunkt.png"  style="vertical-align:text-top">|
185                 . $menu->menuitem(\%myconfig, \%$form, $item, $level)
186                 . qq|$label</a></td></tr>\n|;
187             } else {
188               my $tmpitem = $menu->menuitem(\%myconfig, \%$form, $item, $level);
189               print
190                 qq|<tr><td class="hover" height="13" >$spacer<img src="image/unterpunkt.png"  style="vertical-align:text-top">|
191                 . $tmpitem
192                 . qq|$chunks[0]</a></td></tr>\n|;
193               map {
194                 print
195                   qq|<tr style="vertical-align:top""><td class="hover">$spacer<img src="image/unterpunkt.png" style="visibility:hidden; width:23; height=2;">|
196                   . $tmpitem
197                   . qq|$chunks[$_]</a></td></tr>\n|;
198               } 1..$#chunks;
199             }
200           }
201         }
202       } else {
203         my $ml_ = $form->escape($ml);
204         print
205           qq|<tr><td class="bg" height="22" align="left" valign="middle" ><img src="image/$item.png" style="vertical-align:middle">&nbsp;<a href="menu.pl?action=acc_menu&level=$ml_" class="nohover">$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
206         &section_menu($menu, $item);
207
208         #print qq|<br>\n|;
209       }
210     }
211   }
212   $lxdebug->leave_sub();
213 }