@@ -, +, @@ cancelled slips" tool. on "Notices" tab section. --- Koha/REST/V1/Bookings.pm | 35 +++++++++++++++++++ .../prog/en/modules/tools/letter.tt | 7 ++++ tools/letter.pl | 2 ++ 3 files changed, 44 insertions(+) --- a/Koha/REST/V1/Bookings.pm +++ a/Koha/REST/V1/Bookings.pm @@ -20,6 +20,11 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::Bookings; +use Koha::Items; +use Koha::Patrons; +use Koha::Libraries; + +use C4::Letters; use Try::Tiny qw( catch try ); @@ -134,12 +139,42 @@ sub delete { my $c = shift->openapi->valid_input or return; my $booking = Koha::Bookings->find( $c->param('booking_id') ); + my $patron = Koha::Patrons->find( $booking->patron_id ); + my $item = Koha::Items->find( $booking->item_id ); + my $library = Koha::Libraries->find( $booking->pickup_library_id ); + return $c->render_resource_not_found("Booking") unless $booking; return try { $booking->delete; + my $letter = C4::Letters::GetPreparedLetter( + module => 'bookings', + letter_code => 'BOOKING_CANCELLATION', + message_transport_type => 'email', + branchcode => $patron->branchcode, + lang => $patron->lang, + tables => { + branches => $library->branchcode, + borrowers => $patron->borrowernumber, + items => $item->itemnumber, + biblio => $item->biblionumber, + biblioitems => $item->biblionumber, + bookings => $booking->unblessed, + } + ); + + if ($letter) { + C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $patron->borrowernumber, + message_transport_type => 'email', + } + ); + } + return $c->render_resource_deleted; } catch { $c->unhandled_exception($_); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -182,6 +182,7 @@