diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 40 | ||||
-rw-r--r-- | templates/web/default/dashboard/index.html | 31 |
2 files changed, 56 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 6c327d479..0273e0eda 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -46,31 +46,57 @@ sub index : Path : Args(0) { my $council = $c->forward('check_page_allowed'); + # Set up the data for the dropdowns + my $children = mySociety::MaPit::call('area/children', $council, type => $mySociety::VotingArea::council_child_types, ); $c->stash->{children} = $children; + # XXX Hmm, this is probably the best way to go + $c->stash->{all_councils} = { $council => { id => $council } }; + $c->forward( '/report/new/setup_categories_and_councils' ); + + # See if we've had anything from the dropdowns + + $c->stash->{ward} = $c->req->param('ward'); + $c->stash->{category} = $c->req->param('category'); + $c->stash->{q_state} = $c->req->param('state'); + + my %where = ( + council => $council, # XXX This will break in a two tier council. Restriction needs looking at... + 'problem.state' => [ FixMyStreet::DB::Result::Problem->visible_states() ], + ); + $where{areas} = { 'like', '%,' . $c->stash->{ward} . ',%' } + if $c->stash->{ward}; + $where{category} = $c->stash->{category} + if $c->stash->{category}; + if ( $c->stash->{q_state} eq 'fixed' ) { + $where{'problem.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ]; + } elsif ( $c->stash->{q_state} ) { + $where{'problem.state'} = $c->stash->{q_state} + } + my %counts; my $t = DateTime->today; $counts{wtd} = $c->forward( 'updates_search', [ { - council => $council, + %where, 'me.confirmed' => { '>=', $t->subtract( days => $t->dow - 1 ) } } ] ); $counts{week} = $c->forward( 'updates_search', [ { - council => $council, + %where, 'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 1 ) } } ] ); $counts{weeks} = $c->forward( 'updates_search', [ { - council => $council, + %where, 'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 4 ) } } ] ); $counts{ytd} = $c->forward( 'updates_search', [ { - council => $council, + %where, 'me.confirmed' => { '>=', DateTime->today->set( day => 1, month => 1 ) } } ] ); @@ -102,9 +128,9 @@ sub updates_search : Private { { %$params, mark_fixed => 1 }, { join => 'problem' } )->count; - $counts{total} = $c->cobrand->problems->search( - { %$params, state => [ FixMyStreet::DB::Result::Problem::visible_states() ] } - )->count; + $params->{state} = $params->{'problem.state'}; + delete $params->{'problem.state'}; + $counts{total} = $c->cobrand->problems->search( $params )->count; return \%counts; } diff --git a/templates/web/default/dashboard/index.html b/templates/web/default/dashboard/index.html index c54635b2a..a0ef7b911 100644 --- a/templates/web/default/dashboard/index.html +++ b/templates/web/default/dashboard/index.html @@ -11,19 +11,23 @@ #overview tr:nth-child(2) { background-color: #fee; } </style> -<p>Ward: <select name="ward"><option>All</option> - [% FOR ward IN children.values.sort('name') %] - <option value="[% ward.id %]">[% ward.name %]</option> +<form> + +<p>Ward: <select name="ward"><option value=''>All</option> + [% FOR w IN children.values.sort('name') %] + <option value="[% w.id %]"[% ' selected' IF w.id == ward %]>[% w.name %]</option> [% END %] </select> +<input type="submit" value="Look up"> <h2>Performance Overview</h2> -<p>Report category: <select name="category"><option>All</option> - [% FOR category IN categories %] - <option></option> +<p>Report category: <select name="category"><option value=''>All</option> + [% FOR cat_op IN category_options %] + <option value='[% cat_op | html %]'[% ' selected' IF category == cat_op %]>[% cat_op | html %]</option> [% END %] -</select> + </select> +<input type="submit" value="Look up"> <table width="100%" id="overview"> <tr> @@ -111,7 +115,16 @@ <h2>Reports</h2> -<p>Report state: <select name="state"><option>All</option></select> + </select> +<p>Report state: <select name="state"> +<option value=''>All</option> + [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', + loc('Investigating')], ['planned', loc('Planned')], ['in progress', + loc('In Progress')], ['closed', loc('Closed')], ['fixed', loc('Fixed')] ] %] + <option [% 'selected ' IF state.0 == q_state %] value="[% state.0 %]">[% state.1 %]</option> + [% END %] +</select> +<input type="submit" value="Look up"> <table width="100%"> <tr> @@ -128,4 +141,6 @@ </tr> </table> +</form> + [% INCLUDE 'footer.html' %] |