Lieferantennummer/Kundennummer in Kunden/Lieferantenberichten ersetzt durch schlicht...
[kivitendo-erp.git] / bin / mozilla / rc.pl
index 09a830a..4734433 100644 (file)
 #
 #======================================================================
 
-
 use SL::RC;
 
+require "bin/mozilla/common.pl";
 
 1;
-# end of main
 
+# end of main
 
 sub reconciliation {
   $lxdebug->enter_sub();
-  
+
+  $auth->assert('cash');
+
   RC->paymentaccounts(\%myconfig, \%$form);
 
   $selection = "";
-  map { $selection .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{PR} };
+  map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
+    @{ $form->{PR} };
 
   $form->{title} = $locale->text('Reconciliation');
-
+  $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
+  $form->{"jsscript"} = 1;
   $form->header;
+  $onload = qq|focus()|;
+  $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
 
   print qq|
-<body>
+<body onLoad="$onload">
 
 <form method=post action=$form->{script}>
 
@@ -65,15 +71,17 @@ sub reconciliation {
     <td>
       <table>
        <tr>
-         <th align=right nowrap>|.$locale->text('Account').qq|</th>
+         <th align=right nowrap>| . $locale->text('Account') . qq|</th>
          <td colspan=3><select name=accno>$selection</select>
          </td>
        </tr>
        <tr>
-         <th align=right>|.$locale->text('From').qq|</th>
-         <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
-         <th align=right>|.$locale->text('To').qq|</th>
-         <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
+         <th align=right>| . $locale->text('From') . qq|</th>
+         <td><input name=fromdate id=fromdate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
+     <input type="button" name="fromdate" id="trigger_fromdate" value="?"></td>
+         <th align=right>| . $locale->text('Until') . qq|</th>
+         <td><input name=todate id=todate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
+     <input type="button" name="todate" id="trigger_todate" value="?"></td>
        </tr>
       </table>
     </td>
@@ -83,14 +91,15 @@ sub reconciliation {
   </tr>
 </table>
 
+| . $form->write_trigger(\%myconfig, 2,
+                         "fromdate", "BL", "trigger_fromdate",
+                         "todate", "BL", "trigger_todate") . qq|
+
 <br>
 <input type=hidden name=nextsub value=get_payments>
 
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
-<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
+<input type=submit class=submit name=action value="|
+    . $locale->text('Continue') . qq|">
 
 </form>
 
@@ -101,54 +110,67 @@ sub reconciliation {
   $lxdebug->leave_sub();
 }
 
-
-sub continue { &{ $form->{nextsub} } };
-
+sub continue { call_sub($form->{"nextsub"}); }
 
 sub get_payments {
   $lxdebug->enter_sub();
 
+  $auth->assert('cash');
+
   ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
 
   RC->payment_transactions(\%myconfig, \%$form);
+
   &display_form;
 
   $lxdebug->leave_sub();
 }
 
-
 sub display_form {
   $lxdebug->enter_sub();
-  
+
+  $auth->assert('cash');
+
   @column_index = qw(cleared transdate source name credit debit balance);
-  
+
   $column_header{cleared} = "<th>&nbsp;</th>";
-  $column_header{source} = "<th class=listheading>".$locale->text('Source')."</a></th>";
-  $column_header{name} = "<th class=listheading>".$locale->text('Description')."</a></th>";
-  $column_header{transdate} = "<th class=listheading>".$locale->text('Date')."</a></th>";
+  $column_header{source}  =
+    "<th class=listheading>" . $locale->text('Source') . "</a></th>";
+  $column_header{name} =
+    "<th class=listheading>" . $locale->text('Description') . "</a></th>";
+  $column_header{transdate} =
+    "<th class=listheading>" . $locale->text('Date') . "</a></th>";
 
   if ($form->{category} eq 'A') {
-    $column_header{debit} = "<th class=listheading>".$locale->text('Deposit')."</a></th>";
-    $column_header{credit} = "<th class=listheading>".$locale->text('Payment')."</a></th>";
+    $column_header{debit} =
+      "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
+    $column_header{credit} =
+      "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
   } else {
-    $column_header{debit} = "<th class=listheading>".$locale->text('Decrease')."</a></th>";
-    $column_header{credit} = "<th class=listheading>".$locale->text('Increase')."</a></th>";
+    $column_header{debit} =
+      "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
+    $column_header{credit} =
+      "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
   }
 
-  $column_header{balance} = "<th class=listheading>".$locale->text('Balance')."</a></th>";
+  $column_header{balance} =
+    "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
 
   if ($form->{fromdate}) {
     $option .= "\n<br>" if ($option);
-    $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{fromdate}, 1);
+    $option .=
+        $locale->text('From') . "&nbsp;"
+      . $locale->date(\%myconfig, $form->{fromdate}, 0);
   }
   if ($form->{todate}) {
     $option .= "\n<br>" if ($option);
-    $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{todate}, 1);
+    $option .=
+        $locale->text('Until') . "&nbsp;"
+      . $locale->date(\%myconfig, $form->{todate}, 0);
   }
 
   $form->{title} = "$form->{accno}--$form->{account}";
-  
+
   $form->header;
 
   print qq|
@@ -179,11 +201,14 @@ sub display_form {
   $ml = ($form->{category} eq 'A') ? -1 : 1;
   $form->{beginningbalance} *= $ml;
   $clearedbalance = $balance = $form->{beginningbalance};
-  $i = 0;
-  $id = 0;
-  
-  map { $column_data{$_} = "<td>&nbsp;</td>" } qw(cleared transdate source name debit credit);
-  $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
+  $i              = 0;
+  $id             = 0;
+
+  map { $column_data{$_} = "<td>&nbsp;</td>" }
+    qw(cleared transdate source name debit credit);
+  $column_data{balance} =
+    "<td align=right>"
+    . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
   $j = 0;
   print qq|
        <tr class=listrow$j>
@@ -195,29 +220,36 @@ sub display_form {
        </tr>
 |;
 
-
   foreach $ref (@{ $form->{PR} }) {
 
     $balance += $ref->{amount} * $ml;
     $cleared += $ref->{amount} * $ml if $ref->{cleared};
 
-    $column_data{name} = "<td>$ref->{name}&nbsp;</td>";
+    $column_data{name}   = "<td>$ref->{name}&nbsp;</td>";
     $column_data{source} = qq|<td>$ref->{source}&nbsp;</a>
     </td>|;
     $column_data{transdate} = "<td>$ref->{transdate}&nbsp;</td>";
-    
-    $column_data{debit} = "<td>&nbsp;</td>";
+
+    $column_data{debit}  = "<td>&nbsp;</td>";
     $column_data{credit} = "<td>&nbsp;</td>";
-    
+
     if ($ref->{amount} < 0) {
       $totaldebits += $ref->{amount} * -1;
-      $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} * -1, 2, "&nbsp;")."</td>";
+      $column_data{debit} =
+          "<td align=right>"
+        . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, "&nbsp;")
+        . "</td>";
     } else {
       $totalcredits += $ref->{amount};
-      $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")."</td>";
+      $column_data{credit} =
+          "<td align=right>"
+        . $form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")
+        . "</td>";
     }
-    
-    $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
+
+    $column_data{balance} =
+      "<td align=right>"
+      . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
 
     if ($ref->{fx_transaction}) {
       $i++ unless $id == $ref->{id};
@@ -236,7 +268,8 @@ sub display_form {
     }
     $id = $ref->{id};
 
-    $j++; $j %= 2;
+    $j++;
+    $j %= 2;
     print qq|
        <tr class=listrow$j>
 |;
@@ -252,26 +285,36 @@ sub display_form {
   # print totals
   map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
 
-  $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebits, 2, "&nbsp;")."</th>";
-  $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredits, 2, "&nbsp;")."</th>";
-   
+  $column_data{debit} =
+    "<th class=listtotal align=right>"
+    . $form->format_amount(\%myconfig, $totaldebits, 2, "&nbsp;") . "</th>";
+  $column_data{credit} =
+    "<th class=listtotal align=right>"
+    . $form->format_amount(\%myconfig, $totalcredits, 2, "&nbsp;") . "</th>";
+
   print qq|
        <tr class=listtotal>
 |;
 
   map { print "\n$column_data{$_}" } @column_index;
 
-  $form->{statementbalance} = $form->parse_amount(\%myconfig, $form->{statementbalance});
-  $difference = $form->format_amount(\%myconfig, $form->{statementbalance} - $clearedbalance - $cleared, 2, 0);
-  
-  $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
+  $form->{statementbalance} =
+    $form->parse_amount(\%myconfig, $form->{statementbalance});
+  $difference =
+    $form->format_amount(\%myconfig,
+                        $form->{statementbalance} - $clearedbalance - $cleared,
+                        2, 0);
+
+  $form->{statementbalance} =
+    $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
 
   $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
-  
+
   if ($fx) {
-    $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
+    $fx       = $form->format_amount(\%myconfig, $fx, 2, 0);
     $exchdiff = qq|
-               <th align=right nowrap>|.$locale->text('Exchangerate Difference').qq|</th>
+               <th align=right nowrap>|
+      . $locale->text('Exchangerate Difference') . qq|</th>
                <td width=10%></td>
                <td align=right>$fx</td>
 |;
@@ -289,7 +332,7 @@ sub display_form {
          <td>
            <table>
              <tr>
-               <th align=right nowrap>|.$locale->text('Cleared Balance').qq|</th>
+               <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
                <td width=10%></td>
                <td align=right>$clearedbalance</td>
              </tr>
@@ -301,12 +344,12 @@ sub display_form {
          <td align=right>
            <table>
              <tr>
-               <th align=right nowrap>|.$locale->text('Statement Balance').qq|</th>
+               <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
                <td width=10%></td>
                <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
              </tr>
              <tr>
-               <th align=right nowrap>|.$locale->text('Difference').qq|</th>
+               <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
                <td width=10%></td>
                <td align=right><input name=null size=11 value=$difference></td>
                <input type=hidden name=difference value=$difference>
@@ -329,21 +372,14 @@ sub display_form {
 <input type=hidden name=fromdate value=$form->{fromdate}>
 <input type=hidden name=todate value=$form->{todate}>
 
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
 <br>
-<input type=submit class=submit name=action value="|.$locale->text('Update').qq|">
-<input type=submit class=submit name=action value="|.$locale->text('Select all').qq|">
-<input type=submit class=submit name=action value="|.$locale->text('Done').qq|">|;
+<input type=submit class=submit name=action value="|
+    . $locale->text('Update') . qq|">
+<input type=submit class=submit name=action value="|
+    . $locale->text('Select all') . qq|">
+<input type=submit class=submit name=action value="|
+    . $locale->text('Done') . qq|">
 
-  if ($form->{menubar}) {
-    require "$form->{path}/menu.pl";
-    &menubar;
-  }
-
-  print qq|
 </form>
 
 </body>
@@ -353,10 +389,11 @@ sub display_form {
   $lxdebug->leave_sub();
 }
 
-
 sub update {
   $lxdebug->enter_sub();
-  
+
+  $auth->assert('cash');
+
   RC->payment_transactions(\%myconfig, \%$form);
 
   foreach $ref (@{ $form->{PR} }) {
@@ -367,35 +404,37 @@ sub update {
   }
 
   &display_form;
-  
+
   $lxdebug->leave_sub();
 }
 
-
 sub select_all {
   $lxdebug->enter_sub();
-  
+
+  $auth->assert('cash');
+
   RC->payment_transactions(\%myconfig, \%$form);
 
-  map { $_->{cleared} = "checked" unless $_->{fx_transaction} } @{ $form->{PR} };
+  map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
+    @{ $form->{PR} };
 
   &display_form;
-  
+
   $lxdebug->leave_sub();
 }
 
-
 sub done {
   $lxdebug->enter_sub();
 
-  $form->{callback} = "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
+  $auth->assert('cash');
+
+  $form->{callback} = "$form->{script}?action=reconciliation";
 
   $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
 
   RC->reconcile(\%myconfig, \%$form);
   $form->redirect;
-  
+
   $lxdebug->leave_sub();
 }
 
-