-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-
-function clear_edit(){
- var cancel = confirm(_("Are you sure you want to cancel your changes?"));
- if ( !cancel ) return;
- $('#default-circulation-rules td').removeClass('highlighted-row');
- var edit_row = $("#edit_row");
- $(edit_row).find("input").each(function(){
- var type = $(this).attr("type");
- if (type != "button" && type != "submit" ) {
- $(this).val("");
- $(this).removeAttr("disabled");
- }
- });
- $(edit_row).find("select").removeAttr("disabled");
- $(edit_row).find("select option:first").attr("selected", "selected");
- $(edit_row).find("td:last input[name='clear']").remove();
-}
-
-$(document).ready(function() {
- $('#selectlibrary').find("input:submit").hide();
- $('#branch').change(function() {
- $('#selectlibrary').submit();
- });
- $(".editrule").click(function(){
- if ( $(edit_row).find("input[type='text'][value!='']").length > 0 ) {
- var edit = confirm(_("Are you sure you want to edit another rule?"));
- if (!edit) return false;
- }
- $('#default-circulation-rules td').removeClass('highlighted-row');
- $(this).parent().parent().find("td").each(function (i) {
- $(this).addClass('highlighted-row');
- itm = $(this).text();
- itm = itm.replace(/^\s*|\s*$/g,'');
- var current_column = $("#edit_row td:eq("+i+")");
- if ( i != 5 ) {
- $(current_column).find("input[type='text']").val(itm);
- // select the corresponding option
- $(current_column).find("select option").each(function(){
- opt = $(this).text().toLowerCase();
- opt = opt.replace(/^\s*|\s*$/g,'');
- if ( opt == itm.toLowerCase() ) {
- $(this).attr('selected', 'selected');
- }
- });
- if ( i == 0 || i == 1 ) {
- // Disable the 2 first columns, we cannot update them.
- var val = $(current_column).find("select option:selected").val();
- var name = "categorycode";
- if ( i == 1 ) {
- name="itemtype";
- }
- // Remove potential previous input added
- $(current_column).find("input").remove();
- $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
- } else if ( i == 2 ) {
- // If the value is not an integer for "Current checkouts allowed"
- // The value is "Unlimited" (or an equivalent translated string)
- // an it should be set to an empty string
- if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
- $(current_column).find("input[type='text']").val("");
- }
- }
- } else {
- // specific processing for the Hard due date column
- var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
- var input_value = '';
- if (typeof select_value === 'undefined'){
- select_value = '-1';
- }else {
- input_value = itm.split(' ')[1];
- }
- $(current_column).find("input[type='text']").val(input_value);
- $(current_column).find("select").val(select_value);
- }
- });
- $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled');
- $("#default-circulation-rules tr:last td:eq(1) select").attr('disabled', 'disabled');
- return false;
- });
-});
-//]]>
-</script>