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

(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js (-4 / +14 lines)
Lines 132-139 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
132
    // Lead and Trail days syncing
132
    // Lead and Trail days syncing
133
    let leadDays = 0;
133
    let leadDays = 0;
134
    let trailDays = 0;
134
    let trailDays = 0;
135
    let lengthDays;
135
    function getCirculationRules() {
136
    function getCirculationRules() {
136
        let rules_url = "/api/v1/circulation_rules";
137
        $.ajax({
137
        $.ajax({
138
            url: rules_url,
138
            url: rules_url,
139
            type: "GET",
139
            type: "GET",
Lines 142-151 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
142
                patron_category_id: booking_patron.category_id,
142
                patron_category_id: booking_patron.category_id,
143
                item_type_id: booking_itemtype_id,
143
                item_type_id: booking_itemtype_id,
144
                library_id: pickup_library_id,
144
                library_id: pickup_library_id,
145
                rules: "bookings_lead_period,bookings_trail_period",
145
                rules: "bookings_lead_period,bookings_trail_period,issuelength,renewalsallowed,renewalperiod"
146
            },
146
            },
147
            success: function (response) {
147
            success: function (response) {
148
                let rules = response[0];
148
                let rules = response[0];
149
                let renewalLength = rules.renewalsallowed * rules.renewalperiod;
150
                lengthDays = rules.issuelength + renewalLength;
149
                leadDays = rules.bookings_lead_period;
151
                leadDays = rules.bookings_lead_period;
150
                trailDays = rules.bookings_trail_period;
152
                trailDays = rules.bookings_trail_period;
151
153
Lines 676-683 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
676
                        dateStr,
678
                        dateStr,
677
                        instance
679
                        instance
678
                    ) {
680
                    ) {
681
                        // Start date selected
682
                        if (selectedDates[0] && !selectedDates[1]) {
683
                            // Calculate the maximum date based on the selected start date
684
                            const maxDate = new Date(selectedDates[0]);
685
                            maxDate.setDate(maxDate.getDate() + lengthDays );
686
687
                            // Update the maxDate option of the flatpickr instance
688
                            instance.set('maxDate', maxDate);
689
                        }
679
                        // Range set, update hidden fields and set available items
690
                        // Range set, update hidden fields and set available items
680
                        if (selectedDates[0] && selectedDates[1]) {
691
                        else if (selectedDates[0] && selectedDates[1]) {
681
                            // set form fields from picker
692
                            // set form fields from picker
682
                            let picker_start = dayjs(selectedDates[0]);
693
                            let picker_start = dayjs(selectedDates[0]);
683
                            let picker_end = dayjs(selectedDates[1]).endOf(
694
                            let picker_end = dayjs(selectedDates[1]).endOf(
684
- 

Return to bug 37354