X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=a6649146eac3e8f910a4a922162ace7199aac018;hb=787248feb4b2ea860d35574f35c2c020070bd407;hp=0fd863e514d7a91079c82572a364c0cd49a985f7;hpb=7a1f60ec2df4d0d0a1b546f186df7bb968b8f498;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 0fd863e51..a6649146e 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -32,15 +32,16 @@ #====================================================================== 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/report_generator.pl"; +require "bin/mozilla/reportgenerator.pl"; 1; @@ -77,11 +78,11 @@ require "bin/mozilla/report_generator.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); @@ -119,6 +120,8 @@ sub add { sub prepare_transaction { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + GL->transaction(\%myconfig, \%$form); map { @@ -191,6 +194,8 @@ sub prepare_transaction { sub edit { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + prepare_transaction(); $form->{title} = "Edit"; @@ -208,6 +213,8 @@ sub edit { sub search { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{title} = $locale->text('Journal'); $form->all_departments(\%myconfig); @@ -281,7 +288,7 @@ sub search { print qq| -
{script}> + @@ -382,9 +389,6 @@ $jsscript -{login}> -{password}> -
@@ -415,7 +419,9 @@ sub create_subtotal_row { sub generate_report { $lxdebug->enter_sub(); - $form->{sort} ||= "transdate"; + $auth->assert('general_ledger'); + + report_generator_set_default_sort('transdate', 1); GL->all_transactions(\%myconfig, \%$form); @@ -445,38 +451,24 @@ 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); + + my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); $form->{l_credit_accno} = 'Y'; $form->{l_debit_accno} = 'Y'; @@ -505,14 +497,19 @@ sub generate_report { 'projectnumbers' => { 'text' => $locale->text('Project Numbers'), }, ); - map { $column_defs{$_}->{link} = $callback . "&sort=${_}" } qw(id transdate reference source description); - map { $column_defs{$_}->{link} = $callback . "&sort=accno" } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno debit_tax credit_tax); + foreach my $name (qw(id transdate reference source description debit_accno credit_accno debit_tax_accno credit_tax_accno)) { + my $sortname = $name =~ m/accno/ ? 'accno' : $name; + my $sortdir = $sortname eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir"; + } + map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; map { $column_defs{$_}->{visible} = 0 } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno) if $form->{accno}; my %column_alignment; - map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax); - map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno); + map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax); + map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno); + map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment; my $report = SL::ReportGenerator->new(\%myconfig, $form); @@ -521,7 +518,7 @@ sub generate_report { $report->set_export_options('generate_report', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort} eq 'accno' ? 'debit_accno' : $form->{sort}, $form->{sortdir}); $report->set_options('top_info_text' => join("\n", @options), 'output_format' => 'HTML', @@ -531,7 +528,7 @@ sub generate_report { $report->set_options_from_form(); # add sort to callback - $form->{callback} = "$callback&sort=" . E($form->{sort}); + $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir}); $form->{balance} *= $ml; @@ -580,18 +577,14 @@ sub generate_report { map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description source notes); - map { $row->{$_}->{data} = join "\n", @{ $rows{$_} }; } qw(transdate debit credit); - - map { $row->{$_}->{data} = join "\n", @{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax); + map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno); foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) { - if (lc $report->{options}->{output_format} eq 'html') { - $row->{$col}->{raw_data} = join "
", map { "$_" } @{ $rows{$col} }; - } else { - $row->{$col}->{data} = join "\n", @{ $rows{$col} }; - } + $row->{$col}->{link} = [ map { "${callback}&accno=" . E($_) } @{ $rows{$col} } ]; } + map { $row->{$_}->{data} = \@{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax); + $row->{reference}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{id}), 'callback'); my $row_set = [ $row ]; @@ -643,6 +636,8 @@ sub generate_report { sub update { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{oldtransdate} = $form->{transdate}; my @a = (); @@ -749,6 +744,8 @@ sub display_form { my ($init) = @_; $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + &form_header($init); # for $i (1 .. $form->{rowcount}) { @@ -767,6 +764,8 @@ sub display_rows { my ($init) = @_; $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{debit_1} = 0 if !$form->{"debit_1"}; $form->{totaldebit} = 0; $form->{totalcredit} = 0; @@ -794,10 +793,10 @@ sub display_rows { my %charts = (); my $taxchart_init; foreach my $item (@{ $form->{ALL_CHARTS} }) { - my $key = Q($item->{accno}) . "--" . Q($item->{tax_id}); + my $key = $item->{accno} . "--" . $item->{tax_id}; $taxchart_init = $item->{taxkey_id} unless (@chart_values); push(@chart_values, $key); - $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description}); + $chart_labels{$key} = $item->{accno} . "--" . $item->{description}; $charts{$item->{accno}} = $item; } @@ -805,11 +804,10 @@ sub display_rows { my @taxchart_values = (); my %taxcharts = (); foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { - my $key = Q($item->{id}) . "--" . Q($item->{rate}); + my $key = $item->{id} . "--" . $item->{rate}; $taxchart_init = $key if ($taxchart_init eq $item->{taxkey}); push(@taxchart_values, $key); - $taxchart_labels{$key} = H($item->{taxdescription}) . " " . - H($item->{rate} * 100) . ' %'; + $taxchart_labels{$key} = $item->{taxdescription} . " " . $item->{rate} * 100 . ' %'; $taxcharts{$item->{id}} = $item; } @@ -819,6 +817,10 @@ sub display_rows { |; $memo = qq| |; + $source_hidden = qq| + |; + $memo_hidden = qq| + |; my $selected_accno_full; my ($accno_row) = split(/--/, $form->{"accno_$i"}); @@ -946,6 +948,8 @@ sub display_rows { |; } print qq| + $source_hidden + $memo_hidden |; } @@ -959,12 +963,18 @@ sub display_rows { 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" : ""; $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') @@ -1059,7 +1069,10 @@ sub form_header { print qq| -{script}> + + + + |; $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate)); @@ -1067,6 +1080,10 @@ sub form_header { print qq| + + + + @@ -1151,7 +1168,17 @@ sub form_header { |; } - print qq| + print qq| + + + |; @@ -1193,6 +1220,19 @@ $jsscript 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|

| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|

|; + } + } + ($dec) = ($form->{totaldebit} =~ /\.(\d+)/); $dec = length $dec; $decimalplaces = ($dec > 2) ? $dec : 2; @@ -1214,11 +1254,10 @@ sub form_footer {
+ + +
+ | . $locale->text('OB Transaction') . qq| + + | . $locale->text('CB Transaction') . qq| +
| . $locale->text('Show details') . qq|
-{login}> -{password}> - +$follow_ups_block +
|; @@ -1238,12 +1277,16 @@ sub form_footer { |; } + print qq| + + |; + } else { - if ($transdate > $closedto) { print qq| |; - } } print " @@ -1264,7 +1307,7 @@ sub delete { print qq| -{script}> + |; map { $form->{$_} =~ s/\"/"/g } qw(reference description); @@ -1272,6 +1315,7 @@ sub delete { delete $form->{header}; foreach $key (keys %$form) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); print qq|\n|; } @@ -1435,7 +1479,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!')); } @@ -1468,6 +1512,8 @@ sub post_transaction { sub post { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{title} = $locale->text("$form->{title} General Ledger Transaction"); $form->{storno} = 0; @@ -1482,6 +1528,8 @@ sub post { sub post_as_new { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{id} = 0; &add; $lxdebug->leave_sub(); @@ -1491,6 +1539,8 @@ sub post_as_new { 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"); @@ -1512,3 +1562,6 @@ sub storno { $lxdebug->leave_sub(); } +sub continue { + call_sub($form->{nextsub}); +}