diff --git a/perllib/FixMyStreet/Cobrand/Kingston.pm b/perllib/FixMyStreet/Cobrand/Kingston.pm index 927e0be57cb..1d1c159c8ab 100644 --- a/perllib/FixMyStreet/Cobrand/Kingston.pm +++ b/perllib/FixMyStreet/Cobrand/Kingston.pm @@ -623,6 +623,41 @@ sub admin_fee_cost { return $cost; } +=head2 waste_munge_enquiry_data + +Get the right data in place for the bin not returned / waste spillage / escalation categories. + +=cut + +sub waste_munge_enquiry_data { + my ($self, $data) = @_; + my $c = $self->{c}; + + my $address = $c->stash->{property}->{address}; + + $data->{title} = _enquiry_nice_title($data->{category}); + + my $detail = ""; + if ($data->{category} eq 'Bin not returned') { + my $assisted = $c->stash->{assisted_collection}; + my $returned = $data->{now_returned} || ''; + if ($assisted && lc($returned) eq 'no') { + $data->{extra_Notes} = '*** Property is on assisted list ***'; + } + } elsif ($data->{category} eq 'Waste spillage') { + $detail = $data->{extra_Notes} . "\n\n"; + } + if ($data->{extra_details}) { + my $extra = ref $data->{extra_details} ne '' ? join(', ', @{$data->{extra_details}}) : $data->{extra_details}; + my $nl = $data->{extra_Notes} ? "\n" : ''; + $data->{extra_Notes} .= $nl . "Details: " . $extra; + } + $detail .= $self->service_name_override({ ServiceId => $data->{service_id} }) . "\n\n"; + $detail .= $address; + + $data->{detail} = $detail; +} + =head2 Bulky waste collection =over 4 diff --git a/perllib/FixMyStreet/Cobrand/Sutton.pm b/perllib/FixMyStreet/Cobrand/Sutton.pm index 38af5ff10bb..81970aad5b4 100644 --- a/perllib/FixMyStreet/Cobrand/Sutton.pm +++ b/perllib/FixMyStreet/Cobrand/Sutton.pm @@ -700,93 +700,6 @@ sub request_cost { } } -=head2 waste_munge_enquiry_form_pages - -The Bin not returned flow has some more complex setup depending on whether -the property has an assisted collection or not, with an extra question, -and showing/hiding different notices. - -=cut - -sub waste_munge_enquiry_form_pages { - my ($self, $pages, $fields) = @_; - my $c = $self->{c}; - my $category = $c->get_param('category'); - - # Add the service to the main fields form page - $pages->[1]{intro} = 'enquiry-intro.html'; - $pages->[1]{title} = _enquiry_nice_title($category); - - return unless $category eq 'Bin not returned';; - - my $assisted = $c->stash->{assisted_collection}; - if ($assisted) { - # Add extra first page with extra question - $c->stash->{first_page} = 'now_returned'; - unshift @$pages, now_returned => { - fields => [ 'now_returned', 'continue' ], - intro => 'enquiry-intro.html', - title => _enquiry_nice_title($category), - next => 'enquiry', - }; - push @$fields, now_returned => { - type => 'Select', - widget => 'RadioGroup', - required => 1, - label => 'Has the container now been returned to the property?', - options => [ - { label => 'Yes', value => 'Yes' }, - { label => 'No', value => 'No' }, - ], - }; - - # Remove any non-assisted extra notices - my @new; - for (my $i=0; $i<@$fields; $i+=2) { - if ($fields->[$i] !~ /^extra_NotAssisted/) { - push @new, $fields->[$i], $fields->[$i+1]; - } - } - @$fields = @new; - $pages->[3]{fields} = [ grep { !/^extra_NotAssisted/ } @{$pages->[3]{fields}} ]; - $pages->[3]{update_field_list} = sub { - my $form = shift; - my $c = $form->c; - my $data = $form->saved_data; - my $returned = $data->{now_returned} || ''; - my $key = $returned eq 'No' ? 'extra_AssistedReturned' : 'extra_AssistedNotReturned'; - return { - category => { default => $c->get_param('category') }, - service_id => { default => $c->get_param('service_id') }, - $key => { widget => 'Hidden' }, - } - }; - } else { - # Remove any assisted extra notices - my @new; - for (my $i=0; $i<@$fields; $i+=2) { - if ($fields->[$i] !~ /^extra_Assisted/) { - push @new, $fields->[$i], $fields->[$i+1]; - } - } - @$fields = @new; - $pages->[1]{fields} = [ grep { !/^extra_Assisted/ } @{$pages->[1]{fields}} ]; - } -} - -sub _enquiry_nice_title { - my $category = shift; - if ($category eq 'Bin not returned') { - $category = 'Wheelie bin, box or caddy not returned correctly after collection'; - } elsif ($category eq 'Waste spillage') { - $category = 'Spillage during collection'; - } elsif ($category eq 'Complaint against time') { - $category = 'Issue with collection'; - } elsif ($category eq 'Failure to Deliver Bags/Containers') { - $category = 'Issue with delivery'; - } - return $category; -} =head2 waste_munge_enquiry_data @@ -806,7 +719,7 @@ sub waste_munge_enquiry_data { if ($data->{category} eq 'Bin not returned') { my $assisted = $c->stash->{assisted_collection}; my $returned = $data->{now_returned} || ''; - if ($assisted && $returned eq 'No') { + if ($assisted && lc($returned) eq 'no') { $data->{extra_Notes} = '*** Property is on assisted list ***'; } } elsif ($data->{category} eq 'Waste spillage') { diff --git a/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm b/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm index 48b8f377d73..a5ed0b43931 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm @@ -169,6 +169,93 @@ sub waste_report_form_first_next { }; } +=head2 waste_munge_enquiry_form_pages + +the bin not returned flow has some more complex setup depending on whether +the property has an assisted collection or not, with an extra question, +and showing/hiding different notices. + +=cut + +sub waste_munge_enquiry_form_pages { + my ($self, $pages, $fields) = @_; + my $c = $self->{c}; + my $category = $c->get_param('category'); + + # add the service to the main fields form page + $pages->[1]{intro} = 'enquiry-intro.html'; + $pages->[1]{title} = _enquiry_nice_title($category); + + return unless $category eq 'Bin not returned';; + + my $assisted = $c->stash->{assisted_collection}; + if ($assisted) { + # add extra first page with extra question + $c->stash->{first_page} = 'now_returned'; + unshift @$pages, now_returned => { + fields => [ 'now_returned', 'continue' ], + intro => 'enquiry-intro.html', + title => _enquiry_nice_title($category), + next => 'enquiry', + }; + push @$fields, now_returned => { + type => 'Select', + widget => 'RadioGroup', + required => 1, + label => 'has the container now been returned to the property?', + options => [ + { label => 'Yes', value => 'yes' }, + { label => 'No', value => 'no' }, + ], + }; + + # remove any non-assisted extra notices + my @new; + for (my $i=0; $i<@$fields; $i+=2) { + if ($fields->[$i] !~ /^extra_notassisted/i) { + push @new, $fields->[$i], $fields->[$i+1]; + } + } + @$fields = @new; + $pages->[3]{fields} = [ grep { !/^extra_notassisted/i } @{$pages->[3]{fields}} ]; + $pages->[3]{update_field_list} = sub { + my $form = shift; + my $c = $form->c; + my $data = $form->saved_data; + my $returned = $data->{now_returned} || ''; + my $key = lc($returned) eq 'no' ? 'extra_AssistedReturned' : 'extra_AssistedNotReturned'; + return { + category => { default => $c->get_param('category') }, + service_id => { default => $c->get_param('service_id') }, + $key => { widget => 'Hidden' }, + } + }; + } else { + # remove any assisted extra notices + my @new; + for (my $i=0; $i<@$fields; $i+=2) { + if ($fields->[$i] !~ /^extra_assisted/i) { + push @new, $fields->[$i], $fields->[$i+1]; + } + } + @$fields = @new; + $pages->[1]{fields} = [ grep { !/^extra_assisted/i } @{$pages->[1]{fields}} ]; + } +} + +sub _enquiry_nice_title { + my $category = shift; + if ($category eq 'Bin not returned') { + $category = 'Wheelie bin, box or caddy not returned correctly after collection'; + } elsif ($category eq 'Waste spillage') { + $category = 'Spillage during collection'; + } elsif ($category eq 'Complaint against time') { + $category = 'Issue with collection'; + } elsif ($category eq 'Failure to Deliver Bags/Containers') { + $category = 'Issue with delivery'; + } + return $category; +} =head2 waste_cc_payment_line_item_ref diff --git a/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm b/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm index c0e6071c6a3..d3ddeb2a1cd 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm @@ -249,6 +249,7 @@ sub waste_extra_service_info { } $self->{c}->stash->{communal_property} = 1 if $service_id == $service_ids->{communal_refuse} || $service_id == $service_ids->{communal_food} || $service_id == $service_ids->{communal_paper} || $service_id == $service_ids->{communal_mixed}; + # detect flat above shop if ($service_id == $service_ids->{fas_refuse} || $service_id == $service_ids->{fas_mixed}) { $self->{c}->stash->{fas_property} = 1; } diff --git a/t/app/controller/waste_kingston_4499005.json b/t/app/controller/waste_kingston_4499005.json new file mode 100644 index 00000000000..804c43d9765 --- /dev/null +++ b/t/app/controller/waste_kingston_4499005.json @@ -0,0 +1,146 @@ +[ + { + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "Id": "1001", + "ServiceTasks": { + "ServiceTask": { + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Monday every week", + "LastInstance": { + "Ref": { "Value": { "anyType": [ "23293043", "8318" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }, + "CompletedDate": { "DateTime": "2022-10-10T06:00:00Z" } + }, + "NextInstance": { + "Ref": { "Value": { "anyType": [ "23293043", "8325" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" } + } + }, + "ScheduleDescription": "Every Monday", + "TaskTypeId": "2242", + "Id": "2001", + "Data": { + "ExtensibleDatum": [ + { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "6" }, + { "Value": "1", "DatatypeName": "Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + ] + }, + "TaskTypeName": "Collect Domestic Refuse Bag", + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "ServiceName": "Domestic Refuse Collection", + "ServiceUnitTypeId": "65", + "ServiceId": "967" + }, + { + "ServiceTasks": { + "ServiceTask": { + "ScheduleDescription": "Every Monday", + "TaskTypeId": "2246", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2020-06-08T23:00:00Z" }, + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "29313385", "8325" ] } } + }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "29313385", "8318" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" } + }, + "ScheduleDescription": "Monday every week" + } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "Id": "2002", + "TaskTypeName": "Collect Domestic Recycling Bag", + "Data": { + "ExtensibleDatum": [ + { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "18" }, + { "DatatypeName": "Quantity", "Value": "1" } + ] + }, + "DatatypeName": "Recycling Containers" + } + ] + } + } + }, + "Id": "1002", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "ServiceId": "971", + "ServiceName": "Domestic Recycling Collection" + }, + { + "Id": "1003", + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ServiceId": "975", + "ServiceName": "Domestic Recycling Collection", + "ServiceUnitTypeId": "65", + "ServiceTasks": { + "ServiceTask": { + "Data": { + "ExtensibleDatum": [ + { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "17" }, + { "Value": "1", "DatatypeName": "Quantity" } + ] + }, + "DatatypeName": "Recycling Containers" + } + ] + }, + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Wednesday, Saturday every week", + "LastInstance": { + "Ref": { "Value": { "anyType": [ "23293043", "8318" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" } + }, + "NextInstance": { + "Ref": { "Value": { "anyType": [ "23293043", "8325" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" } + } + }, + "ScheduleDescription": "Every Wednesday and Saturday", + "TaskTypeId": "2246", + "Id": "2001", + "TaskTypeName": "Collect Domestic Refuse Bag", + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + } + } +] diff --git a/t/app/controller/waste_kingston_r.t b/t/app/controller/waste_kingston_r.t index 09b5ae07a67..3d95ff76cd6 100644 --- a/t/app/controller/waste_kingston_r.t +++ b/t/app/controller/waste_kingston_r.t @@ -11,10 +11,11 @@ FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; +my $sample_file = path(__FILE__)->parent->child("sample.jpg"); my $bin_data = decode_json(path(__FILE__)->sibling('waste_kingston_4443082.json')->slurp_utf8); my $kerbside_bag_data = decode_json(path(__FILE__)->sibling('waste_kingston_4471550.json')->slurp_utf8); -my $above_shop_data = decode_json(path(__FILE__)->sibling('waste_4499005.json')->slurp_utf8); +my $above_shop_data = decode_json(path(__FILE__)->sibling('waste_kingston_4499005.json')->slurp_utf8); my $communal_multi_task_data = decode_json(path(__FILE__)->sibling('waste_kingston_2666182.json')->slurp_utf8); my $params = { @@ -54,6 +55,19 @@ create_contact({ category => 'Request new container', email => '3129' }, 'Waste' { code => 'payment', required => 0, automated => 'hidden_field' }, ); +create_contact({ category => 'Bin not returned', email => '3135' }, 'Waste', + { code => 'NotAssisted', description => 'Thank you for bringing this to our attention. We will use your feedback to improve performance in the future. Please accept our apologies for the inconvenience caused.', variable => 'false' }, + { code => 'AssistedReturned', description => 'Thank you for bringing this to our attention. We will not return to your address on this occasion but we will endeavour to train our collection crew so that containers are returned correctly in the future.', variable => 'false' }, + { code => 'AssistedNotReturned', description => 'Thank you for bringing this to our attention. We will return to your address as soon as we can to return the bin to its correct location. This may take up to 2 working days.', variable => 'false' }, + { code => 'Exact_Location', description => 'Exact location', required => 0, datatype => 'text' }, + { code => 'details', order => 0, values => [{key => 'Blocking pavement', name => 'Blocking pavement '}, {key => 'Blocking drive', name => 'Blocking drive'}], datatype => 'multivaluelist', required => 'false', variable => 'true', protected => 'false', description => 'If you think your box, bin or caddy was not returned to the place where you left it after being emptied, please let us know what is the issue (select all that apply):'}, + { code => 'Notes', required => 0, automated => 'hidden_field' }, +); +create_contact({ category => 'Waste spillage', email => '3227' }, 'Waste', + { code => 'Image', description => 'Image', required => 0, datatype => 'image' }, + { code => 'Notes', description => 'Details of the spillage', required => 0, datatype => 'text' }, +); + # Merton also covers Kingston because of an out-of-area park which is their responsibility my $merton = $mech->create_body_ok(2500, 'Merton Council'); FixMyStreet::DB->resultset('BodyArea')->create({ area_id => 2480, body_id => $merton->id }); @@ -513,6 +527,171 @@ FixMyStreet::override_config { $e->mock('GetTasks', sub { [] }); $e->mock('GetServiceUnitsForObject', sub { $bin_data }); }; + + subtest 'test report a problem - bin not returned, not assisted' => sub { + set_fixed_time('2022-09-10T12:00:00Z'); + FixMyStreet::Script::Reports::send(); + $mech->clear_emails_ok; + $mech->get_ok('/waste/12345'); + $mech->content_contains('Report a spillage or bin not returned issue with a non-recyclable refuse collection', 'Can report a problem with non-recyclable waste'); + $mech->content_contains('Report a spillage or bin not returned issue with a food waste collection', 'Can report a problem with food waste'); + my $root = HTML::TreeBuilder->new_from_content($mech->content()); + my $panel = $root->look_down(id => 'panel-974'); + is $panel->as_text =~ /.*Please note that missed collections can only be reported.*/, 1, "Paper and card past reporting deadline"; + $mech->content_lacks('Report a spillage or bin not returned issue with a paper and card collection', 'Can not report a problem with paper and card as past reporting deadline'); + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); + $mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); + $mech->content_contains('We will use your feedback'); + $mech->content_lacks('We will not return to your address on this occasion'); + $mech->content_lacks('We will return to your address as soon as we can to return the bin'); + + $mech->submit_form_ok( { with_fields => { extra_details => 'Blocking pavement', extra_Exact_Location => 'hello' } } ); + $mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => 'schmoe@example.org' } }); + $mech->submit_form_ok( { with_fields => { submit => '1' } }); + $mech->content_contains('Thank you for bringing this to our attention'); + $mech->content_contains('Return to property details'); + $mech->content_contains('/waste/12345"'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->get_extra_field_value('Notes'), 'Details: Blocking pavement', "Notes field contains issue"; + is $report->detail, "Non-recyclable Refuse\n\n2 Example Street, Kingston, KT1 1AA", "Details of report contain information about problem"; + is $report->user->email, 'schmoe@example.org', 'User details added to report'; + is $report->name, 'Joe Schmoe', 'User details added to report'; + is $report->category, 'Bin not returned', "Correct category"; + FixMyStreet::Script::Reports::send(); + my $text = $mech->get_text_body_from_email; + # like $text, qr/apologise for any inconvenience/, 'Other problem text included in email'; + my $req = Open311->test_req_used; + my $cgi = CGI::Simple->new($req->content); + is $cgi->param('api_key'), 'KEY'; + is $cgi->param('attribute[Exact_Location]'), 'hello'; + is $cgi->param('attribute[Notes]'), 'Details: Blocking pavement'; + }; + + subtest 'test report a problem - bin not returned, assisted' => sub { + my $dupe = dclone($bin_data); + # Give the entry an assisted collection + $dupe->[0]{Data}{ExtensibleDatum}{DatatypeName} = 'Assisted Collection'; + $dupe->[0]{Data}{ExtensibleDatum}{Value} = 1; + $e->mock('GetServiceUnitsForObject', sub { $dupe }); + $mech->get_ok('/waste/12345'); + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); + $mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); + $mech->submit_form_ok( { with_fields => { now_returned => 'yes' } } ); + $mech->content_contains('We will not return to your address on this occasion'); + $mech->content_lacks('We will return to your address as soon as we can to return the bin'); + $mech->content_lacks('We will use your feedback'); + + $mech->submit_form_ok( { with_fields => { extra_details => 'Blocking drive', extra_Exact_Location => 'hello' } } ); + $mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => 'schmoe@example.org' } }); + $mech->submit_form_ok( { with_fields => { submit => '1' } }); + $mech->content_contains('Thank you for bringing this to our attention'); + $mech->content_contains('Return to property details'); + $mech->content_contains('/waste/12345"'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->get_extra_field_value('Notes'), 'Details: Blocking drive', "extra details in notes field"; + is $report->detail, "Non-recyclable Refuse\n\n2 Example Street, Kingston, KT1 1AA", "Details of report contain information about problem"; + FixMyStreet::Script::Reports::send(); + my $text = $mech->get_text_body_from_email; + like $text, qr/apologise for any inconvenience/, 'Other problem text included in email'; + my $req = Open311->test_req_used; + my $cgi = CGI::Simple->new($req->content); + is $cgi->param('attribute[Exact_Location]'), 'hello'; + is $cgi->param('attribute[Notes]'), 'Details: Blocking drive'; + $e->mock('GetServiceUnitsForObject', sub { $bin_data }); + }; + + subtest 'test report a problem - bin not returned, assisted, not returned' => sub { + my $dupe = dclone($bin_data); + # Give the entry an assisted collection + $dupe->[0]{Data}{ExtensibleDatum}{DatatypeName} = 'Assisted Collection'; + $dupe->[0]{Data}{ExtensibleDatum}{Value} = 1; + $e->mock('GetServiceUnitsForObject', sub { $dupe }); + $mech->get_ok('/waste/12345'); + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); + $mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); + $mech->submit_form_ok( { with_fields => { now_returned => 'no' } } ); + $mech->content_contains('We will return to your address as soon as we can to return the bin'); + $mech->content_lacks('We will not return to your address on this occasion'); + $mech->content_lacks('We will use your feedback'); + + $mech->submit_form_ok( { with_fields => { extra_details => 'Blocking drive', extra_Exact_Location => 'hello' } } ); + $mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => 'schmoe@example.org' } }); + $mech->submit_form_ok( { with_fields => { submit => '1' } }); + $mech->content_contains('Thank you for bringing this to our attention'); + $mech->content_contains('Return to property details'); + $mech->content_contains('/waste/12345"'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->get_extra_field_value('Notes'), "*** Property is on assisted list ***\nDetails: Blocking drive"; + is $report->detail, "Non-recyclable Refuse\n\n2 Example Street, Kingston, KT1 1AA", "Details of report contain information about problem"; + FixMyStreet::Script::Reports::send(); + my $text = $mech->get_text_body_from_email; + like $text, qr/apologise for any inconvenience/, 'Other problem text included in email'; + my $req = Open311->test_req_used; + my $cgi = CGI::Simple->new($req->content); + is $cgi->param('attribute[Exact_Location]'), 'hello'; + is $cgi->param('attribute[Notes]'), "*** Property is on assisted list ***\r\nDetails: Blocking drive"; + $e->mock('GetServiceUnitsForObject', sub { $bin_data }); + }; + + subtest 'test report a problem - waste spillage' => sub { + $mech->get_ok('/waste/12345'); + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); + $mech->content_lacks("the spillage is on a public highway"); + $mech->submit_form_ok( { with_fields => { category => 'Waste spillage' } }); + $mech->submit_form_ok( { with_fields => { + extra_Notes => 'Rubbish left on driveway', + location_photo => [ $sample_file, undef, Content_Type => 'image/jpeg' ], + } }); + $mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => 'schmoe@example.org' } }); + $mech->submit_form_ok( { with_fields => { submit => '1' } }); + $mech->content_contains('Your enquiry has been submitted'); + $mech->content_contains('We will use your information to improve our service'); + $mech->content_contains('Return to property details'); + $mech->content_contains('/waste/12345"'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->category, 'Waste spillage', "Correct category"; + is $report->get_extra_field_value('Notes'), 'Rubbish left on driveway', "Notes filled in"; + is $report->detail, "Rubbish left on driveway\n\nNon-recyclable Refuse\n\n2 Example Street, Kingston, KT1 1AA", "Details of report contain information about problem"; + is $report->user->email, 'schmoe@example.org', 'User details added to report'; + is $report->name, 'Joe Schmoe', 'User details added to report'; + is $report->photo, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg'; + $mech->clear_emails_ok; + FixMyStreet::Script::Reports::send(); + my $text = $mech->get_text_body_from_email; + like $text, qr/apologise for any inconvenienc/, 'Other problem text included in email'; + my $req = Open311->test_req_used; + foreach ($req->parts) { + my $cd = $_->header('Content-Disposition'); + is $_->content, 'KEY', 'API key present' if $cd =~ /api_key/; + is $_->content, 'Rubbish left on driveway', 'Notes added' if $cd =~ /attribute\[Notes\]/; + is $_->header('Content-Type'), 'image/jpeg', 'Right content type' if $cd =~ /jpeg/; + } + }; + + subtest 'test report a problem - waste spillage - above shop' => sub { + set_fixed_time('2022-10-11T12:00:00Z'); + $e->mock('GetServiceUnitsForObject', sub { $above_shop_data }); + $mech->get_ok('/waste/12345'); + $mech->content_lacks('Report a spillage or bin not returned issue with a non-recyclable refuse collection'); + $mech->content_contains('spillage on a public highway occured during a non-recyclable refuse collection'); + $e->mock('GetServiceUnitsForObject', sub { $bin_data }); + set_fixed_time('2022-09-10T12:00:00Z'); + }; + + subtest 'No spillage report for open request in same service' => sub { + $e->mock('GetEventsForObject', sub { [ { + EventTypeId => 3227, # Waste spillage + ServiceId => 966, # Refuse + EventDate => { DateTime => "2022-09-10T17:00:00Z" }, + } ] }); + $mech->get_ok('/waste/12345'); + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); + $mech->content_like(qr/name="category" value="Waste spillage"[^>]+disabled/s); + $mech->back; + $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a food waste collection' }); + $mech->content_unlike(qr/name="category" value="Waste spillage"[^>]+disabled/s); + $e->mock('GetEventsForObject', sub { [] }); # reset + }; }; sub get_report_from_redirect { diff --git a/t/app/controller/waste_sutton_r.t b/t/app/controller/waste_sutton_r.t index 451aad3fcf8..e20af5f0cd0 100644 --- a/t/app/controller/waste_sutton_r.t +++ b/t/app/controller/waste_sutton_r.t @@ -548,7 +548,7 @@ FixMyStreet::override_config { $mech->get_ok('/waste/12345'); $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); $mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); - $mech->submit_form_ok( { with_fields => { now_returned => 'Yes' } } ); + $mech->submit_form_ok( { with_fields => { now_returned => 'yes' } } ); $mech->content_contains('We will not return to your address on this occasion'); $mech->content_lacks('We will return to your address as soon as we can to return the bin'); $mech->content_lacks('We will use your feedback'); @@ -581,7 +581,7 @@ FixMyStreet::override_config { $mech->get_ok('/waste/12345'); $mech->follow_link_ok({ text => 'Report a spillage or bin not returned issue with a non-recyclable refuse collection' }); $mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); - $mech->submit_form_ok( { with_fields => { now_returned => 'No' } } ); + $mech->submit_form_ok( { with_fields => { now_returned => 'no' } } ); $mech->content_contains('We will return to your address as soon as we can to return the bin'); $mech->content_lacks('We will not return to your address on this occasion'); $mech->content_lacks('We will use your feedback'); diff --git a/templates/email/default/waste/other-reported.html b/templates/email/default/waste/other-reported.html index 0ae6fcf74aa..a889e02a3e4 100644 --- a/templates/email/default/waste/other-reported.html +++ b/templates/email/default/waste/other-reported.html @@ -64,16 +64,34 @@
- On delivery day
- You do not need to be home for our crew to deliver the bin.
-
- Collecting your old bin - If you've requested a collection of your old bin, we'll schedule a specific date for our crew - to remove it. We aim for this to be the same day as we deliver your new bin, but it could be a different day. -
+[% ELSIF cobrand.moniker == 'kingston'%] + [% IF report.category == 'Request new container' %] +
+ On delivery day
+ You do not need to be home for our crew to deliver the bin.
+
+ Collecting your old bin + If you've requested a collection of your old bin, we'll schedule a specific date for our crew + to remove it. We aim for this to be the same day as we deliver your new bin, but it could be a different day. +
+ [% ELSIF report.category == 'Report missed collection' OR report.category == 'Report missed assisted collection' %] +We will arrange another collection as soon as possible over the next 2 working days.
+ [% ELSIF report.category == 'Waste spillage' %] ++ We apologise for any inconvenience caused and appreciate your feedback. We're committed to using it to improve our customer service. +
++ The issue has been logged and a clean up has been organised for within the next 24 hours. +
+ [% ELSIF report.category == 'Bin not returned' %] ++ We apologise for any inconvenience this may have caused and appreciate your feedback. We're committed to using it to improve our customer service. +
++ Please note that we are unable to return to correct the problem, unless you are on the Assisted Collection service and you have indicated you require additional help. +
+ [% END %] [% ELSIF cobrand.moniker == 'merton' AND report.category == 'Waste spillage' %]diff --git a/templates/email/default/waste/other-reported.txt b/templates/email/default/waste/other-reported.txt index 9556801a152..9c4b5f888dc 100644 --- a/templates/email/default/waste/other-reported.txt +++ b/templates/email/default/waste/other-reported.txt @@ -48,17 +48,28 @@ We apologise for any inconvenience this may have caused and appreciate your feed Please note that we are unable to return to correct the problem, unless you are on the Assisted Collection service and you have indicated you require additional help. [% END %] -[% ELSIF cobrand.moniker == 'kingston' AND report.category == 'Request new container' %] +[% ELSIF cobrand.moniker == 'kingston'%] +[% IF report.category == 'Request new container' %] On delivery day - You do not need to be home for our crew to deliver the bin. Collecting your old bin - If you've requested a collection of your old bin, we'll schedule a specific date for our crew to remove it. We aim for this to be the same day as we deliver your new bin, but it could be a different day. +[% ELSIF report.category == 'Report missed collection' OR report.category == 'Report missed assisted collection' %] +We will arrange another collection as soon as possible over the next 2 working days. +[% ELSIF report.category == 'Waste spillage' %] +We apologise for any inconvenience caused and appreciate your feedback. We're committed to using it to improve our customer service. + +The issue has been logged and a clean up has been organised for within the next 24 hours. +[% ELSIF report.category == 'Bin not returned' %] +We apologise for any inconvenience this may have caused and appreciate your feedback. We're committed to using it to improve our customer service. + +Please note that we are unable to return to correct the problem, unless you are on the Assisted Collection service and you have indicated you require additional help. +[% END %] [% ELSIF cobrand.moniker == 'merton' AND report.category == 'Waste spillage' %] Your report about the problem with your bin collection has been made to the council. The crew will be asked to return to clear the spillage within the next working day. - [% ELSIF cobrand.moniker == 'merton' AND (report.category == 'Lid not closed' OR report.category == 'Bin not returned') %] Your report about the problem with your bin collection has been made to the council. The crew will be advised. Please let us know if it happens again. diff --git a/templates/web/base/waste/services.html b/templates/web/base/waste/services.html index 1181e1b6322..18843c92d39 100644 --- a/templates/web/base/waste/services.html +++ b/templates/web/base/waste/services.html @@ -68,6 +68,14 @@ [% END %] [% END %] +[% IF c.cobrand.moniker == 'kingston' AND (property.domestic_refuse_bin OR communal_property OR fas_property) %] + [% IF unit.report_allowed AND fas_property %] + If a spillage on a public highway occured during a [% unit.service_name FILTER lower %] collection, please report a street cleaning issue. + [% ELSIF unit.report_allowed %] + Report a spillage or bin not returned issue with a [% unit.service_name FILTER lower %] collection + [% END %] +[% END %] + [% IF unit.garden_waste %] [% PROCESS 'waste/_services_garden_current.html' %] [% END %] diff --git a/templates/web/kingston/waste/_confirmation_after.html b/templates/web/kingston/waste/_confirmation_after.html index 4ba96efc292..d54a9214498 100644 --- a/templates/web/kingston/waste/_confirmation_after.html +++ b/templates/web/kingston/waste/_confirmation_after.html @@ -9,4 +9,8 @@
Please ensure you recycle all you can and take part in our food waste collections to reduce the amount of general rubbish you produce. For guidance on our services please visit our website https://www.kingston.gov.uk/bins-recycling-rubbish +[% ELSIF report.category == 'Bin not returned' %] +
Thank you for bringing this to our attention. We will use your feedback to improve performance in the future. Please accept our apologies for the inconvenience caused. +[% ELSIF report.category == 'Waste spillage' %] +
Thank you for your report. We will use your information to improve our service but due to collection schedules our collection crews cannot return to specific addresses. If the spillage is on a public highway, please report a street cleaning issue. [% END %] diff --git a/templates/web/kingston/waste/enquiry-intro.html b/templates/web/kingston/waste/enquiry-intro.html new file mode 100644 index 00000000000..47d3cd29c31 --- /dev/null +++ b/templates/web/kingston/waste/enquiry-intro.html @@ -0,0 +1,7 @@ +[% SET service_id = c.req.params.service_id %] +[% IF services.$service_id %] +