-sub display_split_credit {
- $lxdebug->enter_sub();
- $form->{taxchart} = $form->unescape($form->{taxchart});
-
- $form->header;
-
- print qq|
-<body>
-<form method=post name=split_credit action=gl.pl>
-|
- . $locale->text('Credit') . qq|: |
- . $form->format_amount(\%myconfig, $form->{amount}, 2)
- . qq| EUR<br>
-|
- . $locale->text('Still to post')
- . qq|:<input name=creditpost size=10 value="|
- . $form->format_amount(\%myconfig, $form->{creditpost}, 2)
- . qq|"> EUR<br>
-<script type="text/javascript">
- function update_stilltopost (betrag){
- remaining = parseFloat(document.split_credit.creditpost.value) - parseFloat(betrag);
- document.split_credit.creditpost.value= remaining;
- }
-</script>
-
-<table>|;
- for $i (2 .. $form->{creditrowcount}) {
- $form->{"creditchart_$i"} = $form->{chart};
- $form->{"creditchart_$i"} =~
- s/value=\"$form->{"creditchartselected_$i"}\"/value=\"$form->{"creditchartselected_$i"}\" selected/;
-
- $form->{"taxchart_$i"} = $form->{taxchart};
- $form->{"taxchart_$i"} =~
- s/value=\"$form->{"taxchartselected_$i"}\"/value=\"$form->{"taxchartselected_$i"}\" selected/;
- $position = $i - 1;
- print qq|
- <tr><td></td></tr>
- <tr>
- <th>Position $position</th>
- <td><select name=creditchartselected_$i>$form->{"creditchart_$i"}</select></td>
- <th align=right>| . $locale->text('Amount') . qq| $1</th>
- <td><input name=credit_$i size=10 value="|
- . $form->format_amount(\%myconfig, $form->{"credit_$i"}, 2)
- . qq|" onBlur="update_stilltopost(this.value)"> EUR</td>
- </tr>
- <tr>
- <th></th>
- <td><select name=taxchartselected_$i>$form->{"taxchart_$i"}</select></td>
- <th align=right>| . $locale->text('Tax') . qq|</th>
- <td><input name=tax_$i size=10 value="|
- . $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2)
- . qq|"> EUR</td>
- <td><input type=checkbox name=tax_manual_$i value=1> Steuerkorrektur</td>
- </tr>
- <td></td>
- <tr>
- </tr>
- <tr>
- <td colspan=5><hr size=3 noshade></td>
- </tr>
-
-|;
- }
- print qq|
-</table>
-<input type=hidden name=previousform value="$form->{previousform}">
-
-<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=hidden name=callback value=$form->{callback}>
-<input type=hidden name=old_callback value=$form->{old_callback}>
-<input type=hidden name=amount value=$form->{amount}>
-<input type=hidden name=credit_splited value=1>
-<input type=hidden name=creditrowcount value="$form->{creditrowcount}">
-<input type=hidden name=chart value=| . $form->escape($form->{chart}) . qq|>
-<input type=hidden name=taxchart value=|
- . $form->escape($form->{taxchart}) . qq|>
-<p>
-<input class=submit type=submit name=action value="|
- . $locale->text('New Account') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Close') . qq|">
-</form>
-
-</body>
-</html>
-|;
-
- $lxdebug->leave_sub();
-}
-
-sub display_split_debit {
- $lxdebug->enter_sub();
- $form->{taxchart} = $form->unescape($form->{taxchart});
-
- $form->header;
-
- print qq|
-<body>
-<form method=post name=split_debit action=gl.pl>
-|
- . $locale->text('Debit') . qq|: |
- . $form->format_amount(\%myconfig, $form->{amount}, 2)
- . qq| EUR<br>
-|
- . $locale->text('Still to post')
- . qq|:<input name=debitpost size=10 value="|
- . $form->format_amount(\%myconfig, $form->{debitpost}, 2)
- . qq|"> EUR<br>
-<script type="text/javascript">
- function update_stilltopost (betrag){
- remaining = parseFloat(document.split_debit.debitpost.value) - parseFloat(betrag);
- document.split_debit.debitpost.value= remaining;
- }
-</script>
-
-<table>|;
- for $i (2 .. $form->{debitrowcount}) {
- $form->{"debitchart_$i"} = $form->{chart};
- $form->{"debitchart_$i"} =~
- s/value=\"$form->{"debitchartselected_$i"}\"/value=\"$form->{"debitchartselected_$i"}\" selected/;
-
- $form->{"taxchart_$i"} = $form->{taxchart};
- $form->{"taxchart_$i"} =~
- s/value=\"$form->{"taxchartselected_$i"}\"/value=\"$form->{"taxchartselected_$i"}\" selected/;
- $position = $i - 1;
- print qq|
- <tr><td></td></tr>
- <tr>
- <th>Position $position</th>
- <td><select name=debitchartselected_$i>$form->{"debitchart_$i"}</select></td>
- <th align=right>| . $locale->text('Amount') . qq| $1</th>
- <td><input name=debit_$i size=10 value="|
- . $form->format_amount(\%myconfig, $form->{"debit_$i"}, 2)
- . qq|" onBlur="update_stilltopost(this.value)"> EUR</td>
- </tr>
- <tr>
- <th></th>
- <td><select name=taxchartselected_$i>$form->{"taxchart_$i"}</select></td>
- <th align=right>| . $locale->text('Tax') . qq|</th>
- <td><input name=tax_$i size=10 value="|
- . $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2)
- . qq|"> EUR</td>
- <td><input type=checkbox name=tax_manual_$i value=1> Steuerkorrektur</td>
- </tr>
- <td></td>
- <tr>
- </tr>
- <tr>
- <td colspan=5><hr size=3 noshade></td>
- </tr>
-
-|;
- }
- print qq|
-</table>
-<input type=hidden name=previousform value="$form->{previousform}">
-
-<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=hidden name=callback value=$form->{callback}>
-<input type=hidden name=old_callback value=$form->{old_callback}>
-<input type=hidden name=amount value=$form->{amount}>
-<input type=hidden name=debit_splited value=1>
-<input type=hidden name=debitrowcount value="$form->{debitrowcount}">
-<input type=hidden name=chart value=| . $form->escape($form->{chart}) . qq|>
-<input type=hidden name=taxchart value=|
- . $form->escape($form->{taxchart}) . qq|>
-<p>
-<input class=submit type=submit name=action value="|
- . $locale->text('New Account') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Close') . qq|">
-</form>
-
-</body>
-</html>
-|;
-
- $lxdebug->leave_sub();
-}
-
-sub new_account {
- $lxdebug->enter_sub();
-
- $form->{chart} = $form->unescape($form->{chart});
-
- if ($form->{credit_splited}) {
- $form->{creditpost} = $form->{amount};
-
- for $i (2 .. $form->{creditrowcount}) {
- $form->{"credit_$i"} =
- $form->parse_amount(\%myconfig, $form->{"credit_$i"});
- $form->{creditpost} -= $form->{"credit_$i"};
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
- if ($form->{"tax_manual_$i"}) {
- $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
- } else {
- $form->{"tax_$i"} = $form->{"credit_$i"} * $taxrate;
- }
- $form->{creditpost} -= $form->{"tax_$i"};
-
- }
- if ($form->{"credit_$form->{creditrowcount}"}) {
- $form->{creditrowcount}++;
- }
-
- &display_split_credit;
- }
- if ($form->{debit_splited}) {
- $form->{debitpost} = $form->{amount};
-
- for $i (2 .. $form->{debitrowcount}) {
- $form->{"debit_$i"} =
- $form->parse_amount(\%myconfig, $form->{"debit_$i"});
- $form->{debitpost} -= $form->{"debit_$i"};
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
- if ($form->{"tax_manual_$i"}) {
- $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
- } else {
- $form->{"tax_$i"} = $form->{"debit_$i"} * $taxrate;
- }
- $form->{debitpost} -= $form->{"tax_$i"};
-
- }
- if ($form->{"debit_$form->{debitrowcount}"}) {
- $form->{debitrowcount}++;
- }
-
- &display_split_debit;
- }
- $lxdebug->leave_sub();
-}
-
-sub close {
- $lxdebug->enter_sub();
-
- # save the new form variables before splitting previousform
- map { $newform{$_} = $form->{$_} } keys %$form;
-
- $previousform = $form->unescape($form->{previousform});
-
- # don't trample on previous variables
- map { delete $form->{$_} } keys %newform;
-
- # now take it apart and restore original values
- foreach $item (split /&/, $previousform) {
- ($key, $value) = split /=/, $item, 2;
- $value =~ s/%26/&/g;
- $form->{$key} = $value;
- }
- if ($newform{credit_splited}) {
- $form->{credit} = 0;
- $form->{credit_splited} = $newform{credit_splited};
- $form->{creditrowcount} = $newform{creditrowcount};
- for $i (2 .. $form->{creditrowcount}) {
- $form->{"creditchartselected_$i"} = $newform{"creditchartselected_$i"};
- $form->{"credit_$i"} = $newform{"credit_$i"};
- $form->{"credit_$i"} =
- $form->parse_amount(\%myconfig, $form->{"credit_$i"});
- $form->{"taxchartselected_$i"} = $newform{"taxchartselected_$i"};
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
- if ($newform{"tax_manual_$i"}) {
- $form->{"tax_$i"} =
- $form->parse_amount(\%myconfig, $newform{"tax_$i"});
- } else {
- $form->{"tax_$i"} = $form->{"credit_$i"} * $taxrate;
- }
- $form->{credit} += $form->round_amount($form->{"credit_$i"}, 2);
- $form->{credit} += $form->round_amount($form->{"tax_$i"}, 2);
-
- }
- } else {
- $form->{debit} = 0;
- $form->{debit_splited} = $newform{debit_splited};
- $form->{debitrowcount} = $newform{debitrowcount};
- for $i (2 .. $form->{debitrowcount}) {
- $form->{"debitchartselected_$i"} = $newform{"debitchartselected_$i"};
- $form->{"debit_$i"} = $newform{"debit_$i"};
- $form->{"debit_$i"} =
- $form->parse_amount(\%myconfig, $form->{"debit_$i"});
- $form->{"taxchartselected_$i"} = $newform{"taxchartselected_$i"};
- ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
- if ($newform{"tax_manual_$i"}) {
- $form->{"tax_$i"} =
- $form->parse_amount(\%myconfig, $newform{"tax_$i"});
- } else {
- $form->{"tax_$i"} = $form->{"debit_$i"} * $taxrate;
- }
- $form->{debit} += $form->round_amount($form->{"debit_$i"}, 2);
- $form->{debit} += $form->round_amount($form->{"tax_$i"}, 2);
- }
- }
- delete $form->{action};
- $callback = $form->unescape($form->{callback});
- $form->{callback} = $form->unescape($form->{old_callback});
- delete $form->{old_callback};
-
- # put callback together
- foreach $key (keys %$form) {
-
- # do single escape for Apache 2.0
- $value = $form->escape($form->{$key}, 1);
- $callback .= qq|&$key=$value|;
- }
- $form->{callback} = $callback;
-
- # redirect
- $form->redirect;
- $lxdebug->leave_sub();
-}