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 #======================================================================
44 $lxdebug->enter_sub();
46 $form->{title} = "Add";
49 $form->{callback} = "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
51 &{ "form_$form->{type}_header" };
52 &{ "form_$form->{type}_footer" };
54 $lxdebug->leave_sub();
59 $lxdebug->enter_sub();
61 $form->{title} = "Edit";
63 if ($form->{type} eq 'project') {
64 PE->get_project(\%myconfig, \%$form);
66 if ($form->{type} eq 'partsgroup') {
67 PE->get_partsgroup(\%myconfig, \%$form);
70 &{ "form_$form->{type}_header" };
71 &{ "form_$form->{type}_footer" };
73 $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>
116 <form method=post action=$form->{script}>
118 <input type=hidden name=sort value=$sort>
119 <input type=hidden name=type value=$form->{type}>
123 <th class=listtop>$form->{title}</th>
132 <td><input name=status class=radio type=radio value=all checked> |.$locale->text('All').qq|
133 <input name=status class=radio type=radio value=orphaned> |.$locale->text('Orphaned').qq|</td>
139 <td><hr size=3 noshade></td>
143 <input type=hidden name=nextsub value=$report>
145 <input type=hidden name=path value=$form->{path}>
146 <input type=hidden name=login value=$form->{login}>
147 <input type=hidden name=password value=$form->{password}>
150 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
157 $lxdebug->leave_sub();
163 $lxdebug->enter_sub();
165 map { $form->{$_} = $form->unescape($form->{$_}) } (projectnumber, description);
166 PE->projects(\%myconfig, \%$form);
168 $callback = "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
171 if ($form->{status} eq 'all') {
172 $option = $locale->text('All');
174 if ($form->{status} eq 'orphaned') {
175 $option .= $locale->text('Orphaned');
177 if ($form->{projectnumber}) {
178 $href .= "&projectnumber=".$form->escape($form->{projectnumber});
179 $callback .= "&projectnumber=$form->{projectnumber}";
180 $option .= "\n<br>".$locale->text('Project')." : $form->{projectnumber}";
182 if ($form->{description}) {
183 $href .= "&description=".$form->escape($form->{description});
184 $callback .= "&description=$form->{description}";
185 $option .= "\n<br>".$locale->text('Description')." : $form->{description}";
189 @column_index = $form->sort_columns(qw(projectnumber description));
191 $column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Number').qq|</a></th>|;
192 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
194 $form->{title} = $locale->text('Projects');
203 <th class=listtop>$form->{title}</th>
212 <tr class=listheading>
215 map { print "$column_header{$_}\n" } @column_index;
222 $form->{callback} = $callback .= "&sort=$form->{sort}";
224 # escape callback for href
225 $callback = $form->escape($callback);
227 foreach $ref (@{ $form->{project_list} }) {
232 <tr valign=top class=listrow$i>
235 $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>|;
236 $column_data{description} = qq|<td>$ref->{description} </td>|;
238 map { print "$column_data{$_}\n" } @column_index;
250 <td><hr size=3 noshade></td>
255 <form method=post action=$form->{script}>
257 <input name=callback type=hidden value="$form->{callback}">
259 <input type=hidden name=type value=$form->{type}>
261 <input type=hidden name=path value=$form->{path}>
262 <input type=hidden name=login value=$form->{login}>
263 <input type=hidden name=password value=$form->{password}>
265 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">|;
267 if ($form->{menubar}) {
268 require "$form->{path}/menu.pl";
279 $lxdebug->leave_sub();
283 sub form_project_header {
284 $lxdebug->enter_sub();
286 $form->{title} = $locale->text("$form->{title} Project");
288 # $locale->text('Add Project')
289 # $locale->text('Edit Project')
291 $form->{description} =~ s/\"/"/g;
293 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
294 $description = qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
296 $description = qq|<input name=description size=60 value="$form->{description}">|;
304 <form method=post action=$form->{script}>
306 <input type=hidden name=id value=$form->{id}>
307 <input type=hidden name=type value=project>
311 <th class=listtop>$form->{title}</th>
318 <th align=right>|.$locale->text('Number').qq|</th>
319 <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
322 <th align=right>|.$locale->text('Description').qq|</th>
323 <td>$description</td>
329 <td colspan=2><hr size=3 noshade></td>
334 $lxdebug->leave_sub();
338 sub form_project_footer {
339 $lxdebug->enter_sub();
343 <input name=callback type=hidden value="$form->{callback}">
345 <input type=hidden name=path value=$form->{path}>
346 <input type=hidden name=login value=$form->{login}>
347 <input type=hidden name=password value=$form->{password}>
349 <br><input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
352 if ($form->{id} && $form->{orphaned}) {
354 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
357 if ($form->{menubar}) {
358 require "$form->{path}/menu.pl";
369 $lxdebug->leave_sub();
374 $lxdebug->enter_sub();
376 if ($form->{type} eq 'project') {
377 $form->isblank("projectnumber", $locale->text('Project Number missing!'));
378 PE->save_project(\%myconfig, \%$form);
379 $form->redirect($locale->text('Project saved!'));
381 if ($form->{type} eq 'partsgroup') {
382 $form->isblank("partsgroup", $locale->text('Group missing!'));
383 PE->save_partsgroup(\%myconfig, \%$form);
384 $form->redirect($locale->text('Group saved!'));
387 $lxdebug->leave_sub();
392 $lxdebug->enter_sub();
394 PE->delete_tuple(\%myconfig, \%$form);
396 if ($form->{type} eq 'project') {
397 $form->redirect($locale->text('Project deleted!'));
399 if ($form->{type} eq 'partsgroup') {
400 $form->redirect($locale->text('Group deleted!'));
403 $lxdebug->leave_sub();
407 sub continue { &{ $form->{nextsub} } };
410 sub partsgroup_report {
411 $lxdebug->enter_sub();
413 map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
414 PE->partsgroups(\%myconfig, \%$form);
416 $callback = "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
418 if ($form->{status} eq 'all') {
419 $option = $locale->text('All');
421 if ($form->{status} eq 'orphaned') {
422 $option .= $locale->text('Orphaned');
424 if ($form->{partsgroup}) {
425 $callback .= "&partsgroup=$form->{partsgroup}";
426 $option .= "\n<br>".$locale->text('Group')." : $form->{partsgroup}";
430 @column_index = $form->sort_columns(qw(partsgroup));
432 $column_header{partsgroup} = qq|<th class=listheading width=90%>|.$locale->text('Group').qq|</th>|;
434 $form->{title} = $locale->text('Groups');
443 <th class=listtop>$form->{title}</th>
452 <tr class=listheading>
455 map { print "$column_header{$_}\n" } @column_index;
462 $form->{callback} = $callback;
464 # escape callback for href
465 $callback = $form->escape($callback);
467 foreach $ref (@{ $form->{item_list} }) {
472 <tr valign=top class=listrow$i>
475 $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>|;
476 map { print "$column_data{$_}\n" } @column_index;
488 <td><hr size=3 noshade></td>
493 <form method=post action=$form->{script}>
495 <input name=callback type=hidden value="$form->{callback}">
497 <input type=hidden name=type value=$form->{type}>
499 <input type=hidden name=path value=$form->{path}>
500 <input type=hidden name=login value=$form->{login}>
501 <input type=hidden name=password value=$form->{password}>
503 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">|;
505 if ($form->{menubar}) {
506 require "$form->{path}/menu.pl";
517 $lxdebug->leave_sub();
521 sub form_partsgroup_header {
522 $lxdebug->enter_sub();
524 $form->{title} = $locale->text("$form->{title} Group");
526 # $locale->text('Add Group')
527 # $locale->text('Edit Group')
529 $form->{partsgroup} =~ s/\"/"/g;
537 <form method=post action=$form->{script}>
539 <input type=hidden name=id value=$form->{id}>
540 <input type=hidden name=type value=$form->{type}>
544 <th class=listtop>$form->{title}</th>
551 <th align=right>|.$locale->text('Group').qq|</th>
553 <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
559 <td colspan=2><hr size=3 noshade></td>
564 $lxdebug->leave_sub();
568 sub form_partsgroup_footer {
569 $lxdebug->enter_sub();
573 <input name=callback type=hidden value="$form->{callback}">
575 <input type=hidden name=path value=$form->{path}>
576 <input type=hidden name=login value=$form->{login}>
577 <input type=hidden name=password value=$form->{password}>
579 <br><input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
582 if ($form->{id} && $form->{orphaned}) {
584 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
587 if ($form->{menubar}) {
588 require "$form->{path}/menu.pl";
599 $lxdebug->leave_sub();