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);
69 &{"form_$form->{type}_header"};
70 &{"form_$form->{type}_footer"};
72 $lxdebug->leave_sub();
76 $lxdebug->enter_sub();
78 if ($form->{type} eq 'project') {
79 $report = "project_report";
80 $sort = 'projectnumber';
81 $form->{title} = $locale->text('Projects');
85 <th align=right width=1%>| . $locale->text('Number') . qq|</th>
86 <td><input name=projectnumber size=20></td>
89 <th align=right>| . $locale->text('Description') . qq|</th>
90 <td><input name=description size=60></td>
95 if ($form->{type} eq 'partsgroup') {
96 $report = "partsgroup_report";
98 $form->{title} = $locale->text('Groups');
102 <th align=right width=1%>| . $locale->text('Group') . qq|</th>
103 <td><input name=partsgroup size=20></td>
114 <form method=post action=$form->{script}>
116 <input type=hidden name=sort value=$sort>
117 <input type=hidden name=type value=$form->{type}>
121 <th class=listtop>$form->{title}</th>
130 <td><input name=status class=radio type=radio value=all checked> |
131 . $locale->text('All') . qq|
132 <input name=status class=radio type=radio value=orphaned> |
133 . $locale->text('Orphaned')
140 <td><hr size=3 noshade></td>
144 <input type=hidden name=nextsub value=$report>
146 <input type=hidden name=path value=$form->{path}>
147 <input type=hidden name=login value=$form->{login}>
148 <input type=hidden name=password value=$form->{password}>
151 <input class=submit type=submit name=action value="|
152 . $locale->text('Continue') . qq|">
159 $lxdebug->leave_sub();
163 $lxdebug->enter_sub();
165 map { $form->{$_} = $form->unescape($form->{$_}) }
166 (projectnumber, description);
167 PE->projects(\%myconfig, \%$form);
170 "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
173 if ($form->{status} eq 'all') {
174 $option = $locale->text('All');
176 if ($form->{status} eq 'orphaned') {
177 $option .= $locale->text('Orphaned');
179 if ($form->{projectnumber}) {
180 $href .= "&projectnumber=" . $form->escape($form->{projectnumber});
181 $callback .= "&projectnumber=$form->{projectnumber}";
183 "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
185 if ($form->{description}) {
186 $href .= "&description=" . $form->escape($form->{description});
187 $callback .= "&description=$form->{description}";
189 "\n<br>" . $locale->text('Description') . " : $form->{description}";
192 @column_index = $form->sort_columns(qw(projectnumber description));
194 $column_header{projectnumber} =
195 qq|<th><a class=listheading href=$href&sort=projectnumber>|
196 . $locale->text('Number')
198 $column_header{description} =
199 qq|<th><a class=listheading href=$href&sort=description>|
200 . $locale->text('Description')
203 $form->{title} = $locale->text('Projects');
212 <th class=listtop>$form->{title}</th>
221 <tr class=listheading>
224 map { print "$column_header{$_}\n" } @column_index;
231 $form->{callback} = $callback .= "&sort=$form->{sort}";
233 # escape callback for href
234 $callback = $form->escape($callback);
236 foreach $ref (@{ $form->{project_list} }) {
242 <tr valign=top class=listrow$i>
245 $column_data{projectnumber} =
246 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>|;
247 $column_data{description} = qq|<td>$ref->{description} </td>|;
249 map { print "$column_data{$_}\n" } @column_index;
261 <td><hr size=3 noshade></td>
266 <form method=post action=$form->{script}>
268 <input name=callback type=hidden value="$form->{callback}">
270 <input type=hidden name=type value=$form->{type}>
272 <input type=hidden name=path value=$form->{path}>
273 <input type=hidden name=login value=$form->{login}>
274 <input type=hidden name=password value=$form->{password}>
276 <input class=submit type=submit name=action value="|
277 . $locale->text('Add') . qq|">|;
279 if ($form->{menubar}) {
280 require "$form->{path}/menu.pl";
291 $lxdebug->leave_sub();
294 sub form_project_header {
295 $lxdebug->enter_sub();
297 $form->{title} = $locale->text("$form->{title} Project");
299 # $locale->text('Add Project')
300 # $locale->text('Edit Project')
302 $form->{description} =~ s/\"/"/g;
304 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
306 qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
309 qq|<input name=description size=60 value="$form->{description}">|;
317 <form method=post action=$form->{script}>
319 <input type=hidden name=id value=$form->{id}>
320 <input type=hidden name=type value=project>
324 <th class=listtop>$form->{title}</th>
331 <th align=right>| . $locale->text('Number') . qq|</th>
332 <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
335 <th align=right>| . $locale->text('Description') . qq|</th>
336 <td>$description</td>
342 <td colspan=2><hr size=3 noshade></td>
347 $lxdebug->leave_sub();
350 sub form_project_footer {
351 $lxdebug->enter_sub();
355 <input name=callback type=hidden value="$form->{callback}">
357 <input type=hidden name=path value=$form->{path}>
358 <input type=hidden name=login value=$form->{login}>
359 <input type=hidden name=password value=$form->{password}>
361 <br><input type=submit class=submit name=action value="|
362 . $locale->text('Save') . qq|">
365 if ($form->{id} && $form->{orphaned}) {
367 <input type=submit class=submit name=action value="|
368 . $locale->text('Delete') . qq|">|;
371 if ($form->{menubar}) {
372 require "$form->{path}/menu.pl";
383 $lxdebug->leave_sub();
387 $lxdebug->enter_sub();
389 if ($form->{type} eq 'project') {
390 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
391 PE->save_project(\%myconfig, \%$form);
392 $form->redirect($locale->text('Project saved!'));
394 if ($form->{type} eq 'partsgroup') {
395 $form->isblank("partsgroup", $locale->text('Group missing!'));
396 PE->save_partsgroup(\%myconfig, \%$form);
397 $form->redirect($locale->text('Group saved!'));
400 $lxdebug->leave_sub();
404 $lxdebug->enter_sub();
406 PE->delete_tuple(\%myconfig, \%$form);
408 if ($form->{type} eq 'project') {
409 $form->redirect($locale->text('Project deleted!'));
411 if ($form->{type} eq 'partsgroup') {
412 $form->redirect($locale->text('Group deleted!'));
415 $lxdebug->leave_sub();
418 sub continue { &{ $form->{nextsub} } }
420 sub partsgroup_report {
421 $lxdebug->enter_sub();
423 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
424 PE->partsgroups(\%myconfig, \%$form);
427 "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
429 if ($form->{status} eq 'all') {
430 $option = $locale->text('All');
432 if ($form->{status} eq 'orphaned') {
433 $option .= $locale->text('Orphaned');
435 if ($form->{partsgroup}) {
436 $callback .= "&partsgroup=$form->{partsgroup}";
437 $option .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
440 @column_index = $form->sort_columns(qw(partsgroup));
442 $column_header{partsgroup} =
443 qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
445 $form->{title} = $locale->text('Groups');
454 <th class=listtop>$form->{title}</th>
463 <tr class=listheading>
466 map { print "$column_header{$_}\n" } @column_index;
473 $form->{callback} = $callback;
475 # escape callback for href
476 $callback = $form->escape($callback);
478 foreach $ref (@{ $form->{item_list} }) {
484 <tr valign=top class=listrow$i>
487 $column_data{partsgroup} =
488 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>|;
489 map { print "$column_data{$_}\n" } @column_index;
501 <td><hr size=3 noshade></td>
506 <form method=post action=$form->{script}>
508 <input name=callback type=hidden value="$form->{callback}">
510 <input type=hidden name=type value=$form->{type}>
512 <input type=hidden name=path value=$form->{path}>
513 <input type=hidden name=login value=$form->{login}>
514 <input type=hidden name=password value=$form->{password}>
516 <input class=submit type=submit name=action value="|
517 . $locale->text('Add') . qq|">|;
519 if ($form->{menubar}) {
520 require "$form->{path}/menu.pl";
531 $lxdebug->leave_sub();
534 sub form_partsgroup_header {
535 $lxdebug->enter_sub();
537 $form->{title} = $locale->text("$form->{title} Group");
539 # $locale->text('Add Group')
540 # $locale->text('Edit Group')
542 $form->{partsgroup} =~ s/\"/"/g;
549 <form method=post action=$form->{script}>
551 <input type=hidden name=id value=$form->{id}>
552 <input type=hidden name=type value=$form->{type}>
556 <th class=listtop>$form->{title}</th>
563 <th align=right>| . $locale->text('Group') . qq|</th>
565 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
571 <td colspan=2><hr size=3 noshade></td>
576 $lxdebug->leave_sub();
579 sub form_partsgroup_footer {
580 $lxdebug->enter_sub();
584 <input name=callback type=hidden value="$form->{callback}">
586 <input type=hidden name=path value=$form->{path}>
587 <input type=hidden name=login value=$form->{login}>
588 <input type=hidden name=password value=$form->{password}>
590 <br><input type=submit class=submit name=action value="|
591 . $locale->text('Save') . qq|">
594 if ($form->{id} && $form->{orphaned}) {
596 <input type=submit class=submit name=action value="|
597 . $locale->text('Delete') . qq|">|;
600 if ($form->{menubar}) {
601 require "$form->{path}/menu.pl";
612 $lxdebug->leave_sub();