Debitorenrechnungen: Bei Zahlungseingängen ist für jede Zeile eine Projektnummer...
[kivitendo-erp.git] / bin / mozilla / ar.pl
index 291ad06..8b75b2d 100644 (file)
@@ -204,6 +204,7 @@ sub create_links {
         $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
           $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
         $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
+        $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
         $form->{paidaccounts}++;
       } else {
 
@@ -421,6 +422,21 @@ sub form_header {
 |;
   }
 
+  my @old_project_ids = ();
+  map({ push(@old_project_ids, $form->{"project_id_$_"})
+          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+  $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+                                   "all" => 0,
+                                   "old_id" => \@old_project_ids });
+
+  my %project_labels = ();
+  my @project_values = ("");
+  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+    push(@project_values, $item->{"id"});
+    $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+  }
+
   $form->{fokus} = "arledger.customer";
 
   # use JavaScript Calendar or not
@@ -582,6 +598,12 @@ $jsscript
       qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
     $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
 
+    my $projectnumber =
+      NTI($cgi->popup_menu('-name' => "project_id_$i",
+                           '-values' => \@project_values,
+                           '-labels' => \%project_labels,
+                           '-default' => $form->{"project_id_$i"} ));
+
     print qq|
        <tr>
           <td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
@@ -589,9 +611,7 @@ $jsscript
           <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
           <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
           $tax
-         <td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
-             <input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
-             <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
+          <td>$projectnumber</td>
        </tr>
 |;
     $amount  = "";
@@ -637,15 +657,15 @@ $jsscript
     <td>
       <table width=100%>
        <tr class=listheading>
-         <th colspan=6 class=listheading>|
+         <th colspan=7 class=listheading>|
     . $locale->text('Incoming Payments') . qq|</th>
        </tr>
 |;
 
   if ($form->{currency} eq $form->{defaultcurrency}) {
-    @column_index = qw(datepaid source memo paid AR_paid);
+    @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
   } else {
-    @column_index = qw(datepaid source memo paid exchangerate AR_paid);
+    @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
   }
 
   $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
@@ -653,7 +673,8 @@ $jsscript
   $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
   $column_data{AR_paid}      = "<th>" . $locale->text('Account') . "</th>";
   $column_data{source}       = "<th>" . $locale->text('Source') . "</th>";
-  $column_data{memo}         = "<th>" . $locale->text('Memo') . "</th>";
+  $column_data{memo}         = "<th>" . $locale->text('Memo') . "</th>"; 
+  $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>"; 
 
   print "
         <tr>
@@ -710,6 +731,14 @@ $jsscript
     $column_data{memo} =
       qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
 
+    $column_data{paid_project_id} =
+      qq|<td>|
+      . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
+                             '-values' => \@project_values,
+                             '-labels' => \%project_labels,
+                             '-default' => $form->{"paid_project_id_$i"} ))
+      . qq|</td>|;
+
     map { print qq|$column_data{$_}\n| } @column_index;
 
     print "
@@ -741,6 +770,8 @@ sub form_footer {
 
   print qq|
 
+<input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
+
 <input name=callback type=hidden value="$form->{callback}">
 
 <input type=hidden name=path value=$form->{path}>
@@ -753,35 +784,32 @@ sub form_footer {
   $transdate = $form->datetonum($form->{transdate}, \%myconfig);
   $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
 
+  print qq|<input class=submit type=submit name=action value="|
+    . $locale->text('Update') . qq|">
+|;
   if ($form->{id}) {
     if ($form->{radier}) {
-      print qq|<input class=submit type=submit name=action value="|
-        . $locale->text('Update') . qq|">
-  |;
-
-          print qq|
+      print qq|
           <input class=submit type=submit name=action value="|
             . $locale->text('Post') . qq|">
           <input class=submit type=submit name=action value="|
             . $locale->text('Delete') . qq|">
   |;
-  }
-      if ($transdate > $closedto) {
-        print qq|
+    }
+    if ($transdate > $closedto) {
+      print qq|
   <input class=submit type=submit name=action value="|
           . $locale->text('Use As Template') . qq|">
   |;
-      }
-        print qq|
+    }
+    print qq|
   <input class=submit type=submit name=action value="|
-          . $locale->text('Post Payment') . qq|">
+    . $locale->text('Post Payment') . qq|">
   |;
-    
+
   } else {
     if ($transdate > $closedto) {
       print qq|<input class=submit type=submit name=action value="|
-        . $locale->text('Update') . qq|">
-      <input class=submit type=submit name=action value="|
         . $locale->text('Post') . qq|">|;
     }
   }
@@ -870,8 +898,6 @@ sub update {
   &check_name(customer);
   $form->{AR} = $save_AR;
 
-  &check_project;
-
   $form->{invtotal} =
     ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;