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}&login=$form->{login}&password=$form->{password}"
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>
183 <input type=hidden name=login value=$form->{login}>
184 <input type=hidden name=password value=$form->{password}>
187 <input class=submit type=submit name=action value="|
188 . $locale->text('Continue') . qq|">
195 $lxdebug->leave_sub();
199 $lxdebug->enter_sub();
201 $auth->assert('config');
203 map { $form->{$_} = $form->unescape($form->{$_}) }
204 (projectnumber, description);
205 PE->projects(\%myconfig, \%$form);
208 "$form->{script}?action=project_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}&active=" .
212 if ($form->{status} eq 'all') {
213 $option = $locale->text('All');
215 if ($form->{status} eq 'orphaned') {
216 $option .= $locale->text('Orphaned');
218 if ($form->{projectnumber}) {
219 $href .= "&projectnumber=" . $form->escape($form->{projectnumber});
220 $callback .= "&projectnumber=$form->{projectnumber}";
222 "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
224 if ($form->{description}) {
225 $href .= "&description=" . $form->escape($form->{description});
226 $callback .= "&description=$form->{description}";
228 "\n<br>" . $locale->text('Description') . " : $form->{description}";
231 @column_index = qw(projectnumber description);
233 push(@column_index, "active") if ("both" eq $form->{active});
235 $column_header{projectnumber} =
236 qq|<th><a class=listheading href=$href&sort=projectnumber>|
237 . $locale->text('Number')
239 $column_header{description} =
240 qq|<th><a class=listheading href=$href&sort=description>|
241 . $locale->text('Description')
243 $column_header{active} =
244 qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
246 $form->{title} = $locale->text('Projects');
255 <th class=listtop>$form->{title}</th>
264 <tr class=listheading>
267 map { print "$column_header{$_}\n" } @column_index;
274 $form->{callback} = $callback .= "&sort=$form->{sort}";
276 # escape callback for href
277 $callback = $form->escape($callback);
279 foreach $ref (@{ $form->{project_list} }) {
285 <tr valign=top class=listrow$i>
288 $column_data{projectnumber} =
289 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{projectnumber}</td>|;
290 $column_data{description} = qq|<td>$ref->{description} </td>|;
291 $column_data{active} =
293 ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
296 map { print "$column_data{$_}\n" } @column_index;
308 <td><hr size=3 noshade></td>
313 <form method=post action=$form->{script}>
315 <input name=callback type=hidden value="$form->{callback}">
317 <input type=hidden name=type value=$form->{type}>
319 <input type=hidden name=login value=$form->{login}>
320 <input type=hidden name=password value=$form->{password}>
322 <input class=submit type=submit name=action value="|
323 . $locale->text('Add') . qq|">
331 $lxdebug->leave_sub();
334 sub form_project_header {
335 $lxdebug->enter_sub();
337 $auth->assert('config');
339 $form->{title} = $locale->text("$form->{title} Project");
341 # $locale->text('Add Project')
342 # $locale->text('Edit Project')
344 $form->{description} =~ s/\"/"/g;
347 $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
348 '-default' => $form->{projectnumber});
351 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
353 $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
354 '-style' => 'width: 100%', '-wrap' => 'soft',
355 '-default' => $form->{description});
358 $cgi->textfield('-name' => 'description', '-size' => 60,
359 '-default' => $form->{description});
369 $cgi->radio_group('-name' => 'active',
371 '-default' => $form->{active} * 1,
372 '-labels' => { 1 => $locale->text("Active"),
373 0 => $locale->text("Inactive") })
384 <form method=post action=$form->{script}>
386 <input type=hidden name=id value=$form->{id}>
387 <input type=hidden name=type value=project>
391 <th class=listtop>$form->{title}</th>
398 <th align=right>| . $locale->text('Number') . qq|</th>
399 <td>$projectnumber</td>
402 <th align=right>| . $locale->text('Description') . qq|</th>
403 <td>$description</td>
410 <td colspan=2><hr size=3 noshade></td>
415 $lxdebug->leave_sub();
418 sub form_project_footer {
419 $lxdebug->enter_sub();
421 $auth->assert('config');
425 <input name=callback type=hidden value="$form->{callback}">
427 <input type=hidden name=login value=$form->{login}>
428 <input type=hidden name=password value=$form->{password}>
430 <br><input type=submit class=submit name=action value="|
431 . $locale->text('Save') . qq|">
434 if ($form->{id} && $form->{orphaned}) {
436 <input type=submit class=submit name=action value="|
437 . $locale->text('Delete') . qq|">|;
441 # button for saving history
443 <input type=button onclick=set_history_window(|
445 . qq|); name=history id=history value=|
446 . $locale->text('history')
448 # /button for saving history
458 $lxdebug->leave_sub();
462 $lxdebug->enter_sub();
464 $auth->assert('config');
466 if ($form->{type} eq 'project') {
467 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
468 PE->save_project(\%myconfig, \%$form);
469 $form->redirect($locale->text('Project saved!'));
471 if ($form->{type} eq 'partsgroup') {
472 $form->isblank("partsgroup", $locale->text('Group missing!'));
473 PE->save_partsgroup(\%myconfig, \%$form);
474 $form->redirect($locale->text('Group saved!'));
477 # choice pricegroup and save
478 if ($form->{type} eq 'pricegroup') {
479 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
480 PE->save_pricegroup(\%myconfig, \%$form);
481 $form->redirect($locale->text('Pricegroup saved!'));
484 if(!exists $form->{addition} && $form->{id} ne "") {
485 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
486 $form->{addition} = "SAVED";
487 $form->save_history($form->dbconnect(\%myconfig));
489 # /saving the history
491 $lxdebug->leave_sub();
495 $lxdebug->enter_sub();
497 $auth->assert('config');
499 PE->delete_tuple(\%myconfig, \%$form);
501 if ($form->{type} eq 'project') {
502 $form->redirect($locale->text('Project deleted!'));
504 if ($form->{type} eq 'partsgroup') {
505 $form->redirect($locale->text('Group deleted!'));
507 if ($form->{type} eq 'pricegroup') {
508 $form->redirect($locale->text('Pricegroup deleted!'));
511 if(!exists $form->{addition}) {
512 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
513 $form->{addition} = "DELETED";
514 $form->save_history($form->dbconnect(\%myconfig));
516 # /saving the history
517 $lxdebug->leave_sub();
520 sub continue { call_sub($form->{"nextsub"}); }
522 sub partsgroup_report {
523 $lxdebug->enter_sub();
525 $auth->assert('config');
527 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
528 PE->partsgroups(\%myconfig, \%$form);
531 "$form->{script}?action=partsgroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
533 if ($form->{status} eq 'all') {
534 $option = $locale->text('All');
536 if ($form->{status} eq 'orphaned') {
537 $option .= $locale->text('Orphaned');
539 if ($form->{partsgroup}) {
540 $callback .= "&partsgroup=$form->{partsgroup}";
541 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
544 @column_index = $form->sort_columns(qw(partsgroup));
546 $column_header{partsgroup} =
547 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
549 $form->{title} = $locale->text('Groups');
558 <th class=listtop>$form->{title}</th>
567 <tr class=listheading>
570 map { print "$column_header{$_}\n" } @column_index;
577 $form->{callback} = $callback;
579 # escape callback for href
580 $callback = $form->escape($callback);
582 foreach $ref (@{ $form->{item_list} }) {
588 <tr valign=top class=listrow$i>
591 $column_data{partsgroup} =
592 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partsgroup}</td>|;
593 map { print "$column_data{$_}\n" } @column_index;
605 <td><hr size=3 noshade></td>
610 <form method=post action=$form->{script}>
612 <input name=callback type=hidden value="$form->{callback}">
614 <input type=hidden name=type value=$form->{type}>
616 <input type=hidden name=login value=$form->{login}>
617 <input type=hidden name=password value=$form->{password}>
619 <input class=submit type=submit name=action value="|
620 . $locale->text('Add') . qq|">
628 $lxdebug->leave_sub();
631 sub form_partsgroup_header {
632 $lxdebug->enter_sub();
634 $auth->assert('config');
636 $form->{title} = $locale->text("$form->{title} Group");
638 # $locale->text('Add Group')
639 # $locale->text('Edit Group')
641 $form->{partsgroup} =~ s/\"/"/g;
648 <form method=post action=$form->{script}>
650 <input type=hidden name=id value=$form->{id}>
651 <input type=hidden name=type value=$form->{type}>
655 <th class=listtop>$form->{title}</th>
662 <th align=right>| . $locale->text('Group') . qq|</th>
664 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
670 <td colspan=2><hr size=3 noshade></td>
675 $lxdebug->leave_sub();
678 sub form_partsgroup_footer {
679 $lxdebug->enter_sub();
681 $auth->assert('config');
685 <input name=callback type=hidden value="$form->{callback}">
687 <input type=hidden name=login value=$form->{login}>
688 <input type=hidden name=password value=$form->{password}>
690 <br><input type=submit class=submit name=action value="|
691 . $locale->text('Save') . qq|">
694 if ($form->{id} && $form->{orphaned}) {
696 <input type=submit class=submit name=action value="|
697 . $locale->text('Delete') . qq|">|;
700 # button for saving history
702 <input type=button onclick=set_history_window(|
704 . qq|); name=history id=history value=|
705 . $locale->text('history')
707 # /button for saving history
715 $lxdebug->leave_sub();
718 #################################
719 # get pricesgroups and build up html-code
721 sub pricegroup_report {
722 $lxdebug->enter_sub();
724 $auth->assert('config');
726 map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
727 PE->pricegroups(\%myconfig, \%$form);
730 "$form->{script}?action=pricegroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
732 if ($form->{status} eq 'all') {
733 $option = $locale->text('All');
735 if ($form->{status} eq 'orphaned') {
736 $option .= $locale->text('Orphaned');
738 if ($form->{pricegroup}) {
739 $callback .= "&pricegroup=$form->{pricegroup}";
741 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
744 @column_index = $form->sort_columns(qw(pricegroup));
746 $column_header{pricegroup} =
747 qq|<th class=listheading width=90%>|
748 . $locale->text('Pricegroup')
751 $form->{title} = $locale->text('Pricegroup');
760 <th class=listtop>$form->{title}</th>
769 <tr class=listheading>
772 map { print "$column_header{$_}\n" } @column_index;
779 $form->{callback} = $callback;
781 # escape callback for href
782 $callback = $form->escape($callback);
784 foreach $ref (@{ $form->{item_list} }) {
790 <tr valign=top class=listrow$i>
792 $column_data{pricegroup} =
793 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{pricegroup}</td>|;
795 map { print "$column_data{$_}\n" } @column_index;
807 <td><hr size=3 noshade></td>
812 <form method=post action=$form->{script}>
814 <input name=callback type=hidden value="$form->{callback}">
816 <input type=hidden name=type value=$form->{type}>
818 <input type=hidden name=login value=$form->{login}>
819 <input type=hidden name=password value=$form->{password}>
821 <input class=submit type=submit name=action value="|
822 . $locale->text('Add') . qq|">
830 $lxdebug->leave_sub();
833 #######################
834 #build up pricegroup_header
836 sub form_pricegroup_header {
837 $lxdebug->enter_sub();
839 $auth->assert('config');
841 # $locale->text('Add Pricegroup')
842 # $locale->text('Edit Pricegroup')
844 $form->{title} = $locale->text("$form->{title} Pricegroup");
846 $form->{pricegroup} =~ s/\"/"/g;
853 <form method=post action=$form->{script}>
855 <input type=hidden name=id value=$form->{id}>
856 <input type=hidden name=type value=$form->{type}>
860 <th class=listtop>$form->{title}</th>
867 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
868 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
874 <td colspan=2><hr size=3 noshade></td>
879 $lxdebug->leave_sub();
881 ######################
882 #build up pricegroup_footer
884 sub form_pricegroup_footer {
885 $lxdebug->enter_sub();
887 $auth->assert('config');
891 <input name=callback type=hidden value="$form->{callback}">
893 <input type=hidden name=login value=$form->{login}>
894 <input type=hidden name=password value=$form->{password}>
896 <br><input type=submit class=submit name=action value="|
897 . $locale->text('Save') . qq|">
900 if ($form->{id} && $form->{orphaned}) {
902 <input type=submit class=submit name=action value="|
903 . $locale->text('Delete') . qq|">|;
906 # button for saving history
908 <input type=button onclick=set_history_window(|
910 . qq|); name=history id=history value=|
911 . $locale->text('history')
913 # /button for saving history
921 $lxdebug->leave_sub();