From ef294a7520ae7e452f6671676d7a8077bf74a9cf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 2 Dec 2010 10:12:56 +0100 Subject: [PATCH] =?utf8?q?Unterscheidung=20Bankeinzug/=C3=9Cberweisung=20b?= =?utf8?q?ei=20Suchefunktion?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/SEPA.pm | 23 ++++++++++++++--------- bin/mozilla/sepa.pl | 16 +++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/SL/SEPA.pm b/SL/SEPA.pm index 6bc1adc74..904c78ed5 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -230,6 +230,8 @@ sub list_exports { my $myconfig = \%main::myconfig; my $form = $main::form; + my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); @@ -261,16 +263,16 @@ sub list_exports { } if ($filter->{invnumber}) { - push @where_sub, "ap.invnumber ILIKE ?"; + push @where_sub, "arap.invnumber ILIKE ?"; push @values_sub, '%' . $filter->{invnumber} . '%'; - $joins_sub{ap} = 1; + $joins_sub{$arap} = 1; } - if ($filter->{vendor}) { - push @where_sub, "v.name ILIKE ?"; - push @values_sub, '%' . $filter->{vendor} . '%'; - $joins_sub{ap} = 1; - $joins_sub{vendor} = 1; + if ($filter->{vc}) { + push @where_sub, "vc.name ILIKE ?"; + push @values_sub, '%' . $filter->{vc} . '%'; + $joins_sub{$arap} = 1; + $joins_sub{vc} = 1; } foreach my $type (qw(requested_execution execution)) { @@ -283,8 +285,8 @@ sub list_exports { if (@where_sub) { my $joins_sub = ''; - $joins_sub .= ' LEFT JOIN ap ON (items.ap_id = ap.id)' if ($joins_sub{ap}); - $joins_sub .= ' LEFT JOIN vendor v ON (ap.vendor_id = v.id)' if ($joins_sub{vendor}); + $joins_sub .= " LEFT JOIN ${arap} arap ON (items.${arap}_id = arap.id)" if ($joins_sub{$arap}); + $joins_sub .= " LEFT JOIN ${vc} vc ON (arap.${vc}_id = vc.id)" if ($joins_sub{vc}); my $where_sub = join(' AND ', map { "(${_})" } @where_sub); @@ -297,6 +299,9 @@ sub list_exports { push @values, @values_sub; } + push @where, 'se.vc = ?'; + push @values, $vc; + my $where = ' WHERE ' . join(' AND ', map { "(${_})" } @where) if (@where); my $query = diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index 440dc2e4b..1164b3bad 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -167,17 +167,18 @@ sub bank_transfer_list { my $form = $main::form; my $locale = $main::locale; my $cgi = $main::cgi; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; - $form->{title} = $locale->text('List of bank transfers'); + $form->{title} = $vc eq 'customer' ? $::locale->text('List of bank collections') : $locale->text('List of bank transfers'); $form->{sort} ||= 'id'; $form->{sortdir} = '1' if (!defined $form->{sortdir}); - $form->{callback} = build_std_url('action=bank_transfer_list', 'sort', 'sortdir'); + $form->{callback} = build_std_url('action=bank_transfer_list', 'sort', 'sortdir', 'vc'); my %filter = map +( $_ => $form->{"f_${_}"} ), grep { $form->{"f_${_}"} } - (qw(vendor invnumber), + (qw(vc invnumber), map { ("${_}_date_from", "${_}_date_to") } qw(export requested_execution execution)); $filter{executed} = $form->{l_executed} ? 1 : 0 if ($form->{l_executed} != $form->{l_not_executed}); @@ -185,13 +186,14 @@ sub bank_transfer_list { my $exports = SL::SEPA->list_exports('filter' => \%filter, 'sortorder' => $form->{sort}, - 'sortdir' => $form->{sortdir}); + 'sortdir' => $form->{sortdir}, + 'vc' => $vc); my $open_available = any { !$_->{closed} } @{ $exports }; my $report = SL::ReportGenerator->new(\%main::myconfig, $form); - my @hidden_vars = grep { m/^[fl]_/ && $form->{$_} } keys %{ $form }; + my @hidden_vars = ('vc', grep { m/^[fl]_/ && $form->{$_} } keys %{ $form }); my $href = build_std_url('action=bank_transfer_list', @hidden_vars); @@ -216,7 +218,7 @@ sub bank_transfer_list { $column_defs{closed}->{visible} = $form->{l_closed} && $form->{l_open} ? 1 : 0; my @options = (); - push @options, $locale->text('Vendor') . ' : ' . $form->{f_vendor} if ($form->{f_vendor}); + push @options, ($vc eq 'customer' ? $::locale->text('Customer') : $locale->text('Vendor')) . ' : ' . $form->{f_vc} if ($form->{f_vc}); push @options, $locale->text('Invoice number') . ' : ' . $form->{f_invnumber} if ($form->{f_invnumber}); push @options, $locale->text('Export date from') . ' : ' . $form->{f_export_date_from} if ($form->{f_export_date_from}); push @options, $locale->text('Export date to') . ' : ' . $form->{f_export_date_to} if ($form->{f_export_date_to}); @@ -249,7 +251,7 @@ sub bank_transfer_list { map { $row->{$_}->{data} = $export->{$_} ? $locale->text('yes') : $locale->text('no') } qw(executed closed); - $row->{id}->{link} = $edit_url . '&id=' . E($export->{id}); + $row->{id}->{link} = $edit_url . '&id=' . E($export->{id}) . '&vc=' . E($vc); if (!$export->{closed}) { $row->{selected}->{raw_data} = -- 2.20.1