1 #=====================================================================
2 # SQL-Ledger Accounting
3 # Copyright (c) 1998-2002
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
24 # project administration
25 # partsgroup administration
27 #======================================================================
39 $form->{title} = "Add";
42 $form->{callback} = "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
44 &{ "form_$form->{type}_header" };
45 &{ "form_$form->{type}_footer" };
52 $form->{title} = "Edit";
54 if ($form->{type} eq 'project') {
55 PE->get_project(\%myconfig, \%$form);
57 if ($form->{type} eq 'partsgroup') {
58 PE->get_partsgroup(\%myconfig, \%$form);
61 &{ "form_$form->{type}_header" };
62 &{ "form_$form->{type}_footer" };
69 if ($form->{type} eq 'project') {
70 $report = "project_report";
71 $sort = 'projectnumber';
72 $form->{title} = $locale->text('Projects');
76 <th align=right width=1%>|.$locale->text('Number').qq|</th>
77 <td><input name=projectnumber size=20></td>
80 <th align=right>|.$locale->text('Description').qq|</th>
81 <td><input name=description size=60></td>
86 if ($form->{type} eq 'partsgroup') {
87 $report = "partsgroup_report";
89 $form->{title} = $locale->text('Groups');
93 <th align=right width=1%>|.$locale->text('Group').qq|</th>
94 <td><input name=partsgroup size=20></td>
105 <form method=post action=$form->{script}>
107 <input type=hidden name=sort value=$sort>
108 <input type=hidden name=type value=$form->{type}>
112 <th class=listtop>$form->{title}</th>
121 <td><input name=status class=radio type=radio value=all checked> |.$locale->text('All').qq|
122 <input name=status class=radio type=radio value=orphaned> |.$locale->text('Orphaned').qq|</td>
128 <td><hr size=3 noshade></td>
132 <input type=hidden name=nextsub value=$report>
134 <input type=hidden name=path value=$form->{path}>
135 <input type=hidden name=login value=$form->{login}>
136 <input type=hidden name=password value=$form->{password}>
139 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
152 map { $form->{$_} = $form->unescape($form->{$_}) } (projectnumber, description);
153 PE->projects(\%myconfig, \%$form);
155 $callback = "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
158 if ($form->{status} eq 'all') {
159 $option = $locale->text('All');
161 if ($form->{status} eq 'orphaned') {
162 $option .= $locale->text('Orphaned');
164 if ($form->{projectnumber}) {
165 $href .= "&projectnumber=".$form->escape($form->{projectnumber});
166 $callback .= "&projectnumber=$form->{projectnumber}";
167 $option .= "\n<br>".$locale->text('Project')." : $form->{projectnumber}";
169 if ($form->{description}) {
170 $href .= "&description=".$form->escape($form->{description});
171 $callback .= "&description=$form->{description}";
172 $option .= "\n<br>".$locale->text('Description')." : $form->{description}";
176 @column_index = $form->sort_columns(qw(projectnumber description));
178 $column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Number').qq|</a></th>|;
179 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
181 $form->{title} = $locale->text('Projects');
190 <th class=listtop>$form->{title}</th>
199 <tr class=listheading>
202 map { print "$column_header{$_}\n" } @column_index;
209 $form->{callback} = $callback .= "&sort=$form->{sort}";
211 # escape callback for href
212 $callback = $form->escape($callback);
214 foreach $ref (@{ $form->{project_list} }) {
219 <tr valign=top class=listrow$i>
222 $column_data{projectnumber} = 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>|;
223 $column_data{description} = qq|<td>$ref->{description} </td>|;
225 map { print "$column_data{$_}\n" } @column_index;
237 <td><hr size=3 noshade></td>
242 <form method=post action=$form->{script}>
244 <input name=callback type=hidden value="$form->{callback}">
246 <input type=hidden name=type value=$form->{type}>
248 <input type=hidden name=path value=$form->{path}>
249 <input type=hidden name=login value=$form->{login}>
250 <input type=hidden name=password value=$form->{password}>
252 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">
261 sub form_project_header {
263 $form->{title} = $locale->text("$form->{title} Project");
265 # $locale->text('Add Project')
266 # $locale->text('Edit Project')
268 $form->{description} =~ s/"/"/g;
270 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
271 $description = qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
273 $description = qq|<input name=description size=60 value="$form->{description}">|;
281 <form method=post action=$form->{script}>
283 <input type=hidden name=id value=$form->{id}>
284 <input type=hidden name=type value=project>
288 <th class=listtop>$form->{title}</th>
295 <th align=right>|.$locale->text('Number').qq|</th>
296 <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
299 <th align=right>|.$locale->text('Description').qq|</th>
300 <td>$description</td>
306 <td colspan=2><hr size=3 noshade></td>
314 sub form_project_footer {
318 <input name=callback type=hidden value="$form->{callback}">
320 <input type=hidden name=path value=$form->{path}>
321 <input type=hidden name=login value=$form->{login}>
322 <input type=hidden name=password value=$form->{password}>
324 <br><input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
327 if ($form->{id} && $form->{orphaned}) {
329 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
344 if ($form->{type} eq 'project') {
345 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
346 PE->save_project(\%myconfig, \%$form);
347 $form->redirect($locale->text('Project saved!'));
349 if ($form->{type} eq 'partsgroup') {
350 $form->isblank("partsgroup", $locale->text('Group missing!'));
351 PE->save_partsgroup(\%myconfig, \%$form);
352 $form->redirect($locale->text('Group saved!'));
360 PE->delete_tuple(\%myconfig, \%$form);
362 if ($form->{type} eq 'project') {
363 $form->redirect($locale->text('Project deleted!'));
365 if ($form->{type} eq 'partsgroup') {
366 $form->redirect($locale->text('Group deleted!'));
372 sub continue { &{ $form->{nextsub} } };
375 sub partsgroup_report {
377 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
378 PE->partsgroups(\%myconfig, \%$form);
380 $callback = "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
382 if ($form->{status} eq 'all') {
383 $option = $locale->text('All');
385 if ($form->{status} eq 'orphaned') {
386 $option .= $locale->text('Orphaned');
388 if ($form->{partsgroup}) {
389 $callback .= "&partsgroup=$form->{partsgroup}";
390 $option .= "\n<br>".$locale->text('Group')." : $form->{partsgroup}";
394 @column_index = (partsgroup);
396 $column_header{partsgroup} = qq|<th class=listheading width=90%>|.$locale->text('Group').qq|</th>|;
398 $form->{title} = $locale->text('Groups');
407 <th class=listtop>$form->{title}</th>
416 <tr class=listheading>
419 map { print "$column_header{$_}\n" } @column_index;
426 $form->{callback} = $callback;
428 # escape callback for href
429 $callback = $form->escape($callback);
431 foreach $ref (@{ $form->{item_list} }) {
436 <tr valign=top class=listrow$i>
440 $column_data{partsgroup} = 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>|;
442 map { print "$column_data{$_}\n" } @column_index;
454 <td><hr size=3 noshade></td>
459 <form method=post action=$form->{script}>
461 <input name=callback type=hidden value="$form->{callback}">
463 <input type=hidden name=type value=$form->{type}>
465 <input type=hidden name=path value=$form->{path}>
466 <input type=hidden name=login value=$form->{login}>
467 <input type=hidden name=password value=$form->{password}>
469 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">
478 sub form_partsgroup_header {
480 $form->{title} = $locale->text("$form->{title} Group");
482 # $locale->text('Add Group')
483 # $locale->text('Edit Group')
485 $form->{partsgroup} =~ s/"/"/g;
493 <form method=post action=$form->{script}>
495 <input type=hidden name=id value=$form->{id}>
496 <input type=hidden name=type value=$form->{type}>
500 <th class=listtop>$form->{title}</th>
507 <th align=right>|.$locale->text('Group').qq|</th>
508 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
514 <td colspan=2><hr size=3 noshade></td>
522 sub form_partsgroup_footer {
526 <input name=callback type=hidden value="$form->{callback}">
528 <input type=hidden name=path value=$form->{path}>
529 <input type=hidden name=login value=$form->{login}>
530 <input type=hidden name=password value=$form->{password}>
532 <br><input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
535 if ($form->{id} && $form->{orphaned}) {
537 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;