diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 37 | ||||
-rw-r--r-- | templates/web/default/admin/search_reports.html | 61 |
2 files changed, 66 insertions, 32 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 11194fbcf..568d23cf5 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -360,6 +360,8 @@ sub search_reports : Path('search_reports') { if (my $search = $c->req->param('search')) { $c->stash->{searched} = 1; + my ( $site_res_sql, $site_key, $site_restriction ) = $c->cobrand->site_restriction; + my $search_n = 0; $search_n = int($search) if $search =~ /^\d+$/; @@ -382,7 +384,7 @@ sub search_reports : Path('search_reports') { detail => { ilike => $like_search }, council => { like => $like_search }, cobrand_data => { like => $like_search }, - # site restriction + %{ $site_restriction }, ] }, { @@ -393,18 +395,34 @@ sub search_reports : Path('search_reports') { $c->stash->{problems} = [ $problems->all ]; - # Switch quoting back off. See above for explanation of this. - $c->model('DB')->schema->storage->sql_maker->quote_char( '' ); $c->stash->{edit_council_contacts} = 1 if ( grep {$_ eq 'councilcontacts'} keys %{$c->stash->{allowed_pages}}); - } -# print $q->h2(_('Updates')); -# my $updates = Problems::update_search($search); -# admin_show_updates($q, $updates); -# } + my $updates = $c->model('DB::Comment')->search( + { + -or => [ + 'me.id' => $search_n, + 'problem.id' => $search_n, + 'user.email' => { ilike => $like_search }, + 'me.name' => { ilike => $like_search }, + text => { ilike => $like_search }, + 'me.cobrand_data' => { ilike => $like_search }, + %{ $site_restriction }, + ] + }, + { + -select => [ 'me.*', qw/problem.council problem.state/ ], + prefetch => [qw/user problem/], + order_by => [\"(me.state='hidden')",\"(problem.state='hidden')",'me.created'] + } + ); + + $c->stash->{updates} = [ $updates->all ]; + # Switch quoting back off. See above for explanation of this. + $c->model('DB')->schema->storage->sql_maker->quote_char( '' ); + } } sub set_allowed_pages : Private { @@ -527,9 +545,6 @@ sub check_token : Private { # # # -# sub admin_reports { -# } -# # sub admin_edit_report { # my ($q, $id) = @_; # my $row = Problems::admin_fetch_problem($id); diff --git a/templates/web/default/admin/search_reports.html b/templates/web/default/admin/search_reports.html index 56e9e41d8..e2769e5ca 100644 --- a/templates/web/default/admin/search_reports.html +++ b/templates/web/default/admin/search_reports.html @@ -16,18 +16,18 @@ [% IF searched %] <table cellspacing="0" cellpadding="2" border="1"> <tr> - <th>ID</th> - <th>Title</th> - <th>Name</th> - <th>Email</th> - <th>Council</th> - <th>Category</th> - <th>Anonymous</th> - <th>Cobrand</th> - <th>Created</th> - <th>State</th> - <th>When sent</th> - <th>*</th> + <th>[% loc('ID') %]</th> + <th>[% loc('Title') %]</th> + <th>[% loc('Name') %]</th> + <th>[% loc('Email') %]</th> + <th>[% loc('Council') %]</th> + <th>[% loc('Category') %]</th> + <th>[% loc('Anonymous') %]</th> + <th>[% loc('Cobrand') %]</th> + <th>[% loc('Created') %]</th> + <th>[% loc('State') %]</th> + <th>[% loc('When sent') %]</th> + <th>[% loc('*') %]</th> </tr> [%- FOREACH problem IN problems %] <tr[% ' class="hidden"' IF problem.state == 'hidden' %]> @@ -65,16 +65,35 @@ <table cellspacing="0" cellpadding="2" border="1"> <tr> - <th>ID</th> - <th>State</th> - <th>Name</th> - <th>Email</th> - <th>Created</th> - <th>Cobrand</th> - <th>Text</th> - <th>*</th> + <th>[% loc('ID') %]</th> + <th>[% loc('State') %]</th> + <th>[% loc('Name') %]</th> + <th>[% loc('Email') %]</th> + <th>[% loc('Created') %]</th> + <th>[% loc('Anonymous') %]</th> + <th>[% loc('Cobrand') %]</th> + <th>[% loc('Text') %]</th> + <th>[% loc('*') %]</th> </tr> -<tr> +[% FOREACH update IN updates -%] + <tr[% ' class="hidden"' IF update.state == 'hidden' || ( problem.state && problem.state == 'hidden' ) %]> + <td>[%- IF update.state == 'confirmed' -%] + [%- cobrand_data = update.cobrand_data %] + [%- cobrand_data = c.data_for_generic_update IF !update.cobrand %] + <a href="[% c.uri_for_email( '/report', update.problem.id, cobrand_data ) %]#update_[% update.id %]">[% update.id %]</a> + [%- ELSE %] + [%- update.id %] + [%- END -%]</td> + <td>[% update.state %]</td> + <td>[% update.name | html %]</td> + <td>[% update.user.email | html %]</td> + <td>[% PROCESS format_time time=update.created %]</td> + <td>[% IF update.anonymous %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> + <td>[% update.cobrand %]<br>[% update.cobrand_data | html %]</td> + <td>[% update.text | html %]</td> + <td><a href="[% c.uri_for( 'update_edit', update.id ) %]">Edit</a></td> + <tr> +[% END -%] </table> [% END %] |