From: Moritz Bunkus Date: Thu, 23 Jan 2014 13:57:04 +0000 (+0100) Subject: Projektverwaltung: Fixes nach Rebase; Refactoring X-Git-Tag: release-3.2.0beta~467^2~17 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=47dbae62a5c80fd13cb255c3c53b5895ada1b1ba;p=kivitendo-erp.git Projektverwaltung: Fixes nach Rebase; Refactoring --- diff --git a/SL/Controller/Project.pm b/SL/Controller/Project.pm index f028b9e6c..ba7bf1db6 100644 --- a/SL/Controller/Project.pm +++ b/SL/Controller/Project.pm @@ -25,13 +25,11 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(project linked_records) ], - 'scalar --get_set_init' => [ qw(models) ], + 'scalar --get_set_init' => [ qw(models customers project_types project_statuses) ], ); __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('load_project', only => [ qw(edit update destroy) ]); -__PACKAGE__->run_before('load_project_types', only => [ qw(search edit new list) ]); -__PACKAGE__->run_before('load_project_status', only => [ qw(search edit new list) ]); # # actions @@ -115,10 +113,19 @@ sub check_auth { # helpers # +sub init_project_statuses { SL::DB::Manager::ProjectStatus->get_all_sorted } +sub init_project_types { SL::DB::Manager::ProjectType->get_all_sorted } + +sub init_customers { + my ($self) = @_; + my @customer_id = $self->project && $self->project->customer_id ? (id => $self->project->customer_id) : (); + + return SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, @customer_id ]]); +} + sub display_form { my ($self, %params) = @_; - $params{ALL_CUSTOMERS} = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $self->project->customer_id ]]); $params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id); if ($params{keep_cvars}) { @@ -199,7 +206,7 @@ sub prepare_report { description => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } }, project_type => { sub => sub { $_[0]->project_type->description } }, project_status => { sub => sub { $_[0]->project_status->description }, text => t8('Status') }, - customer => { raw_data => sub { $self->presenter->customer($_[0]->customer, display => 'table-cell', callback => $callback) } }, + customer => { raw_data => sub { $_[0]->customer_id ? $self->presenter->customer($_[0]->customer, display => 'table-cell', callback => $callback) : '' } }, active => { sub => sub { $_[0]->active ? $::locale->text('Active') : $::locale->text('Inactive') }, text => $::locale->text('Active') }, valid => { sub => sub { $_[0]->valid ? $::locale->text('Valid') : $::locale->text('Invalid') }, @@ -281,13 +288,4 @@ sub make_filter_summary { $self->{filter_summary} = join ', ', @filter_strings; } - -sub load_project_types { - $_[0]{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted; -} - -sub load_project_status { - $_[0]{ALL_PROJECT_STATUS} = SL::DB::Manager::ProjectStatus->get_all_sorted; -} - 1; diff --git a/templates/webpages/project/_basic_data.html b/templates/webpages/project/_basic_data.html index c9dcd1d76..31bf79d0a 100644 --- a/templates/webpages/project/_basic_data.html +++ b/templates/webpages/project/_basic_data.html @@ -18,17 +18,17 @@ [% 'Project Type' | $T8 %] - [% L.select_tag('project.project_type_id', SELF.ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %] + [% L.select_tag('project.project_type_id', SELF.project_types, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %] [% 'Project Status' | $T8 %] - [% L.select_tag('project.project_status_id', SELF.ALL_PROJECT_STATUS, default=SELF.project.project_status_id, title_key='description', style='width: 300px') %] + [% L.select_tag('project.project_status_id', SELF.project_statuses, default=SELF.project.project_status_id, title_key='description', style='width: 300px') %] [% 'Customer' | $T8 %] - [% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %] + [% L.select_tag('project.customer_id', SELF.customers, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %] diff --git a/templates/webpages/project/_filter.html b/templates/webpages/project/_filter.html index 27fb84b84..3bd198052 100644 --- a/templates/webpages/project/_filter.html +++ b/templates/webpages/project/_filter.html @@ -11,7 +11,7 @@ [% 'Description' | $T8 %] - [% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60) %] + [% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60, class='initial_focus') %] @@ -21,12 +21,12 @@ [% 'Project Type' | $T8 %] - [% L.select_tag('filter.project_type_id', SELF.ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %] + [% L.select_tag('filter.project_type_id', SELF.project_types, default=filter.project_type_id, title_key='description', with_empty=1, style="width: 200px") %] [% 'Project Status' | $T8 %] - [% L.select_tag('filter.project_status_id', SELF.ALL_PROJECT_STATUS, default=filter.project_status_id, title_key='description', with_empty=1) %] + [% L.select_tag('filter.project_status_id', SELF.project_statuses, default=filter.project_status_id, title_key='description', with_empty=1, style="width: 200px") %] [% CUSTOM_VARIABLES_FILTER_CODE %] diff --git a/templates/webpages/project/search.html b/templates/webpages/project/search.html index 23c9fe8de..a4a2d82aa 100644 --- a/templates/webpages/project/search.html +++ b/templates/webpages/project/search.html @@ -10,56 +10,7 @@
[% 'Search projects' | $T8 %]

- - - - - - - - - - - - - - - - - - - - - - - - - - - [% CUSTOM_VARIABLES_FILTER_CODE %] - - - - - -
[% 'Number' | $T8 %][% L.input_tag('filter.projectnumber:substr::ilike', filter.projectnumber_substr__ilike, size=60) %]
[% 'Description' | $T8 %][% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60, class='initial_focus') %]
[% 'Customer' | $T8 %][% L.input_tag('filter.customer.name:substr::ilike', filter.customer.name_substr__ilike, size=60) %]
[% 'Project Type' | $T8 %][% L.select_tag('filter.project_type_id', SELF.ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %]
[% 'Project Status' | $T8 %][% L.select_tag('filter.project_status_id', SELF.ALL_PROJECT_STATUS, default=filter.project_status_id, title_key='description', with_empty=1) %]
[% 'Include in Report' | $T8 %] - - - - - - - - - - - - - - [% CUSTOM_VARIABLES_INCLUSION_CODE %] - -
[% L.select_tag('filter.active', [ [ 'active', LxERP.t8('Active') ], [ 'inactive', LxERP.t8('Inactive') ], [ 'both', LxERP.t8('Both') ] ], default=filter.active, style="width: 200px") %]
[% L.select_tag('filter.valid', [ [ 'valid', LxERP.t8('Valid') ], [ 'invalid', LxERP.t8('Invalid') ], [ 'both', LxERP.t8('Both') ] ], default=filter.valid, style="width: 200px") %]
[% L.select_tag('filter.status', [ [ 'all', LxERP.t8('All') ], [ 'orphaned', LxERP.t8('Orphaned') ] ], default=filter.status, style="width: 200px") %]
-
+[%- INCLUDE 'project/_filter.html' %]