can't set $p without $cgi
[freeside.git] / sql-ledger / old / sql-ledger / 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   
46   @menuorder = $menu->access_control(\%myconfig);
47
48   $form->{title} = "SQL-Ledger $form->{version}";
49   
50   $form->header;
51
52   $offset = int (21 - $#menuorder)/2;
53
54   print "<pre>";
55   print "\n" x $offset;
56   print "</pre>";
57
58   print qq|<center><table>|;
59
60   map { print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $_).$locale->text($_).qq|</a></td></tr>|; } @menuorder;
61
62   print qq'
63 </table>
64
65 </body>
66 </html>
67 ';
68
69   # display the company logo
70 #  $argv = "login=$form->{login}&password=$form->{password}&path=$form->{path}&action=company_logo&noheader=1";
71 #  exec "./login.pl", $argv;
72   
73 }
74
75
76 sub section_menu {
77
78   $menu = new Menu "$menufile", $form->{level};
79   
80   # build tiered menus
81   @menuorder = $menu->access_control(\%myconfig, $form->{level});
82
83   foreach $item (@menuorder) {
84     $a = $item;
85     $item =~ s/^$form->{level}--//;
86     push @neworder, $a unless ($item =~ /--/);
87   }
88   @menuorder = @neworder;
89  
90   $level = $form->{level};
91   $level =~ s/--/ /g;
92
93   $form->{title} = $locale->text($level);
94   
95   $form->header;
96
97   $offset = int (21 - $#menuorder)/2;
98   print "<pre>";
99   print "\n" x $offset;
100   print "</pre>";
101   
102   print qq|<center><table>|;
103
104   foreach $item (@menuorder) {
105     $label = $item;
106     $label =~ s/$form->{level}--//g;
107
108     # remove target
109     $menu->{$item}{target} = "";
110
111     print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $item, $form->{level}).$locale->text($label)."</a></td></tr>";
112   }
113   
114   print qq'</table>
115
116 </body>
117 </html>
118 ';
119
120 }
121
122
123 sub acc_menu {
124   
125   &section_menu;
126   
127 }
128