Überbleibsel von der Unterstützung für html2ps entfernt.
[kivitendo-erp.git] / bin / mozilla / gl.pl
index 6c4b413..7cc8c01 100644 (file)
@@ -32,7 +32,9 @@
 #======================================================================
 
 use POSIX qw(strftime);
+use List::Util qw(sum);
 
+use SL::FU;
 use SL::GL;
 use SL::IS;
 use SL::PE;
@@ -449,36 +451,22 @@ sub generate_report {
   my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto category l_subtotal);
   push @hidden_variables, map { "l_${_}" } @columns;
 
-  my (@options, $date_option);
-  if ($form->{accno}) {
-    push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}";
-  }
-  if ($form->{source}) {
-    push @options, $locale->text('Source') . " : $form->{source}";
-  }
-  if ($form->{reference}) {
-    push @options, $locale->text('Reference') . " : $form->{reference}";
-  }
+  my (@options, @date_options);
+  push @options,      $locale->text('Account')     . " : $form->{accno} $form->{account_description}" if ($form->{accno});
+  push @options,      $locale->text('Source')      . " : $form->{source}"                             if ($form->{source});
+  push @options,      $locale->text('Reference')   . " : $form->{reference}"                          if ($form->{reference});
+  push @options,      $locale->text('Description') . " : $form->{description}"                        if ($form->{description});
+  push @options,      $locale->text('Notes')       . " : $form->{notes}"                              if ($form->{notes});
+
+  push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1)          if ($form->{datefrom});
+  push @date_options, $locale->text('Bis'),  $locale->date(\%myconfig, $form->{dateto},   1)          if ($form->{dateto});
+  push @options,      join(' ', @date_options)                                                        if (scalar @date_options);
+
   if ($form->{department}) {
     my ($department) = split /--/, $form->{department};
     push @options, $locale->text('Department') . " : $department";
   }
-  if ($form->{description}) {
-    push @options, $locale->text('Description') . " : $form->{description}";
-  }
-  if ($form->{notes}) {
-    push @options, $locale->text('Notes') . " : $form->{notes}";
-  }
-  if ($form->{datefrom}) {
-    $date_option = $locale->text('From') . " " . $locale->date(\%myconfig, $form->{datefrom}, 1);
-  }
-  if ($form->{dateto}) {
-    if ($form->{datefrom}) {
-      $date_option .= " ";
-    }
-    $date_option .= $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{dateto}, 1);
-  }
-  push @options, $date_option if $date_option;
+
 
   my $callback = build_std_url('action=generate_report', @hidden_variables);
 
@@ -825,6 +813,10 @@ sub display_rows {
     <td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|;
     $memo = qq|
     <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16"></td>|;
+    $source_hidden = qq|
+    <input type="hidden" name="source_$i" value="$form->{"source_$i"}" size="16">|;
+    $memo_hidden = qq|
+    <input type="hidden" name="memo_$i" value="$form->{"memo_$i"}" size="16">|;
 
     my $selected_accno_full;
     my ($accno_row) = split(/--/, $form->{"accno_$i"});
@@ -952,6 +944,8 @@ sub display_rows {
 |;
     }
     print qq|
+    $source_hidden
+    $memo_hidden
   </tr>
 |;
   }
@@ -974,6 +968,9 @@ sub form_header {
 
   $show_details_checked = "checked" if $form->{show_details};
 
+  $ob_transaction_checked = "checked" if $form->{ob_transaction};
+  $cb_transaction_checked = "checked" if $form->{cb_transaction};
+
   # $locale->text('Add General Ledger Transaction')
   # $locale->text('Edit General Ledger Transaction')
 
@@ -1068,6 +1065,9 @@ sub form_header {
   print qq|
 <body onLoad="fokus()">
 
+<script type="text/javascript" src="js/common.js"></script>
+<script type="text/javascript" src="js/follow_up.js"></script>
+
 <form method=post name="gl" action=gl.pl>
 |;
 
@@ -1076,6 +1076,10 @@ sub form_header {
   print qq|
 <input type=hidden name=title value="$title">
 
+<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|">
+<input type="hidden" name="follow_up_trans_type_1" value="gl_transaction">
+<input type="hidden" name="follow_up_trans_info_1" value="| . H($form->{id}) . qq|">
+<input type="hidden" name="follow_up_rowcount" value="1">
 
 <table width=100%>
   <tr>
@@ -1160,7 +1164,17 @@ sub form_header {
        </tr>|;
   }
 
-  print qq|<tr>
+  print qq|
+      <tr>
+      <tr><td colspan=4><table><tr>
+       <td>
+        | . $locale->text('OB Transaction') . qq|<input type="checkbox" name="ob_transaction" value="1" $ob_transaction_checked>
+       </td>
+       <td>
+        | . $locale->text('CB Transaction') . qq|<input type="checkbox" name="cb_transaction" value="1" $cb_transaction_checked>
+       </td>
+      </tr></table></td></tr>
+      <tr>
        <td width="1%" align="right" nowrap>| . $locale->text('Show details') . qq|</td>
        <td width="1%"><input type="checkbox" onclick="show_form_details();" name="show_details" value="1" $show_details_checked></td>
       </tr>|;
@@ -1205,6 +1219,16 @@ sub form_footer {
 
   $auth->assert('general_ledger');
 
+  my $follow_ups_block;
+  if ($form->{id}) {
+    my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
+
+    if (@{ $follow_ups} ) {
+      my $num_due       = sum map { $_->{due} * 1 } @{ $follow_ups };
+      $follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|;
+    }
+  }
+
   ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
   $dec = length $dec;
   $decimalplaces = ($dec > 2) ? $dec : 2;
@@ -1228,6 +1252,8 @@ sub form_footer {
 
 <input name=callback type=hidden value="$form->{callback}">
 
+$follow_ups_block
+
 <br>
 |;
 
@@ -1247,12 +1273,16 @@ sub form_footer {
         <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
     }
 
+    print qq|        
+        <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
+        <input type="button" class="submit" onclick="follow_up_window()" value="|
+      . $locale->text('Follow-Up')
+      . qq|"> |;
+
   } else {
-    if ($transdate > $closedto) {
       print qq|
         <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
         <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">|;
-    }
   }
 
   print "
@@ -1445,7 +1475,7 @@ sub post_transaction {
 
   # this is just for the wise guys
   $form->error($locale->text('Cannot post transaction for a closed period!'))
-    if ($transdate <= $closedto);
+    if ($form->date_closed($form->{"transdate"}, \%myconfig));
   if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
     $form->error($locale->text('Out of balance transaction!'));
   }