diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 15 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 63 |
2 files changed, 78 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index de69880c1..7869b21b7 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -606,6 +606,21 @@ sub report_edit : Path('report_edit') : Args(1) { } if ( $c->cobrand->moniker eq 'zurich' ) { + + FixMyStreet::Map::display_map( + $c, + latitude => $problem->latitude, + longitude => $problem->longitude, + pins => $problem->used_map + ? [ { + latitude => $problem->latitude, + longitude => $problem->longitude, + colour => 'yellow', + type => 'big', + } ] + : [], + ); + my $done = $c->cobrand->admin_report_edit(); return if $done; } diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 81ace5a05..6ac04ce1e 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,68 @@ 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 is_public_holiday { + my $dt = shift; + return $public_holidays{$dt->ymd}; +} + +sub is_weekend { + my $dt = shift; + return $dt->dow > 5; +} + +sub add_days { + my ( $dt, $days ) = @_; + $dt = $dt->clone; + while ( $days > 0 ) { + $dt->add ( days => 1 ); + next if is_public_holiday($dt) or is_weekend($dt); + $days--; + } + return $dt; +} + +sub sub_days { + my ( $dt, $days ) = @_; + $dt = $dt->clone; + while ( $days > 0 ) { + $dt->subtract ( days => 1 ); + next if is_public_holiday($dt) or is_weekend($dt); + $days--; + } + return $dt; +} + +sub overdue { + my ( $self, $problem ) = @_; + + my $w = $problem->whensent; + return 0 unless $w; + + 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 { |