unstable-Zweig als Kopie des "alten" trunks erstellt.
[kivitendo-erp.git] / bin / lynx / menu.pl
1 ######################################################################
2 # SQL-Ledger Accounting
3 # Copyright (c) 2001
4 #
5 #  Author: Dieter Simader
6 #   Email: dsimader@sql-ledger.org
7 #     Web: http://www.sql-ledger.org
8 #
9 #  Contributors: Christopher Browne
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #######################################################################
24 #
25 # menu for text based browsers (lynx)
26 #
27 # CHANGE LOG:
28 #   DS. 2000-07-04  Created
29 #   DS. 2001-08-07  access control
30 #   CBB 2002-02-09  Refactored HTML out to subroutines
31 #######################################################################
32
33 $menufile = "menu.ini";
34 use SL::Menu;
35
36
37 1;
38 # end of main
39
40
41
42 sub display {
43
44   $menu = new Menu "$menufile";
45   $menu = new Menu "custom_$menufile" if (-f "custom_$menufile");
46   $menu = new Menu "$form->{login}_$menufile" if (-f "$form->{login}_$menufile");
47   
48   @menuorder = $menu->access_control(\%myconfig);
49
50   $form->{title} = "SQL-Ledger $form->{version}";
51   
52   $form->header;
53
54   $offset = int (21 - $#menuorder)/2;
55
56   print "<pre>";
57   print "\n" x $offset;
58   print "</pre>";
59
60   print qq|<center><table>|;
61
62   map { print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $_).$locale->text($_).qq|</a></td></tr>|; } @menuorder;
63
64   print qq'
65 </table>
66
67 </body>
68 </html>
69 ';
70
71   # display the company logo
72 #  $argv = "login=$form->{login}&password=$form->{password}&path=$form->{path}&action=company_logo&noheader=1";
73 #  exec "./login.pl", $argv;
74   
75 }
76
77
78 sub section_menu {
79
80   $menu = new Menu "$menufile", $form->{level};
81   
82   # build tiered menus
83   @menuorder = $menu->access_control(\%myconfig, $form->{level});
84
85   foreach $item (@menuorder) {
86     $a = $item;
87     $item =~ s/^$form->{level}--//;
88     push @neworder, $a unless ($item =~ /--/);
89   }
90   @menuorder = @neworder;
91  
92   $level = $form->{level};
93   $level =~ s/--/ /g;
94
95   $form->{title} = $locale->text($level);
96   
97   $form->header;
98
99   $offset = int (21 - $#menuorder)/2;
100   print "<pre>";
101   print "\n" x $offset;
102   print "</pre>";
103   
104   print qq|<center><table>|;
105
106   foreach $item (@menuorder) {
107     $label = $item;
108     $label =~ s/$form->{level}--//g;
109
110     # remove target
111     $menu->{$item}{target} = "";
112
113     print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $item, $form->{level}).$locale->text($label)."</a></td></tr>";
114   }
115   
116   print qq'</table>
117
118 </body>
119 </html>
120 ';
121
122 }
123
124
125 sub acc_menu {
126   
127   &section_menu;
128   
129 }
130
131
132 sub menubar {
133   $menu = new Menu "$menufile", "";
134   
135   # build menubar
136   @menuorder = $menu->access_control(\%myconfig, "");
137
138   @neworder = ();
139   map { push @neworder, $_ unless ($_ =~ /--/) } @menuorder;
140   @menuorder = @neworder;
141
142   print "<p>";
143   $form->{script} = "menu.pl";
144
145   foreach $item (@menuorder) {
146     $label = $item;
147
148     # remove target
149     $menu->{$item}{target} = "";
150
151     print $menu->menuitem(\%myconfig, \%$form, $item, "").$locale->text($label)." | ";
152   }
153   
154 }
155