Bug 614.
[kivitendo-erp.git] / bin / mozilla / dn.pl
index 2ec5ab0..d81e9b1 100644 (file)
@@ -475,10 +475,10 @@ sub show_invoices {
 
 
     $column_data{dunning_description}           = qq|<td><input type=hidden name=inv_id_$i size=2 value="$ref->{id}"><input type=hidden name=customer_id_$i size=2 value="$ref->{customer_id}">$ref->{dunning_level}:&nbsp;$dunning</td>|;
-    my $active = "checked";
+    my $active = ($ref->{active}) ? "checked" : "";
     $column_data{active} =
       qq|<td><input type=checkbox name=active_$i value=1 $active></td>|;
-    my $email = "checked";
+    my $email = ($ref->{email}) ? "checked" : "";
   $column_data{email} =
     qq|<td><input type=checkbox name=email_$i value=1 $email></td>|;
     $column_data{next_duedate}           = qq|<td><input type=hidden name=next_duedate_$i size=6 value="$ref->{next_duedate}">$ref->{next_duedate}</td>|;
@@ -552,6 +552,12 @@ sub save {
   }
 
   DN->save_config(\%myconfig, \%$form);
+  # saving the history
+  if(!exists $form->{addition} && $form->{id} ne "") {
+       $form->{addition} = "SAVED FOR DUNNING";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history 
   $form->redirect($locale->text('Dunning Process Config saved!'));
 
   $lxdebug->leave_sub();
@@ -605,7 +611,12 @@ sub save_dunning {
   if($form->{DUNNING_PDFS}) {
     DN->melt_pdfs(\%myconfig, \%$form,$spool);
   }
-
+  # saving the history
+  if(!exists $form->{addition} && $form->{id} ne "") {
+       $form->{addition} = "DUNNING STARTED";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history 
   $form->redirect($locale->text('Dunning Process started for selected invoices!'));
 
   $lxdebug->leave_sub();