X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=7f557fb435a2d5563730d33a251e98da5e763c96;hb=bab39fc246bed0c9bb6906032bd47c1d61b8e2ec;hp=0307d7776983ed0d80f53674836b2ce9a0b3795a;hpb=cfc6a60d53597f6a879b28af37f84b4b5fa4cc6b;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 0307d7776..7f557fb43 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -9,6 +9,7 @@ # ###################################################################### +use SL::Form; use YAML; use SL::Common; @@ -16,13 +17,10 @@ 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; - $lxdebug->message(0, "yeah!???\n\n$old_form\n\n\n"); $lxdebug->leave_sub(); @@ -38,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(); } @@ -46,20 +45,27 @@ sub restore_form { sub build_std_url { $lxdebug->enter_sub(); - my $url = "$form->{script}?"; - my $first = 1; - foreach my $key ((qw(login password path), @_)) { + my $script = $form->{script}; + + my @parts; + + foreach my $key ((qw(login password), @_)) { next unless ($key); - $url .= "&" unless ($first); - $first = 0; - if ($key =~ /=/) { - $url .= $key; + if ($key =~ /(.*?)=(.*)/) { + if ($1 eq 'script') { + $script = $2; + } else { + push @parts, $key; + } + } else { - $url .= "${key}=" . E($form->{$key}); + push @parts, "${key}=" . E($form->{$key}); } } + my $url = "${script}?" . join('&', @parts); + $lxdebug->leave_sub(); return $url; @@ -98,7 +104,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(); } @@ -168,7 +174,7 @@ sub select_part_internal { restore_form($form->{"old_form"}); - &{ $callback_sub }($new_item); + call_sub($callback_sub, $new_item); $lxdebug->leave_sub(); } @@ -529,4 +535,59 @@ 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(); +} + +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;