diff options
author | Matthew Somerville <matthew@mysociety.org> | 2013-01-22 10:33:59 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2013-01-22 10:33:59 +0000 |
commit | 4fc0fbc8287e35d79ea65362fc3bbff3e286cc57 (patch) | |
tree | 8e9ed25efe22067f70a16b27c0ad27a1f7738961 | |
parent | 19880b97cc60663494b700c3c6829111e5e17055 (diff) |
Highlight overdue Zurich reports in admin interface.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 41 | ||||
-rw-r--r-- | templates/web/zurich/admin/header.html | 9 | ||||
-rw-r--r-- | templates/web/zurich/admin/problem_row.html | 5 |
3 files changed, 49 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 81ace5a05..6c0c491ca 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1,6 +1,7 @@ package FixMyStreet::Cobrand::Zurich; use base 'FixMyStreet::Cobrand::Default'; +use DateTime; use POSIX qw(strcoll); use strict; @@ -43,6 +44,46 @@ sub get_body_sender { return { method => 'Zurich' }; } +# Report overdue functions + +my %public_holidays = map { $_ => 1 } ( + '2013-01-01', '2013-01-02', '2013-03-29', '2013-04-01', + '2013-04-15', '2013-05-01', '2013-05-09', '2013-05-20', + '2013-08-01', '2013-09-09', '2013-12-25', '2013-12-26', + '2014-01-01', '2014-01-02', '2014-04-18', '2014-04-21', + '2014-04-28', '2014-05-01', '2014-05-29', '2014-06-09', + '2014-08-01', '2014-09-15', '2014-12-25', '2014-12-26', +); + +sub add_days { + my ( $dt, $days ) = @_; + $dt = $dt->clone; + while ( $days > 0 ) { + $dt->add ( days => 1 ); + next if $public_holidays{$dt->ymd}; + next if $dt->dow > 5; + $days--; + } + return $dt; +} + +sub overdue { + my ( $self, $problem ) = @_; + + my $w = $problem->whensent; + if ( $problem->state eq 'unconfirmed' || $problem->state eq 'confirmed' ) { + # One working day + $w = add_days( $w, 1 ); + return $w > DateTime->now(); + } elsif ( $problem->state eq 'in progress' ) { + # Five working days + $w = add_days( $w, 5 ); + return $w > DateTime->now(); + } else { + return 0; + } +} + # Specific administrative displays sub admin_pages { diff --git a/templates/web/zurich/admin/header.html b/templates/web/zurich/admin/header.html index ce252beb4..72472492a 100644 --- a/templates/web/zurich/admin/header.html +++ b/templates/web/zurich/admin/header.html @@ -13,11 +13,10 @@ } %] <style type="text/css"> -dt { clear: left; float: left; font-weight: bold; } -dd { margin-left: 8em; } -.adminhidden { color: #666666; } -.error { color: red; } -select { width: auto; } + .adminhidden { color: #666666; } + .error { color: red; } + .overdue { color: #660000; } + select { width: auto; } </style> <h1 style="clear:both;">[% title %]</h1> diff --git a/templates/web/zurich/admin/problem_row.html b/templates/web/zurich/admin/problem_row.html index 176f1a1a6..617490232 100644 --- a/templates/web/zurich/admin/problem_row.html +++ b/templates/web/zurich/admin/problem_row.html @@ -4,7 +4,10 @@ [% NEXT IF admin_type == 'sdm' AND p_body.id != body.id %] [% NEXT IF admin_type == 'dm' AND p_body.id != body.id AND p_body.parent.id != body.id %] [% END %] - <tr[% ' class="adminhidden"' IF problem.state == 'hidden' %]> + <tr[% + ' class="adminhidden"' IF problem.state == 'hidden'; + ' class="overdue"' IF c.cobrand.overdue( problem ); + %]> <td class="record-id">[%- IF problem.is_visible -%] <a href="[% c.uri_for_email( '/report', problem.id ) %]">[% problem.id %]</a> [%- ELSE %] |