* Auslagerung der OE-Masken in Templates *
[kivitendo-erp.git] / am.pl
1 #!/usr/bin/perl
2 #
3 ######################################################################
4 # SQL-Ledger Accounting
5 # Copyright (C) 2001
6 #
7 #  Author: Dieter Simader
8 #   Email: dsimader@sql-ledger.org
9 #     Web: http://www.sql-ledger.org
10 #
11 #  Contributors:
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #######################################################################
26 #
27 # this script is the frontend called from bin/$terminal/$script
28 # all the accounting modules are linked to this script which in
29 # turn execute the same script in bin/$terminal/
30 #
31 #######################################################################
32
33 BEGIN {
34   unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
35   push    @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
36 }
37
38 # setup defaults, DO NOT CHANGE
39 $userspath  = "users";
40 $templates  = "templates";
41 $memberfile = "users/members";
42 $sendmail   = "| /usr/sbin/sendmail -t";
43 ########## end ###########################################
44
45 $| = 1;
46
47 use SL::LXDebug;
48 $lxdebug = LXDebug->new();
49
50 use CGI qw( -no_xhtml);
51 use SL::Form;
52 use SL::Locale;
53
54 eval { require "lx-erp.conf"; };
55 eval { require "lx-erp-local.conf"; } if -f "lx-erp-local.conf";
56
57 require "bin/mozilla/common.pl";
58
59 if (defined($latex) && !defined($latex_templates)) {
60   $latex_templates = $latex;
61   undef($latex);
62 }
63
64 $form = new Form;
65 $cgi = new CGI('');
66
67 # this prevents most of the tabindexes being created by CGI.
68 # note: most. popup menus and selecttables will still have tabindexes
69 # use common.pl's NTI function to get rid of those
70 local $CGI::TABINDEX = 0;
71
72 # name of this script
73 $0 =~ tr/\\/\//;
74 $pos = rindex $0, '/';
75 $script = substr($0, $pos + 1);
76
77 # we use $script for the language module
78 $form->{script} = $script;
79
80 # strip .pl for translation files
81 $script =~ s/\.pl//;
82
83 # pull in DBI
84 use DBI;
85
86 $form->{login} =~ s|.*/||;
87
88 # check for user config file, could be missing or ???
89 eval { require("$userspath/$form->{login}.conf"); };
90 if ($@) {
91   $locale = new Locale "$language", "$script";
92
93   $form->{callback} = "";
94   $msg1             = $locale->text('You are logged out!');
95   $msg2             = $locale->text('Login');
96   $form->redirect("$msg1 <p><a href=login.pl target=_top>$msg2</a>");
97 }
98
99 $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
100 map { $form->{$_} = $myconfig{$_} } qw(stylesheet charset)
101   unless (($form->{action} eq 'save') && ($form->{type} eq 'preferences'));
102
103 # locale messages
104 $locale = new Locale "$myconfig{countrycode}", "$script";
105
106 # check password
107 $form->error($locale->text('Incorrect Password!'))
108   if ($form->{password} ne $myconfig{password});
109
110 # did sysadmin lock us out
111 if (-e "$userspath/nologin") {
112   $form->error($locale->text('System currently down for maintenance!'));
113 }
114
115 # pull in the main code
116 require "bin/mozilla/$form->{script}";
117
118 # customized scripts
119 if (-f "bin/mozilla/custom_$form->{script}") {
120   eval { require "bin/mozilla/custom_$form->{script}"; };
121   $form->error($@) if ($@);
122 }
123
124 # customized scripts for login
125 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
126   eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
127   $form->error($@) if ($@);
128 }
129
130 if ($form->{action}) {
131
132   # window title bar, user info
133   $form->{titlebar} =
134       "Lx-Office "
135     . $locale->text('Version')
136     . " $form->{version} - $myconfig{name} - $myconfig{dbname}";
137
138   call_sub($locale->findsub($form->{action}));
139 } else {
140   $form->error($locale->text('action= not defined!'));
141 }
142
143 # end
144