X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fpe.pl;h=a9cee792dd558232bd8c741f9a12bb93606a0b6c;hb=519f43a20addf13a264c270f3a4d442f2c187be5;hp=0ee06213a76bedad7bdbd1f01669dee4b16c7e2f;hpb=d319704a66e9be64da837ccea10af6774c2b0838;p=kivitendo-erp.git diff --git a/bin/mozilla/pe.pl b/bin/mozilla/pe.pl index 0ee06213a..a9cee792d 100644 --- a/bin/mozilla/pe.pl +++ b/bin/mozilla/pe.pl @@ -27,588 +27,198 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #====================================================================== # -# project administration -# partsgroup administration +# partsgroup, pricegroup administration # #====================================================================== use SL::PE; +require "bin/mozilla/common.pl"; + +use strict; + 1; # end of main sub add { - $lxdebug->enter_sub(); + $::lxdebug->enter_sub; + $::auth->assert('config'); - $form->{title} = "Add"; + $::form->{title} = "Add"; + $::form->{callback} ||= "$::form->{script}?action=add&type=$::form->{type}"; - # construct callback - $form->{callback} = - "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + call_sub("form_$::form->{type}"); - &{"form_$form->{type}_header"}; - &{"form_$form->{type}_footer"}; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub edit { - $lxdebug->enter_sub(); + $::lxdebug->enter_sub; + $::auth->assert('config'); - $form->{title} = "Edit"; + $::form->{title} = "Edit"; - if ($form->{type} eq 'project') { - PE->get_project(\%myconfig, \%$form); + if ($::form->{type} eq 'partsgroup') { + PE->get_partsgroup(\%::myconfig, $::form); } - if ($form->{type} eq 'partsgroup') { - PE->get_partsgroup(\%myconfig, \%$form); + if ($::form->{type} eq 'pricegroup') { + PE->get_pricegroup(\%::myconfig, $::form); } + call_sub("form_$::form->{type}"); - &{"form_$form->{type}_header"}; - &{"form_$form->{type}_footer"}; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub search { - $lxdebug->enter_sub(); - - 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}> - -
- -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub project_report { - $lxdebug->enter_sub(); - - 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}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub form_project_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Project"); - - # $locale->text('Add Project') - # $locale->text('Edit Project') - - $form->{description} =~ s/\"/"/g; + $::lxdebug->enter_sub; + $::auth->assert('config'); - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } + $::form->header; + print $::form->parse_html_template('pe/search', { + is_pricegroup => $::form->{type} eq 'pricegroup', + }); - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - -
$form->{title}
- - - - - - - - - -
| . $locale->text('Number') . qq|
| . $locale->text('Description') . qq|$description
-

