Bugfix Tabindex in Kundenerfassenmaske fuer Preisgruppe
[kivitendo-erp.git] / bin / mozilla / menunew.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 CGI::Carp qw(fatalsToBrowser);
41
42 1;
43
44 # end of main
45
46 sub display {
47
48   $form->header;
49
50   &clock_line;
51
52   &acc_menu;
53
54   print qq|
55 <iframe id="win1" src="login.pl?login=$form->{login}&password=$form->{password}&action=company_logo&path=$form->{path}" width="100%" height="93%" name="main_window" style="position: absolute; border:0px;">
56 <p>Ihr Browser kann leider keine eingebetteten Frames anzeigen.
57 </p>
58 </iframe>
59 </body>
60 </html>
61
62 |;
63
64 }
65
66 sub clock_line {
67
68   $login = "["
69     . $form->{login}
70     . " - <a href=\"login.pl?path="
71     . $form->{"path"}
72     . "&password="
73     . $form->{"password"}
74     . "&action=logout\" target=\"_top\">"
75     . $locale->text('Logout')
76     . "</a>] ";
77   my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
78       $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
79     = localtime(time);
80   my $CTIME_String = localtime(time);
81   $Monat     += 1;
82   $Jahrestag += 1;
83   $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
84   $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
85   $Jahr += 1900;
86   my @Wochentage = ("Sonntag",    "Montag",  "Dienstag", "Mittwoch",
87                     "Donnerstag", "Freitag", "Samstag");
88   my @Monatsnamen = ("",       "Januar",    "Februar", "M&auml;rz",
89                      "April",  "Mai",       "Juni",    "Juli",
90                      "August", "September", "Oktober", "November",
91                      "Dezember");
92   $datum =
93       $Wochentage[$Wochentag] . ", der "
94     . $Monatstag . "."
95     . $Monat . "."
96     . $Jahr . " - ";
97
98   #$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>";
99   $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>";
100   print qq|
101 <script type="text/javascript">
102 <!--
103 var clockid=new Array()
104 var clockidoutside=new Array()
105 var i_clock=-1
106 var thistime= new Date()
107 var hours= | . $Stunden . qq|;
108 var minutes= | . $Minuten . qq|;
109 var seconds= | . $Sekunden . qq|;
110 if (eval(hours) <10) {hours="0"+hours}
111 if (eval(minutes) < 10) {minutes="0"+minutes}
112 if (seconds < 10) {seconds="0"+seconds}
113 //var thistime = hours+":"+minutes+":"+seconds
114 var thistime = hours+":"+minutes
115
116 function writeclock() {
117         i_clock++
118         if (document.all \|\| document.getElementById \|\| document.layers) {
119                 clockid[i_clock]="clock"+i_clock
120                 document.write("<font family=arial size=2><span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span></font>")
121         }
122 }
123
124 function clockon() {
125         thistime= new Date()
126         hours=thistime.getHours()
127         minutes=thistime.getMinutes()
128         seconds=thistime.getSeconds()
129         if (eval(hours) <10) {hours="0"+hours}
130         if (eval(minutes) < 10) {minutes="0"+minutes}
131         if (seconds < 10) {seconds="0"+seconds}
132         //thistime = hours+":"+minutes+":"+seconds
133         thistime = hours+":"+minutes
134
135         if (document.all) {
136                 for (i=0;i<=clockid.length-1;i++) {
137                         var thisclock=eval(clockid[i])
138                         thisclock.innerHTML=thistime
139                 }
140         }
141
142         if (document.getElementById) {
143                 for (i=0;i<=clockid.length-1;i++) {
144                         document.getElementById(clockid[i]).innerHTML=thistime
145                 }
146         }
147         var timer=setTimeout("clockon()",60000)
148 }
149 //window.onload=clockon
150 //-->
151 </script>
152 <table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
153         <tr>
154                 <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>|
155     . $login . $datum . qq| <script>writeclock()</script>&nbsp;
156                 </td>
157         </tr>
158 </table>
159 |;
160 }
161
162 sub acc_menu {
163   $mainlevel = $form->{level};
164   $mainlevel =~ s/$mainlevel--//g;
165   my $menu = new Menu "$menufile";
166   $menu = new Menu "custom_$menufile" if (-f "custom_$menufile");
167   $menu = new Menu "$form->{login}_$menufile"
168     if (-f "$form->{login}_$menufile");
169
170   $| = 1;
171
172   print qq|
173 <script type="text/javascript">
174 <!--
175 var isDOM = (document.getElementById ? true : false); 
176 var isIE4 = ((document.all && !isDOM) ? true : false);
177 var isNS4 = (document.layers ? true : false);
178 //var KO = (navigator.appName=="Konqueror" \|\| navigator.appName=="Opera") ;
179 var KO = ((navigator.userAgent.indexOf('Opera',0) != -1) \|\| (navigator.userAgent.indexOf('Konqueror',0) != -1));
180 function getRef(id) {
181         if (isDOM) return document.getElementById(id);
182         if (isIE4) return document.all[id];
183         if (isNS4) return document.layers[id];
184 }
185 function getSty(id) {
186         return (isNS4 ? getRef(id) : getRef(id).style);
187
188 var popTimer = 0;
189 var litNow = new Array();
190 function popOver(menuNum, itemNum) {
191         if (KO) document.getElementById("win1").style.visibility = "hidden";
192         clearTimeout(popTimer);
193         hideAllBut(menuNum);
194         litNow = getTree(menuNum, itemNum);
195         changeCol(litNow, true);
196         targetNum = menu[menuNum][itemNum].target;
197         if (targetNum > 0) {
198                 thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
199                 thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
200                 with (menu[targetNum][0].ref) {
201                         left = parseInt(thisX + menu[targetNum][0].x);
202                         top = parseInt(thisY + menu[targetNum][0].y);
203                         visibility = 'visible';
204                 }
205         }
206 }
207 function popOut(menuNum, itemNum) {
208         if ((menuNum == 0) && !menu[menuNum][itemNum].target)
209                 hideAllBut(0)
210                 if (KO) document.getElementById("win1").style.visibility = "visible";
211         else
212                 popTimer = setTimeout('hideAllBut(0)', 500);
213 }
214 function getTree(menuNum, itemNum) {
215         itemArray = new Array(menu.length);
216         while(1) {
217                 itemArray[menuNum] = itemNum;
218                 if (menuNum == 0) return itemArray;
219                 itemNum = menu[menuNum][0].parentItem;
220                 menuNum = menu[menuNum][0].parentMenu;
221         }
222 }
223 function changeCol(changeArray, isOver) {
224         for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
225                 if (changeArray[menuCount]) {
226                         newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
227                         with (menu[menuCount][changeArray[menuCount]].ref) {
228                                 if (isNS4) bgColor = newCol;
229                                 else backgroundColor = newCol;
230                         }
231                 }
232         }
233 }
234 function hideAllBut(menuNum) {
235         var keepMenus = getTree(menuNum, 1);
236         for (count = 0; count < menu.length; count++)
237                 if (!keepMenus[count])
238                         menu[count][0].ref.visibility = 'hidden';
239         changeCol(litNow, false);
240 }
241
242 function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
243         this.isVert = isVert;
244         this.popInd = popInd
245         this.x = x;
246         this.y = y;
247         this.width = width;
248         this.overCol = overCol;
249         this.backCol = backCol;
250         this.borderClass = borderClass;
251         this.textClass = textClass;
252         this.parentMenu = null;
253         this.parentItem = null;
254         this.ref = null;
255 }
256 function Item(text, href, frame, length, spacing, target) {
257         this.text = text;
258         this.href = href;
259         this.frame = frame;
260         this.length = length;
261         this.spacing = spacing;
262         this.target = target;
263         this.ref = null;
264 }
265 function writeMenus() {
266         if (!isDOM && !isIE4 && !isNS4) return;
267         for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
268                 var str = '', itemX = 0, itemY = 0;
269                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
270                         var itemID = 'menu' + currMenu + 'item' + currItem;
271                         var w = (isVert ? width : length);
272                         var h = (isVert ? length : width);
273                         if (isDOM \|\| isIE4) {
274                                 str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
275                                 if (backCol) str += 'background: ' + backCol + '; ';
276                                 str += '" ';
277                         }
278                         if (isNS4) {
279                                 str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
280                                 if (backCol) str += 'bgcolor="' + backCol + '" ';
281                         }
282                         if (borderClass) str += 'class="' + borderClass + '" ';
283                         str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
284                         str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
285                         if (target > 0) {
286                                 menu[target][0].parentMenu = currMenu;
287                                 menu[target][0].parentItem = currItem;
288                                 if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
289                         }
290                         str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
291                         if (isVert) itemY += length + spacing;
292                         else itemX += length + spacing;
293                 }
294                 if (isDOM) {
295                         var newDiv = document.createElement('div');
296                         document.getElementsByTagName('body').item(0).appendChild(newDiv);
297                         newDiv.innerHTML = str;
298                         ref = newDiv.style;
299                         ref.position = 'absolute';
300                         ref.visibility = 'hidden';
301                 }
302                 if (isIE4) {
303                         document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
304                         ref = getSty('menu' + currMenu + 'div');
305                 }
306                 if (isNS4) {
307                         ref = new Layer(0);
308                         ref.document.write(str);
309                         ref.document.close();
310                 }
311                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
312                         itemName = 'menu' + currMenu + 'item' + currItem;
313                         if (isDOM \|\| isIE4) menu[currMenu][currItem].ref = getSty(itemName);
314                         if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
315                 }
316         }
317         with(menu[0][0]) {
318                 ref.left = x;
319                 ref.top = y;
320                 ref.visibility = 'visible';
321    }
322 }
323 var menu = new Array();
324 var defOver = '#AAAAFF', defBack = '#8888DD';
325 var defLength = 22;
326 menu[0] = new Array();
327 menu[0][0] = new Menu(false, '', 5, 18, 19, '#AAAAFF', '#AAAAFF', '', 'itemText');
328
329 |;
330
331   #
332   &section_menu($menu);
333
334   print qq|
335 var popOldWidth = window.innerWidth;
336 nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
337 if (isNS4) document.captureEvents(Event.CLICK);
338 document.onclick = clickHandle;
339 function clickHandle(evt) {
340         if (isNS4) document.routeEvent(evt);
341         hideAllBut(0);
342         if (KO) document.getElementById("win1").style.visibility = "visible";
343 }
344 function moveRoot() {
345         with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
346 }
347 //  End -->
348 </script>
349 <style>
350 <!--
351
352 .itemBorder { border: 1px solid black }
353 .itemText { text-decoration: none; color: #FFFFFF; font: 12px Arial, Helvetica }
354
355 -->
356 </style>
357
358 <!--body bgcolor="#AAAAff" text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#ffffff" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0"-->
359 <BODY scrolling="no" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus(); clockon();" onResize="if (isNS4) nsResizeHandler()">
360 <!--BODY marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus()" onResize="if (isNS4) nsResizeHandler()"-->
361
362
363 <table bgcolor="#AAAAFF" width="100%" border="0" cellpadding="0" cellspacing="0">
364 <tr><td height="21"><font size="1"> </font></td></tr></table>
365
366 |;
367
368   print qq|
369   
370 |;
371
372 }
373
374 sub section_menu {
375   my ($menu, $level) = @_;
376
377   # build tiered menus
378   my @menuorder = $menu->access_control(\%myconfig, $level);
379   $main = 0;
380
381   #$pm=0;
382   while (@menuorder) {
383     $item  = shift @menuorder;
384     $label = $item;
385     $ml    = $item;
386     $label =~ s/$level--//g;
387     $ml    =~ s/--.*//;
388     $label = $locale->text($label);
389     $label =~ s/ /&nbsp;/g;
390     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
391
392     if ($menu->{$item}{submenu}) {
393       $menu->{$item}{$item} = !$form->{$item};
394
395       # Untermenü
396       if ($mlz{"s$ml"} > 1) { $z = $mlz{"s$ml"}++; $sm = 1; }
397       else { $z = $sm; $mlz{"s$ml"}++; }
398       print
399         qq|menu[$mlz{$ml}][$z] = new Item('$label', '#', '', defLength, 0, |
400         . ++$pm
401         . qq|);\n|;
402       $sm = 1;
403       print qq|menu[$pm] = new Array();\n|;
404       print
405         qq|menu[$pm][0] = new Menu(true, '', 85, 0, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
406       map { shift @menuorder } grep /^$item/, @menuorder;
407       &section_menu($menu, $item);
408       map { shift @menuorder } grep /^$item/, @menuorder;
409     } else {
410       if ($menu->{$item}{module}) {
411
412         #Untermenüpunkte
413         $target = $menu->{$item}{target};
414         $uri    = $menu->menuitemNew(\%myconfig, \%$form, $item, $level);
415
416         #print qq|<tr><td class="hover" height="13" >$spacer<img src="image/unterpunkt.png"  style="vertical-align:text-top">|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></td></tr>\n|;
417         print
418           qq|menu[$pm][$sm] = new Item('$label', '$uri', '$target', defLength, 0, 0);\n|;
419         $sm++;
420       } else {    # Hauptmenu
421         my $ml_ = $form->escape($ml);
422         $mm++;
423         $pm++;
424         %mlz   = ($ml, $pm, "s$ml", 1);
425         $sm    = 1;
426         $breit = 15 + length($label) * 6;
427         print
428           qq|menu[0][$mm] = new Item('  $label', '#', '', $breit, 10, $pm);     \n|;
429         print qq|menu[$pm] = new Array();\n|;
430         print
431           qq|menu[$pm][0] = new Menu(true, '>', 0, 20, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
432
433         #print 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?path=bin/mozilla&action=acc_menu&level=$ml_&login=$form->{login}&password=$form->{password}" class="nohover">$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
434         &section_menu($menu, $item);
435
436         #print qq|<br>\n|;
437       }
438     }
439   }
440 }