Lines 301-343
Link Here
|
301 |
</tr> |
301 |
</tr> |
302 |
</thead> |
302 |
</thead> |
303 |
<tbody> |
303 |
<tbody> |
304 |
[% IF library.library_hours # Existing library %] |
304 |
[% SET CalendarFirstDayOfWeek = Koha.Preference("CalendarFirstDayOfWeek") %] |
305 |
[% daycount = 0 %] |
305 |
[% IF library.library_hours.count > 0 # Existing hours %] |
306 |
[% FOREACH hr IN library.library_hours %] |
306 |
[% SET library_hours = library.library_hours.as_list %] |
307 |
<tr id="hours_[% daycount | html %]"> |
307 |
|
|
|
308 |
[% FOR i IN [0..6] %] |
309 |
[% SET d = ( CalendarFirstDayOfWeek + i ) % 7 %] |
310 |
[% SET hr = library_hours.$d %] |
311 |
<tr id="hours_[% d | html %]"> |
308 |
<td> |
312 |
<td> |
309 |
[% PROCESS dayname day=daycount %] |
313 |
[% PROCESS dayname day=d %] |
310 |
<input type="hidden" value="[% daycount | html %]" name="day"> |
314 |
<input type="hidden" value="[% d | html %]" name="day"> |
311 |
</td> |
315 |
</td> |
312 |
<td> |
316 |
<td> |
313 |
[% IF hr.day == daycount && hr.open_time %] |
317 |
[% IF hr.open_time %] |
314 |
<input type="time" value="[% hr.open_time | html %]" name="open_time"> |
318 |
<input type="text" size="5" value="[% hr.open_time | html %]" name="open_time" class="flatpickr" data-flatpickr-time-only="true"> |
315 |
[% ELSE %] |
319 |
[% ELSE %] |
316 |
<input type="time" value="" name="open_time"> |
320 |
<input type="text" size="5" value="" name="open_time" class="flatpickr" data-flatpickr-time-only="true"> |
317 |
[% END %] |
321 |
[% END %] |
318 |
</td> |
322 |
</td> |
319 |
<td> |
323 |
<td> |
320 |
[% IF hr.day == daycount && hr.close_time %] |
324 |
[% IF hr.close_time %] |
321 |
<input type="time" value="[% hr.close_time | html %]" name="close_time"> |
325 |
<input type="text" size="5" value="[% hr.close_time | html %]" name="close_time" class="flatpickr" data-flatpickr-time-only="true"> |
322 |
[% ELSE %] |
326 |
[% ELSE %] |
323 |
<input type="time" value="" name="close_time"> |
327 |
<input type="text" size="5" value="" name="close_time" class="flatpickr" data-flatpickr-time-only="true"> |
324 |
[% END %] |
328 |
[% END %] |
325 |
</td> |
329 |
</td> |
326 |
</tr> |
330 |
</tr> |
327 |
[% daycount = daycount+1 %] |
|
|
328 |
[% END %] |
331 |
[% END %] |
329 |
[% ELSE # New library %] |
332 |
[% ELSE # New hours %] |
330 |
[% FOREACH daycount IN [0..6] %] |
333 |
[% FOR i IN [0..6] %] |
331 |
<tr id="hours_[% day | html %]"> |
334 |
[% SET d = ( CalendarFirstDayOfWeek + i ) % 7 %] |
|
|
335 |
<tr id="hours_[% d | html %]"> |
332 |
<td> |
336 |
<td> |
333 |
[% PROCESS dayname day=daycount %] |
337 |
[% PROCESS dayname day=d %] |
334 |
<input type="hidden" value="[% daycount | html %]" name="day"> |
338 |
<input type="hidden" value="[% d | html %]" name="day"> |
335 |
</td> |
339 |
</td> |
336 |
<td> |
340 |
<td> |
337 |
<input type="time" value="" name="open_time"> |
341 |
<input type="text" size="5" name="open_time" class="noEnterSubmit flatpickr" data-flatpickr-time-only="true"> |
338 |
</td> |
342 |
</td> |
339 |
<td> |
343 |
<td> |
340 |
<input type="time" value="" name="close_time"> |
344 |
<input type="text" size="5" name="close_time" class="noEnerSubmit flatpickr" data-flatpickr-time-only="true"> |
341 |
</td> |
345 |
</td> |
342 |
</tr> |
346 |
</tr> |
343 |
[% END %] |
347 |
[% END %] |
Lines 372-390
Link Here
|
372 |
|
376 |
|
373 |
[% BLOCK dayname %] |
377 |
[% BLOCK dayname %] |
374 |
[% IF day == 0 %] |
378 |
[% IF day == 0 %] |
375 |
<span>Monday</span> |
379 |
<span>Sunday</span> |
376 |
[% ELSIF day == 1 %] |
380 |
[% ELSIF day == 1 %] |
377 |
<span>Tuesday</span> |
381 |
<span>Monday</span> |
378 |
[% ELSIF day == 2 %] |
382 |
[% ELSIF day == 2 %] |
379 |
<span>Wednesday</span> |
383 |
<span>Tuesday</span> |
380 |
[% ELSIF day == 3 %] |
384 |
[% ELSIF day == 3 %] |
381 |
<span>Thursday</span> |
385 |
<span>Wednesday</span> |
382 |
[% ELSIF day == 4 %] |
386 |
[% ELSIF day == 4 %] |
383 |
<span>Friday</span> |
387 |
<span>Thursday</span> |
384 |
[% ELSIF day == 5 %] |
388 |
[% ELSIF day == 5 %] |
385 |
<span>Saturday</span> |
389 |
<span>Friday</span> |
386 |
[% ELSE %] |
390 |
[% ELSE %] |
387 |
<span>Sunday</span> |
391 |
<span>Saturday</span> |
388 |
[% END %] |
392 |
[% END %] |
389 |
[% END %] |
393 |
[% END %] |
390 |
|
394 |
|
Lines 552-558
Link Here
|
552 |
</li> |
556 |
</li> |
553 |
<li> |
557 |
<li> |
554 |
<span class="label">Opening hours: </span> |
558 |
<span class="label">Opening hours: </span> |
555 |
[% IF library.library_hours # Existing library %] |
559 |
[% IF library.library_hours.count > 0 # Existing library %] |
|
|
560 |
[% SET library_hours = library.library_hours.as_list %] |
556 |
<table id="library_hours_table"> |
561 |
<table id="library_hours_table"> |
557 |
<thead> |
562 |
<thead> |
558 |
<tr> |
563 |
<tr> |
Lines 562-572
Link Here
|
562 |
</tr> |
567 |
</tr> |
563 |
</thead> |
568 |
</thead> |
564 |
<tbody> |
569 |
<tbody> |
565 |
[% daycount = 0 %] |
570 |
[% FOR i IN [0..6] %] |
566 |
[% FOREACH hr IN library.library_hours %] |
571 |
[% SET d = ( CalendarFirstDayOfWeek + i) % 7 %] |
567 |
<tr id="hours_[% daycount | html %]"> |
572 |
[% SET hr = library_hours.$d %] |
|
|
573 |
<tr id="hours_[% d | html %]"> |
568 |
<td> |
574 |
<td> |
569 |
<span>[% PROCESS dayname day=daycount %]</span> |
575 |
<span>[% PROCESS dayname day=d %]</span> |
570 |
</td> |
576 |
</td> |
571 |
<td> |
577 |
<td> |
572 |
<span>[% hr.open_time | html %]</span> |
578 |
<span>[% hr.open_time | html %]</span> |
Lines 575-581
Link Here
|
575 |
<span>[% hr.close_time | html %]</span> |
581 |
<span>[% hr.close_time | html %]</span> |
576 |
</td> |
582 |
</td> |
577 |
</tr> |
583 |
</tr> |
578 |
[% daycount = daycount+1 %] |
|
|
579 |
[% END %] |
584 |
[% END %] |
580 |
</tbody> |
585 |
</tbody> |
581 |
</table> |
586 |
</table> |
Lines 611-616
Link Here
|
611 |
|
616 |
|
612 |
[% MACRO jsinclude BLOCK %] |
617 |
[% MACRO jsinclude BLOCK %] |
613 |
[% Asset.js("js/admin-menu.js") | $raw %] |
618 |
[% Asset.js("js/admin-menu.js") | $raw %] |
|
|
619 |
[% INCLUDE 'calendar.inc' %] |
614 |
[% INCLUDE 'datatables.inc' %] |
620 |
[% INCLUDE 'datatables.inc' %] |
615 |
[% INCLUDE 'columns_settings.inc' %] |
621 |
[% INCLUDE 'columns_settings.inc' %] |
616 |
[% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] |
622 |
[% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] |
Lines 640-645
Link Here
|
640 |
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %]; |
646 |
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %]; |
641 |
var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl"); |
647 |
var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl"); |
642 |
var updated_settings = get_columns_saved_state(saved_table, table_settings); |
648 |
var updated_settings = get_columns_saved_state(saved_table, table_settings); |
|
|
649 |
var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]'; |
643 |
|
650 |
|
644 |
$(document).ready(function() { |
651 |
$(document).ready(function() { |
645 |
|
652 |
|
Lines 749-766
Link Here
|
749 |
}, |
756 |
}, |
750 |
{ |
757 |
{ |
751 |
"data": function( row, type, val, meta ) { |
758 |
"data": function( row, type, val, meta ) { |
752 |
const daynames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']; |
759 |
let result = ''; |
753 |
var daycount = 0; |
760 |
if ( row.library_hours.length > 0 ) { |
754 |
var result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>'; |
761 |
const daysOfWeek = [ _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday") ]; |
755 |
while ( row.library_hours[daycount] ) { |
762 |
|
756 |
result += '<tr id="hours_'+daycount+'">'; |
763 |
result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>'; |
757 |
result += '<td>'+daynames[daycount]+'</td>'; |
764 |
let counter = 0; |
758 |
result += '<td><span>'+row.library_hours[daycount].open_time+'</span></td>'; |
765 |
for (let i = calendarFirstDayOfWeek; counter < 7; i++) { |
759 |
result += '<td><span>'+row.library_hours[daycount].close_time+'</span></td>'; |
766 |
const day = i % 7; // Wrap around the day using modulo operator |
760 |
result += '</tr>'; |
767 |
result += '<tr id="hours_'+day+'">'; |
761 |
daycount++; |
768 |
result += '<td>'+daysOfWeek[day]+'</td>'; |
|
|
769 |
result += '<td><span>'+row.library_hours[day].open_time+'</span></td>'; |
770 |
result += '<td><span>'+row.library_hours[day].close_time+'</span></td>'; |
771 |
result += '</tr>'; |
772 |
counter++; |
773 |
} |
774 |
result += '</tbody></table>'; |
775 |
} else { |
776 |
result = _("Library hours not set"); |
762 |
} |
777 |
} |
763 |
result += '</tbody></table>'; |
|
|
764 |
return result; |
778 |
return result; |
765 |
}, |
779 |
}, |
766 |
"searchable": false, |
780 |
"searchable": false, |
767 |
- |
|
|