Kleines Hilfsmodul für Zeichensatzkonvertierung hinzugefügt. In am.pl und rp.pl werde...
[kivitendo-erp.git] / bin / mozilla / common.pl
index 6793a1d..3829757 100644 (file)
@@ -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();
 }
@@ -98,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();
 }
@@ -168,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();
 }
@@ -452,6 +451,13 @@ sub E {
   return $form->escape($_[0]);
 }
 
+sub NTI {
+  my ($element) = @_;
+
+  $element =~ s/tabindex\s*=\s*"\d+"//;
+  return $element;
+}
+
 sub format_dates {
   $lxdebug->enter_sub();
 
@@ -522,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;