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

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

Return to bug 37354