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 # project administration
31 # partsgroup administration
33 #======================================================================
37 require "bin/mozilla/common.pl";
44 $lxdebug->enter_sub();
46 $auth->assert('config');
48 $form->{title} = "Add";
52 "$form->{script}?action=add&type=$form->{type}"
53 unless $form->{callback};
55 call_sub("form_$form->{type}_header");
56 call_sub("form_$form->{type}_footer");
58 $lxdebug->leave_sub();
62 $lxdebug->enter_sub();
64 $auth->assert('config');
67 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
68 #/show hhistory button
69 $form->{title} = "Edit";
71 if ($form->{type} eq 'project') {
72 PE->get_project(\%myconfig, \%$form);
74 if ($form->{type} eq 'partsgroup') {
75 PE->get_partsgroup(\%myconfig, \%$form);
77 if ($form->{type} eq 'pricegroup') {
78 PE->get_pricegroup(\%myconfig, \%$form);
80 call_sub("form_$form->{type}_header");
81 call_sub("form_$form->{type}_footer");
83 $lxdebug->leave_sub();
87 $lxdebug->enter_sub();
89 $auth->assert('config');
91 if ($form->{type} eq 'project') {
92 $report = "project_report";
93 $sort = 'projectnumber';
94 $form->{title} = $locale->text('Projects');
98 <th align=right width=1%>| . $locale->text('Number') . qq|</th>
99 <td>| . $cgi->textfield('-name' => 'projectnumber', '-size' => 20) . qq|</td>
102 <th align=right>| . $locale->text('Description') . qq|</th>
103 <td>| . $cgi->textfield('-name' => 'description', '-size' => 60) . qq|</td>
108 $cgi->radio_group('-name' => 'active', '-default' => 'active',
109 '-values' => ['active', 'inactive', 'both'],
110 '-labels' => { 'active' => ' ' . $locale->text("Active"),
111 'inactive' => ' ' . $locale->text("Inactive"),
112 'both' => ' ' . $locale->text("Both") })
118 if ($form->{type} eq 'partsgroup') {
119 $report = "partsgroup_report";
120 $sort = 'partsgroup';
121 $form->{title} = $locale->text('Groups');
125 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
126 <td><input name=partsgroup size=20></td>
133 if ($form->{type} eq 'pricegroup') {
134 $report = "pricegroup_report";
135 $sort = 'pricegroup';
136 $form->{title} = $locale->text('Pricegroup');
140 <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
141 <td><input name=pricegroup size=20></td>
152 <form method=post action=$form->{script}>
154 <input type=hidden name=sort value=$sort>
155 <input type=hidden name=type value=$form->{type}>
159 <th class=listtop>$form->{title}</th>
168 <td><input name=status class=radio type=radio value=all checked> |
169 . $locale->text('All') . qq|
170 <input name=status class=radio type=radio value=orphaned> |
171 . $locale->text('Orphaned') . qq|</td>
177 <td><hr size=3 noshade></td>
181 <input type=hidden name=nextsub value=$report>
184 <input class=submit type=submit name=action value="|
185 . $locale->text('Continue') . qq|">
192 $lxdebug->leave_sub();
196 $lxdebug->enter_sub();
198 $auth->assert('config');
200 map { $form->{$_} = $form->unescape($form->{$_}) }
201 (projectnumber, description);
202 PE->projects(\%myconfig, \%$form);
205 "$form->{script}?action=project_report&type=$form->{type}&status=$form->{status}&active=" .
209 if ($form->{status} eq 'all') {
210 $option = $locale->text('All');
212 if ($form->{status} eq 'orphaned') {
213 $option .= $locale->text('Orphaned');
215 if ($form->{projectnumber}) {
216 $href .= "&projectnumber=" . $form->escape($form->{projectnumber});
217 $callback .= "&projectnumber=$form->{projectnumber}";
219 "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
221 if ($form->{description}) {
222 $href .= "&description=" . $form->escape($form->{description});
223 $callback .= "&description=$form->{description}";
225 "\n<br>" . $locale->text('Description') . " : $form->{description}";
228 @column_index = qw(projectnumber description);
230 push(@column_index, "active") if ("both" eq $form->{active});
232 $column_header{projectnumber} =
233 qq|<th><a class=listheading href=$href&sort=projectnumber>|
234 . $locale->text('Number')
236 $column_header{description} =
237 qq|<th><a class=listheading href=$href&sort=description>|
238 . $locale->text('Description')
240 $column_header{active} =
241 qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
243 $form->{title} = $locale->text('Projects');
252 <th class=listtop>$form->{title}</th>
261 <tr class=listheading>
264 map { print "$column_header{$_}\n" } @column_index;
271 $form->{callback} = $callback .= "&sort=$form->{sort}";
273 # escape callback for href
274 $callback = $form->escape($callback);
276 foreach $ref (@{ $form->{project_list} }) {
282 <tr valign=top class=listrow$i>
285 $column_data{projectnumber} =
286 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{projectnumber}</td>|;
287 $column_data{description} = qq|<td>$ref->{description} </td>|;
288 $column_data{active} =
290 ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
293 map { print "$column_data{$_}\n" } @column_index;
305 <td><hr size=3 noshade></td>
310 <form method=post action=$form->{script}>
312 <input name=callback type=hidden value="$form->{callback}">
314 <input type=hidden name=type value=$form->{type}>
316 <input class=submit type=submit name=action value="|
317 . $locale->text('Add') . qq|">
325 $lxdebug->leave_sub();
328 sub form_project_header {
329 $lxdebug->enter_sub();
331 $auth->assert('config');
333 $form->{title} = $locale->text("$form->{title} Project");
335 # $locale->text('Add Project')
336 # $locale->text('Edit Project')
338 $form->{description} =~ s/\"/"/g;
341 $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
342 '-default' => $form->{projectnumber});
345 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
347 $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
348 '-style' => 'width: 100%', '-wrap' => 'soft',
349 '-default' => $form->{description});
352 $cgi->textfield('-name' => 'description', '-size' => 60,
353 '-default' => $form->{description});
363 $cgi->radio_group('-name' => 'active',
365 '-default' => $form->{active} * 1,
366 '-labels' => { 1 => $locale->text("Active"),
367 0 => $locale->text("Inactive") })
378 <form method=post action=$form->{script}>
380 <input type=hidden name=id value=$form->{id}>
381 <input type=hidden name=type value=project>
385 <th class=listtop>$form->{title}</th>
392 <th align=right>| . $locale->text('Number') . qq|</th>
393 <td>$projectnumber</td>
396 <th align=right>| . $locale->text('Description') . qq|</th>
397 <td>$description</td>
404 <td colspan=2><hr size=3 noshade></td>
409 $lxdebug->leave_sub();
412 sub form_project_footer {
413 $lxdebug->enter_sub();
415 $auth->assert('config');
419 <input name=callback type=hidden value="$form->{callback}">
421 <br><input type=submit class=submit name=action value="|
422 . $locale->text('Save') . qq|">
425 if ($form->{id} && $form->{orphaned}) {
427 <input type=submit class=submit name=action value="|
428 . $locale->text('Delete') . qq|">|;
432 # button for saving history
434 <input type=button onclick=set_history_window(|
436 . qq|); name=history id=history value=|
437 . $locale->text('history')
439 # /button for saving history
449 $lxdebug->leave_sub();
453 $lxdebug->enter_sub();
455 $auth->assert('config');
457 if ($form->{type} eq 'project') {
458 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
459 PE->save_project(\%myconfig, \%$form);
460 $form->redirect($locale->text('Project saved!'));
462 if ($form->{type} eq 'partsgroup') {
463 $form->isblank("partsgroup", $locale->text('Group missing!'));
464 PE->save_partsgroup(\%myconfig, \%$form);
465 $form->redirect($locale->text('Group saved!'));
468 # choice pricegroup and save
469 if ($form->{type} eq 'pricegroup') {
470 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
471 PE->save_pricegroup(\%myconfig, \%$form);
472 $form->redirect($locale->text('Pricegroup saved!'));
475 if(!exists $form->{addition} && $form->{id} ne "") {
476 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
477 $form->{addition} = "SAVED";
478 $form->save_history($form->dbconnect(\%myconfig));
480 # /saving the history
482 $lxdebug->leave_sub();
486 $lxdebug->enter_sub();
488 $auth->assert('config');
490 PE->delete_tuple(\%myconfig, \%$form);
492 if ($form->{type} eq 'project') {
493 $form->redirect($locale->text('Project deleted!'));
495 if ($form->{type} eq 'partsgroup') {
496 $form->redirect($locale->text('Group deleted!'));
498 if ($form->{type} eq 'pricegroup') {
499 $form->redirect($locale->text('Pricegroup deleted!'));
502 if(!exists $form->{addition}) {
503 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
504 $form->{addition} = "DELETED";
505 $form->save_history($form->dbconnect(\%myconfig));
507 # /saving the history
508 $lxdebug->leave_sub();
511 sub continue { call_sub($form->{"nextsub"}); }
513 sub partsgroup_report {
514 $lxdebug->enter_sub();
516 $auth->assert('config');
518 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
519 PE->partsgroups(\%myconfig, \%$form);
522 "$form->{script}?action=partsgroup_report&type=$form->{type}&status=$form->{status}";
524 if ($form->{status} eq 'all') {
525 $option = $locale->text('All');
527 if ($form->{status} eq 'orphaned') {
528 $option .= $locale->text('Orphaned');
530 if ($form->{partsgroup}) {
531 $callback .= "&partsgroup=$form->{partsgroup}";
532 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
535 @column_index = $form->sort_columns(qw(partsgroup));
537 $column_header{partsgroup} =
538 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
540 $form->{title} = $locale->text('Groups');
549 <th class=listtop>$form->{title}</th>
558 <tr class=listheading>
561 map { print "$column_header{$_}\n" } @column_index;
568 $form->{callback} = $callback;
570 # escape callback for href
571 $callback = $form->escape($callback);
573 foreach $ref (@{ $form->{item_list} }) {
579 <tr valign=top class=listrow$i>
582 $column_data{partsgroup} =
583 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{partsgroup}</td>|;
584 map { print "$column_data{$_}\n" } @column_index;
596 <td><hr size=3 noshade></td>
601 <form method=post action=$form->{script}>
603 <input name=callback type=hidden value="$form->{callback}">
605 <input type=hidden name=type value=$form->{type}>
607 <input class=submit type=submit name=action value="|
608 . $locale->text('Add') . qq|">
616 $lxdebug->leave_sub();
619 sub form_partsgroup_header {
620 $lxdebug->enter_sub();
622 $auth->assert('config');
624 $form->{title} = $locale->text("$form->{title} Group");
626 # $locale->text('Add Group')
627 # $locale->text('Edit Group')
629 $form->{partsgroup} =~ s/\"/"/g;
636 <form method=post action=$form->{script}>
638 <input type=hidden name=id value=$form->{id}>
639 <input type=hidden name=type value=$form->{type}>
643 <th class=listtop>$form->{title}</th>
650 <th align=right>| . $locale->text('Group') . qq|</th>
652 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
658 <td colspan=2><hr size=3 noshade></td>
663 $lxdebug->leave_sub();
666 sub form_partsgroup_footer {
667 $lxdebug->enter_sub();
669 $auth->assert('config');
673 <input name=callback type=hidden value="$form->{callback}">
675 <br><input type=submit class=submit name=action value="|
676 . $locale->text('Save') . qq|">
679 if ($form->{id} && $form->{orphaned}) {
681 <input type=submit class=submit name=action value="|
682 . $locale->text('Delete') . qq|">|;
685 # button for saving history
687 <input type=button onclick=set_history_window(|
689 . qq|); name=history id=history value=|
690 . $locale->text('history')
692 # /button for saving history
700 $lxdebug->leave_sub();
703 #################################
704 # get pricesgroups and build up html-code
706 sub pricegroup_report {
707 $lxdebug->enter_sub();
709 $auth->assert('config');
711 map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
712 PE->pricegroups(\%myconfig, \%$form);
715 "$form->{script}?action=pricegroup_report&type=$form->{type}&status=$form->{status}";
717 if ($form->{status} eq 'all') {
718 $option = $locale->text('All');
720 if ($form->{status} eq 'orphaned') {
721 $option .= $locale->text('Orphaned');
723 if ($form->{pricegroup}) {
724 $callback .= "&pricegroup=$form->{pricegroup}";
726 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
729 @column_index = $form->sort_columns(qw(pricegroup));
731 $column_header{pricegroup} =
732 qq|<th class=listheading width=90%>|
733 . $locale->text('Pricegroup')
736 $form->{title} = $locale->text('Pricegroup');
745 <th class=listtop>$form->{title}</th>
754 <tr class=listheading>
757 map { print "$column_header{$_}\n" } @column_index;
764 $form->{callback} = $callback;
766 # escape callback for href
767 $callback = $form->escape($callback);
769 foreach $ref (@{ $form->{item_list} }) {
775 <tr valign=top class=listrow$i>
777 $column_data{pricegroup} =
778 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{pricegroup}</td>|;
780 map { print "$column_data{$_}\n" } @column_index;
792 <td><hr size=3 noshade></td>
797 <form method=post action=$form->{script}>
799 <input name=callback type=hidden value="$form->{callback}">
801 <input type=hidden name=type value=$form->{type}>
803 <input class=submit type=submit name=action value="|
804 . $locale->text('Add') . qq|">
812 $lxdebug->leave_sub();
815 #######################
816 #build up pricegroup_header
818 sub form_pricegroup_header {
819 $lxdebug->enter_sub();
821 $auth->assert('config');
823 # $locale->text('Add Pricegroup')
824 # $locale->text('Edit Pricegroup')
826 $form->{title} = $locale->text("$form->{title} Pricegroup");
828 $form->{pricegroup} =~ s/\"/"/g;
835 <form method=post action=$form->{script}>
837 <input type=hidden name=id value=$form->{id}>
838 <input type=hidden name=type value=$form->{type}>
842 <th class=listtop>$form->{title}</th>
849 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
850 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
856 <td colspan=2><hr size=3 noshade></td>
861 $lxdebug->leave_sub();
863 ######################
864 #build up pricegroup_footer
866 sub form_pricegroup_footer {
867 $lxdebug->enter_sub();
869 $auth->assert('config');
873 <input name=callback type=hidden value="$form->{callback}">
875 <br><input type=submit class=submit name=action value="|
876 . $locale->text('Save') . qq|">
879 if ($form->{id} && $form->{orphaned}) {
881 <input type=submit class=submit name=action value="|
882 . $locale->text('Delete') . qq|">|;
885 # button for saving history
887 <input type=button onclick=set_history_window(|
889 . qq|); name=history id=history value=|
890 . $locale->text('history')
892 # /button for saving history
900 $lxdebug->leave_sub();