diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-02 20:48:48 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-06 17:24:12 +0000 |
commit | c851d416f8774166fc709c49e0a2ad01e55e827b (patch) | |
tree | f289232a3fd579a746407ed71adc6d781858121f | |
parent | 1bda0aabdeb0120ae86d48870bc908bfd12d68bc (diff) |
[Zurich] Admin stats/CSV per category.
Adapt look of default dashboard filtering.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 25 | ||||
-rw-r--r-- | templates/web/zurich/admin/stats/index.html | 38 | ||||
-rw-r--r-- | web/cobrands/zurich/layout.scss | 8 |
3 files changed, 49 insertions, 22 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 4fd2def30..457bc1e75 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1114,28 +1114,35 @@ sub admin_stats { my $self = shift; my $c = $self->{c}; - my %date_params; + my %optional_params; my $ym = $c->get_param('ym'); my ($m, $y) = $ym ? ($ym =~ /^(\d+)\.(\d+)$/) : (); $c->stash->{ym} = $ym; if ($y && $m) { $c->stash->{start_date} = DateTime->new( year => $y, month => $m, day => 1 ); $c->stash->{end_date} = $c->stash->{start_date} + DateTime::Duration->new( months => 1 ); - $date_params{created} = { + $optional_params{created} = { '>=', DateTime::Format::Pg->format_datetime($c->stash->{start_date}), '<', DateTime::Format::Pg->format_datetime($c->stash->{end_date}), }; } + my $cat = $c->stash->{category} = $c->get_param('category'); + $optional_params{category} = $cat if $cat; + my %params = ( - %date_params, + %optional_params, state => [ FixMyStreet::DB::Result::Problem->visible_states() ], ); if ( $c->get_param('export') ) { - return $self->export_as_csv($c, \%date_params); + return $self->export_as_csv($c, \%optional_params); } + # Can change category to any other + my @categories = $c->model('DB::Contact')->not_deleted->all; + $c->stash->{category_options} = [ map { { name => $_->category, value => $_->category } } @categories ]; + # Total reports (non-hidden) my $total = $c->model('DB::Problem')->search( \%params )->count; # Device for apps (iOS/Android) @@ -1145,17 +1152,17 @@ sub admin_stats { group_by => [ 'service' ], }); # Reports solved - my $solved = $c->model('DB::Problem')->search( { state => 'fixed - council', %date_params } )->count; + my $solved = $c->model('DB::Problem')->search( { state => 'fixed - council', %optional_params } )->count; # Reports marked as spam - my $hidden = $c->model('DB::Problem')->search( { state => 'hidden', %date_params } )->count; + my $hidden = $c->model('DB::Problem')->search( { state => 'hidden', %optional_params } )->count; # Reports assigned to third party - my $closed = $c->model('DB::Problem')->search( { state => 'closed', %date_params } )->count; + my $closed = $c->model('DB::Problem')->search( { state => 'closed', %optional_params } )->count; # Reports moderated within 1 day - my $moderated = $c->model('DB::Problem')->search( { extra => { like => '%moderated_overdue,I1:0%' }, %date_params } )->count; + my $moderated = $c->model('DB::Problem')->search( { extra => { like => '%moderated_overdue,I1:0%' }, %optional_params } )->count; # Reports solved within 5 days (sent back from subdiv) my $subdiv_dealtwith = $c->model('DB::Problem')->search( { extra => { like => '%subdiv_overdue,I1:0%' }, %params } )->count; # Reports solved within 5 days (marked as 'fixed - council', 'closed', or 'hidden' - my $fixed_in_time = $c->model('DB::Problem')->search( { extra => { like => '%closed_overdue,I1:0%' }, %date_params } )->count; + my $fixed_in_time = $c->model('DB::Problem')->search( { extra => { like => '%closed_overdue,I1:0%' }, %optional_params } )->count; # Reports per category my $per_category = $c->model('DB::Problem')->search( \%params, { select => [ 'category', { count => 'id' } ], diff --git a/templates/web/zurich/admin/stats/index.html b/templates/web/zurich/admin/stats/index.html index ce8e238f7..9fa145188 100644 --- a/templates/web/zurich/admin/stats/index.html +++ b/templates/web/zurich/admin/stats/index.html @@ -2,14 +2,12 @@ [% PROCESS 'admin/report_blocks.html' %] [% USE date %] -<p style="float:right"><a href="[% c.uri_with( { export=1 } ) %]">[% loc('All Reports as CSV') %]</a></p> +<form method="get" action="[% c.uri_for('/admin/stats') %]"> +<div class="filters"> -[% IF start_date AND end_date %] -<p><strong>[% tprintf( loc( 'All reports between %s and %s' ), start_date.ymd, end_date.ymd ) | html %]</strong></p> -[% END %] - -<form method="get" action="[% c.uri_for('stats') %]"> -<p><select class="form-control" name="ym"> +<p> + <label for="ym">[% loc('Month') %]</label> + <select class="form-control" name="ym" id="ym"> <option value="">[% loc('All reports') %]</option> [% FOR y IN [ 2013 .. date.format(date.now, '%Y') ]; SET max = 12; @@ -21,11 +19,33 @@ <option[% ' selected' IF v == ym %]>[% v %]</option> [% END %] [% END %] -</select> + </select> +</p> + +<p> + <label for="category">[% loc('Category') %]</label> + <select class="form-control" name="category" id="category"> + <option value="">--</option> + [% FOREACH cat IN category_options %] + <option value="[% cat.name %]"[% ' selected' IF cat.name == category %]>[% cat.value %]</option> + [% END %] + </select> +</p> + +<p class="no-label"> + <input type="submit" class="btn" value="[% loc('Go') %]"> +</p> -<input type="submit" class="btn" value="[% loc('Go') %]"> +</div> </form> +<ul class="dashboard-options-tabs"> + [% IF start_date AND end_date %] + <li><strong>[% tprintf( loc( 'All reports between %s and %s' ), start_date.ymd, end_date.ymd ) | html %]</strong></li> + [% END %] + <li class="pull-right"><a href="[% c.uri_with( { export=1 } ) %]">[% loc('All Reports as CSV') %]</a></li> +</ul> + <ul> <li>[% loc('Total') %]: [% reports_total || 0 %] <li>[% loc('Closed') %]: [% reports_solved || 0 %] diff --git a/web/cobrands/zurich/layout.scss b/web/cobrands/zurich/layout.scss index d49f400e6..31469926f 100644 --- a/web/cobrands/zurich/layout.scss +++ b/web/cobrands/zurich/layout.scss @@ -283,6 +283,10 @@ body.mappage.admin { } } +.admin-report-edit--interact { + margin-top: -1.25em; // To counteract the label's default top margin +} + .admin { .content { margin: 2em 0 1em; @@ -300,10 +304,6 @@ body.mappage.admin { font-weight: bold; padding-right: 0.333em; } - :first-child > label { - // avoid empty space above first label in a container - margin-top: 0; - } textarea { min-height: 0; } |