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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cancel_booking.inc (+22 lines)
Line 0 Link Here
1
<!-- Cancel booking modal -->
2
<div class="modal" id="cancelBookingModal" tabindex="-1" role="dialog" aria-labelledby="cancelBookingLabel">
3
    <form id="cancelBookingForm">
4
        <div class="modal-dialog" role="document">
5
            <div class="modal-content">
6
                <div class="modal-header">
7
                    <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
8
                    <h4 class="modal-title" id="cancelBookingLabel">Cancel booking</h4>
9
                </div>
10
                <div class="modal-body">
11
                    <div id="cancel_booking_result"></div>
12
                    <input type="hidden" name="booking_id" id="cancel_booking_id">
13
                    <p>Are you sure you want to cancel this booking?</p>
14
                </div> <!-- /.modal-body -->
15
                <div class="modal-footer">
16
                    <button type="submit" class="btn btn-danger">Confirm</button>
17
                    <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
18
                </div> <!-- /.modal-footer -->
19
            </div> <!-- /.modal-content -->
20
        </div> <!-- /.modal-dialog -->
21
    </form>
22
</div> <!-- /#cancelBookingModal -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt (+12 lines)
Lines 57-62 Link Here
57
    </div> <!-- /.row -->
57
    </div> <!-- /.row -->
58
58
59
    [% INCLUDE modals/place_booking.inc %]
59
    [% INCLUDE modals/place_booking.inc %]
60
    [% INCLUDE modals/cancel_booking.inc %]
60
61
61
    [% MACRO jsinclude BLOCK %]
62
    [% MACRO jsinclude BLOCK %]
62
    [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %]
63
    [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %]
Lines 66-71 Link Here
66
    [% INCLUDE 'select2.inc' %]
67
    [% INCLUDE 'select2.inc' %]
67
    [% INCLUDE 'js-date-format.inc' %]
68
    [% INCLUDE 'js-date-format.inc' %]
68
    [% Asset.js("js/place_booking_modal.js") | $raw %]
69
    [% Asset.js("js/place_booking_modal.js") | $raw %]
70
    [% Asset.js("js/cancel_booking_modal.js") | $raw %]
69
<script>
71
<script>
70
    var bookings_table;
72
    var bookings_table;
71
    $(document).ready(function(){
73
    $(document).ready(function(){
Lines 132-137 Link Here
132
                "render": function(data, type, row, meta) {
134
                "render": function(data, type, row, meta) {
133
                    return $date(row.end_date);
135
                    return $date(row.end_date);
134
                }
136
                }
137
            },
138
            {
139
                "data": "",
140
                "title": "Actions",
141
                "searchable": false,
142
                "orderable": false,
143
                "render": function(data, type, row, meta) {
144
                    var result = '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>';
145
                    return result;
146
                }
135
            }]
147
            }]
136
        }, [], 1);
148
        }, [], 1);
137
    });
149
    });
(-)a/koha-tmpl/intranet-tmpl/prog/js/cancel_booking_modal.js (-1 / +28 lines)
Line 0 Link Here
0
- 
1
$('#cancelBookingModal').on('show.bs.modal', function(e) {
2
    var button = $(e.relatedTarget);
3
    var booking = button.data('booking');
4
    $('#cancel_booking_id').val(booking);
5
});
6
7
$("#cancelBookingForm").on('submit', function(e) {
8
    e.preventDefault();
9
10
    var booking_id = $('#cancel_booking_id').val();
11
    var url = '/api/v1/bookings/'+booking_id;
12
13
    var deleting = $.ajax({
14
        'method': "DELETE",
15
        'url': url
16
    });
17
18
    deleting.done(function(data) {
19
        if (bookings_table) {
20
            bookings_table.api().ajax.reload();
21
        }
22
        $('#cancelBookingModal').modal('hide');
23
    });
24
25
    deleting.fail(function(data) {
26
        $('#cancel_booking_result').replaceWith('<div id="booking_result" class="alert alert-danger">Failure</div>');
27
    });
28
});

Return to bug 29002