X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=f4a07f6674b29025799aafdebbcf6d02f4522c5f;hb=599030d5e26bcef0f9850ddbbedba106ded70ebb;hp=2c44c094ac3f138f09ef5b8086b2f3fb6d40f47d;hpb=1d6a8f5f46dd9d8c9bc53b78528957db10ef7a11;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 2c44c094a..f4a07f667 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -9,6 +9,7 @@ # ###################################################################### +use SL::Form; use YAML; use SL::Common; @@ -16,9 +17,7 @@ use SL::Common; sub save_form { $lxdebug->enter_sub(); - my $yaml = new YAML; - $yaml->Indent(1); - my $old_form = $yaml->dump($form); + my $old_form = YAML::Dump($form); $old_form =~ s|!|!!|g; $old_form =~ s|\n|!n|g; $old_form =~ s|\r|!r|g; @@ -37,7 +36,8 @@ sub restore_form { $old_form =~ s|!r|\r|g; $old_form =~ s|!n|\n|g; $old_form =~ s|!!|!|g; - $form = YAML::Load($old_form); + my $new_form = YAML::Load($old_form); + map({ $form->{$_} = $new_form->{$_}; } keys(%{$new_form})); $lxdebug->leave_sub(); } @@ -47,7 +47,7 @@ sub build_std_url { my $url = "$form->{script}?"; my $first = 1; - foreach my $key ((qw(login password path), @_)) { + foreach my $key ((qw(login password), @_)) { next unless ($key); $url .= "&" unless ($first); $first = 0; @@ -97,7 +97,7 @@ sub select_employee_internal { restore_form($form->{"old_form"}); - &{ $callback_sub }($new_id, $new_name); + call_sub($callback_sub, $new_id, $new_name); $lxdebug->leave_sub(); } @@ -167,7 +167,7 @@ sub select_part_internal { restore_form($form->{"old_form"}); - &{ $callback_sub }($new_item); + call_sub($callback_sub, $new_item); $lxdebug->leave_sub(); } @@ -528,4 +528,39 @@ sub reformat_numbers { $lxdebug->leave_sub(); } +sub show_history { + $lxdebug->enter_sub(); + my $dbh = $form->dbconnect(\%myconfig); + + $form->{title} = $locale->text("History"); + $form->header(); + print $form->parse_html_template( "common/show_history", { + "DATEN" => $form->get_history($dbh,$form->{input_name}), + "SUCCESS" => ($form->get_history($dbh,$form->{input_name}) ne "0") + } ); + + $dbh->disconnect(); + $lxdebug->leave_sub(); +} + +sub call_sub { + $lxdebug->enter_sub(); + + my $name = shift; + + if (!$name) { + $form->error($locale->text("Trying to call a sub without a name")); + } + + $name =~ s/[^a-zA-Z0-9_]//g; + + if (!defined(&{ $name })) { + $form->error(sprintf($locale->text("Attempt to call an undefined sub named '%s'"), $name)); + } + + &{ $name }(@_); + + $lxdebug->leave_sub(); +} + 1;