-|; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } -sub form_project_footer { - $lxdebug->enter_sub(); - - print qq| - - - -{path}> -{login}> -{password}> - -
-|; - - if ($form->{id} && $form->{orphaned}) { - print qq| -|; - } +sub save { + $::lxdebug->enter_sub; + $::auth->assert('config'); - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + if ($::form->{type} eq 'partsgroup') { + $::form->isblank("partsgroup", $::locale->text('Group missing!')); + PE->save_partsgroup(\%::myconfig, $::form); + $::form->redirect($::locale->text('Group saved!')); } - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub save { - $lxdebug->enter_sub(); - - if ($form->{type} eq 'project') { - $form->isblank("projectnumber", $locale->text('Project Number missing!')); - PE->save_project(\%myconfig, \%$form); - $form->redirect($locale->text('Project saved!')); + # choice pricegroup and save + if ($::form->{type} eq 'pricegroup') { + $::form->isblank("pricegroup", $::locale->text('Pricegroup missing!')); + PE->save_pricegroup(\%::myconfig, $::form); + $::form->redirect($::locale->text('Pricegroup saved!')); } - if ($form->{type} eq 'partsgroup') { - $form->isblank("partsgroup", $locale->text('Group missing!')); - PE->save_partsgroup(\%myconfig, \%$form); - $form->redirect($locale->text('Group saved!')); + # saving the history + if(!exists $::form->{addition} && $::form->{id} ne "") { + $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber}; + $::form->{addition} = "SAVED"; + $::form->save_history; } + # /saving the history - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub delete { - $lxdebug->enter_sub(); + $::lxdebug->enter_sub; + $::auth->assert('config'); - PE->delete_tuple(\%myconfig, \%$form); + 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!')); } - if ($form->{type} eq 'partsgroup') { - $form->redirect($locale->text('Group deleted!')); + if ($::form->{type} eq 'pricegroup') { + $::form->redirect($::locale->text('Pricegroup deleted!')); } - - $lxdebug->leave_sub(); + # saving the history + if(!exists $::form->{addition}) { + $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber}; + $::form->{addition} = "DELETED"; + $::form->save_history; + } + # /saving the history + $::lxdebug->leave_sub; } -sub continue { &{ $form->{nextsub} } } +sub continue { call_sub($::form->{nextsub}); } sub partsgroup_report { - $lxdebug->enter_sub(); - - 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 = $form->sort_columns(qw(partsgroup)); - - $column_header{partsgroup} = - qq|| . $locale->text('Group') . qq||; - - $form->{title} = $locale->text('Groups'); - - $form->header; + $::lxdebug->enter_sub; + $::auth->assert('config'); - print qq| - + $::form->{$_} = $::form->unescape($::form->{$_}) for qw(partsgroup); + PE->partsgroups(\%::myconfig, $::form); - - - - - - - - - - - - - - -
$form->{title}
$option
- - -|; + my $callback = build_std_url("action=partsgroup_report", qw(type status)); - map { print "$column_header{$_}\n" } @column_index; + my $option = ''; + $option .= $::locale->text('All') if $::form->{status} eq 'all'; + $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned'; - print qq| - -|; + if ($::form->{partsgroup}) { + $callback .= "&partsgroup=$::form->{partsgroup}"; + $option .= ", " . $::locale->text('Group') . " : $::form->{partsgroup}"; + } # escape callback - $form->{callback} = $callback; - - # escape callback for href - $callback = $form->escape($callback); + $::form->{callback} = $callback; - foreach $ref (@{ $form->{item_list} }) { + $::form->header; + print $::form->parse_html_template('pe/partsgroup_report', { + option => $option, + callback => $callback, + editlink => build_std_url('action=edit', qw(type status callback)), + }); - $i++; - $i %= 2; - - print qq| - -|; + $::lxdebug->leave_sub; +} - $column_data{partsgroup} = - qq||; - map { print "$column_data{$_}\n" } @column_index; +sub form_partsgroup { + $::lxdebug->enter_sub; + $::auth->assert('config'); - print " - -"; - } + # $locale->text('Add Group') + # $locale->text('Edit Group') + $::form->{title} = $::locale->text("$::form->{title} Group"); - 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}
-

+ $::form->header; + print $::form->parse_html_template('pe/partsgroup_form'); -
-
{script}> + $::lxdebug->leave_sub; +} - +sub pricegroup_report { + $::lxdebug->enter_sub; + $::auth->assert('config'); -{type}> + $::form->{$_} = $::form->unescape($::form->{$_}) for qw(pricegroup); + PE->pricegroups(\%::myconfig, $::form); -{path}> -{login}> -{password}> + my $callback = build_std_url('action=pricegroup_report', qw(type status)); -|; + my $option = ''; + $option .= $::locale->text('All') if $::form->{status} eq 'all'; + $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned'; - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + if ($::form->{pricegroup}) { + $callback .= "&pricegroup=$::form->{pricegroup}"; + $option .= ", " . $::locale->text('Pricegroup') . " : $::form->{pricegroup}"; } - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub form_partsgroup_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Group"); + # escape callback + $::form->{callback} = $callback; - # $locale->text('Add Group') - # $locale->text('Edit Group') + $::form->header; + print $::form->parse_html_template('pe/pricegroup_report', { + option => $option, + callback => $callback, + editlink => build_std_url('action=edit', qw(type status callback)), + }); - $form->{partsgroup} =~ s/\"/"/g; - - $form->header; - - print qq| - - -
{script}> - -{id}> -{type}> - - - - - - - - - - - - -
$form->{title}
- - - - - - -
| . $locale->text('Group') . qq|
-

-|; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } -sub form_partsgroup_footer { - $lxdebug->enter_sub(); - - print qq| - - - -{path}> -{login}> -{password}> +sub form_pricegroup { + $::lxdebug->enter_sub; + $::auth->assert('config'); -
-|; + # $locale->text('Add Pricegroup') + # $locale->text('Edit Pricegroup') + $::form->{title} = $::locale->text("$::form->{title} Pricegroup"); - if ($form->{id} && $form->{orphaned}) { - print qq| -|; - } - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + $::form->header; + print $::form->parse_html_template('pe/pricegroup_form'); - print qq| -
- - - -|; - - $lxdebug->leave_sub(); + $::lxdebug->leave_sub; } -