1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # partsgroup, pricegroup administration
32 #======================================================================
36 require "bin/mozilla/common.pl";
45 $::lxdebug->enter_sub;
46 $::auth->assert('config');
48 $::form->{title} = "Add";
49 $::form->{callback} ||= "$::form->{script}?action=add&type=$::form->{type}";
51 call_sub("form_$::form->{type}");
53 $::lxdebug->leave_sub;
57 $::lxdebug->enter_sub;
58 $::auth->assert('config');
60 $::form->{title} = "Edit";
62 if ($::form->{type} eq 'partsgroup') {
63 PE->get_partsgroup(\%::myconfig, $::form);
65 if ($::form->{type} eq 'pricegroup') {
66 PE->get_pricegroup(\%::myconfig, $::form);
68 call_sub("form_$::form->{type}");
70 $::lxdebug->leave_sub;
74 $::lxdebug->enter_sub;
75 $::auth->assert('config');
78 print $::form->parse_html_template('pe/search', {
79 is_pricegroup => $::form->{type} eq 'pricegroup',
82 $::lxdebug->leave_sub;
86 $::lxdebug->enter_sub;
87 $::auth->assert('config');
89 if ($::form->{type} eq 'partsgroup') {
90 $::form->isblank("partsgroup", $::locale->text('Group missing!'));
91 PE->save_partsgroup(\%::myconfig, $::form);
92 $::form->redirect($::locale->text('Group saved!'));
95 # choice pricegroup and save
96 if ($::form->{type} eq 'pricegroup') {
97 $::form->isblank("pricegroup", $::locale->text('Pricegroup missing!'));
98 PE->save_pricegroup(\%::myconfig, $::form);
99 $::form->redirect($::locale->text('Pricegroup saved!'));
102 if(!exists $::form->{addition} && $::form->{id} ne "") {
103 $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber};
104 $::form->{addition} = "SAVED";
105 $::form->save_history;
107 # /saving the history
109 $::lxdebug->leave_sub;
113 $::lxdebug->enter_sub;
114 $::auth->assert('config');
116 PE->delete_tuple(\%::myconfig, $::form);
118 if ($::form->{type} eq 'partsgroup') {
119 $::form->redirect($::locale->text('Group deleted!'));
121 if ($::form->{type} eq 'pricegroup') {
122 $::form->redirect($::locale->text('Pricegroup deleted!'));
125 if(!exists $::form->{addition}) {
126 $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber};
127 $::form->{addition} = "DELETED";
128 $::form->save_history;
130 # /saving the history
131 $::lxdebug->leave_sub;
134 sub continue { call_sub($::form->{nextsub}); }
136 sub partsgroup_report {
137 $::lxdebug->enter_sub;
138 $::auth->assert('config');
140 $::form->{$_} = $::form->unescape($::form->{$_}) for qw(partsgroup);
141 PE->partsgroups(\%::myconfig, $::form);
143 my $callback = build_std_url("action=partsgroup_report", qw(type status));
146 $option .= $::locale->text('All') if $::form->{status} eq 'all';
147 $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned';
149 if ($::form->{partsgroup}) {
150 $callback .= "&partsgroup=$::form->{partsgroup}";
151 $option .= ", " . $::locale->text('Group') . " : $::form->{partsgroup}";
155 $::form->{callback} = $callback;
158 print $::form->parse_html_template('pe/partsgroup_report', {
160 callback => $callback,
161 editlink => build_std_url('action=edit', qw(type status callback)),
164 $::lxdebug->leave_sub;
167 sub form_partsgroup {
168 $::lxdebug->enter_sub;
169 $::auth->assert('config');
171 # $locale->text('Add Group')
172 # $locale->text('Edit Group')
173 $::form->{title} = $::locale->text("$::form->{title} Group");
176 print $::form->parse_html_template('pe/partsgroup_form');
178 $::lxdebug->leave_sub;
181 sub pricegroup_report {
182 $::lxdebug->enter_sub;
183 $::auth->assert('config');
185 $::form->{$_} = $::form->unescape($::form->{$_}) for qw(pricegroup);
186 PE->pricegroups(\%::myconfig, $::form);
188 my $callback = build_std_url('action=pricegroup_report', qw(type status));
191 $option .= $::locale->text('All') if $::form->{status} eq 'all';
192 $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned';
194 if ($::form->{pricegroup}) {
195 $callback .= "&pricegroup=$::form->{pricegroup}";
196 $option .= ", " . $::locale->text('Pricegroup') . " : $::form->{pricegroup}";
200 $::form->{callback} = $callback;
203 print $::form->parse_html_template('pe/pricegroup_report', {
205 callback => $callback,
206 editlink => build_std_url('action=edit', qw(type status callback)),
209 $::lxdebug->leave_sub;
212 sub form_pricegroup {
213 $::lxdebug->enter_sub;
214 $::auth->assert('config');
216 # $locale->text('Add Pricegroup')
217 # $locale->text('Edit Pricegroup')
218 $::form->{title} = $::locale->text("$::form->{title} Pricegroup");
221 print $::form->parse_html_template('pe/pricegroup_form');
223 $::lxdebug->leave_sub;