#======================================================================
use POSIX qw(strftime);
+use List::Util qw(sum);
+use SL::FU;
use SL::GL;
use SL::IS;
use SL::PE;
use SL::ReportGenerator;
-require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
require "bin/mozilla/reportgenerator.pl";
sub add {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{title} = "Add";
- $form->{callback} =
- "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
- unless $form->{callback};
+ $form->{callback} = "gl.pl?action=add" unless $form->{callback};
# we use this only to set a default date
GL->transaction(\%myconfig, \%$form);
sub prepare_transaction {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
GL->transaction(\%myconfig, \%$form);
map {
sub edit {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
prepare_transaction();
$form->{title} = "Edit";
sub search {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{title} = $locale->text('Journal');
$form->all_departments(\%myconfig);
print qq|
<body onLoad="$onload">
-<form method=post action=$form->{script}>
+<form method=post action=gl.pl>
<input type=hidden name=sort value=transdate>
<input type=hidden name=nextsub value=generate_report>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
<br>
<input class=submit type=submit name=action value="|
. $locale->text('Continue') . qq|">
sub generate_report {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{sort} ||= "transdate";
GL->all_transactions(\%myconfig, \%$form);
sub update {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{oldtransdate} = $form->{transdate};
my @a = ();
my ($init) = @_;
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
&form_header($init);
# for $i (1 .. $form->{rowcount}) {
my ($init) = @_;
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{debit_1} = 0 if !$form->{"debit_1"};
$form->{totaldebit} = 0;
$form->{totalcredit} = 0;
sub form_header {
my ($init) = @_;
$lxdebug->enter_sub();
+
+ $auth->assert('general_ledger');
+
$title = $form->{title};
$form->{title} = $locale->text("$title General Ledger Transaction");
$readonly = ($form->{id}) ? "readonly" : "";
print qq|
<body onLoad="fokus()">
-<form method=post name="gl" action=$form->{script}>
+<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>
|;
$form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate));
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>
sub form_footer {
$lxdebug->enter_sub();
+
+ $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;
</tr>
</table>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
<input name=callback type=hidden value="$form->{callback}">
+$follow_ups_block
+
<br>
|;
<input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
}
+ print qq|
+ <input type="button" class="submit" onclick="follow_up_window()" value="|
+ . $locale->text('Follow-Up')
+ . qq|"> |;
+
} else {
if ($transdate > $closedto) {
print qq|
print qq|
<body>
-<form method=post action=$form->{script}>
+<form method=post action=gl.pl>
|;
map { $form->{$_} =~ s/\"/"/g } qw(reference description);
delete $form->{header};
foreach $key (keys %$form) {
+ next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
}
sub post {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{title} = $locale->text("$form->{title} General Ledger Transaction");
$form->{storno} = 0;
sub post_as_new {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{id} = 0;
&add;
$lxdebug->leave_sub();
sub storno {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
# don't cancel cancelled transactions
if (IS->has_storno(\%myconfig, $form, 'gl')) {
$form->{title} = $locale->text("Cancel Accounts Receivables Transaction");
$lxdebug->leave_sub();
}
+sub continue {
+ call_sub($form->{nextsub});
+}