Filehandles als lokal deklarieren; Kosmetik; Argumente für open() nicht aus $form...
[kivitendo-erp.git] / bin / mozilla / menuv3.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 #######################################################################
34
35 $menufile = "menu.ini";
36 use SL::Menu;
37
38 1;
39
40 # end of main
41
42 sub display {
43   $form->header(qq|<link rel="stylesheet" href="css/menuv3.css?id=| .
44                 int(rand(100000)) . qq|" type="text/css">|);
45
46   print(qq|<body style="padding:0px; margin:0px;">\n|);
47
48   clock_line();
49
50   print qq|
51
52 <div id="menu">
53
54 | . acc_menu() . qq|
55
56 </div>
57
58 <div style="clear: both;"></div>
59
60 <iframe id="win1" src="login.pl?login=$form->{login}&password=$form->{password}&action=company_logo" width="100%" height="94%" name="main_window" style="position: absolute; border: 0px; z-index: 99; ">
61 <p>Ihr Browser kann leider keine eingebetteten Frames anzeigen. Bitte w&auml;hlen Sie ein anderes Men&uuml; in der Benutzerkonfiguration im Administrationsmen&uuml; aus.
62 </p>
63 </iframe>
64 </body>
65 </html>
66
67 |;
68
69 }
70
71 sub clock_line {
72
73   $fensterlink="menuv3.pl?login=$form->{login}&password=$form->{password}&action=display";
74   $fenster = "["."<a href=\"$fensterlink\" target=\"_blank\">neues Fenster</a>]";
75
76   $login = "[".$locale->text('User') . ": "
77     . $form->{login}
78     . " - <a href=\"login.pl?password="
79     . $form->{"password"}
80     . "&action=logout\" target=\"_top\">"
81     . $locale->text('Logout')
82     . "</a>] ";
83   my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
84       $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
85     = localtime(time);
86   my $CTIME_String = localtime(time);
87   $Monat     += 1;
88   $Jahrestag += 1;
89   $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
90   $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
91   $Jahr += 1900;
92   my @Wochentage = ("Sonntag",    "Montag",  "Dienstag", "Mittwoch",
93                     "Donnerstag", "Freitag", "Samstag");
94   my @Monatsnamen = ("",       "Januar",    "Februar", "M&auml;rz",
95                      "April",  "Mai",       "Juni",    "Juli",
96                      "August", "September", "Oktober", "November",
97                      "Dezember");
98   $datum =
99       $Wochentage[$Wochentag] . ", der "
100     . $Monatstag . "."
101     . $Monat . "."
102     . $Jahr . " - ";
103
104   #$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>";
105   $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>";
106   print qq|
107 <script type="text/javascript">
108 <!--
109 function clockon() {
110   var now = new Date();
111   var h = now.getHours();
112   var m = now.getMinutes();
113   document.getElementById('clock_id').innerHTML = (h<10?'0'+h:h)+":"+(m<10?'0'+m:m);
114   var timer=setTimeout("clockon()", 10000);
115 }
116 window.onload=clockon
117 //-->
118 </script>
119 <table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
120   <tr>
121     <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>
122     <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
123       $login $datum <span id='clock_id' style='position:relative'></span>&nbsp;
124     </td>
125   </tr>
126 </table>
127 |;
128 }
129
130 sub acc_menu {
131   $locale = Locale->new($language, "menu");
132
133   $mainlevel = $form->{level};
134   $mainlevel =~ s/$mainlevel--//g;
135   my $menu = new Menu "$menufile";
136
137   $| = 1;
138
139   return print_menu($menu);
140 }
141
142 sub print_menu {
143   my ($menu, $parent, $depth) = @_;
144   my $html;
145
146   die if ($depth * 1 > 5);
147
148   my @menuorder;
149
150   @menuorder = $menu->access_control(\%myconfig, $parent);
151
152   $parent .= "--" if ($parent);
153
154   foreach my $item (@menuorder) {
155     substr($item, 0, length($parent)) = "";
156     next if (($item eq "") || ($item =~ /--/));
157
158     my $menu_item = $menu->{"${parent}${item}"};
159     my $menu_title = $locale->text($item);
160     my $menu_text = $menu_title;
161
162     my $target = "main_window";
163     $target = $menu_item->{"target"} if ($menu_item->{"target"});
164
165     if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) ||
166         ($menu_item->{"module"} eq "menu.pl")) {
167
168       my $h = print_menu($menu, "${parent}${item}", $depth * 1 + 1)."\n";
169       if (!$parent) {
170         $html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|;
171       } else {
172         $html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|;
173       }
174     } else {
175       $html .= qq|<li>|;
176       $html .= $menu->menuitem_v3(\%myconfig, $form, "${parent}$item",
177                                   { "title" => $menu_title,
178                                     "target" => $target });
179       $html .= qq|${menu_text}</a></li>\n|;
180     }
181   }
182
183   return $html;
184 }