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
# 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}) {
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') },
$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;
<tr>
<th align="right">[% 'Project Type' | $T8 %]</th>
- <td>[% L.select_tag('project.project_type_id', SELF.ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]</td>
+ <td>[% L.select_tag('project.project_type_id', SELF.project_types, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]</td>
</tr>
<tr>
<th align="right">[% 'Project Status' | $T8 %]</th>
- <td>[% L.select_tag('project.project_status_id', SELF.ALL_PROJECT_STATUS, default=SELF.project.project_status_id, title_key='description', style='width: 300px') %]</td>
+ <td>[% L.select_tag('project.project_status_id', SELF.project_statuses, default=SELF.project.project_status_id, title_key='description', style='width: 300px') %]</td>
</tr>
<tr>
<th align="right">[% 'Customer' | $T8 %]</th>
- <td>[% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]</td>
+ <td>[% L.select_tag('project.customer_id', SELF.customers, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]</td>
</tr>
<tr>
<tr>
<th align="right">[% 'Description' | $T8 %]</th>
- <td>[% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60) %]</td>
+ <td>[% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60, class='initial_focus') %]</td>
</tr>
<tr>
<tr>
<th align="right">[% 'Project Type' | $T8 %]</th>
- <td>[% L.select_tag('filter.project_type_id', SELF.ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %]</td>
+ <td>[% L.select_tag('filter.project_type_id', SELF.project_types, default=filter.project_type_id, title_key='description', with_empty=1, style="width: 200px") %]</td>
</tr>
<tr>
<th align="right">[% 'Project Status' | $T8 %]</th>
- <td>[% L.select_tag('filter.project_status_id', SELF.ALL_PROJECT_STATUS, default=filter.project_status_id, title_key='description', with_empty=1) %]</td>
+ <td>[% L.select_tag('filter.project_status_id', SELF.project_statuses, default=filter.project_status_id, title_key='description', with_empty=1, style="width: 200px") %]</td>
</tr>
[% CUSTOM_VARIABLES_FILTER_CODE %]
<div class="listtop">[% 'Search projects' | $T8 %]</div>
<p>
- <table>
- <tr>
- <th align="right">[% 'Number' | $T8 %]</th>
- <td>[% L.input_tag('filter.projectnumber:substr::ilike', filter.projectnumber_substr__ilike, size=60) %]</td>
- </tr>
-
- <tr>
- <th align="right">[% 'Description' | $T8 %]</th>
- <td>[% L.input_tag('filter.description:substr::ilike', filter.description_substr__ilike, size=60, class='initial_focus') %]</td>
- </tr>
-
- <tr>
- <th align="right">[% 'Customer' | $T8 %]</th>
- <td>[% L.input_tag('filter.customer.name:substr::ilike', filter.customer.name_substr__ilike, size=60) %]</td>
- </tr>
-
- <tr>
- <th align="right">[% 'Project Type' | $T8 %]</th>
- <td>[% L.select_tag('filter.project_type_id', SELF.ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %]</td>
- </tr>
-
- <tr>
- <th align="right">[% 'Project Status' | $T8 %]</th>
- <td>[% L.select_tag('filter.project_status_id', SELF.ALL_PROJECT_STATUS, default=filter.project_status_id, title_key='description', with_empty=1) %]</td>
- </tr>
-
- [% CUSTOM_VARIABLES_FILTER_CODE %]
-
- <tr>
- <th>[% 'Include in Report' | $T8 %]</th>
- <td>
- <table>
- <tr>
- <td>[% L.select_tag('filter.active', [ [ 'active', LxERP.t8('Active') ], [ 'inactive', LxERP.t8('Inactive') ], [ 'both', LxERP.t8('Both') ] ], default=filter.active, style="width: 200px") %]</td>
- </tr>
-
- <tr>
- <td>[% L.select_tag('filter.valid', [ [ 'valid', LxERP.t8('Valid') ], [ 'invalid', LxERP.t8('Invalid') ], [ 'both', LxERP.t8('Both') ] ], default=filter.valid, style="width: 200px") %]</td>
- </tr>
-
- <tr>
- <td>[% L.select_tag('filter.status', [ [ 'all', LxERP.t8('All') ], [ 'orphaned', LxERP.t8('Orphaned') ] ], default=filter.status, style="width: 200px") %]</td>
- </tr>
-
- [% CUSTOM_VARIABLES_INCLUSION_CODE %]
-
- </table>
- </td>
- </tr>
- </table>
+[%- INCLUDE 'project/_filter.html' %]
</p>
<hr size="3" noshade>