diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 18 | ||||
-rw-r--r-- | templates/web/zurich/admin/stats.html | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 3d5d52b91..e53de03c3 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -89,7 +89,7 @@ sub updates_as_hashref { my $hashref = {}; if ( $problem->state eq 'fixed - council' || $problem->state eq 'closed' ) { - $hashref->{update_pp} = $self->prettify_dt( $problem->lastupdate_local ); + $hashref->{update_pp} = $self->prettify_dt( $problem->lastupdate ); if ( $problem->state eq 'fixed - council' ) { $hashref->{details} = FixMyStreet::App::View::Web->add_links( $ctx, $problem->extra->{public_response} ); @@ -579,9 +579,9 @@ sub admin_stats { my ($m, $y) = $ym =~ /^(\d+)\.(\d+)$/; $c->stash->{ym} = $ym; if ($y && $m) { - my $start_date = DateTime->new( year => $y, month => $m, day => 1 ); - my $end_date = $start_date + DateTime::Duration->new( months => 1 ); - $date_params{created} = { '>=', $start_date, '<', $end_date }; + $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} = { '>=', $c->stash->{start_date}, '<', $c->stash->{end_date} }; } my %params = ( @@ -589,6 +589,16 @@ sub admin_stats { state => [ FixMyStreet::DB::Result::Problem->visible_states() ], ); + if ( $c->req->params->{export} ) { + my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand' ] } ); + my $body = ''; + while (my $report = $problems->next) { + $body .= join( ',', $report->id, $report->created, $report->local_coords ) . "\n"; + } + $c->res->content_type('text/csv; charset=utf-8'); + $c->res->body($body); + } + # Device for apps (iOS/Android) my $per_service = $c->model('DB::Problem')->search( \%params, { select => [ 'service', { count => 'id' } ], diff --git a/templates/web/zurich/admin/stats.html b/templates/web/zurich/admin/stats.html index f03311a83..97a66cd11 100644 --- a/templates/web/zurich/admin/stats.html +++ b/templates/web/zurich/admin/stats.html @@ -2,6 +2,8 @@ [% PROCESS 'admin/report_blocks.html' %] [% USE date %] +<p style="float:right"><a href="[% c.uri_with( { export=1 } ) %]">[% loc('All Reports') %]</a></p> + [% 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 %] |