View | Details | Raw Unified | Return to bug 36915
Collapse All | Expand All

(-)a/Koha/REST/V1/Bookings.pm (+35 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use Koha::Bookings;
22
use Koha::Bookings;
23
use Koha::Items;
24
use Koha::Patrons;
25
use Koha::Libraries;
26
27
use C4::Letters;
23
28
24
use Try::Tiny qw( catch try );
29
use Try::Tiny qw( catch try );
25
30
Lines 134-145 sub delete { Link Here
134
    my $c = shift->openapi->valid_input or return;
139
    my $c = shift->openapi->valid_input or return;
135
140
136
    my $booking = Koha::Bookings->find( $c->param('booking_id') );
141
    my $booking = Koha::Bookings->find( $c->param('booking_id') );
142
    my $patron  = Koha::Patrons->find( $booking->patron_id );
143
    my $item    = Koha::Items->find( $booking->item_id );
144
    my $library = Koha::Libraries->find( $booking->pickup_library_id );
137
145
146
    
138
    return $c->render_resource_not_found("Booking")
147
    return $c->render_resource_not_found("Booking")
139
        unless $booking;
148
        unless $booking;
140
149
141
    return try {
150
    return try {
142
        $booking->delete;
151
        $booking->delete;
152
        my $letter = C4::Letters::GetPreparedLetter(
153
            module                 => 'bookings',
154
            letter_code            => 'BOOKING_CANCELLATION',
155
            message_transport_type => 'email',
156
            branchcode             => $patron->branchcode,
157
            lang                   => $patron->lang,
158
            tables                 => {
159
                branches    => $library->branchcode,
160
                borrowers   => $patron->borrowernumber,
161
                items       => $item->itemnumber,
162
                biblio      => $item->biblionumber,
163
                biblioitems => $item->biblionumber,
164
                bookings    => $booking->unblessed,
165
            }
166
        );
167
168
        if ($letter) {
169
            C4::Letters::EnqueueLetter(
170
                {
171
                    letter                 => $letter,
172
                    borrowernumber         => $patron->borrowernumber,
173
                    message_transport_type => 'email',
174
                }
175
            );
176
        }
177
143
        return $c->render_resource_deleted;
178
        return $c->render_resource_deleted;
144
    } catch {
179
    } catch {
145
        $c->unhandled_exception($_);
180
        $c->unhandled_exception($_);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt (+7 lines)
Lines 182-187 Link Here
182
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=suggestions">Suggestions</a></li>
182
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=suggestions">Suggestions</a></li>
183
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=pos">Point of sale</a></li>
183
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=pos">Point of sale</a></li>
184
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=report">Reports</a></li>
184
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=report">Reports</a></li>
185
                                <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=bookings">Bookings</a></li>
185
                            </ul>
186
                            </ul>
186
                        </div>
187
                        </div>
187
                    </div> <!-- /#toolbar -->
188
                    </div> <!-- /#toolbar -->
Lines 243-248 Link Here
243
                                                    [% CASE 'suggestions' %]<span>Suggestions</span>
244
                                                    [% CASE 'suggestions' %]<span>Suggestions</span>
244
                                                    [% CASE 'pos' %]<span>Point of sale</span>
245
                                                    [% CASE 'pos' %]<span>Point of sale</span>
245
                                                    [% CASE 'report' %]<span>Reports</span>
246
                                                    [% CASE 'report' %]<span>Reports</span>
247
                                                    [% CASE 'bookings' %]<span>Bookings</span>
246
                                                    [% CASE %]<span>[% lette.module | html %]</span>
248
                                                    [% CASE %]<span>[% lette.module | html %]</span>
247
                                                [% END %]
249
                                                [% END %]
248
                                            </td>
250
                                            </td>
Lines 441-446 Link Here
441
                                        [% ELSE %]
443
                                        [% ELSE %]
442
                                            <option value="report">Reports</option>
444
                                            <option value="report">Reports</option>
443
                                        [% END %]
445
                                        [% END %]
446
                                        [% IF ( module == "bookings" ) %]
447
                                            <option value="bookings" selected="selected">Bookings</option>
448
                                        [% ELSE %]
449
                                            <option value="bookings" >Bookings</option>
450
                                        [% END %]
444
                                    </select>
451
                                    </select>
445
                                </li>
452
                                </li>
446
                                <li>
453
                                <li>
(-)a/tools/letter.pl (-1 / +2 lines)
Lines 254-259 sub add_form { Link Here
254
            add_fields( 'branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial' );
254
            add_fields( 'branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial' );
255
    } elsif ( $module eq 'suggestions' ) {
255
    } elsif ( $module eq 'suggestions' ) {
256
        push @{$field_selection}, add_fields( 'suggestions', 'borrowers', 'biblio' );
256
        push @{$field_selection}, add_fields( 'suggestions', 'borrowers', 'biblio' );
257
    } elsif ( $module eq 'bookings' ) {
258
        push @{$field_selection}, add_fields( 'borrowers', 'bookings', 'biblio', 'biblioitems', 'items' );
257
    } else {
259
    } else {
258
        push @{$field_selection}, add_fields( 'biblio', 'biblioitems' ),
260
        push @{$field_selection}, add_fields( 'biblio', 'biblioitems' ),
259
            add_fields('items'),
261
            add_fields('items'),
260
- 

Return to bug 36915