Die Variablen "texnumber" (früher "steuernummer"), "co_ustid" und "duns" aus der...
[kivitendo-erp.git] / bin / mozilla / is.pl
index 110beee..6ef3fb2 100644 (file)
@@ -261,10 +261,11 @@ sub prepare_invoice {
     #     # get pricegroups for parts
     #     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
+    my $i = 0;
+
     foreach $ref (@{ $form->{invoice_details} }) {
       $i++;
 
       map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
       $form->{"discount_$i"} =
         $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
@@ -311,6 +312,9 @@ sub form_header {
     }
   }
 
+  $form->{radier} =
+    ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+
   $payment = qq|<option value=""></option>|;
   foreach $item (@{ $form->{payment_terms} }) {
     if ($form->{payment_id} eq $item->{id}) {
@@ -320,16 +324,22 @@ sub form_header {
     }
   }
 
+  my $set_duedate_url =
+    "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=set_duedate";
+
+  my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
+  push(@ { $form->{AJAX} }, $pjx);
 
   if (@{ $form->{TAXZONE} }) {
     $form->{selecttaxzone} = "";
     foreach $item (@{ $form->{TAXZONE} }) {
       if ($item->{id} == $form->{taxzone_id}) {
         $form->{selecttaxzone} .=
-          "<option value=$item->{id} selected>$item->{description}</option>";
+          "<option value=$item->{id} selected>" . H($item->{description}) .
+          "</option>";
       } else {
         $form->{selecttaxzone} .=
-          "<option value=$item->{id}>$item->{description}</option>";
+          "<option value=$item->{id}>" . H($item->{description}) . "</option>";
       }
 
     }
@@ -339,11 +349,6 @@ sub form_header {
       $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
     }
   }
-  if ($form->{rowcount} >0) {
-    $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
-    $form->{selecttaxzone} = $&;
-  }
-  
 
   $taxzone = qq|
              <tr>
@@ -443,13 +448,11 @@ sub form_header {
   $exchangerate .= qq|
 <input type=hidden name=forex value=$form->{forex}>
 |;
-  print(STDERR "$form->{customer} Kunde\n");
 
   $customer =
     ($form->{selectcustomer})
     ? qq|<select name=customer>$form->{selectcustomer}</select>\n<input type=hidden name="selectcustomer" value="$form->{selectcustomer}">|
     : qq|<input name=customer value="$form->{customer}" size=35>|;
-  print(STDERR "$form->{customer} Kunde\n");
 
   #sk
   $contact =
@@ -909,7 +912,7 @@ sub form_footer {
              <tr valign=top>
                <td>$notes</td>
                <td>$intnotes</td>
-                <td><select name=payment_id tabindex=24>$payment
+                <td><select name=payment_id onChange="set_duedate(['payment_id__' + this.value],['duedate'])">$payment
                 </select></td>
              </tr>
            </table>
@@ -1012,8 +1015,10 @@ if ($form->{type} eq "credit_note") {
 
     # format amounts
     $totalpaid += $form->{"paid_$i"};
-    $form->{"paid_$i"} =
-      $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+    if ($form->{"paid_$i"}) {
+      $form->{"paid_$i"} =
+        $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+    }
     $form->{"exchangerate_$i"} =
       $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
 
@@ -1096,6 +1101,12 @@ if ($form->{type} eq "credit_note") {
       . $locale->text('Credit Note') . qq|">
 |;
   }
+    if ($form->{radier}) {
+    print qq|
+    <input class=submit type=submit name=action value="|
+      . $locale->text('Delete') . qq|">
+|;
+  }
 
 
     if ($invdate > $closedto) {
@@ -1200,8 +1211,6 @@ sub update {
 
   } else {
 
-    $form->{"selected_unit_$i"} = $form->{"unit_$i"};
-
     IS->retrieve_item(\%myconfig, \%$form);
 
     $rows = scalar @{ $form->{item_list} };
@@ -1336,6 +1345,7 @@ sub post_payment {
 
   ($form->{AR})      = split /--/, $form->{AR};
   ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+  relink_accounts();
   $form->redirect($locale->text(' Payment posted!'))
       if (IS->post_payment(\%myconfig, \%$form));
     $form->error($locale->text('Cannot post payment!'));
@@ -1402,6 +1412,7 @@ sub post {
       $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
     }
   }
+  relink_accounts();
   if ($print_post) {
     if (!(IS->post_invoice(\%myconfig, \%$form))) {
       $form->error($locale->text('Cannot post invoice!'));