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 $form->{title} = "Add";
50 "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&password=$form->{password}"
51 unless $form->{callback};
53 call_sub("form_$form->{type}_header");
54 call_sub("form_$form->{type}_footer");
56 $lxdebug->leave_sub();
60 $lxdebug->enter_sub();
62 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
63 #/show hhistory button
64 $form->{title} = "Edit";
66 if ($form->{type} eq 'project') {
67 PE->get_project(\%myconfig, \%$form);
69 if ($form->{type} eq 'partsgroup') {
70 PE->get_partsgroup(\%myconfig, \%$form);
72 if ($form->{type} eq 'pricegroup') {
73 PE->get_pricegroup(\%myconfig, \%$form);
75 call_sub("form_$form->{type}_header");
76 call_sub("form_$form->{type}_footer");
78 $lxdebug->leave_sub();
82 $lxdebug->enter_sub();
84 if ($form->{type} eq 'project') {
85 $report = "project_report";
86 $sort = 'projectnumber';
87 $form->{title} = $locale->text('Projects');
91 <th align=right width=1%>| . $locale->text('Number') . qq|</th>
92 <td>| . $cgi->textfield('-name' => 'projectnumber', '-size' => 20) . qq|</td>
95 <th align=right>| . $locale->text('Description') . qq|</th>
96 <td>| . $cgi->textfield('-name' => 'description', '-size' => 60) . qq|</td>
101 $cgi->radio_group('-name' => 'active', '-default' => 'active',
102 '-values' => ['active', 'inactive', 'both'],
103 '-labels' => { 'active' => ' ' . $locale->text("Active"),
104 'inactive' => ' ' . $locale->text("Inactive"),
105 'both' => ' ' . $locale->text("Both") })
111 if ($form->{type} eq 'partsgroup') {
112 $report = "partsgroup_report";
113 $sort = 'partsgroup';
114 $form->{title} = $locale->text('Groups');
118 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
119 <td><input name=partsgroup size=20></td>
126 if ($form->{type} eq 'pricegroup') {
127 $report = "pricegroup_report";
128 $sort = 'pricegroup';
129 $form->{title} = $locale->text('Pricegroup');
133 <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
134 <td><input name=pricegroup size=20></td>
145 <form method=post action=$form->{script}>
147 <input type=hidden name=sort value=$sort>
148 <input type=hidden name=type value=$form->{type}>
152 <th class=listtop>$form->{title}</th>
161 <td><input name=status class=radio type=radio value=all checked> |
162 . $locale->text('All') . qq|
163 <input name=status class=radio type=radio value=orphaned> |
164 . $locale->text('Orphaned') . qq|</td>
170 <td><hr size=3 noshade></td>
174 <input type=hidden name=nextsub value=$report>
176 <input type=hidden name=login value=$form->{login}>
177 <input type=hidden name=password value=$form->{password}>
180 <input class=submit type=submit name=action value="|
181 . $locale->text('Continue') . qq|">
188 $lxdebug->leave_sub();
192 $lxdebug->enter_sub();
194 map { $form->{$_} = $form->unescape($form->{$_}) }
195 (projectnumber, description);
196 PE->projects(\%myconfig, \%$form);
199 "$form->{script}?action=project_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}&active=" .
203 if ($form->{status} eq 'all') {
204 $option = $locale->text('All');
206 if ($form->{status} eq 'orphaned') {
207 $option .= $locale->text('Orphaned');
209 if ($form->{projectnumber}) {
210 $href .= "&projectnumber=" . $form->escape($form->{projectnumber});
211 $callback .= "&projectnumber=$form->{projectnumber}";
213 "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
215 if ($form->{description}) {
216 $href .= "&description=" . $form->escape($form->{description});
217 $callback .= "&description=$form->{description}";
219 "\n<br>" . $locale->text('Description') . " : $form->{description}";
222 @column_index = qw(projectnumber description);
224 push(@column_index, "active") if ("both" eq $form->{active});
226 $column_header{projectnumber} =
227 qq|<th><a class=listheading href=$href&sort=projectnumber>|
228 . $locale->text('Number')
230 $column_header{description} =
231 qq|<th><a class=listheading href=$href&sort=description>|
232 . $locale->text('Description')
234 $column_header{active} =
235 qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
237 $form->{title} = $locale->text('Projects');
246 <th class=listtop>$form->{title}</th>
255 <tr class=listheading>
258 map { print "$column_header{$_}\n" } @column_index;
265 $form->{callback} = $callback .= "&sort=$form->{sort}";
267 # escape callback for href
268 $callback = $form->escape($callback);
270 foreach $ref (@{ $form->{project_list} }) {
276 <tr valign=top class=listrow$i>
279 $column_data{projectnumber} =
280 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>|;
281 $column_data{description} = qq|<td>$ref->{description} </td>|;
282 $column_data{active} =
284 ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
287 map { print "$column_data{$_}\n" } @column_index;
299 <td><hr size=3 noshade></td>
304 <form method=post action=$form->{script}>
306 <input name=callback type=hidden value="$form->{callback}">
308 <input type=hidden name=type value=$form->{type}>
310 <input type=hidden name=login value=$form->{login}>
311 <input type=hidden name=password value=$form->{password}>
313 <input class=submit type=submit name=action value="|
314 . $locale->text('Add') . qq|">
322 $lxdebug->leave_sub();
325 sub form_project_header {
326 $lxdebug->enter_sub();
328 $form->{title} = $locale->text("$form->{title} Project");
330 # $locale->text('Add Project')
331 # $locale->text('Edit Project')
333 $form->{description} =~ s/\"/"/g;
336 $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
337 '-default' => $form->{projectnumber});
340 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
342 $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
343 '-style' => 'width: 100%', '-wrap' => 'soft',
344 '-default' => $form->{description});
347 $cgi->textfield('-name' => 'description', '-size' => 60,
348 '-default' => $form->{description});
358 $cgi->radio_group('-name' => 'active',
360 '-default' => $form->{active} * 1,
361 '-labels' => { 1 => $locale->text("Active"),
362 0 => $locale->text("Inactive") })
373 <form method=post action=$form->{script}>
375 <input type=hidden name=id value=$form->{id}>
376 <input type=hidden name=type value=project>
380 <th class=listtop>$form->{title}</th>
387 <th align=right>| . $locale->text('Number') . qq|</th>
388 <td>$projectnumber</td>
391 <th align=right>| . $locale->text('Description') . qq|</th>
392 <td>$description</td>
399 <td colspan=2><hr size=3 noshade></td>
404 $lxdebug->leave_sub();
407 sub form_project_footer {
408 $lxdebug->enter_sub();
412 <input name=callback type=hidden value="$form->{callback}">
414 <input type=hidden name=login value=$form->{login}>
415 <input type=hidden name=password value=$form->{password}>
417 <br><input type=submit class=submit name=action value="|
418 . $locale->text('Save') . qq|">
421 if ($form->{id} && $form->{orphaned}) {
423 <input type=submit class=submit name=action value="|
424 . $locale->text('Delete') . qq|">|;
428 # button for saving history
430 <input type=button onclick=set_history_window(|
432 . qq|); name=history id=history value=|
433 . $locale->text('history')
435 # /button for saving history
445 $lxdebug->leave_sub();
449 $lxdebug->enter_sub();
451 if ($form->{type} eq 'project') {
452 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
453 PE->save_project(\%myconfig, \%$form);
454 $form->redirect($locale->text('Project saved!'));
456 if ($form->{type} eq 'partsgroup') {
457 $form->isblank("partsgroup", $locale->text('Group missing!'));
458 PE->save_partsgroup(\%myconfig, \%$form);
459 $form->redirect($locale->text('Group saved!'));
462 # choice pricegroup and save
463 if ($form->{type} eq 'pricegroup') {
464 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
465 PE->save_pricegroup(\%myconfig, \%$form);
466 $form->redirect($locale->text('Pricegroup saved!'));
469 if(!exists $form->{addition} && $form->{id} ne "") {
470 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
471 $form->{addition} = "SAVED";
472 $form->save_history($form->dbconnect(\%myconfig));
474 # /saving the history
476 $lxdebug->leave_sub();
480 $lxdebug->enter_sub();
482 PE->delete_tuple(\%myconfig, \%$form);
484 if ($form->{type} eq 'project') {
485 $form->redirect($locale->text('Project deleted!'));
487 if ($form->{type} eq 'partsgroup') {
488 $form->redirect($locale->text('Group deleted!'));
490 if ($form->{type} eq 'pricegroup') {
491 $form->redirect($locale->text('Pricegroup deleted!'));
494 if(!exists $form->{addition}) {
495 $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
496 $form->{addition} = "DELETED";
497 $form->save_history($form->dbconnect(\%myconfig));
499 # /saving the history
500 $lxdebug->leave_sub();
503 sub continue { call_sub($form->{"nextsub"}); }
505 sub partsgroup_report {
506 $lxdebug->enter_sub();
508 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
509 PE->partsgroups(\%myconfig, \%$form);
512 "$form->{script}?action=partsgroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
514 if ($form->{status} eq 'all') {
515 $option = $locale->text('All');
517 if ($form->{status} eq 'orphaned') {
518 $option .= $locale->text('Orphaned');
520 if ($form->{partsgroup}) {
521 $callback .= "&partsgroup=$form->{partsgroup}";
522 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
525 @column_index = $form->sort_columns(qw(partsgroup));
527 $column_header{partsgroup} =
528 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
530 $form->{title} = $locale->text('Groups');
539 <th class=listtop>$form->{title}</th>
548 <tr class=listheading>
551 map { print "$column_header{$_}\n" } @column_index;
558 $form->{callback} = $callback;
560 # escape callback for href
561 $callback = $form->escape($callback);
563 foreach $ref (@{ $form->{item_list} }) {
569 <tr valign=top class=listrow$i>
572 $column_data{partsgroup} =
573 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>|;
574 map { print "$column_data{$_}\n" } @column_index;
586 <td><hr size=3 noshade></td>
591 <form method=post action=$form->{script}>
593 <input name=callback type=hidden value="$form->{callback}">
595 <input type=hidden name=type value=$form->{type}>
597 <input type=hidden name=login value=$form->{login}>
598 <input type=hidden name=password value=$form->{password}>
600 <input class=submit type=submit name=action value="|
601 . $locale->text('Add') . qq|">
609 $lxdebug->leave_sub();
612 sub form_partsgroup_header {
613 $lxdebug->enter_sub();
615 $form->{title} = $locale->text("$form->{title} Group");
617 # $locale->text('Add Group')
618 # $locale->text('Edit Group')
620 $form->{partsgroup} =~ s/\"/"/g;
627 <form method=post action=$form->{script}>
629 <input type=hidden name=id value=$form->{id}>
630 <input type=hidden name=type value=$form->{type}>
634 <th class=listtop>$form->{title}</th>
641 <th align=right>| . $locale->text('Group') . qq|</th>
643 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
649 <td colspan=2><hr size=3 noshade></td>
654 $lxdebug->leave_sub();
657 sub form_partsgroup_footer {
658 $lxdebug->enter_sub();
662 <input name=callback type=hidden value="$form->{callback}">
664 <input type=hidden name=login value=$form->{login}>
665 <input type=hidden name=password value=$form->{password}>
667 <br><input type=submit class=submit name=action value="|
668 . $locale->text('Save') . qq|">
671 if ($form->{id} && $form->{orphaned}) {
673 <input type=submit class=submit name=action value="|
674 . $locale->text('Delete') . qq|">|;
677 # button for saving history
679 <input type=button onclick=set_history_window(|
681 . qq|); name=history id=history value=|
682 . $locale->text('history')
684 # /button for saving history
692 $lxdebug->leave_sub();
695 #################################
696 # get pricesgroups and build up html-code
698 sub pricegroup_report {
699 $lxdebug->enter_sub();
701 map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
702 PE->pricegroups(\%myconfig, \%$form);
705 "$form->{script}?action=pricegroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
707 if ($form->{status} eq 'all') {
708 $option = $locale->text('All');
710 if ($form->{status} eq 'orphaned') {
711 $option .= $locale->text('Orphaned');
713 if ($form->{pricegroup}) {
714 $callback .= "&pricegroup=$form->{pricegroup}";
716 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
719 @column_index = $form->sort_columns(qw(pricegroup));
721 $column_header{pricegroup} =
722 qq|<th class=listheading width=90%>|
723 . $locale->text('Pricegroup')
726 $form->{title} = $locale->text('Pricegroup');
735 <th class=listtop>$form->{title}</th>
744 <tr class=listheading>
747 map { print "$column_header{$_}\n" } @column_index;
754 $form->{callback} = $callback;
756 # escape callback for href
757 $callback = $form->escape($callback);
759 foreach $ref (@{ $form->{item_list} }) {
765 <tr valign=top class=listrow$i>
767 $column_data{pricegroup} =
768 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>|;
770 map { print "$column_data{$_}\n" } @column_index;
782 <td><hr size=3 noshade></td>
787 <form method=post action=$form->{script}>
789 <input name=callback type=hidden value="$form->{callback}">
791 <input type=hidden name=type value=$form->{type}>
793 <input type=hidden name=login value=$form->{login}>
794 <input type=hidden name=password value=$form->{password}>
796 <input class=submit type=submit name=action value="|
797 . $locale->text('Add') . qq|">
805 $lxdebug->leave_sub();
808 #######################
809 #build up pricegroup_header
811 sub form_pricegroup_header {
812 $lxdebug->enter_sub();
814 # $locale->text('Add Pricegroup')
815 # $locale->text('Edit Pricegroup')
817 $form->{title} = $locale->text("$form->{title} Pricegroup");
819 $form->{pricegroup} =~ s/\"/"/g;
826 <form method=post action=$form->{script}>
828 <input type=hidden name=id value=$form->{id}>
829 <input type=hidden name=type value=$form->{type}>
833 <th class=listtop>$form->{title}</th>
840 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
841 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
847 <td colspan=2><hr size=3 noshade></td>
852 $lxdebug->leave_sub();
854 ######################
855 #build up pricegroup_footer
857 sub form_pricegroup_footer {
858 $lxdebug->enter_sub();
862 <input name=callback type=hidden value="$form->{callback}">
864 <input type=hidden name=login value=$form->{login}>
865 <input type=hidden name=password value=$form->{password}>
867 <br><input type=submit class=submit name=action value="|
868 . $locale->text('Save') . qq|">
871 if ($form->{id} && $form->{orphaned}) {
873 <input type=submit class=submit name=action value="|
874 . $locale->text('Delete') . qq|">|;
877 # button for saving history
879 <input type=button onclick=set_history_window(|
881 . qq|); name=history id=history value=|
882 . $locale->text('history')
884 # /button for saving history
892 $lxdebug->leave_sub();