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

(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js (-9 / +38 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
    let boldDates = [];
137
    let issueLength;
138
    let renewalLength;
139
    let renewalsAllowed;
137
    function getCirculationRules() {
140
    function getCirculationRules() {
141
        let rules_url = "/api/v1/circulation_rules";
138
        $.ajax({
142
        $.ajax({
139
            url: rules_url,
143
            url: rules_url,
140
            type: "GET",
144
            type: "GET",
Lines 147-154 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
147
            },
151
            },
148
            success: function (response) {
152
            success: function (response) {
149
                let rules = response[0];
153
                let rules = response[0];
150
                let renewalLength = rules.renewalsallowed * rules.renewalperiod;
154
                issueLength = rules.issuelength;
151
                lengthDays = rules.issuelength + renewalLength;
155
                renewalsAllowed = rules.renewalsallowed;
156
                renewalLength = rules.renewalperiod;
152
                leadDays = rules.bookings_lead_period;
157
                leadDays = rules.bookings_lead_period;
153
                trailDays = rules.bookings_trail_period;
158
                trailDays = rules.bookings_trail_period;
154
159
Lines 677-685 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
677
                    ) {
682
                    ) {
678
                        // Start date selected
683
                        // Start date selected
679
                        if (selectedDates[0] && !selectedDates[1]) {
684
                        if (selectedDates[0] && !selectedDates[1]) {
685
686
                            const startDate = new Date(selectedDates[0]);
687
688
                            // Custom format function to make specific dates bold
689
                            boldDates = [new Date(startDate)];
690
                            // Add issueLength days after the startDate
691
                            const nextDate = new Date(startDate);
692
                            nextDate.setDate(nextDate.getDate() + parseInt(issueLength));
693
                            boldDates.push(new Date(nextDate));
694
695
                            // Add subsequent dates based on renewalsAllowed and renewalLength
696
                            for (let i = 0; i < renewalsAllowed; i++) {
697
                                nextDate.setDate(nextDate.getDate() + parseInt(renewalLength));
698
                                boldDates.push(new Date(nextDate));
699
                            }
700
680
                            // Calculate the maximum date based on the selected start date
701
                            // Calculate the maximum date based on the selected start date
681
                            const maxDate = new Date(selectedDates[0]);
702
                            let totalRenewalLength = parseInt(renewalsAllowed) * parseInt(renewalLength);
682
                            maxDate.setDate(maxDate.getDate() + lengthDays );
703
                            let totalIssueLength = parseInt(issueLength) + parseInt(totalRenewalLength);
704
705
                            const maxDate = new Date(startDate.getTime());
706
                            maxDate.setDate(maxDate.getDate() + totalIssueLength );
683
707
684
                            // Update the maxDate option of the flatpickr instance
708
                            // Update the maxDate option of the flatpickr instance
685
                            instance.set('maxDate', maxDate);
709
                            instance.set('maxDate', maxDate);
Lines 796-810 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
796
                        instance,
820
                        instance,
797
                        dayElem
821
                        dayElem
798
                    ) {
822
                    ) {
799
                        const currentDate = dayElem.dateObj
823
                        const currentDate = dayElem.dateObj;
824
                        const dateString = currentDate
800
                            .toISOString()
825
                            .toISOString()
801
                            .split("T")[0];
826
                            .split("T")[0];
802
827
803
                        if (bookingsByDate[currentDate]) {
828
                        const isBold = boldDates.some(boldDate => boldDate.getTime() === currentDate.getTime());
829
                        if (isBold) {
830
                            dayElem.classList.add('title');
831
                        }
832
833
                        if (bookingsByDate[dateString]) {
804
                            const dots = document.createElement("span");
834
                            const dots = document.createElement("span");
805
                            dots.className = "event-dots";
835
                            dots.className = "event-dots";
806
                            dayElem.appendChild(dots);
836
                            dayElem.appendChild(dots);
807
                            bookingsByDate[currentDate].forEach(item => {
837
                            bookingsByDate[dateString].forEach(item => {
808
                                const dot = document.createElement("span");
838
                                const dot = document.createElement("span");
809
                                dot.className = "event item_" + item;
839
                                dot.className = "event item_" + item;
810
                                dots.appendChild(dot);
840
                                dots.appendChild(dot);
811
- 

Return to bug 37354