6 [% USE TablesSettings %]
7 [% PROCESS 'i18n.inc' %]
8 [% INCLUDE 'doc-head-open.inc' %]
10 Curbside pickup › Administration › Koha
12 [% INCLUDE 'doc-head-close.inc' %]
15 border: 2px solid #b9d8d9;
22 <body id="admin_curbside_pickup" class="admin">
23 [% WRAPPER 'header.inc' %]
24 [% INCLUDE 'prefs-admin-search.inc' %]
27 [% USE format_minutes = format('%02d') %]
28 [% MACRO minutes_format BLOCK %][% IF m != "" %][% format_minutes(m) | html %][% END %][% END %]
29 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
32 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
35 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
39 <a href="#" aria-current="page">
46 <div class="main container-fluid">
48 <div class="col-sm-10 col-sm-push-2">
51 [% FOR m IN messages %]
52 <div class="dialog [% m.type | html %]">
55 <span>[% m.code | html %]</span>
62 <h1>Curbside pickup configuration</h1>
64 [% UNLESS Koha.Preference('CurbsidePickup') %]
65 [% SET pref_CurbsidePickup_link = '<a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CurbsidePickup">CurbsidePickup</a>' %]
66 <div class="dialog message">The [% pref_CurbsidePickup_link | $raw | $KohaSpan %] preference is not enabled, do not forget to enable it to turn the feature on.</div>
68 <form method="post" class="form">
69 <div id="curbside_pickup_tabs" class="toptabs">
70 <ul class="nav nav-tabs" role="tablist">
71 [% FOREACH l IN libraries %]
73 <li role="presentation" class="active">
75 <li role="presentation">
77 <a href="#conf-[% l.branchcode | uri %]" aria-controls="conf-[% l.branchcode | html %]" role="tab" data-toggle="tab">[% l.branchname | html %]</a>
82 <div class="tab-content">
83 [% FOREACH l IN libraries %]
84 [% SET branchcode = l.branchcode %]
86 <div id="conf-[% l.branchcode | html %]" role="tabpanel" class="tab-pane active">
88 <div id="conf-[% l.branchcode | html %]" role="tabpanel" class="tab-pane">
90 <fieldset class="rows" style="float: none;">
93 <label for="enable-[% l.branchcode | html %]">Enable: </label>
94 [% IF policies.$branchcode.enabled %]
95 <input name="enable-[% l.branchcode | html %]" id="enable-[% l.branchcode | html %]" value="1" type="checkbox" checked>
97 <input name="enable-[% l.branchcode | html %]" id="enable-[% l.branchcode | html %]" value="1" type="checkbox">
99 <span class="hint">Enable curbside pickup.<span>
103 <label for="interval-[% l.branchcode | html %]">Pickup interval: </label>
104 <input name="interval-[% l.branchcode | html %]" id="interval-[% l.branchcode | html %]" value="[% policies.$branchcode.pickup_interval | html %]" type="text">
105 <span class="hint">Number of minutes each curbside pickup interaction will take.</span>
109 <label for="max-per-interval-[% l.branchcode | html %]">Maximum patrons per interval: </label>
110 <input name="max-per-interval-[% l.branchcode | html %]" id="max-per-interval-[% l.branchcode | html %]" value="[% policies.$branchcode.patrons_per_interval | html %]" type="text">
111 <span class="hint">Maximum number of simultaneous pickups per interval.</span>
115 <label for="patron-scheduled-[% l.branchcode | html %]">Patron-scheduled pickup: </label>
116 [% IF policies.$branchcode.patron_scheduled_pickup %]
117 <input name="patron-scheduled-[% l.branchcode | html %]" id="patron-scheduled-[% l.branchcode | html %]" value="1" type="checkbox" checked>
119 <input name="patron-scheduled-[% l.branchcode | html %]" id="patron-scheduled-[% l.branchcode | html %]" value="1" type="checkbox">
121 <span class="hint">Enable patrons to schedule their own curbside pickups.</span>
125 <label for="enable-waiting-holds-only-[% l.branchcode | html %]">Enable for waiting holds only: </label>
126 [% IF policies.$branchcode.enable_waiting_holds_only %]
127 <input name="enable-waiting-holds-only-[% l.branchcode | html %]" id="enable-waiting-holds-only-[% l.branchcode | html %]" value="1" type="checkbox" checked>
129 <input name="enable-waiting-holds-only-[% l.branchcode | html %]" id="enable-waiting-holds-only-[% l.branchcode | html %]" value="1" type="checkbox">
131 <span class="hint">Enable only if the patron has waiting holds.</span>
136 <fieldset class="rows" style="float: none;">
137 <legend>Curbside pickup hours</legend>
139 <em>Times should be in 24-hour format (00:00 to 23:59).</em>
141 <ol class="pickup_hours"></ol>
145 <label>New slot:</label>
146 [% days = { "0" = t("Sunday"), "1" = t("Monday"), "2" = t("Tuesday"), "3" = t("Wednesday"), "4" = t("Thursday"), "5" = t("Friday"), "6" = t("Saturday") } %]
147 [% SET CalendarFirstDayOfWeek = Koha.Preference("CalendarFirstDayOfWeek") %]
149 <select id="day-[% l.branchcode | html %]">
150 [% FOR i IN [0, 1, 2, 3, 4, 5, 6] %]
151 [% SET d = ( CalendarFirstDayOfWeek + i ) % 7 %]
152 <option value="[% d | html %]">[% days.$d | html %]</option>
156 From <input type="text" size="5" class="noEnterSubmit" id="new-start-[% l.branchcode | html %]" placeholder="00:00" />
157 to <input type="text" size="5" class="noEnterSubmit" id="new-end-[% l.branchcode | html %]" placeholder="23:55" />
159 <input type="button" class="add-new-slot" data-branchcode="[% l.branchcode | html %]" value="Add" />
160 <span id="invalid_slot_warning" style="display:none;">Invalid format for this new slot, must be '00:00 to 23:59'.</span>
171 <input type="hidden" name="op" value="save" />
173 <fieldset class="action">
174 <input type="submit" class="btn btn-primary" value="Save configuration" />
180 </div> <!-- /.col-sm-10.col-sm-push-2 -->
182 <div class="col-sm-2 col-sm-pull-10">
184 [% INCLUDE 'admin-menu.inc' %]
186 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
187 </div> <!-- /.row -->
189 [% MACRO jsinclude BLOCK %]
190 [% Asset.js("js/admin-menu.js") | $raw %]
193 let opening_slots = {};
195 [% FOR l IN libraries %]
196 [% SET branchcode = l.branchcode %]
198 [% FOR p IN policies.$branchcode.opening_slots %]
199 slots.push('%s-%s-%s'.format("[% p.day | html %]", format_hhmm("[% p.start_hour | html %]:[% p.start_minute | html %]"), format_hhmm("[% p.end_hour | html %]:[% p.end_minute | html %]")));
201 opening_slots["[% l.branchcode | html %]"] = slots;
204 function format_hhmm(hhmm){
206 [ hh, mm ] = hhmm.split(':');
207 return String(hh).padStart(2, '0') + ':' + String(mm).padStart(2, '0');
209 function format_slot(slot){
211 [ day, start, end ] = slot.split("-");
212 return format_hhmm(start) + _(" to ") + format_hhmm(end);
214 function delete_slot(node, branchcode){
215 let slot = $(node).find('input').val();
216 opening_slots[branchcode] = $.grep(opening_slots[branchcode], function(elt, index) {
219 refresh_pickup_hours(branchcode);
221 function refresh_pickup_hours(branchcode) {
222 let slots_per_day = {};
223 opening_slots[branchcode].forEach(function(slot){
225 [ day, start, end ] = slot.split("-");
226 if(!slots_per_day[day]) slots_per_day[day] = [];
227 slots_per_day[day].push(slot);
230 $("#conf-"+branchcode).find(".pickup_hours li").remove();
232 const CalendarFirstDayOfWeek = [% Koha.Preference("CalendarFirstDayOfWeek") || 0 | html %];
233 [0, 1, 2, 3, 4, 5, 6]
234 .map(i => ( CalendarFirstDayOfWeek + i ) % 7)
235 .filter(d => d in slots_per_day)
237 let li_node = $('<li><label>'+get_day_lib(day)+'<label></li>');
238 slots_per_day[day].forEach(function(slot) {
239 let span_node = $('<span class="pickup-slot"></span>');
240 span_node.append('<input type="hidden" name="pickup-slot-'+branchcode+'" value="'+slot+'"/>');
241 span_node.append('<span>'+format_slot(slot)+'</span>');
243 let delete_link = $('<a href="#" on> <i class="fa fa-trash" aria-hidden="true" title="%s"></i>'.format(_("Remove this slot"))).on('click', function(e){ e.preventDefault(); delete_slot($(this).closest('li'), branchcode); });
244 span_node.append(delete_link);
246 span_node.appendTo(li_node);
248 li_node.appendTo($("#conf-"+branchcode).find(".pickup_hours"));
251 function get_day_lib(day){
264 lib = _("Wednesday");
279 $(document).ready(function(){
280 [% FOR l IN libraries %]
281 refresh_pickup_hours("[% l.branchcode | html %]");
284 $(".add-new-slot").on("click", function(){
285 let branchcode = $(this).data('branchcode');
286 let day = $("#day-" + branchcode).val();
287 let start = $("#new-start-" + branchcode).val();
288 let end = $("#new-end-" + branchcode).val();
290 let start_hour, start_minute, end_hour, end_minute;
291 [ start_hour, start_minute ] = start.split(":");
292 [ end_hour, end_minute ] = end.split(":");
293 if ( start_hour === undefined
294 || start_minute === undefined
295 || end_hour === undefined
296 || end_minute === undefined
297 || isNaN(parseInt(start_hour))
298 || isNaN(parseInt(end_hour))
299 || isNaN(parseInt(start_minute))
300 || isNaN(parseInt(end_minute))
301 || start_hour > 23 || start_minute > 59
302 || end_hour > 23 || end_minute > 59
304 $("#invalid_slot_warning").show();
307 $("#invalid_slot_warning").hide();
310 let new_slot = day + '-' + start + '-' + end;
311 if ( opening_slots[branchcode].indexOf(new_slot) < 0 )
312 opening_slots[branchcode].push(new_slot);
314 refresh_pickup_hours(branchcode);
319 [% INCLUDE 'intranet-bottom.inc' %]