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