Projektsuche auf simpel+filter umgestellt
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 7 May 2013 09:51:32 +0000 (11:51 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:03:21 +0000 (13:03 +0200)
SL/Controller/Project.pm
menus/erp.ini
templates/webpages/project/_filter.html [new file with mode: 0644]
templates/webpages/project/report_top.html [new file with mode: 0644]

index c14f62e..9b34a5a 100644 (file)
@@ -30,8 +30,8 @@ use Rose::Object::MakeMethods::Generic
 
 __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) ]);
-__PACKAGE__->run_before('load_project_status', only => [ qw(search edit new) ]);
+__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
@@ -54,7 +54,7 @@ sub action_search {
 sub action_list {
   my ($self) = @_;
 
-  $self->make_filter_summary;
+  $self->make_filter_summary;
 
   my $projects = $self->models->get;
 
@@ -228,7 +228,8 @@ sub prepare_report {
     std_column_visibility => 1,
     controller_class      => 'Project',
     output_format         => 'HTML',
-    top_info_text         => $::locale->text('Projects'),
+    raw_top_info_text     => $self->render('project/report_top', { output => 0 }),
+    raw_bottom_info_text  => $self->render('project/report_bottom', { output => 0 }),
     title                 => $::locale->text('Projects'),
     allow_pdf_export      => 1,
     allow_csv_export      => 1,
@@ -262,6 +263,38 @@ sub init_models {
   );
 }
 
+sub make_filter_summary {
+  my ($self) = @_;
+
+  my $filter = $::form->{filter} || {};
+  my @filter_strings;
+
+  my @filters = (
+    [ $filter->{"projectnumber:substr::ilike"},  t8('Project Number') ],
+    [ $filter->{"description:substr::ilike"},    t8('Description')    ],
+    [ $filter->{customer}{"name:substr::ilike"}, t8('Customer')       ],
+    [ $filter->{"project_type_id"},              t8('Project Type'),    sub { SL::DB::Manager::ProjectType->find_by(id => $filter->{"project_type_id"})->description }   ],
+    [ $filter->{"project_status_id"},            t8('Project Status'),  sub { SL::DB::Manager::ProjectStatus->find_by(id => $filter->{"project_status_id"})->description } ],
+  );
+
+  my @flags = (
+    [ $filter->{active} eq 'active',    $::locale->text('Active')      ],
+    [ $filter->{active} eq 'inactive',  $::locale->text('Inactive')    ],
+    [ $filter->{valid}  eq 'valid',     $::locale->text('Valid')       ],
+    [ $filter->{valid}  eq 'invalid',   $::locale->text('Invalid')     ],
+    [ $filter->{orphaned},              $::locale->text('Orphaned')    ],
+  );
+
+  for (@flags) {
+    push @filter_strings, "$_->[1]" if $_->[0];
+  }
+  for (@filters) {
+    push @filter_strings, "$_->[1]: " . ($_->[2] ? $_->[2]->() : $_->[0]) if $_->[0];
+  }
+
+  $self->{filter_summary} = join ', ', @filter_strings;
+}
+
 sub load_project_types {
   $_[0]{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted;
 }
index 5f73f1a..a03f150 100644 (file)
@@ -85,7 +85,9 @@ searchitems=assembly
 [Master Data--Reports--Projects]
 ACCESS=project_edit
 module=controller.pl
-action=Project/search
+action=Project/list
+filter.active=active
+filter.valid=valid
 
 [AR]
 
diff --git a/templates/webpages/project/_filter.html b/templates/webpages/project/_filter.html
new file mode 100644 (file)
index 0000000..27fb84b
--- /dev/null
@@ -0,0 +1,55 @@
+[%- USE T8 %]
+[%- USE HTML %]
+[%- USE L %]
+[%- USE LxERP %]
+
+<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) %]</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>
diff --git a/templates/webpages/project/report_top.html b/templates/webpages/project/report_top.html
new file mode 100644 (file)
index 0000000..df03f9e
--- /dev/null
@@ -0,0 +1,26 @@
+[%- USE L %]
+[%- USE T8 %]
+[%- USE LxERP %]
+[%- USE HTML %]
+<form action='controller.pl' method='post'>
+<div class='filter_toggle'>
+<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
+  [% SELF.filter_summary | html %]
+</div>
+<div class='filter_toggle' style='display:none'>
+<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Hide Filter' | $T8 %]</a>
+[%- PROCESS 'project/_filter.html' filter=SELF.filter %]
+
+[% L.hidden_tag('action', 'Project/dispatch') %]
+[% L.hidden_tag('sort_by', FORM.sort_by) %]
+[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
+[% L.hidden_tag('page', FORM.page) %]
+[% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%]
+
+
+<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>
+
+</div>
+
+</form>
+ <hr>