Kosmetik: Perltidy-Lauf nach den Einstellungen in doc/programmierrichtlinien.txt...
[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 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 function getRef(id) {
179         if (isDOM) return document.getElementById(id);
180         if (isIE4) return document.all[id];
181         if (isNS4) return document.layers[id];
182 }
183 function getSty(id) {
184         return (isNS4 ? getRef(id) : getRef(id).style);
185
186 var popTimer = 0;
187 var litNow = new Array();
188 function popOver(menuNum, itemNum) {
189         clearTimeout(popTimer);
190         hideAllBut(menuNum);
191         litNow = getTree(menuNum, itemNum);
192         changeCol(litNow, true);
193         targetNum = menu[menuNum][itemNum].target;
194         if (targetNum > 0) {
195                 thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
196                 thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
197                 with (menu[targetNum][0].ref) {
198                         left = parseInt(thisX + menu[targetNum][0].x);
199                         top = parseInt(thisY + menu[targetNum][0].y);
200                         visibility = 'visible';
201                 }
202         }
203 }
204 function popOut(menuNum, itemNum) {
205         if ((menuNum == 0) && !menu[menuNum][itemNum].target)
206                 hideAllBut(0)
207         else
208                 popTimer = setTimeout('hideAllBut(0)', 500);
209 }
210 function getTree(menuNum, itemNum) {
211         itemArray = new Array(menu.length);
212         while(1) {
213                 itemArray[menuNum] = itemNum;
214                 if (menuNum == 0) return itemArray;
215                 itemNum = menu[menuNum][0].parentItem;
216                 menuNum = menu[menuNum][0].parentMenu;
217         }
218 }
219 function changeCol(changeArray, isOver) {
220         for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
221                 if (changeArray[menuCount]) {
222                         newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
223                         with (menu[menuCount][changeArray[menuCount]].ref) {
224                                 if (isNS4) bgColor = newCol;
225                                 else backgroundColor = newCol;
226                         }
227                 }
228         }
229 }
230 function hideAllBut(menuNum) {
231         var keepMenus = getTree(menuNum, 1);
232         for (count = 0; count < menu.length; count++)
233                 if (!keepMenus[count])
234                         menu[count][0].ref.visibility = 'hidden';
235         changeCol(litNow, false);
236 }
237 function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
238         this.isVert = isVert;
239         this.popInd = popInd
240         this.x = x;
241         this.y = y;
242         this.width = width;
243         this.overCol = overCol;
244         this.backCol = backCol;
245         this.borderClass = borderClass;
246         this.textClass = textClass;
247         this.parentMenu = null;
248         this.parentItem = null;
249         this.ref = null;
250 }
251 function Item(text, href, frame, length, spacing, target) {
252         this.text = text;
253         this.href = href;
254         this.frame = frame;
255         this.length = length;
256         this.spacing = spacing;
257         this.target = target;
258         this.ref = null;
259 }
260 function writeMenus() {
261         if (!isDOM && !isIE4 && !isNS4) return;
262         for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
263                 var str = '', itemX = 0, itemY = 0;
264                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
265                         var itemID = 'menu' + currMenu + 'item' + currItem;
266                         var w = (isVert ? width : length);
267                         var h = (isVert ? length : width);
268                         if (isDOM \|\| isIE4) {
269                                 str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
270                                 if (backCol) str += 'background: ' + backCol + '; ';
271                                 str += '" ';
272                         }
273                         if (isNS4) {
274                                 str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
275                                 if (backCol) str += 'bgcolor="' + backCol + '" ';
276                         }
277                         if (borderClass) str += 'class="' + borderClass + '" ';
278                         str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
279                         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>';
280                         if (target > 0) {
281                                 menu[target][0].parentMenu = currMenu;
282                                 menu[target][0].parentItem = currItem;
283                                 if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
284                         }
285                         str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
286                         if (isVert) itemY += length + spacing;
287                         else itemX += length + spacing;
288                 }
289                 if (isDOM) {
290                         var newDiv = document.createElement('div');
291                         document.getElementsByTagName('body').item(0).appendChild(newDiv);
292                         newDiv.innerHTML = str;
293                         ref = newDiv.style;
294                         ref.position = 'absolute';
295                         ref.visibility = 'hidden';
296                 }
297                 if (isIE4) {
298                         document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
299                         ref = getSty('menu' + currMenu + 'div');
300                 }
301                 if (isNS4) {
302                         ref = new Layer(0);
303                         ref.document.write(str);
304                         ref.document.close();
305                 }
306                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
307                         itemName = 'menu' + currMenu + 'item' + currItem;
308                         if (isDOM \|\| isIE4) menu[currMenu][currItem].ref = getSty(itemName);
309                         if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
310                 }
311         }
312         with(menu[0][0]) {
313                 ref.left = x;
314                 ref.top = y;
315                 ref.visibility = 'visible';
316    }
317 }
318 var menu = new Array();
319 var defOver = '#AAAAFF', defBack = '#8888DD';
320 var defLength = 22;
321 menu[0] = new Array();
322 menu[0][0] = new Menu(false, '', 5, 18, 19, '#AAAAFF', '#AAAAFF', '', 'itemText');
323
324 |;
325
326   #
327   &section_menu($menu);
328
329   print qq|
330 var popOldWidth = window.innerWidth;
331 nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
332 if (isNS4) document.captureEvents(Event.CLICK);
333 document.onclick = clickHandle;
334 function clickHandle(evt) {
335         if (isNS4) document.routeEvent(evt);
336         hideAllBut(0);
337 }
338 function moveRoot() {
339         with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
340 }
341 //  End -->
342 </script>
343 <style>
344 <!--
345
346 .itemBorder { border: 1px solid black }
347 .itemText { text-decoration: none; color: #FFFFFF; font: 12px Arial, Helvetica }
348
349 -->
350 </style>
351
352 <!--body bgcolor="#AAAAff" text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#ffffff" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0"-->
353 <BODY scrolling="no" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus(); clockon();" onResize="if (isNS4) nsResizeHandler()">
354 <!--BODY marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus()" onResize="if (isNS4) nsResizeHandler()"-->
355
356
357 <table bgcolor="#AAAAFF" width="100%" border="0" cellpadding="0" cellspacing="0">
358 <tr><td height="21"><font size="1"> </font></td></tr></table>
359
360 |;
361
362   print qq|
363   
364 |;
365
366 }
367
368 sub section_menu {
369   my ($menu, $level) = @_;
370
371   # build tiered menus
372   my @menuorder = $menu->access_control(\%myconfig, $level);
373   $main = 0;
374
375   #$pm=0;
376   while (@menuorder) {
377     $item  = shift @menuorder;
378     $label = $item;
379     $ml    = $item;
380     $label =~ s/$level--//g;
381     $ml    =~ s/--.*//;
382     $label = $locale->text($label);
383     $label =~ s/ /&nbsp;/g;
384     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
385
386     if ($menu->{$item}{submenu}) {
387       $menu->{$item}{$item} = !$form->{$item};
388
389       # Untermenü
390       if ($mlz{"s$ml"} > 1) { $z = $mlz{"s$ml"}++; $sm = 1; }
391       else { $z = $sm; $mlz{"s$ml"}++; }
392       print
393         qq|menu[$mlz{$ml}][$z] = new Item('$label', '#', '', defLength, 0, |
394         . ++$pm
395         . qq|);\n|;
396       $sm = 1;
397       print qq|menu[$pm] = new Array();\n|;
398       print
399         qq|menu[$pm][0] = new Menu(true, '', 85, 0, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
400       map { shift @menuorder } grep /^$item/, @menuorder;
401       &section_menu($menu, $item);
402       map { shift @menuorder } grep /^$item/, @menuorder;
403     } else {
404       if ($menu->{$item}{module}) {
405
406         #Untermenüpunkte
407         $target = $menu->{$item}{target};
408         $uri    = $menu->menuitemNew(\%myconfig, \%$form, $item, $level);
409
410         #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|;
411         print
412           qq|menu[$pm][$sm] = new Item('$label', '$uri', '$target', defLength, 0, 0);\n|;
413         $sm++;
414       } else {    # Hauptmenu
415         my $ml_ = $form->escape($ml);
416         $mm++;
417         $pm++;
418         %mlz   = ($ml, $pm, "s$ml", 1);
419         $sm    = 1;
420         $breit = 15 + length($label) * 6;
421         print
422           qq|menu[0][$mm] = new Item('  $label', '#', '', $breit, 10, $pm);     \n|;
423         print qq|menu[$pm] = new Array();\n|;
424         print
425           qq|menu[$pm][0] = new Menu(true, '>', 0, 22, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
426
427         #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|;
428         &section_menu($menu, $item);
429
430         #print qq|<br>\n|;
431       }
432     }
433   }
434 }