#===================================================================== # SQL-Ledger Accounting # Copyright (c) 1998-2002 # # Author: Dieter Simader # Email: dsimader@sql-ledger.org # Web: http://www.sql-ledger.org # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #====================================================================== # # project administration # partsgroup administration # #====================================================================== use SL::PE; 1; # end of main sub add { $form->{title} = "Add"; # construct callback $form->{callback} = "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; &{ "form_$form->{type}_header" }; &{ "form_$form->{type}_footer" }; } sub edit { $form->{title} = "Edit"; if ($form->{type} eq 'project') { PE->get_project(\%myconfig, \%$form); } if ($form->{type} eq 'partsgroup') { PE->get_partsgroup(\%myconfig, \%$form); } &{ "form_$form->{type}_header" }; &{ "form_$form->{type}_footer" }; } sub search { if ($form->{type} eq 'project') { $report = "project_report"; $sort = 'projectnumber'; $form->{title} = $locale->text('Projects'); $number = qq| |.$locale->text('Number').qq| |.$locale->text('Description').qq| |; } if ($form->{type} eq 'partsgroup') { $report = "partsgroup_report"; $sort = 'partsgroup'; $form->{title} = $locale->text('Groups'); $number = qq| |.$locale->text('Group').qq| |; } $form->header; print qq|
{script}> {type}>
$form->{title}
$number
 |.$locale->text('All').qq|  |.$locale->text('Orphaned').qq|

{path}> {login}> {password}>
|; } sub project_report { map { $form->{$_} = $form->unescape($form->{$_}) } (projectnumber, description); PE->projects(\%myconfig, \%$form); $callback = "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}"; $href = $callback; if ($form->{status} eq 'all') { $option = $locale->text('All'); } if ($form->{status} eq 'orphaned') { $option .= $locale->text('Orphaned'); } if ($form->{projectnumber}) { $href .= "&projectnumber=".$form->escape($form->{projectnumber}); $callback .= "&projectnumber=$form->{projectnumber}"; $option .= "\n
".$locale->text('Project')." : $form->{projectnumber}"; } if ($form->{description}) { $href .= "&description=".$form->escape($form->{description}); $callback .= "&description=$form->{description}"; $option .= "\n
".$locale->text('Description')." : $form->{description}"; } @column_index = $form->sort_columns(qw(projectnumber description)); $column_header{projectnumber} = qq||.$locale->text('Number').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $form->{title} = $locale->text('Projects'); $form->header; print qq|
$form->{title}
$option
|; map { print "$column_header{$_}\n" } @column_index; print qq| |; # escape callback $form->{callback} = $callback .= "&sort=$form->{sort}"; # escape callback for href $callback = $form->escape($callback); foreach $ref (@{ $form->{project_list} }) { $i++; $i %= 2; print qq| |; $column_data{projectnumber} = qq||; $column_data{description} = qq||; map { print "$column_data{$_}\n" } @column_index; print " "; } print qq|
{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}$ref->{description} 


{script}> {type}> {path}> {login}> {password}> |; } sub form_project_header { $form->{title} = $locale->text("$form->{title} Project"); # $locale->text('Add Project') # $locale->text('Edit Project') $form->{description} =~ s/"/"/g; if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { $description = qq||; } else { $description = qq||; } $form->header; print qq| {script}> {id}>
$form->{title}
|.$locale->text('Number').qq|
|.$locale->text('Description').qq| $description

|; } sub form_project_footer { print qq| {path}> {login}> {password}>
|; if ($form->{id} && $form->{orphaned}) { print qq| |; } print qq|
|; } sub save { if ($form->{type} eq 'project') { $form->isblank("projectnumber", $locale->text('Project Number missing!')); PE->save_project(\%myconfig, \%$form); $form->redirect($locale->text('Project saved!')); } if ($form->{type} eq 'partsgroup') { $form->isblank("partsgroup", $locale->text('Group missing!')); PE->save_partsgroup(\%myconfig, \%$form); $form->redirect($locale->text('Group saved!')); } } sub delete { PE->delete_tuple(\%myconfig, \%$form); if ($form->{type} eq 'project') { $form->redirect($locale->text('Project deleted!')); } if ($form->{type} eq 'partsgroup') { $form->redirect($locale->text('Group deleted!')); } } sub continue { &{ $form->{nextsub} } }; sub partsgroup_report { map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup); PE->partsgroups(\%myconfig, \%$form); $callback = "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}"; if ($form->{status} eq 'all') { $option = $locale->text('All'); } if ($form->{status} eq 'orphaned') { $option .= $locale->text('Orphaned'); } if ($form->{partsgroup}) { $callback .= "&partsgroup=$form->{partsgroup}"; $option .= "\n
".$locale->text('Group')." : $form->{partsgroup}"; } @column_index = (partsgroup); $column_header{partsgroup} = qq||.$locale->text('Group').qq||; $form->{title} = $locale->text('Groups'); $form->header; print qq|
$form->{title}
$option
|; map { print "$column_header{$_}\n" } @column_index; print qq| |; # escape callback $form->{callback} = $callback; # escape callback for href $callback = $form->escape($callback); foreach $ref (@{ $form->{item_list} }) { $i++; $i %= 2; print qq| |; $column_data{partsgroup} = qq||; map { print "$column_data{$_}\n" } @column_index; print " "; } print qq|
{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}


{script}> {type}> {path}> {login}> {password}> |; } sub form_partsgroup_header { $form->{title} = $locale->text("$form->{title} Group"); # $locale->text('Add Group') # $locale->text('Edit Group') $form->{partsgroup} =~ s/"/"/g; $form->header; print qq| {script}> {id}> {type}>
$form->{title}
|.$locale->text('Group').qq|

|; } sub form_partsgroup_footer { print qq| {path}> {login}> {password}>
|; if ($form->{id} && $form->{orphaned}) { print qq| |; } print qq|
|; }