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 #======================================================================
42 $lxdebug->enter_sub();
44 $form->{title} = "Add";
48 "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
49 unless $form->{callback};
51 &{"form_$form->{type}_header"};
52 &{"form_$form->{type}_footer"};
54 $lxdebug->leave_sub();
58 $lxdebug->enter_sub();
60 $form->{title} = "Edit";
62 if ($form->{type} eq 'project') {
63 PE->get_project(\%myconfig, \%$form);
65 if ($form->{type} eq 'partsgroup') {
66 PE->get_partsgroup(\%myconfig, \%$form);
68 if ($form->{type} eq 'pricegroup') {
69 PE->get_pricegroup(\%myconfig, \%$form);
71 &{"form_$form->{type}_header"};
72 &{"form_$form->{type}_footer"};
74 $lxdebug->leave_sub();
78 $lxdebug->enter_sub();
80 if ($form->{type} eq 'project') {
81 $report = "project_report";
82 $sort = 'projectnumber';
83 $form->{title} = $locale->text('Projects');
87 <th align=right width=1%>| . $locale->text('Number') . qq|</th>
88 <td><input name=projectnumber size=20></td>
91 <th align=right>| . $locale->text('Description') . qq|</th>
92 <td><input name=description size=60></td>
97 if ($form->{type} eq 'partsgroup') {
98 $report = "partsgroup_report";
100 $form->{title} = $locale->text('Groups');
104 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
105 <td><input name=partsgroup size=20></td>
112 if ($form->{type} eq 'pricegroup') {
113 $report = "pricegroup_report";
114 $sort = 'pricegroup';
115 $form->{title} = $locale->text('Pricegroup');
119 <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
120 <td><input name=pricegroup size=20></td>
131 <form method=post action=$form->{script}>
133 <input type=hidden name=sort value=$sort>
134 <input type=hidden name=type value=$form->{type}>
138 <th class=listtop>$form->{title}</th>
147 <td><input name=status class=radio type=radio value=all checked> |
148 . $locale->text('All') . qq|
149 <input name=status class=radio type=radio value=orphaned> |
150 . $locale->text('Orphaned') . qq|</td>
156 <td><hr size=3 noshade></td>
160 <input type=hidden name=nextsub value=$report>
162 <input type=hidden name=path value=$form->{path}>
163 <input type=hidden name=login value=$form->{login}>
164 <input type=hidden name=password value=$form->{password}>
167 <input class=submit type=submit name=action value="|
168 . $locale->text('Continue') . qq|">
175 $lxdebug->leave_sub();
179 $lxdebug->enter_sub();
181 map { $form->{$_} = $form->unescape($form->{$_}) }
182 (projectnumber, description);
183 PE->projects(\%myconfig, \%$form);
186 "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
189 if ($form->{status} eq 'all') {
190 $option = $locale->text('All');
192 if ($form->{status} eq 'orphaned') {
193 $option .= $locale->text('Orphaned');
195 if ($form->{projectnumber}) {
196 $href .= "&projectnumber=" . $form->escape($form->{projectnumber});
197 $callback .= "&projectnumber=$form->{projectnumber}";
199 "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
201 if ($form->{description}) {
202 $href .= "&description=" . $form->escape($form->{description});
203 $callback .= "&description=$form->{description}";
205 "\n<br>" . $locale->text('Description') . " : $form->{description}";
208 @column_index = $form->sort_columns(qw(projectnumber description));
210 $column_header{projectnumber} =
211 qq|<th><a class=listheading href=$href&sort=projectnumber>|
212 . $locale->text('Number')
214 $column_header{description} =
215 qq|<th><a class=listheading href=$href&sort=description>|
216 . $locale->text('Description')
219 $form->{title} = $locale->text('Projects');
228 <th class=listtop>$form->{title}</th>
237 <tr class=listheading>
240 map { print "$column_header{$_}\n" } @column_index;
247 $form->{callback} = $callback .= "&sort=$form->{sort}";
249 # escape callback for href
250 $callback = $form->escape($callback);
252 foreach $ref (@{ $form->{project_list} }) {
258 <tr valign=top class=listrow$i>
261 $column_data{projectnumber} =
262 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{projectnumber}</td>|;
263 $column_data{description} = qq|<td>$ref->{description} </td>|;
265 map { print "$column_data{$_}\n" } @column_index;
277 <td><hr size=3 noshade></td>
282 <form method=post action=$form->{script}>
284 <input name=callback type=hidden value="$form->{callback}">
286 <input type=hidden name=type value=$form->{type}>
288 <input type=hidden name=path value=$form->{path}>
289 <input type=hidden name=login value=$form->{login}>
290 <input type=hidden name=password value=$form->{password}>
292 <input class=submit type=submit name=action value="|
293 . $locale->text('Add') . qq|">|;
295 if ($form->{menubar}) {
296 require "$form->{path}/menu.pl";
307 $lxdebug->leave_sub();
310 sub form_project_header {
311 $lxdebug->enter_sub();
313 $form->{title} = $locale->text("$form->{title} Project");
315 # $locale->text('Add Project')
316 # $locale->text('Edit Project')
318 $form->{description} =~ s/\"/"/g;
320 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
322 qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
325 qq|<input name=description size=60 value="$form->{description}">|;
333 <form method=post action=$form->{script}>
335 <input type=hidden name=id value=$form->{id}>
336 <input type=hidden name=type value=project>
340 <th class=listtop>$form->{title}</th>
347 <th align=right>| . $locale->text('Number') . qq|</th>
348 <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
351 <th align=right>| . $locale->text('Description') . qq|</th>
352 <td>$description</td>
358 <td colspan=2><hr size=3 noshade></td>
363 $lxdebug->leave_sub();
366 sub form_project_footer {
367 $lxdebug->enter_sub();
371 <input name=callback type=hidden value="$form->{callback}">
373 <input type=hidden name=path value=$form->{path}>
374 <input type=hidden name=login value=$form->{login}>
375 <input type=hidden name=password value=$form->{password}>
377 <br><input type=submit class=submit name=action value="|
378 . $locale->text('Save') . qq|">
381 if ($form->{id} && $form->{orphaned}) {
383 <input type=submit class=submit name=action value="|
384 . $locale->text('Delete') . qq|">|;
387 if ($form->{menubar}) {
388 require "$form->{path}/menu.pl";
399 $lxdebug->leave_sub();
403 $lxdebug->enter_sub();
405 if ($form->{type} eq 'project') {
406 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
407 PE->save_project(\%myconfig, \%$form);
408 $form->redirect($locale->text('Project saved!'));
410 if ($form->{type} eq 'partsgroup') {
411 $form->isblank("partsgroup", $locale->text('Group missing!'));
412 PE->save_partsgroup(\%myconfig, \%$form);
413 $form->redirect($locale->text('Group saved!'));
416 # choice pricegroup and save
417 if ($form->{type} eq 'pricegroup') {
418 $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
419 PE->save_pricegroup(\%myconfig, \%$form);
420 $form->redirect($locale->text('Pricegroup saved!'));
423 $lxdebug->leave_sub();
427 $lxdebug->enter_sub();
429 PE->delete_tuple(\%myconfig, \%$form);
431 if ($form->{type} eq 'project') {
432 $form->redirect($locale->text('Project deleted!'));
434 if ($form->{type} eq 'partsgroup') {
435 $form->redirect($locale->text('Group deleted!'));
437 if ($form->{type} eq 'pricegroup') {
438 $form->redirect($locale->text('Pricegroup deleted!'));
441 $lxdebug->leave_sub();
444 sub continue { &{ $form->{nextsub} } }
446 sub partsgroup_report {
447 $lxdebug->enter_sub();
449 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
450 PE->partsgroups(\%myconfig, \%$form);
453 "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
455 if ($form->{status} eq 'all') {
456 $option = $locale->text('All');
458 if ($form->{status} eq 'orphaned') {
459 $option .= $locale->text('Orphaned');
461 if ($form->{partsgroup}) {
462 $callback .= "&partsgroup=$form->{partsgroup}";
463 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
466 @column_index = $form->sort_columns(qw(partsgroup));
468 $column_header{partsgroup} =
469 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
471 $form->{title} = $locale->text('Groups');
480 <th class=listtop>$form->{title}</th>
489 <tr class=listheading>
492 map { print "$column_header{$_}\n" } @column_index;
499 $form->{callback} = $callback;
501 # escape callback for href
502 $callback = $form->escape($callback);
504 foreach $ref (@{ $form->{item_list} }) {
510 <tr valign=top class=listrow$i>
513 $column_data{partsgroup} =
514 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partsgroup}</td>|;
515 map { print "$column_data{$_}\n" } @column_index;
527 <td><hr size=3 noshade></td>
532 <form method=post action=$form->{script}>
534 <input name=callback type=hidden value="$form->{callback}">
536 <input type=hidden name=type value=$form->{type}>
538 <input type=hidden name=path value=$form->{path}>
539 <input type=hidden name=login value=$form->{login}>
540 <input type=hidden name=password value=$form->{password}>
542 <input class=submit type=submit name=action value="|
543 . $locale->text('Add') . qq|">|;
545 if ($form->{menubar}) {
546 require "$form->{path}/menu.pl";
557 $lxdebug->leave_sub();
560 sub form_partsgroup_header {
561 $lxdebug->enter_sub();
563 $form->{title} = $locale->text("$form->{title} Group");
565 # $locale->text('Add Group')
566 # $locale->text('Edit Group')
568 $form->{partsgroup} =~ s/\"/"/g;
575 <form method=post action=$form->{script}>
577 <input type=hidden name=id value=$form->{id}>
578 <input type=hidden name=type value=$form->{type}>
582 <th class=listtop>$form->{title}</th>
589 <th align=right>| . $locale->text('Group') . qq|</th>
591 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
597 <td colspan=2><hr size=3 noshade></td>
602 $lxdebug->leave_sub();
605 sub form_partsgroup_footer {
606 $lxdebug->enter_sub();
610 <input name=callback type=hidden value="$form->{callback}">
612 <input type=hidden name=path value=$form->{path}>
613 <input type=hidden name=login value=$form->{login}>
614 <input type=hidden name=password value=$form->{password}>
616 <br><input type=submit class=submit name=action value="|
617 . $locale->text('Save') . qq|">
620 if ($form->{id} && $form->{orphaned}) {
622 <input type=submit class=submit name=action value="|
623 . $locale->text('Delete') . qq|">|;
626 if ($form->{menubar}) {
627 require "$form->{path}/menu.pl";
638 $lxdebug->leave_sub();
641 #################################
642 # get pricesgroups and build up html-code
644 sub pricegroup_report {
645 $lxdebug->enter_sub();
647 map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
648 PE->pricegroups(\%myconfig, \%$form);
651 "$form->{script}?action=pricegroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
653 if ($form->{status} eq 'all') {
654 $option = $locale->text('All');
656 if ($form->{status} eq 'orphaned') {
657 $option .= $locale->text('Orphaned');
659 if ($form->{pricegroup}) {
660 $callback .= "&pricegroup=$form->{pricegroup}";
662 "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
665 @column_index = $form->sort_columns(qw(pricegroup));
667 $column_header{pricegroup} =
668 qq|<th class=listheading width=90%>|
669 . $locale->text('Pricegroup')
672 $form->{title} = $locale->text('Pricegroup');
681 <th class=listtop>$form->{title}</th>
690 <tr class=listheading>
693 map { print "$column_header{$_}\n" } @column_index;
700 $form->{callback} = $callback;
702 # escape callback for href
703 $callback = $form->escape($callback);
705 foreach $ref (@{ $form->{item_list} }) {
711 <tr valign=top class=listrow$i>
713 $column_data{pricegroup} =
714 qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{pricegroup}</td>|;
716 map { print "$column_data{$_}\n" } @column_index;
728 <td><hr size=3 noshade></td>
733 <form method=post action=$form->{script}>
735 <input name=callback type=hidden value="$form->{callback}">
737 <input type=hidden name=type value=$form->{type}>
739 <input type=hidden name=path value=$form->{path}>
740 <input type=hidden name=login value=$form->{login}>
741 <input type=hidden name=password value=$form->{password}>
743 <input class=submit type=submit name=action value="|
744 . $locale->text('Add') . qq|">|;
746 if ($form->{menubar}) {
747 require "$form->{path}/menu.pl";
758 $lxdebug->leave_sub();
761 #######################
762 #build up pricegroup_header
764 sub form_pricegroup_header {
765 $lxdebug->enter_sub();
767 # $locale->text('Add Pricegroup')
768 # $locale->text('Edit Pricegroup')
770 $form->{title} = $locale->text("$form->{title} Pricegroup");
772 $form->{pricegroup} =~ s/\"/"/g;
779 <form method=post action=$form->{script}>
781 <input type=hidden name=id value=$form->{id}>
782 <input type=hidden name=type value=$form->{type}>
786 <th class=listtop>$form->{title}</th>
793 <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
794 <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
800 <td colspan=2><hr size=3 noshade></td>
805 $lxdebug->leave_sub();
807 ######################
808 #build up pricegroup_footer
810 sub form_pricegroup_footer {
811 $lxdebug->enter_sub();
815 <input name=callback type=hidden value="$form->{callback}">
817 <input type=hidden name=path value=$form->{path}>
818 <input type=hidden name=login value=$form->{login}>
819 <input type=hidden name=password value=$form->{password}>
821 <br><input type=submit class=submit name=action value="|
822 . $locale->text('Save') . qq|">
825 if ($form->{id} && $form->{orphaned}) {
827 <input type=submit class=submit name=action value="|
828 . $locale->text('Delete') . qq|">|;
831 if ($form->{menubar}) {
832 require "$form->{path}/menu.pl";
843 $lxdebug->leave_sub();