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