From: G. Richardson Date: Sun, 12 Feb 2017 12:51:17 +0000 (+0100) Subject: DATEV Export - nach Abteilung filtern X-Git-Tag: release-3.5.4~1154 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c0f873c1ffccfd565995500b459d53bba394c04d;p=kivitendo-erp.git DATEV Export - nach Abteilung filtern --- diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 9f8719b10..ce5f48e8c 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -374,6 +374,12 @@ sub generate_datev_data { my $form = $main::form; my $trans_id_filter = ''; + my ($ar_department_id_filter, $ap_department_id_filter, $gl_department_id_filter); + if ( $form->{department_id} ) { + $ar_department_id_filter = " AND ar.department_id = ? "; + $ap_department_id_filter = " AND ap.department_id = ? "; + $gl_department_id_filter = " AND gl.department_id = ? "; + } if ( $self->{trans_id} ) { # ignore dates when trans_id is passed so that the entire transaction is @@ -400,6 +406,7 @@ sub generate_datev_data { t.rate AS taxrate, t.taxdescription, 'ar' as table, tc.accno AS tax_accno, tc.description AS tax_accname, + ar.department_id, ar.notes FROM acc_trans ac LEFT JOIN ar ON (ac.trans_id = ar.id) @@ -410,6 +417,7 @@ sub generate_datev_data { WHERE (ar.id IS NOT NULL) AND $fromto $trans_id_filter + $ar_department_id_filter $filter UNION ALL @@ -422,6 +430,7 @@ sub generate_datev_data { t.rate AS taxrate, t.taxdescription, 'ap' as table, tc.accno AS tax_accno, tc.description AS tax_accname, + ap.department_id, ap.notes FROM acc_trans ac LEFT JOIN ap ON (ac.trans_id = ap.id) @@ -432,6 +441,7 @@ sub generate_datev_data { WHERE (ap.id IS NOT NULL) AND $fromto $trans_id_filter + $ap_department_id_filter $filter UNION ALL @@ -444,6 +454,7 @@ sub generate_datev_data { t.rate AS taxrate, t.taxdescription, 'gl' as table, tc.accno AS tax_accno, tc.description AS tax_accname, + gl.department_id, gl.notes FROM acc_trans ac LEFT JOIN gl ON (ac.trans_id = gl.id) @@ -453,11 +464,17 @@ sub generate_datev_data { WHERE (gl.id IS NOT NULL) AND $fromto $trans_id_filter + $gl_department_id_filter $filter ORDER BY trans_id, acc_trans_id|; - my $sth = prepare_execute_query($form, $self->dbh, $query); + my @query_args; + if ( $form->{department_id} ) { + push(@query_args, ($form->{department_id}) x 3); + } + + my $sth = prepare_execute_query($form, $self->dbh, $query, @query_args); $self->{DATEV} = []; my $counter = 0; diff --git a/bin/mozilla/datev.pl b/bin/mozilla/datev.pl index 8604da00d..5acf55517 100644 --- a/bin/mozilla/datev.pl +++ b/bin/mozilla/datev.pl @@ -32,6 +32,7 @@ use Archive::Zip qw(:ERROR_CODES :CONSTANTS); use SL::Common; use SL::DATEV qw(:CONSTANTS); use SL::Locale::String qw(t8); +use SL::DB::Department; use strict; @@ -76,6 +77,7 @@ sub export_bewegungsdaten { setup_datev_export2_action_bar(); $::form->header; + $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all; print $::form->parse_html_template('datev/export_bewegungsdaten'); $::lxdebug->leave_sub; diff --git a/templates/webpages/datev/export_bewegungsdaten.html b/templates/webpages/datev/export_bewegungsdaten.html index 5a3b5627d..441d83df9 100644 --- a/templates/webpages/datev/export_bewegungsdaten.html +++ b/templates/webpages/datev/export_bewegungsdaten.html @@ -54,6 +54,22 @@ + [% IF ALL_DEPARTMENTS.as_list.size %] + + [% 'Department' | $T8 %] + + + + + + + + + +
[% 'Department' | $T8 %][% L.select_tag('department_id', ALL_DEPARTMENTS, title_key = 'description', with_empty = 1) %]
+ + + [% END %]