|
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 146-153
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
| 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 676-684
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
| 676 |
) { |
681 |
) { |
| 677 |
// Start date selected |
682 |
// Start date selected |
| 678 |
if (selectedDates[0] && !selectedDates[1]) { |
683 |
if (selectedDates[0] && !selectedDates[1]) { |
|
|
684 |
|
| 685 |
const startDate = new Date(selectedDates[0]); |
| 686 |
|
| 687 |
// Custom format function to make specific dates bold |
| 688 |
boldDates = [new Date(startDate)]; |
| 689 |
// Add issueLength days after the startDate |
| 690 |
const nextDate = new Date(startDate); |
| 691 |
nextDate.setDate(nextDate.getDate() + parseInt(issueLength)); |
| 692 |
boldDates.push(new Date(nextDate)); |
| 693 |
|
| 694 |
// Add subsequent dates based on renewalsAllowed and renewalLength |
| 695 |
for (let i = 0; i < renewalsAllowed; i++) { |
| 696 |
nextDate.setDate(nextDate.getDate() + parseInt(renewalLength)); |
| 697 |
boldDates.push(new Date(nextDate)); |
| 698 |
} |
| 699 |
|
| 679 |
// Calculate the maximum date based on the selected start date |
700 |
// Calculate the maximum date based on the selected start date |
| 680 |
const maxDate = new Date(selectedDates[0]); |
701 |
let totalRenewalLength = parseInt(renewalsAllowed) * parseInt(renewalLength); |
| 681 |
maxDate.setDate(maxDate.getDate() + lengthDays ); |
702 |
let totalIssueLength = parseInt(issueLength) + parseInt(totalRenewalLength); |
|
|
703 |
|
| 704 |
const maxDate = new Date(startDate.getTime()); |
| 705 |
maxDate.setDate(maxDate.getDate() + totalIssueLength ); |
| 682 |
|
706 |
|
| 683 |
// Update the maxDate option of the flatpickr instance |
707 |
// Update the maxDate option of the flatpickr instance |
| 684 |
instance.set('maxDate', maxDate); |
708 |
instance.set('maxDate', maxDate); |
|
Lines 795-809
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
| 795 |
instance, |
819 |
instance, |
| 796 |
dayElem |
820 |
dayElem |
| 797 |
) { |
821 |
) { |
| 798 |
const currentDate = dayElem.dateObj |
822 |
const currentDate = dayElem.dateObj; |
|
|
823 |
const dateString = currentDate |
| 799 |
.toISOString() |
824 |
.toISOString() |
| 800 |
.split("T")[0]; |
825 |
.split("T")[0]; |
| 801 |
|
826 |
|
| 802 |
if (bookingsByDate[currentDate]) { |
827 |
const isBold = boldDates.some(boldDate => boldDate.getTime() === currentDate.getTime()); |
|
|
828 |
if (isBold) { |
| 829 |
dayElem.classList.add('title'); |
| 830 |
} |
| 831 |
|
| 832 |
if (bookingsByDate[dateString]) { |
| 803 |
const dots = document.createElement("span"); |
833 |
const dots = document.createElement("span"); |
| 804 |
dots.className = "event-dots"; |
834 |
dots.className = "event-dots"; |
| 805 |
dayElem.appendChild(dots); |
835 |
dayElem.appendChild(dots); |
| 806 |
bookingsByDate[currentDate].forEach(item => { |
836 |
bookingsByDate[dateString].forEach(item => { |
| 807 |
const dot = document.createElement("span"); |
837 |
const dot = document.createElement("span"); |
| 808 |
dot.className = "event item_" + item; |
838 |
dot.className = "event item_" + item; |
| 809 |
dots.appendChild(dot); |
839 |
dots.appendChild(dot); |
| 810 |
- |
|
|