Umstellung der HTML-Vorlagen aus templates/webpages/report_generator von HTML::Templa...
[kivitendo-erp.git] / bin / mozilla / ap.pl
index 1b2f652..f05d158 100644 (file)
@@ -42,7 +42,7 @@ use SL::ReportGenerator;
 require "bin/mozilla/arap.pl";
 require "bin/mozilla/common.pl";
 require "bin/mozilla/drafts.pl";
-require "bin/mozilla/report_generator.pl";
+require "bin/mozilla/reportgenerator.pl";
 
 1;
 
@@ -780,8 +780,8 @@ sub form_footer {
     }
 
     # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
-    print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
-      if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap') && !$form->{paid_1});
+    print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
+      if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}));
 
     print qq| <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|">
               <input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|">
@@ -793,13 +793,12 @@ sub form_footer {
   }
   # button for saving history
   if($form->{id} ne "") {
-    print qq| <input type="button" class="submit" onclick="set_history_window($form->{id});" name="history" id="history" value="| . $locale->text('history') . qq|">|;
+    print qq| <input type="button" class="submit" onclick="set_history_window($form->{id});" name="history" id="history" value="| . $locale->text('history') . qq|"> |;
   }
   # /button for saving history
   # mark_as_paid button 
   if($form->{id} ne "") {  
-    print qq|<input type="submit" class="submit" name="action" value="| 
-          . $locale->text('mark as paid') . qq|">|;
+    print qq| <input type="submit" class="submit" name="action" value="| . $locale->text('mark as paid') . qq|"> |;
   }
   # /mark_as_paid button
   print "
@@ -1423,7 +1422,7 @@ sub ap_transactions {
   }
 
   $report->set_options('top_info_text'        => join("\n", @options),
-                       'raw_bottom_info_text' => $form->parse_html_template('ap/ap_transactions_bottom'),
+                       'raw_bottom_info_text' => $form->parse_html_template2('ap/ap_transactions_bottom'),
                        'output_format'        => 'HTML',
                        'title'                => $form->{title},
                        'attachment_basename'  => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time),
@@ -1497,26 +1496,7 @@ sub storno {
     $form->error($locale->text("Transaction has already been cancelled!"));
   }
 
-  # negate amount/taxes
-  for my $i (1 .. $form->{rowcount}) {
-    $form->{"amount_$i"} *= -1;
-    $form->{"tax_$i"}    *= -1; 
-  }
-
-  # format things
-  for my $i (1 .. $form->{rowcount}) {
-    for (qw(amount tax)) {
-      $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"};
-    }
-  }
-
-  $form->{storno}      = 1;
-  $form->{storno_id}   = $form->{id};
-  $form->{id}          = 0;
-
-  $form->{invnumber}   = "Storno-" . $form->{invnumber};
-
-  post();
+  AP->storno($form, \%myconfig, $form->{id});
 
   # saving the history
   if(!exists $form->{addition} && $form->{id} ne "") {
@@ -1526,5 +1506,7 @@ sub storno {
   }
   # /saving the history 
 
+  $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); 
+
   $lxdebug->leave_sub();
 }