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