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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/_flatpickr.scss (+18 lines)
Lines 575-580 Link Here
575
    }
575
    }
576
}
576
}
577
577
578
span.event-dots {
579
    display: block;
580
    position: absolute;
581
    bottom: 5px;
582
    left: 5px;
583
}
584
585
span.event {
586
    position: inline-block;
587
    width: 3px;
588
    height: 3px;
589
    border-radius: 150px;
590
    bottom: 3px;
591
    left: calc(50% - 1.5px);
592
    content: " ";
593
    display: block;
594
    background: #3d8eb9;
595
}
578
596
579
597
580
span.flatpickr-weekday {
598
span.flatpickr-weekday {
(-)a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js (-1 / +56 lines)
Lines 631-636 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
631
                    });
631
                    });
632
                }
632
                }
633
633
634
                // Create a bookings store keyed on date
635
                let bookingsByDate = {};
636
                // Iterate through the bookings array
637
                bookings.forEach(booking => {
638
                    const start_date = flatpickr.parseDate(booking.start_date);
639
                    const end_date = flatpickr.parseDate(booking.end_date);
640
                    const item_id = booking.item_id;
641
642
                    // Iterate through each date within the range of start_date and end_date
643
                    let currentDate = new Date(start_date);
644
                    while (currentDate <= end_date) {
645
                        const currentDateStr = currentDate
646
                            .toISOString()
647
                            .split("T")[0];
648
649
                        // If the date key doesn't exist in the hash, create an empty array for it
650
                        if (!bookingsByDate[currentDateStr]) {
651
                            bookingsByDate[currentDateStr] = [];
652
                        }
653
654
                        // Push the booking ID to the array corresponding to the date key
655
                        bookingsByDate[currentDateStr].push(item_id);
656
657
                        // Move to the next day
658
                        currentDate.setDate(currentDate.getDate() + 1);
659
                    }
660
                });
661
662
                // Set onDayCreate for flatpickr
663
                let dayCreateExists = periodPicker.config.onDayCreate.filter(
664
                    f => f.name === "dayCreate"
665
                );
666
                if (dayCreateExists.length === 0) {
667
                    periodPicker.config.onDayCreate.push(function dayCreate(
668
                        dObj,
669
                        dStr,
670
                        instance,
671
                        dayElem
672
                    ) {
673
                        const currentDate = dayElem.dateObj
674
                            .toISOString()
675
                            .split("T")[0];
676
677
                        if (bookingsByDate[currentDate]) {
678
                            const dots = document.createElement("span");
679
                            dots.className = "event-dots";
680
                            dayElem.appendChild(dots);
681
                            bookingsByDate[currentDate].forEach(item => {
682
                                const dot = document.createElement("span");
683
                                dot.className = "event item_" + item;
684
                                dots.appendChild(dot);
685
                            });
686
                        }
687
                    });
688
                }
689
634
                // Enable flatpickr now we have date function populated
690
                // Enable flatpickr now we have date function populated
635
                periodPicker.redraw();
691
                periodPicker.redraw();
636
                $("#period_fields :input").prop("disabled", false);
692
                $("#period_fields :input").prop("disabled", false);
637
- 

Return to bug 36373