|
Lines 1-130
Link Here
|
| 1 |
[% USE Branches %] |
1 |
[% USE Branches %] |
|
|
2 |
[% SET footerjs = 1 %] |
| 2 |
[% INCLUDE 'doc-head-open.inc' %] |
3 |
[% INCLUDE 'doc-head-open.inc' %] |
| 3 |
<title>Koha › Administration › Circulation and fine rules</title> |
4 |
<title>Koha › Administration › Circulation and fine rules</title> |
| 4 |
[% INCLUDE 'doc-head-close.inc' %] |
5 |
[% INCLUDE 'doc-head-close.inc' %] |
| 5 |
[% INCLUDE 'calendar.inc' %] |
|
|
| 6 |
<script type="text/javascript"> |
| 7 |
//<![CDATA[ |
| 8 |
|
| 9 |
function clear_edit(){ |
| 10 |
var cancel = confirm(_("Are you sure you want to cancel your changes?")); |
| 11 |
if ( !cancel ) return; |
| 12 |
$('#default-circulation-rules td').removeClass('highlighted-row'); |
| 13 |
var edit_row = $("#edit_row"); |
| 14 |
$(edit_row).find("input").each(function(){ |
| 15 |
var type = $(this).attr("type"); |
| 16 |
if (type != "button" && type != "submit" ) { |
| 17 |
$(this).val(""); |
| 18 |
$(this).prop('disabled', false); |
| 19 |
} |
| 20 |
if ( type == "checkbox" ) { |
| 21 |
$(this).prop('checked', false); |
| 22 |
} |
| 23 |
}); |
| 24 |
$(edit_row).find("select").prop('disabled', false); |
| 25 |
$(edit_row).find("select option:first").attr("selected", "selected"); |
| 26 |
$(edit_row).find("td:last input[name='clear']").remove(); |
| 27 |
} |
| 28 |
|
| 29 |
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); |
| 30 |
|
| 31 |
|
| 32 |
$(document).ready(function() { |
| 33 |
$(".delete").on("click",function(){ |
| 34 |
return confirmDelete(MSG_CONFIRM_DELETE); |
| 35 |
}); |
| 36 |
|
| 37 |
$("#clone_rules").on("click",function(){ |
| 38 |
var library_dropdown = document.getElementById("branch"); |
| 39 |
var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value; |
| 40 |
var selected_library_text = $("#branch option:selected").text(); |
| 41 |
var to_library = $("#tobranch option:selected").text(); |
| 42 |
var MSG_CONFIRM_CLONE; |
| 43 |
if (selected_library === "*") { |
| 44 |
MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library); |
| 45 |
return confirmClone(MSG_CONFIRM_CLONE); |
| 46 |
} else { |
| 47 |
MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library); |
| 48 |
return confirmClone(MSG_CONFIRM_CLONE); |
| 49 |
} |
| 50 |
}); |
| 51 |
|
| 52 |
$('#cap_fine_to_replacement_price').on('change', function(){ |
| 53 |
$('#overduefinescap').prop('disabled', $(this).is(':checked') ); |
| 54 |
}); |
| 55 |
$('#selectlibrary').find("input:submit").hide(); |
| 56 |
$('#branch').change(function() { |
| 57 |
$('#selectlibrary').submit(); |
| 58 |
}); |
| 59 |
$(".editrule").click(function(){ |
| 60 |
if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) { |
| 61 |
var edit = confirm(_("Are you sure you want to edit another rule?")); |
| 62 |
if (!edit) return false; |
| 63 |
} |
| 64 |
$('#default-circulation-rules td').removeClass('highlighted-row'); |
| 65 |
$(this).parent().parent().find("td").each(function (i) { |
| 66 |
$(this).addClass('highlighted-row'); |
| 67 |
itm = $(this).text(); |
| 68 |
itm = itm.replace(/^\s*|\s*$/g,''); |
| 69 |
var current_column = $("#edit_row td:eq("+i+")"); |
| 70 |
if ( i == 7 ) { |
| 71 |
// specific processing for the Hard due date column |
| 72 |
var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); |
| 73 |
var input_value = ''; |
| 74 |
if (typeof select_value === 'undefined'){ |
| 75 |
select_value = '-1'; |
| 76 |
}else { |
| 77 |
input_value = itm.split(' ')[1]; |
| 78 |
} |
| 79 |
$(current_column).find("input[type='text']").val(input_value); |
| 80 |
$(current_column).find("select").val(select_value); |
| 81 |
} else if ( i == 13 ) { |
| 82 |
// specific processing for cap_fine_to_replacement_price |
| 83 |
var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); |
| 84 |
$('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); |
| 85 |
$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); |
| 86 |
} else { |
| 87 |
$(current_column).find("input[type='text']").val(itm); |
| 88 |
// select the corresponding option |
| 89 |
$(current_column).find("select option").each(function(){ |
| 90 |
opt = $(this).text().toLowerCase(); |
| 91 |
opt = opt.replace(/^\s*|\s*$/g,''); |
| 92 |
if ( opt == itm.toLowerCase() ) { |
| 93 |
$(this).attr('selected', 'selected'); |
| 94 |
} |
| 95 |
}); |
| 96 |
if ( i == 0 || i == 1 ) { |
| 97 |
// Disable the 2 first columns, we cannot update them. |
| 98 |
var val = $(current_column).find("select option:selected").val(); |
| 99 |
var name = "categorycode"; |
| 100 |
if ( i == 1 ) { |
| 101 |
name="itemtype"; |
| 102 |
} |
| 103 |
// Remove potential previous input added |
| 104 |
$(current_column).find("input").remove(); |
| 105 |
$(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); |
| 106 |
} else if ( i == 3 || i == 4 ) { |
| 107 |
// If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" |
| 108 |
// The value is "Unlimited" (or an equivalent translated string) |
| 109 |
// an it should be set to an empty string |
| 110 |
if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) { |
| 111 |
$(current_column).find("input[type='text']").val(""); |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
}); |
| 116 |
$("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true); |
| 117 |
$("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); |
| 118 |
return false; |
| 119 |
}); |
| 120 |
$(".clear_edit").on("click",function(e){ |
| 121 |
e.preventDefault(); |
| 122 |
clear_edit(); |
| 123 |
}); |
| 124 |
}); |
| 125 |
//]]> |
| 126 |
</script> |
| 127 |
</head> |
6 |
</head> |
|
|
7 |
|
| 128 |
<body id="admin_smart-rules" class="admin"> |
8 |
<body id="admin_smart-rules" class="admin"> |
| 129 |
[% INCLUDE 'header.inc' %] |
9 |
[% INCLUDE 'header.inc' %] |
| 130 |
[% INCLUDE 'prefs-admin-search.inc' %] |
10 |
[% INCLUDE 'prefs-admin-search.inc' %] |
|
Lines 834-837
$(document).ready(function() {
Link Here
|
| 834 |
[% INCLUDE 'admin-menu.inc' %] |
714 |
[% INCLUDE 'admin-menu.inc' %] |
| 835 |
</div> |
715 |
</div> |
| 836 |
</div> |
716 |
</div> |
|
|
717 |
|
| 718 |
[% MACRO jsinclude BLOCK %] |
| 719 |
<script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> |
| 720 |
[% INCLUDE 'calendar.inc' %] |
| 721 |
<script type="text/javascript"> |
| 722 |
|
| 723 |
function clear_edit(){ |
| 724 |
var cancel = confirm(_("Are you sure you want to cancel your changes?")); |
| 725 |
if ( !cancel ) return; |
| 726 |
$('#default-circulation-rules td').removeClass('highlighted-row'); |
| 727 |
var edit_row = $("#edit_row"); |
| 728 |
$(edit_row).find("input").each(function(){ |
| 729 |
var type = $(this).attr("type"); |
| 730 |
if (type != "button" && type != "submit" ) { |
| 731 |
$(this).val(""); |
| 732 |
$(this).prop('disabled', false); |
| 733 |
} |
| 734 |
if ( type == "checkbox" ) { |
| 735 |
$(this).prop('checked', false); |
| 736 |
} |
| 737 |
}); |
| 738 |
$(edit_row).find("select").prop('disabled', false); |
| 739 |
$(edit_row).find("select option:first").attr("selected", "selected"); |
| 740 |
$(edit_row).find("td:last input[name='clear']").remove(); |
| 741 |
} |
| 742 |
|
| 743 |
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); |
| 744 |
|
| 745 |
$(document).ready(function() { |
| 746 |
$(".delete").on("click",function(){ |
| 747 |
return confirmDelete(MSG_CONFIRM_DELETE); |
| 748 |
}); |
| 749 |
|
| 750 |
$("#clone_rules").on("click",function(){ |
| 751 |
var library_dropdown = document.getElementById("branch"); |
| 752 |
var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value; |
| 753 |
var selected_library_text = $("#branch option:selected").text(); |
| 754 |
var to_library = $("#tobranch option:selected").text(); |
| 755 |
var MSG_CONFIRM_CLONE; |
| 756 |
if (selected_library === "*") { |
| 757 |
MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library); |
| 758 |
return confirmClone(MSG_CONFIRM_CLONE); |
| 759 |
} else { |
| 760 |
MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library); |
| 761 |
return confirmClone(MSG_CONFIRM_CLONE); |
| 762 |
} |
| 763 |
}); |
| 764 |
|
| 765 |
$('#cap_fine_to_replacement_price').on('change', function(){ |
| 766 |
$('#overduefinescap').prop('disabled', $(this).is(':checked') ); |
| 767 |
}); |
| 768 |
$('#selectlibrary').find("input:submit").hide(); |
| 769 |
$('#branch').change(function() { |
| 770 |
$('#selectlibrary').submit(); |
| 771 |
}); |
| 772 |
$(".editrule").click(function(){ |
| 773 |
if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) { |
| 774 |
var edit = confirm(_("Are you sure you want to edit another rule?")); |
| 775 |
if (!edit) return false; |
| 776 |
} |
| 777 |
$('#default-circulation-rules td').removeClass('highlighted-row'); |
| 778 |
$(this).parent().parent().find("td").each(function (i) { |
| 779 |
$(this).addClass('highlighted-row'); |
| 780 |
itm = $(this).text(); |
| 781 |
itm = itm.replace(/^\s*|\s*$/g,''); |
| 782 |
var current_column = $("#edit_row td:eq("+i+")"); |
| 783 |
if ( i == 7 ) { |
| 784 |
// specific processing for the Hard due date column |
| 785 |
var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); |
| 786 |
var input_value = ''; |
| 787 |
if (typeof select_value === 'undefined'){ |
| 788 |
select_value = '-1'; |
| 789 |
}else { |
| 790 |
input_value = itm.split(' ')[1]; |
| 791 |
} |
| 792 |
$(current_column).find("input[type='text']").val(input_value); |
| 793 |
$(current_column).find("select").val(select_value); |
| 794 |
} else if ( i == 13 ) { |
| 795 |
// specific processing for cap_fine_to_replacement_price |
| 796 |
var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); |
| 797 |
$('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); |
| 798 |
$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); |
| 799 |
} else { |
| 800 |
$(current_column).find("input[type='text']").val(itm); |
| 801 |
// select the corresponding option |
| 802 |
$(current_column).find("select option").each(function(){ |
| 803 |
opt = $(this).text().toLowerCase(); |
| 804 |
opt = opt.replace(/^\s*|\s*$/g,''); |
| 805 |
if ( opt == itm.toLowerCase() ) { |
| 806 |
$(this).attr('selected', 'selected'); |
| 807 |
} |
| 808 |
}); |
| 809 |
if ( i == 0 || i == 1 ) { |
| 810 |
// Disable the 2 first columns, we cannot update them. |
| 811 |
var val = $(current_column).find("select option:selected").val(); |
| 812 |
var name = "categorycode"; |
| 813 |
if ( i == 1 ) { |
| 814 |
name="itemtype"; |
| 815 |
} |
| 816 |
// Remove potential previous input added |
| 817 |
$(current_column).find("input").remove(); |
| 818 |
$(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); |
| 819 |
} else if ( i == 3 || i == 4 ) { |
| 820 |
// If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" |
| 821 |
// The value is "Unlimited" (or an equivalent translated string) |
| 822 |
// an it should be set to an empty string |
| 823 |
if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) { |
| 824 |
$(current_column).find("input[type='text']").val(""); |
| 825 |
} |
| 826 |
} |
| 827 |
} |
| 828 |
}); |
| 829 |
$("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true); |
| 830 |
$("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); |
| 831 |
return false; |
| 832 |
}); |
| 833 |
$(".clear_edit").on("click",function(e){ |
| 834 |
e.preventDefault(); |
| 835 |
clear_edit(); |
| 836 |
}); |
| 837 |
}); |
| 838 |
</script> |
| 839 |
[% END %] |
| 837 |
[% INCLUDE 'intranet-bottom.inc' %] |
840 |
[% INCLUDE 'intranet-bottom.inc' %] |