Bugzilla – Attachment 167010 Details for
Bug 36915
Send email notification when a booking is cancelled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36915: Send email notification when a booking is cancelled
Bug-36915-Send-email-notification-when-a-booking-i.patch (text/plain), 5.79 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-05-22 08:13:14 UTC
(
hide
)
Description:
Bug 36915: Send email notification when a booking is cancelled
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-05-22 08:13:14 UTC
Size:
5.79 KB
patch
obsolete
>From 70d9ec4e7e4fc69fe50db7b0991969671fe6370b Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Wed, 22 May 2024 09:59:51 +0200 >Subject: [PATCH] Bug 36915: Send email notification when a booking is > cancelled >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When a booking is cancelled, patron received an email based on specific >letter. > >Test plan: > >1) Create a letter with code "BOOKING_CANCELLATION" on "Notices and > slips" tool. >2) Add booking or go on item already booked in advance. >3) Cancel it >4) Verify in message_queue table directly or go on patron page and click > on "Notices" tab section. > >Sponsored by: Association de Gestion des Ã…uvres Sociales d'Inria (AGOS) >--- > Koha/REST/V1/Bookings.pm | 35 +++++++++++++++++++ > .../prog/en/modules/tools/letter.tt | 7 ++++ > tools/letter.pl | 2 ++ > 3 files changed, 44 insertions(+) > >diff --git a/Koha/REST/V1/Bookings.pm b/Koha/REST/V1/Bookings.pm >index 44e381ef1b9..5ddd9816f84 100644 >--- a/Koha/REST/V1/Bookings.pm >+++ b/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($_); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >index 22379532e50..eb6e0a3e9d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -182,6 +182,7 @@ > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=suggestions">Suggestions</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=pos">Point of sale</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=report">Reports</a></li> >+ <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=bookings">Bookings</a></li> > </ul> > </div> > </div> <!-- /#toolbar --> >@@ -243,6 +244,7 @@ > [% CASE 'suggestions' %]<span>Suggestions</span> > [% CASE 'pos' %]<span>Point of sale</span> > [% CASE 'report' %]<span>Reports</span> >+ [% CASE 'bookings' %]<span>Bookings</span> > [% CASE %]<span>[% lette.module | html %]</span> > [% END %] > </td> >@@ -441,6 +443,11 @@ > [% ELSE %] > <option value="report">Reports</option> > [% END %] >+ [% IF ( module == "bookings" ) %] >+ <option value="bookings" selected="selected">Bookings</option> >+ [% ELSE %] >+ <option value="bookings" >Bookings</option> >+ [% END %] > </select> > </li> > <li> >diff --git a/tools/letter.pl b/tools/letter.pl >index 9e9b9e386fa..c3ed7e432fd 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -254,6 +254,8 @@ sub add_form { > add_fields( 'branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial' ); > } elsif ( $module eq 'suggestions' ) { > push @{$field_selection}, add_fields( 'suggestions', 'borrowers', 'biblio' ); >+ } elsif ( $module eq 'bookings' ) { >+ push @{$field_selection}, add_fields( 'borrowers', 'bookings', 'biblio', 'biblioitems', 'items' ); > } else { > push @{$field_selection}, add_fields( 'biblio', 'biblioitems' ), > add_fields('items'), >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36915
:
167010
|
167013
|
168149
|
168150
|
168155
|
170058
|
170077
|
170078
|
170079
|
170080
|
170099
|
170155
|
170203
|
170204
|
170205
|
170206
|
170207
|
170208
|
170385
|
170386
|
170387
|
170388
|
170389
|
170390
|
170391