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 |
function setBufferDays() { |
136 |
function getCirculationRules() { |
137 |
let rules_url = "/api/v1/circulation_rules"; |
137 |
let rules_url = "/api/v1/circulation_rules"; |
138 |
$.ajax({ |
138 |
$.ajax({ |
139 |
url: rules_url, |
139 |
url: rules_url, |
Lines 149-154
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
149 |
let rules = response[0] |
149 |
let rules = response[0] |
150 |
leadDays = rules.bookings_lead_period; |
150 |
leadDays = rules.bookings_lead_period; |
151 |
trailDays = rules.bookings_trail_period; |
151 |
trailDays = rules.bookings_trail_period; |
|
|
152 |
|
153 |
// redraw pariodPicker taking selected item into account |
154 |
periodPicker.redraw(); |
155 |
|
156 |
// Enable flatpickr now we have data we need |
157 |
if (dataFetched) { |
158 |
$("#period_fields :input").prop("disabled", false); |
159 |
} |
152 |
}, |
160 |
}, |
153 |
error: function (xhr, status, error) { |
161 |
error: function (xhr, status, error) { |
154 |
console.log("Circulation rules fetch failed: ", error); |
162 |
console.log("Circulation rules fetch failed: ", error); |
Lines 274-280
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
274 |
} |
282 |
} |
275 |
|
283 |
|
276 |
// Populate circulation rules |
284 |
// Populate circulation rules |
277 |
setBufferDays(); |
285 |
getCirculationRules(); |
278 |
}); |
286 |
}); |
279 |
|
287 |
|
280 |
// Adopt periodPicker |
288 |
// Adopt periodPicker |
Lines 578-585
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
578 |
}); |
586 |
}); |
579 |
$("#booking_item_id").trigger("change.select2"); |
587 |
$("#booking_item_id").trigger("change.select2"); |
580 |
|
588 |
|
581 |
// update buffer days |
589 |
// Update circulation rules |
582 |
setBufferDays(); |
590 |
getCirculationRules(); |
583 |
}); |
591 |
}); |
584 |
|
592 |
|
585 |
// Setup listener for item select2 |
593 |
// Setup listener for item select2 |
Lines 625-635
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
625 |
$("#booking_itemtype").prop("disabled", false); |
633 |
$("#booking_itemtype").prop("disabled", false); |
626 |
} |
634 |
} |
627 |
|
635 |
|
628 |
// update buffer days |
636 |
// Update circulation rules |
629 |
setBufferDays(); |
637 |
getCirculationRules(); |
630 |
|
|
|
631 |
// redraw pariodPicker taking selected item into account |
632 |
periodPicker.redraw(); |
633 |
}); |
638 |
}); |
634 |
|
639 |
|
635 |
// Setup listener for pickup location select2 |
640 |
// Setup listener for pickup location select2 |
Lines 859-865
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
859 |
|
864 |
|
860 |
// Enable flatpickr now we have date function populated |
865 |
// Enable flatpickr now we have date function populated |
861 |
periodPicker.redraw(); |
866 |
periodPicker.redraw(); |
862 |
$("#period_fields :input").prop("disabled", false); |
|
|
863 |
|
867 |
|
864 |
// Redraw itemtype select with new options and enable |
868 |
// Redraw itemtype select with new options and enable |
865 |
let $bookingItemtypeSelect = $("#booking_itemtype"); |
869 |
let $bookingItemtypeSelect = $("#booking_itemtype"); |
866 |
- |
|
|