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";
43 $lxdebug->enter_sub();
45 $auth->assert('config');
47 $form->{title} = "Add";
51 "$form->{script}?action=add&type=$form->{type}"
52 unless $form->{callback};
54 call_sub("form_$form->{type}_header");
55 call_sub("form_$form->{type}_footer");
57 $lxdebug->leave_sub();
61 $lxdebug->enter_sub();
63 $auth->assert('config');
66 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
67 #/show hhistory button
68 $form->{title} = "Edit";
70 if ($form->{type} eq 'partsgroup') {
71 PE->get_partsgroup(\%myconfig, \%$form);
73 if ($form->{type} eq 'pricegroup') {
74 PE->get_pricegroup(\%myconfig, \%$form);
76 call_sub("form_$form->{type}_header");
77 call_sub("form_$form->{type}_footer");
79 $lxdebug->leave_sub();
83 $lxdebug->enter_sub();
85 $auth->assert('config');
87 if ($form->{type} eq 'partsgroup') {
88 $report = "partsgroup_report";
90 $form->{title} = $locale->text('Groups');
94 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
95 <td><input name=partsgroup size=20></td>
102 if ($form->{type} eq 'pricegroup') {
103 $report = "pricegroup_report";
104 $sort = 'pricegroup';
105 $form->{title} = $locale->text('Pricegroup');
109 <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
110 <td><input name=pricegroup size=20></td>
121 <form method=post action=$form->{script}>
123 <input type=hidden name=sort value=$sort>
124 <input type=hidden name=type value=$form->{type}>
128 <th class=listtop>$form->{title}</th>
137 <td><input name=status class=radio type=radio value=all checked> |
138 . $locale->text('All') . qq|
139 <input name=status class=radio type=radio value=orphaned> |
140 . $locale->text('Orphaned') . qq|</td>
146 <td><hr size=3 noshade></td>
150 <input type=hidden name=nextsub value=$report>
153 <input class=submit type=submit name=action value="|
154 . $locale->text('Continue') . qq|">
161 $lxdebug->leave_sub();
165 $lxdebug->enter_sub();
167 $auth->assert('config');
169 if ($form->{type} eq 'partsgroup') {
170 $form->isblank("partsgroup", $locale->text('Group missing!'));
171 PE->save_partsgroup(\%myconfig, \%$form);
172 $form->redirect($locale->text('Group saved!'));
175 # choice pricegroup and save
176 if ($form->{type} eq 'pricegroup') {
177 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
178 PE->save_pricegroup(\%myconfig, \%$form);
179 $form->redirect($locale->text('Pricegroup saved!'));
182 if(!exists $form->{addition} && $form->{id} ne "") {
183 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
184 $form->{addition} = "SAVED";
185 $form->save_history($form->dbconnect(\%myconfig));
187 # /saving the history
189 $lxdebug->leave_sub();
193 $lxdebug->enter_sub();
195 $auth->assert('config');
197 PE->delete_tuple(\%myconfig, \%$form);
199 if ($form->{type} eq 'partsgroup') {
200 $form->redirect($locale->text('Group deleted!'));
202 if ($form->{type} eq 'pricegroup') {
203 $form->redirect($locale->text('Pricegroup deleted!'));
206 if(!exists $form->{addition}) {
207 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
208 $form->{addition} = "DELETED";
209 $form->save_history($form->dbconnect(\%myconfig));
211 # /saving the history
212 $lxdebug->leave_sub();
215 sub continue { call_sub($form->{"nextsub"}); }
217 sub partsgroup_report {
218 $lxdebug->enter_sub();
220 $auth->assert('config');
222 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
223 PE->partsgroups(\%myconfig, \%$form);
226 "$form->{script}?action=partsgroup_report&type=$form->{type}&status=$form->{status}";
228 if ($form->{status} eq 'all') {
229 $option = $locale->text('All');
231 if ($form->{status} eq 'orphaned') {
232 $option .= $locale->text('Orphaned');
234 if ($form->{partsgroup}) {
235 $callback .= "&partsgroup=$form->{partsgroup}";
236 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
239 @column_index = $form->sort_columns(qw(partsgroup));
241 $column_header{partsgroup} =
242 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
244 $form->{title} = $locale->text('Groups');
253 <th class=listtop>$form->{title}</th>
262 <tr class=listheading>
265 map { print "$column_header{$_}\n" } @column_index;
272 $form->{callback} = $callback;
274 # escape callback for href
275 $callback = $form->escape($callback);
277 foreach $ref (@{ $form->{item_list} }) {
283 <tr valign=top class=listrow$i>
286 $column_data{partsgroup} =
287 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{partsgroup}</td>|;
288 map { print "$column_data{$_}\n" } @column_index;
300 <td><hr size=3 noshade></td>
305 <form method=post action=$form->{script}>
307 <input name=callback type=hidden value="$form->{callback}">
309 <input type=hidden name=type value=$form->{type}>
311 <input class=submit type=submit name=action value="|
312 . $locale->text('Add') . qq|">
320 $lxdebug->leave_sub();
323 sub form_partsgroup_header {
324 $lxdebug->enter_sub();
326 $auth->assert('config');
328 $form->{title} = $locale->text("$form->{title} Group");
330 # $locale->text('Add Group')
331 # $locale->text('Edit Group')
333 $form->{partsgroup} =~ s/\"/"/g;
340 <form method=post action=$form->{script}>
342 <input type=hidden name=id value=$form->{id}>
343 <input type=hidden name=type value=$form->{type}>
347 <th class=listtop>$form->{title}</th>
354 <th align=right>| . $locale->text('Group') . qq|</th>
356 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
362 <td colspan=2><hr size=3 noshade></td>
367 $lxdebug->leave_sub();
370 sub form_partsgroup_footer {
371 $lxdebug->enter_sub();
373 $auth->assert('config');
377 <input name=callback type=hidden value="$form->{callback}">
379 <br><input type=submit class=submit name=action value="|
380 . $locale->text('Save') . qq|">
383 if ($form->{id} && $form->{orphaned}) {
385 <input type=submit class=submit name=action value="|
386 . $locale->text('Delete') . qq|">|;
389 # button for saving history
391 <input type=button onclick=set_history_window(|
393 . qq|); name=history id=history value=|
394 . $locale->text('history')
396 # /button for saving history
404 $lxdebug->leave_sub();
407 #################################
408 # get pricesgroups and build up html-code
410 sub pricegroup_report {
411 $lxdebug->enter_sub();
413 $auth->assert('config');
415 map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
416 PE->pricegroups(\%myconfig, \%$form);
419 "$form->{script}?action=pricegroup_report&type=$form->{type}&status=$form->{status}";
421 if ($form->{status} eq 'all') {
422 $option = $locale->text('All');
424 if ($form->{status} eq 'orphaned') {
425 $option .= $locale->text('Orphaned');
427 if ($form->{pricegroup}) {
428 $callback .= "&pricegroup=$form->{pricegroup}";
430 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
433 @column_index = $form->sort_columns(qw(pricegroup));
435 $column_header{pricegroup} =
436 qq|<th class=listheading width=90%>|
437 . $locale->text('Pricegroup')
440 $form->{title} = $locale->text('Pricegroup');
449 <th class=listtop>$form->{title}</th>
458 <tr class=listheading>
461 map { print "$column_header{$_}\n" } @column_index;
468 $form->{callback} = $callback;
470 # escape callback for href
471 $callback = $form->escape($callback);
473 foreach $ref (@{ $form->{item_list} }) {
479 <tr valign=top class=listrow$i>
481 $column_data{pricegroup} =
482 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{pricegroup}</td>|;
484 map { print "$column_data{$_}\n" } @column_index;
496 <td><hr size=3 noshade></td>
501 <form method=post action=$form->{script}>
503 <input name=callback type=hidden value="$form->{callback}">
505 <input type=hidden name=type value=$form->{type}>
507 <input class=submit type=submit name=action value="|
508 . $locale->text('Add') . qq|">
516 $lxdebug->leave_sub();
519 #######################
520 #build up pricegroup_header
522 sub form_pricegroup_header {
523 $lxdebug->enter_sub();
525 $auth->assert('config');
527 # $locale->text('Add Pricegroup')
528 # $locale->text('Edit Pricegroup')
530 $form->{title} = $locale->text("$form->{title} Pricegroup");
532 $form->{pricegroup} =~ s/\"/"/g;
539 <form method=post action=$form->{script}>
541 <input type=hidden name=id value=$form->{id}>
542 <input type=hidden name=type value=$form->{type}>
546 <th class=listtop>$form->{title}</th>
553 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
554 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
560 <td colspan=2><hr size=3 noshade></td>
565 $lxdebug->leave_sub();
567 ######################
568 #build up pricegroup_footer
570 sub form_pricegroup_footer {
571 $lxdebug->enter_sub();
573 $auth->assert('config');
577 <input name=callback type=hidden value="$form->{callback}">
579 <br><input type=submit class=submit name=action value="|
580 . $locale->text('Save') . qq|">
583 if ($form->{id} && $form->{orphaned}) {
585 <input type=submit class=submit name=action value="|
586 . $locale->text('Delete') . qq|">|;
589 # button for saving history
591 <input type=button onclick=set_history_window(|
593 . qq|); name=history id=history value=|
594 . $locale->text('history')
596 # /button for saving history
604 $lxdebug->leave_sub();