diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/SeeSomething.pm | 40 | ||||
-rw-r--r-- | templates/web/seesomething/admin/stats.html | 43 |
3 files changed, 87 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 4999d16f2..1bb9c8e4c 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -925,6 +925,10 @@ sub stats : Path('stats') : Args(0) { $c->forward('check_page_allowed'); + if ( $c->cobrand->moniker eq 'seesomething' ) { + return $c->cobrand->admin_stats( $c ); + } + $c->forward('set_up_council_details'); if ( $c->req->param('getcounts') ) { diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm index 629a5ee50..ca7657176 100644 --- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm +++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm @@ -80,5 +80,45 @@ sub allow_anonymous_reports { 1; } sub anonymous_account { return { name => 'anon user', email => 'anon@example.com' }; } +sub admin_pages { + my $self = shift; + + return { + 'stats' => ['Reports', 0], + }; +}; + +sub admin_stats { + my ( $self, $c ) = @_; + + my %filters = (); + + if ( !$c->user_exists || !grep { $_ == $c->user->from_council } @{ $self->council_id } ) { + $c->detach( '/page_error_404_not_found' ); + } + + if ( $c->req->param('category') ) { + $filters{category} = $c->req->param('category'); + } + + if ( $c->req->param('subcategory') ) { + $filters{subcategory} = $c->req->param('subcategory'); + } + + my $p = $c->model('DB::Problem')->search( + { + confirmed => { not => undef }, + %filters + }, + { + order_by => { -desc=> [ 'confirmed' ] } + } + ); + + $c->stash->{reports} = $p; + + return 1; +} + 1; diff --git a/templates/web/seesomething/admin/stats.html b/templates/web/seesomething/admin/stats.html new file mode 100644 index 000000000..2ddb3e665 --- /dev/null +++ b/templates/web/seesomething/admin/stats.html @@ -0,0 +1,43 @@ +[% INCLUDE 'admin/header.html' title=loc('Reports') %] +[% PROCESS 'admin/report_blocks.html' %] + +<form method="post" action="[% c.uri_for('reports') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <select name="category"> + <option value="">Select</option> + <option value="Bus">Bus</option> + <option value="Metro">Metro</option> + <option value="Train">Train</option> + </select> + + <select name="subcategory"> + <option value="">Select</option> + <option value="Smoking">Smoking</option> + </select> + + <input type="submit" name="getcounts" size="30" id="getcounts" value="Look Up" /> +</form> + +<table> + <thead> + <tr> + <th>ID</th> + <th>Description</th> + <th>Transport Category</th> + <th>Incident Category</th> + <th>Submitted</th> + </tr> + </thead> + <tbody> + [%- WHILE (report = reports.next) %] + <tr> + <td>[% report.id %]</td> + <td>[% report.detail %]</td> + <td>[% report.category %]</td> + <td>[% report.subcategory %]</td> + <td>[% PROCESS format_time time=report.confirmed %]</td> + </tr> + [%- END %] + </tbody> +</table> + +[% INCLUDE 'admin/footer.html' %] |