Syntaxhighlighting für Emacs erleichter.
[kivitendo-erp.git] / bin / mozilla / ir.pl
index c3374b6..3bfcbf6 100644 (file)
@@ -112,7 +112,7 @@ sub invoice_links {
   }
 
   # currencies
-  @curr = split /:/, $form->{currencies};
+  @curr = split(/:/, $form->{currencies});
   chomp $curr[0];
   $form->{defaultcurrency} = $curr[0];
 
@@ -121,7 +121,7 @@ sub invoice_links {
   $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
 
   # vendors
-  if ($form->{all_vendor}) {
+  if (@{ $form->{all_vendor} }) {
     $form->{vendor} = "$form->{vendor}--$form->{vendor_id}";
     map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
       (@{ $form->{all_vendor} });
@@ -224,6 +224,9 @@ sub form_header {
       s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
   }
 
+  $form->{radier} =
+    ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+
   #quote selectvendor Bug 133
   $form->{"selectvendor"} = $form->quote($form->{"selectvendor"});
 
@@ -743,7 +746,12 @@ sub form_footer {
     print qq|<input class=submit type=submit name=action value="|
       . $locale->text('Storno') . qq|">
 | unless ($form->{storno});
-
+    if ($form->{radier}) {
+    print qq|
+    <input class=submit type=submit name=action value="|
+      . $locale->text('Delete') . qq|">
+|;
+  }
   } else {
     if ($invdate > $closedto) {
       print qq|<input class=submit type=submit name=action value="|
@@ -823,8 +831,6 @@ sub update {
 
   } else {
 
-    $form->{"selected_unit_$i"} = $form->{"unit_$i"};
-
     IR->retrieve_item(\%myconfig, \%$form);
 
     my $rows = scalar @{ $form->{item_list} };
@@ -993,6 +999,12 @@ sub post {
 
   $form->{id} = 0 if $form->{postasnew};
 
+  # get new invnumber in sequence if no invnumber is given or if posasnew was requested
+  if (!$form->{invnumber} || $form->{postasnew}) {
+    $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
+  }
+
+  relink_accounts();
   $form->redirect(  $locale->text('Invoice')
                   . " $form->{invnumber} "
                   . $locale->text('posted!'))