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

Return to bug 36373