X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=b661c34dce81d89518607058db80bed521b11f32;hb=fc490063361896eb3b2aa0939fc0df716ae38262;hp=1c4719aaf82eba1c5a20904f9e607621709cfa51;hpb=bde667c235b2347bdd1322f118b032a2f0d93367;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 1c4719aaf..b661c34dc 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -17,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; @@ -49,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; @@ -99,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(); } @@ -169,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(); } @@ -545,4 +543,44 @@ sub show_history { $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(); +} + +sub show_vc_details { + $lxdebug->enter_sub(); + + $form->{vc} = $form->{vc} eq "customer" ? "customer" : "vendor"; + $form->isblank("vc_id", + $form->{vc} eq "customer" ? + $locale->text("No customer has been selected yet.") : + $locale->text("No vendor has been selected yet.")); + + Common->get_vc_details(\%myconfig, $form, $form->{vc}, $form->{vc_id}); + + $form->{title} = $form->{vc} eq "customer" ? + $locale->text("Customer details") : $locale->text("Vendor details"); + $form->header(); + print($form->parse_html_template("common/show_vc_details", + { "is_customer" => $form->{vc} eq "customer" })); + + $lxdebug->leave_sub(); +} + 1;