Ein oben angedocktes, auf CSS basierendes Menü hinzugefügt.
[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>\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&path=$form->{path}" width="100%" height="93%" name="main_window" style="position: absolute; border: 0px; z-index: 99; ">
61 <p>Ihr Browser kann leider keine eingebetteten Frames anzeigen.
62 </p>
63 </iframe>
64 </body>
65 </html>
66
67 |;
68
69 }
70
71 sub clock_line {
72
73   $login = "["
74     . $form->{login}
75     . " - <a href=\"login.pl?path="
76     . $form->{"path"}
77     . "&password="
78     . $form->{"password"}
79     . "&action=logout\" target=\"_top\">"
80     . $locale->text('Logout')
81     . "</a>] ";
82   my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
83       $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
84     = localtime(time);
85   my $CTIME_String = localtime(time);
86   $Monat     += 1;
87   $Jahrestag += 1;
88   $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
89   $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
90   $Jahr += 1900;
91   my @Wochentage = ("Sonntag",    "Montag",  "Dienstag", "Mittwoch",
92                     "Donnerstag", "Freitag", "Samstag");
93   my @Monatsnamen = ("",       "Januar",    "Februar", "M&auml;rz",
94                      "April",  "Mai",       "Juni",    "Juli",
95                      "August", "September", "Oktober", "November",
96                      "Dezember");
97   $datum =
98       $Wochentage[$Wochentag] . ", der "
99     . $Monatstag . "."
100     . $Monat . "."
101     . $Jahr . " - ";
102
103   #$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>";
104   $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>";
105   print qq|
106 <script type="text/javascript">
107 <!--
108 var clockid=new Array()
109 var clockidoutside=new Array()
110 var i_clock=-1
111 var thistime= new Date()
112 var hours= | . $Stunden . qq|;
113 var minutes= | . $Minuten . qq|;
114 var seconds= | . $Sekunden . qq|;
115 if (eval(hours) <10) {hours="0"+hours}
116 if (eval(minutes) < 10) {minutes="0"+minutes}
117 if (seconds < 10) {seconds="0"+seconds}
118 //var thistime = hours+":"+minutes+":"+seconds
119 var thistime = hours+":"+minutes
120
121 function writeclock() {
122         i_clock++
123         if (document.all \|\| document.getElementById \|\| document.layers) {
124                 clockid[i_clock]="clock"+i_clock
125                 document.write("<font family=arial size=2><span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span></font>")
126         }
127 }
128
129 function clockon() {
130         thistime= new Date()
131         hours=thistime.getHours()
132         minutes=thistime.getMinutes()
133         seconds=thistime.getSeconds()
134         if (eval(hours) <10) {hours="0"+hours}
135         if (eval(minutes) < 10) {minutes="0"+minutes}
136         if (seconds < 10) {seconds="0"+seconds}
137         //thistime = hours+":"+minutes+":"+seconds
138         thistime = hours+":"+minutes
139
140         if (document.all) {
141                 for (i=0;i<=clockid.length-1;i++) {
142                         var thisclock=eval(clockid[i])
143                         thisclock.innerHTML=thistime
144                 }
145         }
146
147         if (document.getElementById) {
148                 for (i=0;i<=clockid.length-1;i++) {
149                         document.getElementById(clockid[i]).innerHTML=thistime
150                 }
151         }
152         var timer=setTimeout("clockon()",60000)
153 }
154 //window.onload=clockon
155 //-->
156 </script>
157 <table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
158         <tr>
159                 <td  style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;"> &nbsp; [<a href="JavaScript:top.main_window.print()">drucken</a>]</td>
160                 <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>|
161     . $login . $datum . qq| <script>writeclock()</script>&nbsp;
162                 </td>
163         </tr>
164 </table>
165 |;
166 }
167
168 sub acc_menu {
169   $locale = Locale->new($language, "menu");
170
171   $mainlevel = $form->{level};
172   $mainlevel =~ s/$mainlevel--//g;
173   my $menu = new Menu "$menufile";
174   $menu = new Menu "custom_$menufile" if (-f "custom_$menufile");
175   $menu = new Menu "$form->{login}_$menufile"
176     if (-f "$form->{login}_$menufile");
177
178   $| = 1;
179
180   return print_menu($menu);
181 }
182
183 sub my_length {
184   my ($s) = @_;
185   my $len = 0;
186   my $i;
187   my $skip = 0;
188
189   for ($i = 0; $i < length($s); $i++) {
190     my $c = substr($s, $i, 1);
191     if ($skip && ($c eq ";")) {
192       $skip = 0;
193     } elsif ($skip) {
194       next;
195     } elsif ($c eq "&") {
196       $skip = 1;
197       $len++;
198     } else {
199       $len++;
200     }
201   }
202
203   return $len;
204 }
205
206 sub print_menu {
207   my ($menu, $parent, $depth) = @_;
208   my $html;
209
210   die if ($depth * 1 > 5);
211
212   my @menuorder;
213
214   @menuorder = $menu->access_control(\%myconfig, $parent);
215
216   $parent .= "--" if ($parent);
217
218   foreach my $item (@menuorder) {
219     substr($item, 0, length($parent)) = "";
220     next if (($item eq "") || ($item =~ /--/));
221
222     my $menu_item = $menu->{"${parent}${item}"};
223     my $menu_title = $locale->text($item);
224     my $menu_text = $menu_title;
225
226     $menu_text =~ s/ /<br>/ if ($parent && (my_length($menu_text) >= 17));
227
228     my $target = "main_window";
229     $target = $menu_item->{"target"} if ($menu_item->{"target"});
230
231     if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) ||
232         ($menu_item->{"module"} eq "menu.pl")) {
233
234       my $h = print_menu($menu, "${parent}${item}", $depth * 1 + 1);
235       if (!$parent) {
236         $html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>|;
237       } else {
238         $html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>|;
239       }
240     } else {
241       $html .= qq|<li>|;
242       $html .= $menu->menuitem_v3(\%myconfig, $form, "${parent}$item",
243                                   { "title" => $menu_title,
244                                     "target" => $target });
245       $html .= qq|${menu_text}</a></li>|;
246     }
247   }
248
249   return $html;
250 }