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

(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js (-44 / +44 lines)
Lines 93-121 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
93
            let $patron = $("<span></span>")
93
            let $patron = $("<span></span>")
94
                .append(
94
                .append(
95
                    "" +
95
                    "" +
96
                        (patron.surname
96
                    (patron.surname
97
                            ? escape_str(patron.surname) + ", "
97
                        ? escape_str(patron.surname) + ", "
98
                            : "") +
98
                        : "") +
99
                        (patron.firstname
99
                    (patron.firstname
100
                            ? escape_str(patron.firstname) + " "
100
                        ? escape_str(patron.firstname) + " "
101
                            : "") +
101
                        : "") +
102
                        (patron.cardnumber
102
                    (patron.cardnumber
103
                            ? " (" + escape_str(patron.cardnumber) + ")"
103
                        ? " (" + escape_str(patron.cardnumber) + ")"
104
                            : "") +
104
                        : "") +
105
                        "<small>" +
105
                    "<small>" +
106
                        (patron.date_of_birth
106
                    (patron.date_of_birth
107
                            ? ' <span class="age_years">' +
107
                        ? ' <span class="age_years">' +
108
                              $get_age(patron.date_of_birth) +
108
                        $get_age(patron.date_of_birth) +
109
                              " " +
109
                        " " +
110
                              __("years") +
110
                        __("years") +
111
                              "</span>"
111
                        "</span>"
112
                            : "") +
112
                        : "") +
113
                        (patron.library
113
                    (patron.library
114
                            ? ' <span class="ac-library">' +
114
                        ? ' <span class="ac-library">' +
115
                              escape_str(patron.library.name) +
115
                        escape_str(patron.library.name) +
116
                              "</span>"
116
                        "</span>"
117
                            : "") +
117
                        : "") +
118
                        "</small>"
118
                    "</small>"
119
                )
119
                )
120
                .addClass(loggedInClass);
120
                .addClass(loggedInClass);
121
            return $patron;
121
            return $patron;
Lines 170-175 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
170
                    if (changed) {
170
                    if (changed) {
171
                        periodPicker.clear();
171
                        periodPicker.clear();
172
                    }
172
                    }
173
                    periodPicker.set("disable", periodPicker.config.disable);
173
                    periodPicker.redraw();
174
                    periodPicker.redraw();
174
175
175
                    // Enable flatpickr now we have data we need
176
                    // Enable flatpickr now we have data we need
Lines 211-220 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
211
            ) {
212
            ) {
212
                let option = $(
213
                let option = $(
213
                    '<option value="' +
214
                    '<option value="' +
214
                        pickup_location.library_id +
215
                    pickup_location.library_id +
215
                        '">' +
216
                    '">' +
216
                        pickup_location.name +
217
                    pickup_location.name +
217
                        "</option>"
218
                    "</option>"
218
                );
219
                );
219
220
220
                option.attr(
221
                option.attr(
Lines 413-420 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
413
                    if (
414
                    if (
414
                        !$("#booking_itemtype").find(
415
                        !$("#booking_itemtype").find(
415
                            "option[value='" +
416
                            "option[value='" +
416
                                item.item_type.item_type_id +
417
                            item.item_type.item_type_id +
417
                                "']"
418
                            "']"
418
                        ).length
419
                        ).length
419
                    ) {
420
                    ) {
420
                        // Create a DOM Option and de-select by default
421
                        // Create a DOM Option and de-select by default
Lines 458-464 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
458
                            }
459
                            }
459
460
460
                            // iterate existing bookings
461
                            // iterate existing bookings
461
                            for (booking of bookings) {
462
                            for (let booking of bookings) {
462
                                // Skip if we're editing this booking
463
                                // Skip if we're editing this booking
463
                                if (
464
                                if (
464
                                    booking_id &&
465
                                    booking_id &&
Lines 752-758 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
752
                                for (let i = 0; i < renewalsAllowed; i++) {
753
                                for (let i = 0; i < renewalsAllowed; i++) {
753
                                    nextDate.setDate(
754
                                    nextDate.setDate(
754
                                        nextDate.getDate() +
755
                                        nextDate.getDate() +
755
                                            parseInt(renewalLength)
756
                                        parseInt(renewalLength)
756
                                    );
757
                                    );
757
                                    boldDates.push(new Date(nextDate));
758
                                    boldDates.push(new Date(nextDate));
758
                                }
759
                                }
Lines 932-939 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
932
                            );
933
                            );
933
                            const startDate = periodPicker.selectedDates[0]
934
                            const startDate = periodPicker.selectedDates[0]
934
                                ? dayjs(periodPicker.selectedDates[0]).startOf(
935
                                ? dayjs(periodPicker.selectedDates[0]).startOf(
935
                                      "day"
936
                                    "day"
936
                                  )
937
                                )
937
                                : null;
938
                                : null;
938
939
939
                            const leadStart = startDate
940
                            const leadStart = startDate
Lines 959-965 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
959
                                    dayElem.classList.toggle(
960
                                    dayElem.classList.toggle(
960
                                        "leadRange",
961
                                        "leadRange",
961
                                        elemDate.isSameOrAfter(leadStart) &&
962
                                        elemDate.isSameOrAfter(leadStart) &&
962
                                            elemDate.isBefore(leadEnd)
963
                                        elemDate.isBefore(leadEnd)
963
                                    );
964
                                    );
964
                                    dayElem.classList.toggle(
965
                                    dayElem.classList.toggle(
965
                                        "leadRangeEnd",
966
                                        "leadRangeEnd",
Lines 972-978 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
972
                                    dayElem.classList.toggle(
973
                                    dayElem.classList.toggle(
973
                                        "trailRange",
974
                                        "trailRange",
974
                                        elemDate.isAfter(trailStart) &&
975
                                        elemDate.isAfter(trailStart) &&
975
                                            elemDate.isSameOrBefore(trailEnd)
976
                                        elemDate.isSameOrBefore(trailEnd)
976
                                    );
977
                                    );
977
                                    dayElem.classList.toggle(
978
                                    dayElem.classList.toggle(
978
                                        "trailRangeEnd",
979
                                        "trailRangeEnd",
Lines 1195-1202 $("#placeBookingForm").on("submit", function (e) { Link Here
1195
            // Set feedback
1196
            // Set feedback
1196
            $("#transient_result").replaceWith(
1197
            $("#transient_result").replaceWith(
1197
                '<div id="transient_result" class="alert alert-info">' +
1198
                '<div id="transient_result" class="alert alert-info">' +
1198
                    __("Booking successfully placed") +
1199
                __("Booking successfully placed") +
1199
                    "</div>"
1200
                "</div>"
1200
            );
1201
            );
1201
1202
1202
            // Close modal
1203
            // Close modal
Lines 1206-1213 $("#placeBookingForm").on("submit", function (e) { Link Here
1206
        posting.fail(function (data) {
1207
        posting.fail(function (data) {
1207
            $("#booking_result").replaceWith(
1208
            $("#booking_result").replaceWith(
1208
                '<div id="booking_result" class="alert alert-danger">' +
1209
                '<div id="booking_result" class="alert alert-danger">' +
1209
                    __("Failure") +
1210
                __("Failure") +
1210
                    "</div>"
1211
                "</div>"
1211
            );
1212
            );
1212
        });
1213
        });
1213
    } else {
1214
    } else {
Lines 1264-1271 $("#placeBookingForm").on("submit", function (e) { Link Here
1264
            // Set feedback
1265
            // Set feedback
1265
            $("#transient_result").replaceWith(
1266
            $("#transient_result").replaceWith(
1266
                '<div id="transient_result" class="alert alert-info">' +
1267
                '<div id="transient_result" class="alert alert-info">' +
1267
                    __("Booking successfully updated") +
1268
                __("Booking successfully updated") +
1268
                    "</div>"
1269
                "</div>"
1269
            );
1270
            );
1270
1271
1271
            // Close modal
1272
            // Close modal
Lines 1275-1282 $("#placeBookingForm").on("submit", function (e) { Link Here
1275
        putting.fail(function (data) {
1276
        putting.fail(function (data) {
1276
            $("#booking_result").replaceWith(
1277
            $("#booking_result").replaceWith(
1277
                '<div id="booking_result" class="alert alert-danger">' +
1278
                '<div id="booking_result" class="alert alert-danger">' +
1278
                    __("Failure") +
1279
                __("Failure") +
1279
                    "</div>"
1280
                "</div>"
1280
            );
1281
            );
1281
        });
1282
        });
1282
    }
1283
    }
1283
- 

Return to bug 39916