From a222e32406aade497b6c8dce6f4869d8b0eec6e1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 15 Oct 2013 15:51:39 +0200 Subject: [PATCH] =?utf8?q?Finanz=C3=BCbersicht:=20Filterm=C3=B6glichkeit?= =?utf8?q?=20nach=20Verk=C3=A4uferIn?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/FinancialOverview.pm | 25 +++++++++++-------- .../financial_overview/report_top.html | 6 ++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/SL/Controller/FinancialOverview.pm b/SL/Controller/FinancialOverview.pm index 38d2fc61b..fec091572 100644 --- a/SL/Controller/FinancialOverview.pm +++ b/SL/Controller/FinancialOverview.pm @@ -5,6 +5,7 @@ use parent qw(SL::Controller::Base); use List::MoreUtils qw(none); +use SL::DB::Employee; use SL::DB::Invoice; use SL::DB::Order; use SL::DB::PurchaseInvoice; @@ -12,7 +13,8 @@ use SL::Controller::Helper::ReportGenerator; use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(report number_columns year current_year types objects data subtotals_per_quarter) ], + scalar => [ qw(report number_columns year current_year types objects data subtotals_per_quarter salesman_id) ], + 'scalar --get_set_init' => [ qw(employees) ], ); __PACKAGE__->run_before(sub { $::auth->assert('report'); }); @@ -20,7 +22,7 @@ __PACKAGE__->run_before(sub { $::auth->assert('report'); }); sub action_list { my ($self) = @_; - $self->subtotals_per_quarter($::form->{subtotals_per_quarter}); + $self->$_($::form->{$_}) for qw(subtotals_per_quarter salesman_id); $self->get_objects; $self->calculate_data; @@ -64,7 +66,7 @@ sub prepare_report { ); $self->report->set_columns(%column_defs); $self->report->set_column_order(@columns); - $self->report->set_export_options(qw(list year subtotals_per_quarter)); + $self->report->set_export_options(qw(list year subtotals_per_quarter salesman_id)); $self->report->set_options_from_form; } @@ -77,15 +79,16 @@ sub get_objects { my $start = DateTime->new(year => $self->year, month => 1, day => 1); my $end = DateTime->new(year => $self->year, month => 12, day => 31); - my @date_filter = (and => [ transdate => { ge => $start }, transdate => { le => $end } ]); + my @f_date = (transdate => { ge => $start }, transdate => { le => $end }); + my @f_salesman = $self->salesman_id ? (salesman_id => $self->salesman_id) : (); $self->objects({ - sales_quotations => SL::DB::Manager::Order->get_all( where => [ and => [ @date_filter, SL::DB::Manager::Order->type_filter('sales_quotation') ]]), - sales_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @date_filter, SL::DB::Manager::Order->type_filter('sales_order') ]]), - requests_for_quotation => SL::DB::Manager::Order->get_all( where => [ and => [ @date_filter, SL::DB::Manager::Order->type_filter('request_quotation') ]]), - purchase_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @date_filter, SL::DB::Manager::Order->type_filter('purchase_order') ]]), - sales_invoices => SL::DB::Manager::Invoice->get_all( where => \@date_filter), - purchase_invoices => SL::DB::Manager::PurchaseInvoice->get_all(where => \@date_filter), + sales_quotations => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_quotation') ]]), + sales_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_order') ]]), + requests_for_quotation => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('request_quotation') ]]), + purchase_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('purchase_order') ]]), + sales_invoices => SL::DB::Manager::Invoice->get_all( where => [ and => [ @f_date, @f_salesman, ]]), + purchase_invoices => SL::DB::Manager::PurchaseInvoice->get_all(where => [ and => \@f_date ]), }); } @@ -162,4 +165,6 @@ sub list_data { return $self->report->generate_with_headers; } +sub init_employees { SL::DB::Manager::Employee->get_all_sorted } + 1; diff --git a/templates/webpages/financial_overview/report_top.html b/templates/webpages/financial_overview/report_top.html index ae362abf6..38716f0e7 100644 --- a/templates/webpages/financial_overview/report_top.html +++ b/templates/webpages/financial_overview/report_top.html @@ -11,8 +11,12 @@ | [%- LxERP.t8("Following year") %]: [% SELF.year + 1 %] » [% END %] -
+ [% L.checkbox_tag('subtotals_per_quarter', checked=SELF.subtotals_per_quarter, label=LxERP.t8('Subtotals per quarter'), onchange='$("#form").submit();') %] +
+ + [% LxERP.t8("Salesperson") %]: + [% L.select_tag('salesman_id', SELF.employees, with_empty=1, title_key='name', onchange='$("#form").submit();', default=SELF.salesman_id) %]


-- 2.20.1