fix FSF address
[kivitendo-erp.git] / bin / mozilla / pe.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 #
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 # MA 02110-1335, USA.
29 #======================================================================
30 #
31 # partsgroup administration
32 #
33 #======================================================================
34
35 use SL::PE;
36
37 require "bin/mozilla/common.pl";
38
39 use strict;
40
41 1;
42
43 # end of main
44
45 sub add {
46   $::lxdebug->enter_sub;
47   $::auth->assert('config');
48
49   $::form->{title} = "Add";
50   $::form->{callback} ||= "$::form->{script}?action=add&type=$::form->{type}";
51
52   call_sub("form_$::form->{type}");
53
54   $::lxdebug->leave_sub;
55 }
56
57 sub edit {
58   $::lxdebug->enter_sub;
59   $::auth->assert('config');
60
61   $::form->{title} = "Edit";
62
63   if ($::form->{type} eq 'partsgroup') {
64     PE->get_partsgroup(\%::myconfig, $::form);
65   }
66   call_sub("form_$::form->{type}");
67
68   $::lxdebug->leave_sub;
69 }
70
71 sub search {
72   $::lxdebug->enter_sub;
73   $::auth->assert('config');
74
75   $::form->header;
76   print $::form->parse_html_template('pe/search', {
77     is_pricegroup => $::form->{type} eq 'pricegroup',
78   });
79
80   $::lxdebug->leave_sub;
81 }
82
83 sub save {
84   $::lxdebug->enter_sub;
85   $::auth->assert('config');
86
87   if ($::form->{type} eq 'partsgroup') {
88     $::form->isblank("partsgroup", $::locale->text('Group missing!'));
89     PE->save_partsgroup(\%::myconfig, $::form);
90     $::form->redirect($::locale->text('Group saved!'));
91   }
92
93   # saving the history
94   if(!exists $::form->{addition} && $::form->{id} ne "") {
95     $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber};
96     $::form->{addition} = "SAVED";
97     $::form->save_history;
98   }
99   # /saving the history
100
101   $::lxdebug->leave_sub;
102 }
103
104 sub delete {
105   $::lxdebug->enter_sub;
106   $::auth->assert('config');
107
108   PE->delete_tuple(\%::myconfig, $::form);
109
110   if ($::form->{type} eq 'partsgroup') {
111     $::form->redirect($::locale->text('Group deleted!'));
112   }
113   $::lxdebug->leave_sub;
114 }
115
116 sub continue { call_sub($::form->{nextsub}); }
117
118 sub partsgroup_report {
119   $::lxdebug->enter_sub;
120   $::auth->assert('config');
121
122   $::form->{$_} = $::form->unescape($::form->{$_}) for qw(partsgroup);
123   PE->partsgroups(\%::myconfig, $::form);
124
125   my $callback = build_std_url("action=partsgroup_report", qw(type status));
126
127   my $option = '';
128   $option .= $::locale->text('All')      if $::form->{status} eq 'all';
129   $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned';
130
131   if ($::form->{partsgroup}) {
132     $callback .= "&partsgroup=$::form->{partsgroup}";
133     $option   .= ", " . $::locale->text('Group') . " : $::form->{partsgroup}";
134   }
135
136   # escape callback
137   $::form->{callback} = $callback;
138
139   $::form->header;
140   print $::form->parse_html_template('pe/partsgroup_report', {
141     option   => $option,
142     callback => $callback,
143     editlink => build_std_url('action=edit', qw(type status callback)),
144   });
145
146   $::lxdebug->leave_sub;
147 }
148
149 sub form_partsgroup {
150   $::lxdebug->enter_sub;
151   $::auth->assert('config');
152
153   # $locale->text('Add Group')
154   # $locale->text('Edit Group')
155   $::form->{title} = $::locale->text("$::form->{title} Group");
156
157   $::form->header;
158   print $::form->parse_html_template('pe/partsgroup_form');
159
160   $::lxdebug->leave_sub;
161 }