Umstellung der Benutzerverwaltung von Dateien im Verzeichnis "users" auf die Verwendu...
[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?action=company_logo" 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   $fensterlink="menunew.pl?action=display";
69   $fenster = "["."<a href=\"$fensterlink\" target=\"_blank\">neues Fenster</a>]";
70
71   $login = "[Nutzer "
72     . $form->{login}
73     . " - <a href=\"login.pl?action=logout\" target=\"_top\">"
74     . $locale->text('Logout')
75     . "</a>] ";
76   my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
77       $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
78     = localtime(time);
79   my $CTIME_String = localtime(time);
80   $Monat     += 1;
81   $Jahrestag += 1;
82   $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
83   $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
84   $Jahr += 1900;
85   my @Wochentage = ("Sonntag",    "Montag",  "Dienstag", "Mittwoch",
86                     "Donnerstag", "Freitag", "Samstag");
87   my @Monatsnamen = ("",       "Januar",    "Februar", "M&auml;rz",
88                      "April",  "Mai",       "Juni",    "Juli",
89                      "August", "September", "Oktober", "November",
90                      "Dezember");
91   $datum =
92       $Wochentage[$Wochentag] . ", der "
93     . $Monatstag . "."
94     . $Monat . "."
95     . $Jahr . " - ";
96
97   #$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>";
98   $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>";
99   print qq|
100 <script type="text/javascript">
101 <!--
102 function clockon() {
103   var now = new Date();
104   var h = now.getHours();
105   var m = now.getMinutes();
106   document.getElementById('clock_id').innerHTML = (h<10?'0'+h:h)+":"+(m<10?'0'+m:m);
107   var timer=setTimeout("clockon()", 10000);
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; $fenster &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/\Q$mainlevel\E--//g;
126   my $menu = new Menu "$menufile";
127
128   $| = 1;
129
130   print qq|
131 <style>
132 <!--
133
134 .itemBorder {
135   border: 1px solid black
136 }
137
138 .itemText {
139   text-decoration: none;
140   color: #000000;
141   font: 12px Arial, Helvetica
142 }
143
144 .rootItemText {
145   text-decoration: none;
146   color: #ffffff;
147   font: 12px Arial, Helvetica
148 }
149
150 .menu {
151   color:#ffffff;
152   background:url(image/bg_css_menu.png) repeat bottom;
153   border:1px solid;
154   border-color:#ccc #888 #555 #bbb;
155 }
156
157 -->
158 </style>
159
160 <script type="text/javascript">
161 <!--
162 var isDOM = (document.getElementById ? true : false); 
163 var isIE4 = ((document.all && !isDOM) ? true : false);
164 var isNS4 = (document.layers ? true : false);
165 //var KO = (navigator.appName=="Konqueror" \|\| navigator.appName=="Opera") ;
166 var KO = ((navigator.userAgent.indexOf('Opera',0) != -1) \|\| (navigator.userAgent.indexOf('Konqueror',0) != -1));
167 function getRef(id) {
168         if (isDOM) return document.getElementById(id);
169         if (isIE4) return document.all[id];
170         if (isNS4) return document.layers[id];
171 }
172 function getSty(id) {
173         return (isNS4 ? getRef(id) : getRef(id).style);
174
175 var popTimer = 0;
176 var litNow = new Array();
177 function popOver(menuNum, itemNum) {
178         if (KO) document.getElementById("win1").style.visibility = "hidden";
179         clearTimeout(popTimer);
180         hideAllBut(menuNum);
181         litNow = getTree(menuNum, itemNum);
182         changeCol(litNow, true);
183         targetNum = menu[menuNum][itemNum].target;
184         if (targetNum > 0) {
185                 thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
186                 thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
187                 with (menu[targetNum][0].ref) {
188                         left = parseInt(thisX + menu[targetNum][0].x);
189                         top = parseInt(thisY + menu[targetNum][0].y);
190                         visibility = 'visible';
191                 }
192         }
193 }
194 function popOut(menuNum, itemNum) {
195         if ((menuNum == 0) && !menu[menuNum][itemNum].target)
196                 hideAllBut(0)
197                 if (KO) document.getElementById("win1").style.visibility = "visible";
198         else
199                 popTimer = setTimeout('hideAllBut(0)', 500);
200 }
201 function getTree(menuNum, itemNum) {
202         itemArray = new Array(menu.length);
203         while(1) {
204                 itemArray[menuNum] = itemNum;
205                 if (menuNum == 0) return itemArray;
206                 itemNum = menu[menuNum][0].parentItem;
207                 menuNum = menu[menuNum][0].parentMenu;
208         }
209 }
210 function changeCol(changeArray, isOver) {
211         for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
212                 if (changeArray[menuCount]) {
213                         newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
214                         with (menu[menuCount][changeArray[menuCount]].ref) {
215                                 if (isNS4) bgColor = newCol;
216                                 else backgroundColor = newCol;
217                         }
218                 }
219         }
220 }
221 function hideAllBut(menuNum) {
222         var keepMenus = getTree(menuNum, 1);
223         for (count = 0; count < menu.length; count++)
224                 if (!keepMenus[count])
225                         menu[count][0].ref.visibility = 'hidden';
226         changeCol(litNow, false);
227 }
228
229 function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
230         this.isVert = isVert;
231         this.popInd = popInd
232         this.x = x;
233         this.y = y;
234         this.width = width;
235         this.overCol = overCol;
236         this.backCol = backCol;
237         this.borderClass = borderClass;
238         this.textClass = textClass;
239         this.parentMenu = null;
240         this.parentItem = null;
241         this.ref = null;
242 }
243 function Item(text, href, frame, length, spacing, target) {
244         this.text = text;
245         this.href = href;
246         this.frame = frame;
247         this.length = length;
248         this.spacing = spacing;
249         this.target = target;
250         this.ref = null;
251 }
252 function go(link,frame) {
253         tmp=eval("top."+frame);
254         tmp.location=link;
255         //top.main_window.location=link;
256 }
257 function writeMenus() {
258         if (!isDOM && !isIE4 && !isNS4) return;
259         for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
260                 var str = '', itemX = 0, itemY = 0;
261                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
262                         var itemID = 'menu' + currMenu + 'item' + currItem;
263                         var w = (isVert ? width : length);
264                         var h = (isVert ? length : width);
265                         if (isDOM \|\| isIE4) {
266                                 str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
267                                 if (backCol) str += 'background: ' + backCol + '; ';
268                                 str += '" ';
269                         }
270                         if (isNS4) {
271                                 str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
272                                 if (backCol) str += 'bgcolor="' + backCol + '" ';
273                         }
274                         if (borderClass) str += 'class="' + borderClass + '" "';
275                         str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
276                         str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '">';
277                         str +='<tr><td class="' + textClass + '" style="cursor:pointer;" align="left" height="' + (h - 7) + '" onClick=\\'go("' + href + '","' + frame + '")\\'>' + text + '</a></td>';
278                         if (target > 0) {
279                                 menu[target][0].parentMenu = currMenu;
280                                 menu[target][0].parentItem = currItem;
281                                 if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
282                         }
283                         str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
284                         if (isVert) itemY += length + spacing;
285                         else itemX += length + spacing;
286                 }
287                 if (isDOM) {
288                         var newDiv = document.createElement('div');
289                         document.getElementsByTagName('body').item(0).appendChild(newDiv);
290                         newDiv.innerHTML = str;
291                         ref = newDiv.style;
292                         ref.position = 'absolute';
293                         ref.visibility = 'hidden';
294                 }
295                 if (isIE4) {
296                         document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
297                         ref = getSty('menu' + currMenu + 'div');
298                 }
299                 if (isNS4) {
300                         ref = new Layer(0);
301                         ref.document.write(str);
302                         ref.document.close();
303                 }
304                 for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
305                         itemName = 'menu' + currMenu + 'item' + currItem;
306                         if (isDOM \|\| isIE4) menu[currMenu][currItem].ref = getSty(itemName);
307                         if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
308                 }
309         }
310         with(menu[0][0]) {
311                 ref.left = x;
312                 ref.top = y;
313                 ref.visibility = 'visible';
314    }
315 }
316 var menu = new Array();
317 var defOver = '#cccccc';
318 var defBack = '#dddddd';
319 var defLength = 22;
320 menu[0] = new Array();
321 menu[0][0] = new Menu(false, '', 5, 18, 19, '#cccccc', '', '', 'rootItemText');
322
323 |;
324
325   &section_menu($menu);
326
327   print qq|
328 var popOldWidth = window.innerWidth;
329 nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
330 if (isNS4) document.captureEvents(Event.CLICK);
331 document.onclick = clickHandle;
332 function clickHandle(evt) {
333         if (isNS4) document.routeEvent(evt);
334         hideAllBut(0);
335         if (KO) document.getElementById("win1").style.visibility = "visible";
336 }
337 function moveRoot() {
338         with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
339 }
340 //  End -->
341 </script>
342
343 <BODY scrolling="no" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus(); clockon();" onResize="if (isNS4) nsResizeHandler()">
344
345
346 <table class="menu" width="100%" border="0" cellpadding="0" cellspacing="0">
347 <tr><td height="21"><font size="1"> </font></td></tr></table>
348
349
350 |;
351
352   print qq|
353   
354 |;
355
356 }
357
358 sub section_menu {
359   my ($menu, $level) = @_;
360
361   # build tiered menus
362   my @menuorder = $menu->access_control(\%myconfig, $level);
363   $main = 0;
364
365   #$pm=0;
366   $shlp=0;
367   while (@menuorder) {
368     $item  = shift @menuorder;
369     $label = $item;
370     $ml    = $item;
371     $label =~ s/\Q$level\E--//g;
372     $ml    =~ s/--.*//;
373     $label = $locale->text($label);
374     $label =~ s/ /&nbsp;/g;
375     $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
376
377     if ($menu->{$item}{submenu}) {
378       $menu->{$item}{$item} = !$form->{$item};
379
380       # Untermen
381       if ($mlz{"s$ml"} > 1) { 
382                 $z++; 
383                 $sm = 1; 
384       } else { 
385                 $z = $sm; 
386                 $mlz{"s$ml"}++; 
387       }
388       print
389         qq|menu[$mlz{$ml}][$z] = new Item('$label', '#', '', defLength, 0, |
390         . ++$pm
391         . qq|);\n|;
392       $sm = 1;
393       print qq|menu[$pm] = new Array();\n|;
394       print
395         qq|menu[$pm][0] = new Menu(true, '', 85, 0, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
396       map { shift @menuorder } grep /^$item/, @menuorder;
397       &section_menu($menu, $item);
398       map { shift @menuorder } grep /^$item/, @menuorder;
399     } else {
400       if ($menu->{$item}{module}) {
401
402         #Untermenüpunkte
403         $target = $menu->{$item}{target};
404         $uri    = $menu->menuitemNew(\%myconfig, \%$form, $item, $level);
405
406         #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|;
407         print
408           qq|menu[$pm][$sm] = new Item('$label', '$uri', '$target', defLength, 0, 0);\n|;
409         $sm++;
410       } else {    # Hauptmenu
411         my $ml_ = $form->escape($ml);
412         $mm++;
413         $pm++;
414         %mlz   = ($ml, $pm, "s$ml", 1);
415         $shlp = $sm;
416         $sm    = 1;
417         $breit = 15 + length($label) * 6;
418         print
419           qq|menu[0][$mm] = new Item('  $label', '#', '', $breit, 10, $pm);     \n|;
420         print qq|menu[$pm] = new Array();\n|;
421         print
422           qq|menu[$pm][0] = new Menu(true, '>', 0, 20, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
423
424         #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?action=acc_menu&level=$ml_" class="nohover">$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
425         &section_menu($menu, $item);
426
427         #print qq|<br>\n|;
428       }
429     }
430   }
431 }