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