|
Lines 454-495
Link Here
|
| 454 |
</script> |
454 |
</script> |
| 455 |
<script> |
455 |
<script> |
| 456 |
function holidayOperation(formObject, opType) { |
456 |
function holidayOperation(formObject, opType) { |
| 457 |
var op = document.getElementsByName('operation'); |
457 |
var op = document.getElementsByName("operation"); |
| 458 |
op[0].value = opType; |
458 |
op[0].value = opType; |
| 459 |
formObject.submit(); |
459 |
formObject.submit(); |
| 460 |
} |
460 |
} |
| 461 |
|
461 |
|
| 462 |
// This function shows the "Show Holiday" panel // |
462 |
// This function shows the "Show Holiday" panel // |
| 463 |
function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) { |
463 |
function showHoliday(exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) { |
| 464 |
$("#newHoliday").slideUp("fast"); |
464 |
$("#newHoliday").slideUp("fast"); |
| 465 |
$("#showHoliday").slideDown("fast"); |
465 |
$("#showHoliday").slideDown("fast"); |
| 466 |
$('#showDaynameOutput').html(dayName); |
466 |
$("#showDaynameOutput").html(dayName); |
| 467 |
$('#showDayname').val(dayName); |
467 |
$("#showDayname").val(dayName); |
| 468 |
$('#showBranchNameOutput').html($("#branch :selected").text()); |
468 |
$("#showBranchNameOutput").html($("#branch :selected").text()); |
| 469 |
$('#showBranchName').val($("#branch").val()); |
469 |
$("#showBranchName").val($("#branch").val()); |
| 470 |
$('#showDayOutput').html(day); |
470 |
$("#showDayOutput").html(day); |
| 471 |
$('#showDay').val(day); |
471 |
$("#showDay").val(day); |
| 472 |
$('#showMonthOutput').html(month); |
472 |
$("#showMonthOutput").html(month); |
| 473 |
$('#showMonth').val(month); |
473 |
$("#showMonth").val(month); |
| 474 |
$('#showYearOutput').html(year); |
474 |
$("#showYearOutput").html(year); |
| 475 |
$('#showYear').val(year); |
475 |
$("#showYear").val(year); |
| 476 |
$('#showDescription').val(description); |
476 |
$("#showDescription").val(description); |
| 477 |
$('#showWeekday:first').val(weekDay); |
477 |
$("#showWeekday:first").val(weekDay); |
| 478 |
$('#showTitle').val(title); |
478 |
$("#showTitle").val(title); |
| 479 |
$('#showHolidayType').val(holidayType); |
479 |
$("#showHolidayType").val(holidayType); |
| 480 |
|
480 |
|
| 481 |
if (holidayType == 'exception') { |
481 |
if (holidayType == "exception") { |
| 482 |
$("#showOperationDelLabel").html(_("Delete this exception.")); |
482 |
$("#showOperationDelLabel").html(_("Delete this exception.")); |
| 483 |
$("#holtype").attr("class","key exception").html(_("Holiday exception")); |
483 |
$("#holtype").attr("class", "key exception").html(_("Holiday exception")); |
| 484 |
} else if(holidayType == 'weekday') { |
484 |
} else if (holidayType == "weekday") { |
| 485 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
485 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
| 486 |
$("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly")); |
486 |
$("#holtype").attr("class", "key repeatableweekly").html(_("Holiday repeating weekly")); |
| 487 |
} else if(holidayType == 'daymonth') { |
487 |
} else if (holidayType == "daymonth") { |
| 488 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
488 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
| 489 |
$("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly")); |
489 |
$("#holtype").attr("class", "key repeatableyearly").html(_("Holiday repeating yearly")); |
| 490 |
} else { |
490 |
} else { |
| 491 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
491 |
$("#showOperationDelLabel").html(_("Delete this holiday.")); |
| 492 |
$("#holtype").attr("class","key holiday").html(_("Unique holiday")); |
492 |
$("#holtype").attr("class", "key holiday").html(_("Unique holiday")); |
| 493 |
} |
493 |
} |
| 494 |
|
494 |
|
| 495 |
if (exceptionPossibility == 1) { |
495 |
if (exceptionPossibility == 1) { |
|
Lines 500-512
Link Here
|
| 500 |
} |
500 |
} |
| 501 |
|
501 |
|
| 502 |
// This function shows the "Add Holiday" panel // |
502 |
// This function shows the "Add Holiday" panel // |
| 503 |
function newHoliday (dayName, day, month, year, weekDay) { |
503 |
function newHoliday(dayName, day, month, year, weekDay) { |
| 504 |
$("#showHoliday").slideUp("fast"); |
504 |
$("#showHoliday").slideUp("fast"); |
| 505 |
$("#newHoliday").slideDown("fast"); |
505 |
$("#newHoliday").slideDown("fast"); |
| 506 |
$("#newDaynameOutput").html(dayName); |
506 |
$("#newDaynameOutput").html(dayName); |
| 507 |
$("#newDayname").val(dayName); |
507 |
$("#newDayname").val(dayName); |
| 508 |
$("#newBranchNameOutput").html($('#branch :selected').text()); |
508 |
$("#newBranchNameOutput").html($("#branch :selected").text()); |
| 509 |
$("#newBranchName").val($('#branch').val()); |
509 |
$("#newBranchName").val($("#branch").val()); |
| 510 |
$("#newDayOutput").html(day); |
510 |
$("#newDayOutput").html(day); |
| 511 |
$("#newDay").val(day); |
511 |
$("#newDay").val(day); |
| 512 |
$("#newMonthOutput").html(month); |
512 |
$("#newMonthOutput").html(month); |
|
Lines 517-619
Link Here
|
| 517 |
} |
517 |
} |
| 518 |
|
518 |
|
| 519 |
function hidePanel(aPanelName) { |
519 |
function hidePanel(aPanelName) { |
| 520 |
$("#"+aPanelName).slideUp("fast"); |
520 |
$("#" + aPanelName).slideUp("fast"); |
| 521 |
} |
521 |
} |
| 522 |
|
522 |
|
| 523 |
function changeBranch () { |
523 |
function changeBranch() { |
| 524 |
var branch = $("#branch option:selected").val(); |
524 |
var branch = $("#branch option:selected").val(); |
| 525 |
location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + calendardate; |
525 |
location.href = "/cgi-bin/koha/tools/holidays.pl?branch=" + branch + "&calendardate=" + calendardate; |
| 526 |
} |
526 |
} |
| 527 |
|
527 |
|
| 528 |
/** |
528 |
/** |
| 529 |
* Build settings to be passed to the formatDay function for each day in the calendar |
529 |
* Build settings to be passed to the formatDay function for each day in the calendar |
| 530 |
* @param {object} dayElem - HTML node passed from Flatpickr |
530 |
* @param {object} dayElem - HTML node passed from Flatpickr |
| 531 |
* @return {void} |
531 |
* @return {void} |
| 532 |
*/ |
532 |
*/ |
| 533 |
function dateStatusHandler( dayElem ) { |
533 |
function dateStatusHandler(dayElem) { |
| 534 |
var day = dayElem.dateObj.getDate(); |
534 |
var day = dayElem.dateObj.getDate(); |
| 535 |
var month = dayElem.dateObj.getMonth() + 1; |
535 |
var month = dayElem.dateObj.getMonth() + 1; |
| 536 |
var year = dayElem.dateObj.getFullYear(); |
536 |
var year = dayElem.dateObj.getFullYear(); |
| 537 |
var weekDay = dayElem.dateObj.getDay(); |
537 |
var weekDay = dayElem.dateObj.getDay(); |
| 538 |
var dayMonth = month + '/' + day; |
538 |
var dayMonth = month + "/" + day; |
| 539 |
var dateString = year + '/' + month + '/' + day; |
539 |
var dateString = year + "/" + month + "/" + day; |
| 540 |
if (exception_holidays[dateString] != null) { |
540 |
if (exception_holidays[dateString] != null) { |
| 541 |
formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem ); |
541 |
formatDay(["exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem); |
| 542 |
} else if ( week_days[weekDay] != null ){ |
542 |
} else if (week_days[weekDay] != null) { |
| 543 |
formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem ); |
543 |
formatDay(["repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem); |
| 544 |
} else if ( day_month_holidays[dayMonth] != null ) { |
544 |
} else if (day_month_holidays[dayMonth] != null) { |
| 545 |
formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem ); |
545 |
formatDay(["repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem); |
| 546 |
} else if (holidays[dateString] != null) { |
546 |
} else if (holidays[dateString] != null) { |
| 547 |
formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem ); |
547 |
formatDay(["holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem); |
| 548 |
} else { |
548 |
} else { |
| 549 |
formatDay( [ "normalday", _("Normal day")], dayElem ); |
549 |
formatDay(["normalday", _("Normal day")], dayElem); |
| 550 |
} |
550 |
} |
| 551 |
} |
551 |
} |
| 552 |
|
552 |
|
| 553 |
/** |
553 |
/** |
| 554 |
* Adds style and title attribute to a day on the calendar |
554 |
* Adds style and title attribute to a day on the calendar |
| 555 |
* @param {object} settings - span class attribute ([0]) and title attribute ([1]) |
555 |
* @param {object} settings - span class attribute ([0]) and title attribute ([1]) |
| 556 |
* @param {node} dayElem - HTML node passed from Flatpickr |
556 |
* @param {node} dayElem - HTML node passed from Flatpickr |
| 557 |
* @return {void} |
557 |
* @return {void} |
| 558 |
*/ |
558 |
*/ |
| 559 |
function formatDay( settings, dayElem ){ |
559 |
function formatDay(settings, dayElem) { |
| 560 |
$(dayElem).attr("title", settings[1]).addClass( settings[0]); |
560 |
$(dayElem).attr("title", settings[1]).addClass(settings[0]); |
| 561 |
} |
561 |
} |
| 562 |
|
562 |
|
| 563 |
/** |
563 |
/** |
| 564 |
* Triggers an action based on a click on a calendar day: If a holiday exists on |
564 |
* Triggers an action based on a click on a calendar day: If a holiday exists on |
| 565 |
* that day it loads an edit form. If there is no existing holiday one can be created |
565 |
* that day it loads an edit form. If there is no existing holiday one can be created |
| 566 |
* @param {object} calendar - a Date object corresponding to the clicked day |
566 |
* @param {object} calendar - a Date object corresponding to the clicked day |
| 567 |
* @return {void} |
567 |
* @return {void} |
| 568 |
*/ |
568 |
*/ |
| 569 |
function dateChanged( calendar ) { |
569 |
function dateChanged(calendar) { |
| 570 |
var day = calendar.getDate(); |
570 |
var day = calendar.getDate(); |
| 571 |
var month = calendar.getMonth() + 1; |
571 |
var month = calendar.getMonth() + 1; |
| 572 |
var year = calendar.getFullYear(); |
572 |
var year = calendar.getFullYear(); |
| 573 |
var weekDay = calendar.getDay(); |
573 |
var weekDay = calendar.getDay(); |
| 574 |
var dayName = weekdays[weekDay]; |
574 |
var dayName = weekdays[weekDay]; |
| 575 |
var dayMonth = month + '/' + day; |
575 |
var dayMonth = month + "/" + day; |
| 576 |
var dateString = year + '/' + month + '/' + day; |
576 |
var dateString = year + "/" + month + "/" + day; |
| 577 |
if (holidays[dateString] != null) { |
577 |
if (holidays[dateString] != null) { |
| 578 |
showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd'); |
578 |
showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, "ymd"); |
| 579 |
} else if (exception_holidays[dateString] != null) { |
579 |
} else if (exception_holidays[dateString] != null) { |
| 580 |
showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception'); |
580 |
showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, "exception"); |
| 581 |
} else if (week_days[weekDay] != null) { |
581 |
} else if (week_days[weekDay] != null) { |
| 582 |
showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday'); |
582 |
showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, "weekday"); |
| 583 |
} else if (day_month_holidays[dayMonth] != null) { |
583 |
} else if (day_month_holidays[dayMonth] != null) { |
| 584 |
showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth'); |
584 |
showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, "daymonth"); |
| 585 |
} else { |
585 |
} else { |
| 586 |
newHoliday(dayName, day, month, year, weekDay); |
586 |
newHoliday(dayName, day, month, year, weekDay); |
| 587 |
} |
587 |
} |
| 588 |
}; |
588 |
} |
| 589 |
|
589 |
|
| 590 |
/* Custom table search configuration: If a table row |
590 |
/* Custom table search configuration: If a table row |
| 591 |
has an "expired" class, hide it UNLESS the |
591 |
has an "expired" class, hide it UNLESS the |
| 592 |
show_expired checkbox is checked */ |
592 |
show_expired checkbox is checked */ |
| 593 |
$.fn.dataTable.ext.search.push( |
593 |
$.fn.dataTable.ext.search.push(function (settings, searchData, index, rowData, counter) { |
| 594 |
function( settings, searchData, index, rowData, counter ) { |
594 |
var table = settings.nTable.id; |
| 595 |
var table = settings.nTable.id; |
595 |
var row = $(settings.aoData[index].nTr); |
| 596 |
var row = $(settings.aoData[index].nTr); |
596 |
if (row.hasClass("date_past") && !$("#show_past_" + table).prop("checked")) { |
| 597 |
if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){ |
597 |
return false; |
| 598 |
return false; |
598 |
} else { |
| 599 |
} else { |
599 |
return true; |
| 600 |
return true; |
|
|
| 601 |
} |
| 602 |
} |
600 |
} |
| 603 |
); |
601 |
}); |
| 604 |
|
602 |
|
| 605 |
// Create current date variable |
603 |
// Create current date variable |
| 606 |
var date = new Date(); |
604 |
var date = new Date(); |
| 607 |
var datestring = date.toISOString().substring(0, 10); |
605 |
var datestring = date.toISOString().substring(0, 10); |
| 608 |
|
606 |
|
| 609 |
$(document).ready(function() { |
607 |
$(document).ready(function () { |
| 610 |
|
|
|
| 611 |
$(".helptext + .hint").hide(); |
608 |
$(".helptext + .hint").hide(); |
| 612 |
$("#branch").change(function(){ |
609 |
$("#branch").change(function () { |
| 613 |
changeBranch(); |
610 |
changeBranch(); |
| 614 |
}); |
611 |
}); |
| 615 |
$("#holidayweeklyrepeatable>tbody>tr").each(function(){ |
612 |
$("#holidayweeklyrepeatable>tbody>tr").each(function () { |
| 616 |
var first_td = $(this).find('td').first(); |
613 |
var first_td = $(this).find("td").first(); |
| 617 |
first_td.html(weekdays[first_td.html()]); |
614 |
first_td.html(weekdays[first_td.html()]); |
| 618 |
}); |
615 |
}); |
| 619 |
$("#holidayweeklyrepeatable").kohaTable({ |
616 |
$("#holidayweeklyrepeatable").kohaTable({ |
|
Lines 636-696
Link Here
|
| 636 |
$("#holidaysunique").kohaTable(dt_params); |
633 |
$("#holidaysunique").kohaTable(dt_params); |
| 637 |
|
634 |
|
| 638 |
let exceptions_table = $("#holidayexceptions").DataTable(); |
635 |
let exceptions_table = $("#holidayexceptions").DataTable(); |
| 639 |
let unique_table = $("#holidaysunique").DataTable(); |
636 |
let unique_table = $("#holidaysunique").DataTable(); |
| 640 |
|
637 |
|
| 641 |
$(".show_past").on("change", function(){ |
638 |
$(".show_past").on("change", function () { |
| 642 |
exceptions_table.draw(); |
639 |
exceptions_table.draw(); |
| 643 |
unique_table.draw(); |
640 |
unique_table.draw(); |
| 644 |
}); |
641 |
}); |
| 645 |
|
642 |
|
| 646 |
$("a.helptext").click(function(){ |
643 |
$("a.helptext").click(function () { |
| 647 |
$(this).parent().find(".helptext + .hint").toggle(); return false; |
644 |
$(this).parent().find(".helptext + .hint").toggle(); |
|
|
645 |
return false; |
| 648 |
}); |
646 |
}); |
| 649 |
|
647 |
|
| 650 |
const dateofrange = document.querySelector("#dateofrange")._flatpickr; |
648 |
const dateofrange = document.querySelector("#dateofrange")._flatpickr; |
| 651 |
const datecancelrange = document.querySelector("#datecancelrange")._flatpickr; |
649 |
const datecancelrange = document.querySelector("#datecancelrange")._flatpickr; |
| 652 |
|
650 |
|
| 653 |
$("#dateofrange").each(function () { this.value = "" }); |
651 |
$("#dateofrange").each(function () { |
| 654 |
$("#datecancelrange").each(function () { this.value = "" }); |
652 |
this.value = ""; |
|
|
653 |
}); |
| 654 |
$("#datecancelrange").each(function () { |
| 655 |
this.value = ""; |
| 656 |
}); |
| 655 |
|
657 |
|
| 656 |
var maincalendar = $("#calendar-anchor").flatpickr({ |
658 |
var maincalendar = $("#calendar-anchor").flatpickr({ |
| 657 |
inline: true, |
659 |
inline: true, |
| 658 |
onReady: function( selectedDates, dateStr, instance ){ |
660 |
onReady: function (selectedDates, dateStr, instance) { |
| 659 |
// We do not want to display the 'close' icon in this case |
661 |
// We do not want to display the 'close' icon in this case |
| 660 |
$(instance.input).siblings('.flatpickr-input').hide(); |
662 |
$(instance.input).siblings(".flatpickr-input").hide(); |
| 661 |
}, |
663 |
}, |
| 662 |
onDayCreate: function( dObj, dStr, fp, dayElem ){ |
664 |
onDayCreate: function (dObj, dStr, fp, dayElem) { |
| 663 |
/* for each day on the calendar, get the |
665 |
/* for each day on the calendar, get the |
| 664 |
correct status information for the date */ |
666 |
correct status information for the date */ |
| 665 |
dateStatusHandler( dayElem ); |
667 |
dateStatusHandler(dayElem); |
| 666 |
}, |
668 |
}, |
| 667 |
onChange: function( selectedDates, dateStr, instance ){ |
669 |
onChange: function (selectedDates, dateStr, instance) { |
| 668 |
var fromdate = selectedDates[0]; |
670 |
var fromdate = selectedDates[0]; |
| 669 |
var enddate = dateofrange.selectedDates[0]; |
671 |
var enddate = dateofrange.selectedDates[0]; |
| 670 |
|
672 |
|
| 671 |
dateChanged( fromdate ); |
673 |
dateChanged(fromdate); |
| 672 |
|
674 |
|
| 673 |
dateofrange.set( 'defaultDate', fromdate ); |
675 |
dateofrange.set("defaultDate", fromdate); |
| 674 |
dateofrange.set( 'minDate', fromdate ); |
676 |
dateofrange.set("minDate", fromdate); |
| 675 |
|
677 |
|
| 676 |
if ( enddate != undefined ) { |
678 |
if (enddate != undefined) { |
| 677 |
if ( enddate < fromdate ) { |
679 |
if (enddate < fromdate) { |
| 678 |
dateofrange.set("defaultDate", fromdate); |
680 |
dateofrange.set("defaultDate", fromdate); |
| 679 |
dateofrange.setDate(fromdate); |
681 |
dateofrange.setDate(fromdate); |
| 680 |
} |
682 |
} |
| 681 |
} |
683 |
} |
| 682 |
|
|
|
| 683 |
}, |
684 |
}, |
| 684 |
defaultDate: new Date(keydate); |
685 |
defaultDate: new Date(keydate), |
| 685 |
}); |
686 |
}); |
| 686 |
|
687 |
|
| 687 |
$(".hidePanel").on("click",function(){ |
688 |
$(".hidePanel").on("click", function () { |
| 688 |
if( $(this).hasClass("showHoliday") ){ |
689 |
if ($(this).hasClass("showHoliday")) { |
| 689 |
hidePanel("showHoliday"); |
690 |
hidePanel("showHoliday"); |
| 690 |
} else { |
691 |
} else { |
| 691 |
hidePanel("newHoliday"); |
692 |
hidePanel("newHoliday"); |
| 692 |
} |
693 |
} |
| 693 |
}) |
694 |
}); |
| 694 |
}); |
695 |
}); |
| 695 |
</script> |
696 |
</script> |
| 696 |
[% END %] |
697 |
[% END %] |
| 697 |
- |
|
|