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 $main::lxdebug->enter_sub();
47 $main::auth->assert('config');
49 my $form = $main::form;
51 $form->{title} = "Add";
55 "$form->{script}?action=add&type=$form->{type}"
56 unless $form->{callback};
58 call_sub("form_$form->{type}_header");
59 call_sub("form_$form->{type}_footer");
61 $main::lxdebug->leave_sub();
65 $main::lxdebug->enter_sub();
67 $main::auth->assert('config');
69 my $form = $main::form;
70 my %myconfig = %main::myconfig;
73 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
74 #/show hhistory button
75 $form->{title} = "Edit";
77 if ($form->{type} eq 'partsgroup') {
78 PE->get_partsgroup(\%myconfig, \%$form);
80 if ($form->{type} eq 'pricegroup') {
81 PE->get_pricegroup(\%myconfig, \%$form);
83 call_sub("form_$form->{type}_header");
84 call_sub("form_$form->{type}_footer");
86 $main::lxdebug->leave_sub();
90 $main::lxdebug->enter_sub();
92 $main::auth->assert('config');
94 my $form = $main::form;
95 my $locale = $main::locale;
97 my ($report, $sort, $number);
98 if ($form->{type} eq 'partsgroup') {
99 $report = "partsgroup_report";
100 $sort = 'partsgroup';
101 $form->{title} = $locale->text('Groups');
105 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
106 <td><input name=partsgroup size=20></td>
113 if ($form->{type} eq 'pricegroup') {
114 $report = "pricegroup_report";
115 $sort = 'pricegroup';
116 $form->{title} = $locale->text('Pricegroup');
120 <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
121 <td><input name=pricegroup size=20></td>
132 <form method=post action=$form->{script}>
134 <input type=hidden name=sort value=$sort>
135 <input type=hidden name=type value=$form->{type}>
139 <th class=listtop>$form->{title}</th>
148 <td><input name=status class=radio type=radio value=all checked> |
149 . $locale->text('All') . qq|
150 <input name=status class=radio type=radio value=orphaned> |
151 . $locale->text('Orphaned') . qq|</td>
157 <td><hr size=3 noshade></td>
161 <input type=hidden name=nextsub value=$report>
164 <input class=submit type=submit name=action value="|
165 . $locale->text('Continue') . qq|">
172 $main::lxdebug->leave_sub();
176 $main::lxdebug->enter_sub();
178 $main::auth->assert('config');
180 my $form = $main::form;
181 my %myconfig = %main::myconfig;
182 my $locale = $main::locale;
184 if ($form->{type} eq 'partsgroup') {
185 $form->isblank("partsgroup", $locale->text('Group missing!'));
186 PE->save_partsgroup(\%myconfig, \%$form);
187 $form->redirect($locale->text('Group saved!'));
190 # choice pricegroup and save
191 if ($form->{type} eq 'pricegroup') {
192 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
193 PE->save_pricegroup(\%myconfig, \%$form);
194 $form->redirect($locale->text('Pricegroup saved!'));
197 if(!exists $form->{addition} && $form->{id} ne "") {
198 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
199 $form->{addition} = "SAVED";
200 $form->save_history($form->dbconnect(\%myconfig));
202 # /saving the history
204 $main::lxdebug->leave_sub();
208 $main::lxdebug->enter_sub();
210 $main::auth->assert('config');
212 my $form = $main::form;
213 my %myconfig = %main::myconfig;
214 my $locale = $main::locale;
216 PE->delete_tuple(\%myconfig, \%$form);
218 if ($form->{type} eq 'partsgroup') {
219 $form->redirect($locale->text('Group deleted!'));
221 if ($form->{type} eq 'pricegroup') {
222 $form->redirect($locale->text('Pricegroup deleted!'));
225 if(!exists $form->{addition}) {
226 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
227 $form->{addition} = "DELETED";
228 $form->save_history($form->dbconnect(\%myconfig));
230 # /saving the history
231 $main::lxdebug->leave_sub();
234 sub continue { call_sub($main::form->{"nextsub"}); }
236 sub partsgroup_report {
237 $main::lxdebug->enter_sub();
239 $main::auth->assert('config');
241 my $form = $main::form;
242 my %myconfig = %main::myconfig;
243 my $locale = $main::locale;
245 map { $form->{$_} = $form->unescape($form->{$_}) } qw(partsgroup);
246 PE->partsgroups(\%myconfig, \%$form);
249 "$form->{script}?action=partsgroup_report&type=$form->{type}&status=$form->{status}";
252 if ($form->{status} eq 'all') {
253 $option = $locale->text('All');
255 if ($form->{status} eq 'orphaned') {
256 $option .= $locale->text('Orphaned');
258 if ($form->{partsgroup}) {
259 $callback .= "&partsgroup=$form->{partsgroup}";
260 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
263 my @column_index = $form->sort_columns(qw(partsgroup));
265 $column_header{partsgroup} =
266 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
268 $form->{title} = $locale->text('Groups');
277 <th class=listtop>$form->{title}</th>
286 <tr class=listheading>
289 map { print "$column_header{$_}\n" } @column_index;
296 $form->{callback} = $callback;
298 # escape callback for href
299 $callback = $form->escape($callback);
301 my ($i, %column_data);
302 foreach my $ref (@{ $form->{item_list} }) {
308 <tr valign=top class=listrow$i>
311 $column_data{partsgroup} =
312 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{partsgroup}</td>|;
313 map { print "$column_data{$_}\n" } @column_index;
325 <td><hr size=3 noshade></td>
330 <form method=post action=$form->{script}>
332 <input name=callback type=hidden value="$form->{callback}">
334 <input type=hidden name=type value=$form->{type}>
336 <input class=submit type=submit name=action value="|
337 . $locale->text('Add') . qq|">
345 $main::lxdebug->leave_sub();
348 sub form_partsgroup_header {
349 $main::lxdebug->enter_sub();
351 $main::auth->assert('config');
353 my $form = $main::form;
354 my $locale = $main::locale;
356 $form->{title} = $locale->text("$form->{title} Group");
358 # $locale->text('Add Group')
359 # $locale->text('Edit Group')
361 $form->{partsgroup} =~ s/\"/"/g;
368 <form method=post action=$form->{script}>
370 <input type=hidden name=id value=$form->{id}>
371 <input type=hidden name=type value=$form->{type}>
375 <th class=listtop>$form->{title}</th>
382 <th align=right>| . $locale->text('Group') . qq|</th>
384 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
390 <td colspan=2><hr size=3 noshade></td>
395 $main::lxdebug->leave_sub();
398 sub form_partsgroup_footer {
399 $main::lxdebug->enter_sub();
401 $main::auth->assert('config');
403 my $form = $main::form;
404 my $locale = $main::locale;
408 <input name=callback type=hidden value="$form->{callback}">
410 <br><input type=submit class=submit name=action value="|
411 . $locale->text('Save') . qq|">
414 if ($form->{id} && $form->{orphaned}) {
416 <input type=submit class=submit name=action value="|
417 . $locale->text('Delete') . qq|">|;
420 # button for saving history
422 <input type=button onclick=set_history_window(|
424 . qq|); name=history id=history value=|
425 . $locale->text('history')
427 # /button for saving history
435 $main::lxdebug->leave_sub();
438 #################################
439 # get pricesgroups and build up html-code
441 sub pricegroup_report {
442 $main::lxdebug->enter_sub();
444 $main::auth->assert('config');
446 my $form = $main::form;
447 my %myconfig = %main::myconfig;
448 my $locale = $main::locale;
450 map { $form->{$_} = $form->unescape($form->{$_}) } qw(pricegroup);
451 PE->pricegroups(\%myconfig, \%$form);
454 "$form->{script}?action=pricegroup_report&type=$form->{type}&status=$form->{status}";
457 if ($form->{status} eq 'all') {
458 $option = $locale->text('All');
460 if ($form->{status} eq 'orphaned') {
461 $option .= $locale->text('Orphaned');
463 if ($form->{pricegroup}) {
464 $callback .= "&pricegroup=$form->{pricegroup}";
466 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
469 my @column_index = $form->sort_columns(qw(pricegroup));
471 $column_header{pricegroup} =
472 qq|<th class=listheading width=90%>|
473 . $locale->text('Pricegroup')
476 $form->{title} = $locale->text('Pricegroup');
485 <th class=listtop>$form->{title}</th>
494 <tr class=listheading>
497 map { print "$column_header{$_}\n" } @column_index;
504 $form->{callback} = $callback;
506 # escape callback for href
507 $callback = $form->escape($callback);
509 my ($i, %column_data);
510 foreach my $ref (@{ $form->{item_list} }) {
516 <tr valign=top class=listrow$i>
518 $column_data{pricegroup} =
519 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{pricegroup}</td>|;
521 map { print "$column_data{$_}\n" } @column_index;
533 <td><hr size=3 noshade></td>
538 <form method=post action=$form->{script}>
540 <input name=callback type=hidden value="$form->{callback}">
542 <input type=hidden name=type value=$form->{type}>
544 <input class=submit type=submit name=action value="|
545 . $locale->text('Add') . qq|">
553 $main::lxdebug->leave_sub();
556 #######################
557 #build up pricegroup_header
559 sub form_pricegroup_header {
560 $main::lxdebug->enter_sub();
562 $main::auth->assert('config');
564 my $form = $main::form;
565 my $locale = $main::locale;
567 # $locale->text('Add Pricegroup')
568 # $locale->text('Edit Pricegroup')
570 $form->{title} = $locale->text("$form->{title} Pricegroup");
572 $form->{pricegroup} =~ s/\"/"/g;
579 <form method=post action=$form->{script}>
581 <input type=hidden name=id value=$form->{id}>
582 <input type=hidden name=type value=$form->{type}>
586 <th class=listtop>$form->{title}</th>
593 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
594 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
600 <td colspan=2><hr size=3 noshade></td>
605 $main::lxdebug->leave_sub();
607 ######################
608 #build up pricegroup_footer
610 sub form_pricegroup_footer {
611 $main::lxdebug->enter_sub();
613 $main::auth->assert('config');
615 my $form = $main::form;
616 my $locale = $main::locale;
620 <input name=callback type=hidden value="$form->{callback}">
622 <br><input type=submit class=submit name=action value="|
623 . $locale->text('Save') . qq|">
626 if ($form->{id} && $form->{orphaned}) {
628 <input type=submit class=submit name=action value="|
629 . $locale->text('Delete') . qq|">|;
632 # button for saving history
634 <input type=button onclick=set_history_window(|
636 . qq|); name=history id=history value=|
637 . $locale->text('history')
639 # /button for saving history
647 $main::lxdebug->leave_sub();