Historie eingefügt
[kivitendo-erp.git] / bin / mozilla / ar.pl
index 9ca39fd..1e5aa98 100644 (file)
@@ -73,7 +73,14 @@ require "bin/mozilla/common.pl";
 
 sub add {
   $lxdebug->enter_sub();
-
+  
+  # saving the history
+  if(!exists $form->{addition} && ($form->{id} ne "")) {
+       $form->{addition} = "ADDED";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history 
+  
   $form->{title}    = "Add";
   $form->{callback} =
     "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
@@ -82,12 +89,14 @@ sub add {
   &create_links;
   AR->get_transdate(\%myconfig, $form);
   &display_form;
-
   $lxdebug->leave_sub();
 }
 
 sub edit {
   $lxdebug->enter_sub();
+  # show history button
+  $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
+  #/show hhistory button
 
   $form->{title} = "Edit";
 
@@ -204,6 +213,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 {
 
@@ -327,6 +337,9 @@ sub form_header {
   };
   //-->
   </script>|;
+  # show history button js
+  $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
+  #/show history button js
 
   $readonly = ($form->{id}) ? "readonly" : "";
 
@@ -656,15 +669,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>";
@@ -672,7 +685,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>
@@ -729,6 +743,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 "
@@ -760,6 +782,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}>
@@ -772,39 +796,50 @@ 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|">|;
     }
   }
 
+  if ($form->{menubar}) {
+    require "$form->{path}/menu.pl";
+    &menubar;
+  }
+  # button for saving history
+  if($form->{id} ne "") {
+    print qq|
+         <input type=button class=submit onclick=set_history_window(|
+         . $form->{id} 
+         . qq|); name=history id=history value=|
+         . $locale->text('history') 
+         . qq|>|;
+  }
+  # /button for saving history
   print "
 </form>
 
@@ -996,9 +1031,9 @@ sub post {
     exit;
   }
 
-  ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
-  ($taxkey,      $NULL)         = split /--/, $form->{taxchartselected};
-  ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
+  my ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
+  my ($taxkey,      $NULL)         = split /--/, $form->{taxchartselected};
+  my ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
   $form->{AR}{amount_1}    = $creditaccno;
   $form->{AR}{receivables} = $receivablesaccno;
   $form->{taxkey}          = $taxkey;
@@ -1007,9 +1042,15 @@ sub post {
     unless $form->{invnumber};
 
   $form->{id} = 0 if $form->{postasnew};
-
-  $form->redirect($locale->text('Transaction posted!'))
-    if (AR->post_transaction(\%myconfig, \%$form));
+  if (AR->post_transaction(\%myconfig, \%$form)) {
+    # saving the history
+    if(!exists $form->{addition} && $form->{id} ne "") {
+         $form->{addition} = "POSTED";
+         $form->save_history($form->dbconnect(\%myconfig));
+    }
+    # /saving the history 
+    $form->redirect($locale->text('Transaction posted!'));
+  }
   $form->error($locale->text('Cannot post transaction!'));
 
   $lxdebug->leave_sub();
@@ -1019,6 +1060,12 @@ sub post_as_new {
   $lxdebug->enter_sub();
 
   $form->{postasnew} = 1;
+  # saving the history
+  if(!exists $form->{addition} && $form->{id} ne "") {
+       $form->{addition} = "POSTED AS NEW";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history 
   &post;
 
   $lxdebug->leave_sub();
@@ -1076,9 +1123,15 @@ sub delete {
 
 sub yes {
   $lxdebug->enter_sub();
-
-  $form->redirect($locale->text('Transaction deleted!'))
-    if (AR->delete_transaction(\%myconfig, \%$form, $spool));
+  if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
+    # saving the history
+    if(!exists $form->{addition}) {
+         $form->{addition} = "DELETED";
+         $form->save_history($form->dbconnect(\%myconfig));
+    }
+    # /saving the history 
+    $form->redirect($locale->text('Transaction deleted!'));
+  }
   $form->error($locale->text('Cannot delete transaction!'));
 
   $lxdebug->leave_sub();