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 464-469 $("#placeBookingModal").on("show.bs.modal", function (e) { Link Here
464
                    });
464
                    });
465
                }
465
                }
466
466
467
                // Create a bookings store keyed on date
468
                let bookingsByDate = {};
469
                // Iterate through the bookings array
470
                bookings.forEach(booking => {
471
                    const start_date = flatpickr.parseDate(booking.start_date);
472
                    const end_date = flatpickr.parseDate(booking.end_date);
473
                    const item_id = booking.item_id;
474
475
                    // Iterate through each date within the range of start_date and end_date
476
                    let currentDate = new Date(start_date);
477
                    while (currentDate <= end_date) {
478
                        const currentDateStr = currentDate
479
                            .toISOString()
480
                            .split("T")[0];
481
482
                        // If the date key doesn't exist in the hash, create an empty array for it
483
                        if (!bookingsByDate[currentDateStr]) {
484
                            bookingsByDate[currentDateStr] = [];
485
                        }
486
487
                        // Push the booking ID to the array corresponding to the date key
488
                        bookingsByDate[currentDateStr].push(item_id);
489
490
                        // Move to the next day
491
                        currentDate.setDate(currentDate.getDate() + 1);
492
                    }
493
                });
494
495
                // Set onDayCreate for flatpickr
496
                let dayCreateExists = periodPicker.config.onDayCreate.filter(
497
                    f => f.name === "dayCreate"
498
                );
499
                if (dayCreateExists.length === 0) {
500
                    periodPicker.config.onDayCreate.push(function dayCreate(
501
                        dObj,
502
                        dStr,
503
                        instance,
504
                        dayElem
505
                    ) {
506
                        const currentDate = dayElem.dateObj
507
                            .toISOString()
508
                            .split("T")[0];
509
510
                        if (bookingsByDate[currentDate]) {
511
                            const dots = document.createElement("span");
512
                            dots.className = "event-dots";
513
                            dayElem.appendChild(dots);
514
                            bookingsByDate[currentDate].forEach(item => {
515
                                const dot = document.createElement("span");
516
                                dot.className = "event item_" + item;
517
                                dots.appendChild(dot);
518
                            });
519
                        }
520
                    });
521
                }
522
467
                // Enable flatpickr now we have date function populated
523
                // Enable flatpickr now we have date function populated
468
                periodPicker.redraw();
524
                periodPicker.redraw();
469
                $("#period_fields :input").prop("disabled", false);
525
                $("#period_fields :input").prop("disabled", false);
470
- 

Return to bug 36373