Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / bin / mozilla / ap.pl
index f961ead..732eaed 100644 (file)
@@ -40,6 +40,7 @@ use SL::IR;
 use SL::IS;
 use SL::PE;
 use SL::ReportGenerator;
+use SL::DB::Default;
 
 require "bin/mozilla/arap.pl";
 require "bin/mozilla/common.pl";
@@ -238,7 +239,9 @@ sub form_header {
   }
   my $readonly = ($form->{id}) ? "readonly" : "";
 
-  $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+  $form->{radier} = ($::instance_conf->get_ap_changeable == 2)
+                      ? ($form->current_date(\%myconfig) eq $form->{gldate})
+                      : ($::instance_conf->get_ap_changeable == 1);
   $readonly       = ($form->{radier}) ? "" : $readonly;
 
   $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell');
@@ -409,11 +412,7 @@ sub form_header {
                          '-default' => $form->{"globalproject_id"} ));
 
   $form->header;
-  my $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
-  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
   print qq|
-<body onLoad="$onload">
-
 <form method=post action=$form->{script}>
 
 <input type=hidden name=id value=$form->{id}>
@@ -697,11 +696,11 @@ $jsscript
     print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
     print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
     my $changeable = 1;
-    if ($::lx_office_conf{features}->{payments_changeable} == 0) {
+    if (SL::DB::Default->get->payments_changeable == 0) {
       # never
       $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
     }
-    if ($::lx_office_conf{features}->{payments_changeable} == 2) {
+    if (SL::DB::Default->get->payments_changeable == 2) {
       # on the same day
       $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
     }
@@ -856,10 +855,10 @@ sub form_footer {
 
   $::form->header;
   print $::form->parse_html_template('ap/form_footer', {
-    num_due         => $num_due,
-    num_follow_ups  => $num_follow_ups,
-    show_post_draft => ($transdate > $closedto) && !$::form->{id},
-    show_storno     => $storno,
+    num_due           => $num_due,
+    num_follow_ups    => $num_follow_ups,
+    show_post_draft   => ($transdate > $closedto) && !$::form->{id},
+    show_storno       => $storno,
   });
 
   $::lxdebug->leave_sub;
@@ -1164,8 +1163,6 @@ sub delete {
   delete $form->{header};
 
   print qq|
-<body>
-
 <form method=post action=$form->{script}>
 |;
 
@@ -1185,9 +1182,6 @@ sub delete {
 <input name=action class=submit type=submit value="|
     . $locale->text('Yes') . qq|">
 </form>
-
-</body>
-</html>
 |;
 
   $main::lxdebug->leave_sub();
@@ -1230,7 +1224,7 @@ sub search {
   $form->all_vc(\%myconfig, "vendor", "AP");
 
   $form->{title}    = $locale->text('AP Transactions');
-  $form->{fokus}    = "search.vendor";
+  $::request->{layout}->focus('#vendor');
   $form->{jsscript} = 1;
 
   $form->get_lists("projects"     => { "key" => "ALL_PROJECTS", "all" => 1 },
@@ -1445,6 +1439,9 @@ sub storno {
     $form->error($locale->text("Transaction has already been cancelled!"));
   }
 
+  $form->error($locale->text('Cannot post storno for a closed period!'))
+    if ( $form->date_closed($form->{transdate}, \%myconfig));
+
   AP->storno($form, \%myconfig, $form->{id});
 
   # saving the history