Lines 132-139
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
132 |
// Lead and Trail days syncing |
132 |
// Lead and Trail days syncing |
133 |
let leadDays = 0; |
133 |
let leadDays = 0; |
134 |
let trailDays = 0; |
134 |
let trailDays = 0; |
135 |
let lengthDays; |
135 |
let boldDates = []; |
|
|
136 |
let issueLength; |
137 |
let renewalLength; |
138 |
let renewalsAllowed; |
136 |
function getCirculationRules() { |
139 |
function getCirculationRules() { |
|
|
140 |
let rules_url = "/api/v1/circulation_rules"; |
137 |
$.ajax({ |
141 |
$.ajax({ |
138 |
url: rules_url, |
142 |
url: rules_url, |
139 |
type: "GET", |
143 |
type: "GET", |
Lines 142-153
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
142 |
patron_category_id: booking_patron.category_id, |
146 |
patron_category_id: booking_patron.category_id, |
143 |
item_type_id: booking_itemtype_id, |
147 |
item_type_id: booking_itemtype_id, |
144 |
library_id: pickup_library_id, |
148 |
library_id: pickup_library_id, |
145 |
rules: "bookings_lead_period,bookings_trail_period,issuelength,renewalsallowed,renewalperiod" |
149 |
rules: "bookings_lead_period,bookings_trail_period,issuelength,renewalsallowed,renewalperiod", |
146 |
}, |
150 |
}, |
147 |
success: function (response) { |
151 |
success: function (response) { |
148 |
let rules = response[0]; |
152 |
let rules = response[0]; |
149 |
let renewalLength = rules.renewalsallowed * rules.renewalperiod; |
153 |
issueLength = rules.issuelength; |
150 |
lengthDays = rules.issuelength + renewalLength; |
154 |
renewalsAllowed = rules.renewalsallowed; |
|
|
155 |
renewalLength = rules.renewalperiod; |
151 |
leadDays = rules.bookings_lead_period; |
156 |
leadDays = rules.bookings_lead_period; |
152 |
trailDays = rules.bookings_trail_period; |
157 |
trailDays = rules.bookings_trail_period; |
153 |
|
158 |
|
Lines 680-691
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
680 |
) { |
685 |
) { |
681 |
// Start date selected |
686 |
// Start date selected |
682 |
if (selectedDates[0] && !selectedDates[1]) { |
687 |
if (selectedDates[0] && !selectedDates[1]) { |
|
|
688 |
const startDate = new Date(selectedDates[0]); |
689 |
|
690 |
// Custom format function to make specific dates bold |
691 |
boldDates = [new Date(startDate)]; |
692 |
// Add issueLength days after the startDate |
693 |
const nextDate = new Date(startDate); |
694 |
nextDate.setDate( |
695 |
nextDate.getDate() + parseInt(issueLength) |
696 |
); |
697 |
boldDates.push(new Date(nextDate)); |
698 |
|
699 |
// Add subsequent dates based on renewalsAllowed and renewalLength |
700 |
for (let i = 0; i < renewalsAllowed; i++) { |
701 |
nextDate.setDate( |
702 |
nextDate.getDate() + parseInt(renewalLength) |
703 |
); |
704 |
boldDates.push(new Date(nextDate)); |
705 |
} |
706 |
|
683 |
// Calculate the maximum date based on the selected start date |
707 |
// Calculate the maximum date based on the selected start date |
684 |
const maxDate = new Date(selectedDates[0]); |
708 |
let totalRenewalLength = |
685 |
maxDate.setDate(maxDate.getDate() + lengthDays ); |
709 |
parseInt(renewalsAllowed) * |
|
|
710 |
parseInt(renewalLength); |
711 |
let totalIssueLength = |
712 |
parseInt(issueLength) + |
713 |
parseInt(totalRenewalLength); |
714 |
|
715 |
const maxDate = new Date(startDate.getTime()); |
716 |
maxDate.setDate( |
717 |
maxDate.getDate() + totalIssueLength |
718 |
); |
686 |
|
719 |
|
687 |
// Update the maxDate option of the flatpickr instance |
720 |
// Update the maxDate option of the flatpickr instance |
688 |
instance.set('maxDate', maxDate); |
721 |
instance.set("maxDate", maxDate); |
689 |
} |
722 |
} |
690 |
// Range set, update hidden fields and set available items |
723 |
// Range set, update hidden fields and set available items |
691 |
else if (selectedDates[0] && selectedDates[1]) { |
724 |
else if (selectedDates[0] && selectedDates[1]) { |
Lines 799-813
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
799 |
instance, |
832 |
instance, |
800 |
dayElem |
833 |
dayElem |
801 |
) { |
834 |
) { |
802 |
const currentDate = dayElem.dateObj |
835 |
const currentDate = dayElem.dateObj; |
|
|
836 |
const dateString = currentDate |
803 |
.toISOString() |
837 |
.toISOString() |
804 |
.split("T")[0]; |
838 |
.split("T")[0]; |
805 |
|
839 |
|
806 |
if (bookingsByDate[currentDate]) { |
840 |
const isBold = boldDates.some( |
|
|
841 |
boldDate => |
842 |
boldDate.getTime() === currentDate.getTime() |
843 |
); |
844 |
if (isBold) { |
845 |
dayElem.classList.add("title"); |
846 |
} |
847 |
|
848 |
if (bookingsByDate[dateString]) { |
807 |
const dots = document.createElement("span"); |
849 |
const dots = document.createElement("span"); |
808 |
dots.className = "event-dots"; |
850 |
dots.className = "event-dots"; |
809 |
dayElem.appendChild(dots); |
851 |
dayElem.appendChild(dots); |
810 |
bookingsByDate[currentDate].forEach(item => { |
852 |
bookingsByDate[dateString].forEach(item => { |
811 |
const dot = document.createElement("span"); |
853 |
const dot = document.createElement("span"); |
812 |
dot.className = "event item_" + item; |
854 |
dot.className = "event item_" + item; |
813 |
dots.appendChild(dot); |
855 |
dots.appendChild(dot); |
814 |
- |
|
|