JQuery Library
JQuery modifications are a great way to customize the look and feel of your Koha install. Here are a few tips to remember when writing JQuery modifications:
- For the staff side, all JQuery statements go in the IntranetUserJS system preference
- For the OPAC, all JQuery statements go in the OPACUserJS system preference
- You must include inside the preference, around your statements. Most examples listed below are considered "statements" while some show the full preference code.
$(document).ready(function(){ <multiple statements go here> });
- Clients must have Javascript enabled in their browsers for these changes to take effect.
Template
Developers: Please use the following template to add your JQuery statements to the wiki.
JQuery Title
- Developer: Name of JQuery developer
- Creation Date: the date you entered the script (YYYY-MM-DD)
- Purpose: Purpose of the JQuery script
- Status: Completed / In progress
- Intranet or OPAC?:
- Version: (The Koha version you are using this with, or Any, if applicable)
Some JQuery code
Intranet JQuery Statements
Add Hyperlink to Action Logs for a given Hold
- Developer: Kyle Hall
- Creation Date: 2020-01-30
- Purpose: Adds a tiny asterisk beside the cancel hold button that links to the action logs for the hold
- Status: Completed
- Version: any
$(document).ready(function() {
if (window.location.href.indexOf("reserve/request.pl") > -1) {
$("a.cancel-hold").each(function() {
let url = $(this).attr('href');
let reserve_id = getURLParameter(url, 'reserve_id');
$(this).after(`<a title="Action logs for this hold" target="_blank" href="/cgi-bin/koha/tools/viewlog.pl?do_it=1&modules=HOLDS&object=${reserve_id}">*</a>`);
});
}
});
function getURLParameter(url, name) {
return (RegExp(name + '=' + '(.+?)(&|$)').exec(url) || [, null])[1];
}
Highlight scanned barcode on biblio
- Developer: Lucas Gass
- Creation Date: 2022-06-29
- Purpose: Highlght scanned item on bib when searching by barcode
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11
$(document).ready(function () {
if ( $('#catalog_detail').length && window.location.href.indexOf("found1=1") > -1 ) {
setTimeout(function() {
let search_value = $('#search-form').val().trim();
let barcode_index = $('th:contains("Barcode")').index() +1; //add one for nth-child
$('#holdings_table tbody tr td:nth-child('+barcode_index+')').each( function() {
if ( $(this).text() === search_value ) {
$(this).parent().addClass('found_bc');
$(this).parent().children('td').css('background' , 'khaki');
}
})
//now clear the search form
if ( $('#cat-search-block').length ) {
$('#search-form').val('');
localStorage.setItem('searchbox_value', '');
$('#search-form').focus();
}
}, 100);
}
});
Alternative to AllFinesNeedOverride
- Developer: Kyle M Hall
- Purpose: Alternative to AllFinesNeedOverride in case you need to disable it for SIP2 to allow checkouts for patrons with fines or fees
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(document).ready(function() {
if ($("a[href^='/cgi-bin/koha/members/pay.pl?borrowernumber=']")) {
$('#circ_circulation_issue input').attr('disabled', 'disabled');
$('#circ_circulation_issue button').hide();
$("<button id='allow-circulation' class='btn btn-danger'>Patron owes fees</button>").insertAfter('#circ_circulation_issue button');
$('#allow-circulation').on('click', function(e) {
e.preventDefault();
$('#circ_circulation_issue input').removeAttr('disabled');
$('#circ_circulation_issue button').show();
$('#allow-circulation').hide();
});
}
});
Hide a dataTable column
- Developer: Kyle M Hall
- Purpose: To hide a column of a dataTable with jQuery
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
In this example, we are hiding the 3rd column ("base-level allocated") of the budgets table in acquisitions
$( document ).ready(function() {
$('#budgeth').on( 'init.dt', function () {
$('#budgeth').dataTable().fnSetColumnVis( 4, false );
});
});
Uncheck renew by default
- Developer: Kyle M Hall
- Purpose: Stop renew checkboxes from being checked by default on check out page
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$( document ).ready(function() {
$('#issues-table').on( 'init.dt', function () {
$('.renew').attr('checked', false);
});
});
Hide patron messages for library
- Developer: Kyle M Hall
- Purpose: To hide non-public patron messages from rubbernecking patrons, displaying the message only after clicking a "Show message" link
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(document).ready(function(){
if (window.location.href.indexOf("circ/circulation.pl") > -1) {
$("#messages .circ-hlt i").addClass("hidden-message").hide();
$("#messages .circ-hlt i").parent().append("<a class='show-hidden-message' href=''>[Show Message]</a>");
$(".show-hidden-message").on('click', function() {
$(this). parent().children('.hidden-message').show();
$(this). parent().children('.show-hidden-message').hide();
return false;
});
}
});
Set all library pulldowns to the logged in library
- Developer: Kyle M Hall
- Updated by: Christopher Brannon
- Purpose: To set all library pulldowns to the logged in library by default
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$( document ).ready(function() {
var library_name = $.trim($('#drop3 strong').text());
$(document.body).find('option').filter(function(index) {
return library_name === $(this).text();
}).attr("selected", "selected")
});
- Version: 19.x
Not sure when this changed, but have noticed in 19.05 this doesn't work. Here is an update, and it also limits the pulldowns to the reports. Change "#rep_guided_reports_start" to "document.body" if you want any pulldown throughout Koha that selects branches to be set:
var library_name = $.trim($('#user-menu span.logged-in-branch-name:first').text());
$('#rep_guided_reports_start').find('option').filter(function(index) {
return library_name === $(this).text();
}).attr("selected", "selected");
Modify Labels on memberentry.pl (Patron edit screen)
- Developer: Liz Rea (NEKLS)
- Purpose: To change phone/email labels from Home/Mobile Phone to Phone/Email (primary) and Phone/Email (secondary). Also adds a helpful tip as to which field will be printed on transit slips.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$("#memberentry_contact label[for='phone']").html("Primary Phone :");
$("#memberentry_contact label[for='email']").html("Primary Email :");
$("#memberentry_contact label[for='emailpro']").html("Alternate Email :");
$("#memberentry_contact li:contains('Primary Phone')").append("<strong><em> Shows on transit slips</em></strong>");
$("#memberentry_contact li:contains('Primary Email')").append("<strong><em> Shows on transit slips</em></strong>");
This second bit changes the labels on the patron detail page:
$("#patron-information .label:contains('Home:')").html('Primary Phone:');
$("#patron-information .label:contains('Work:')").html('Alternate Phone:');
$("#patron-information .label:contains('Email (work):')").html('Alternate Email:');
$("#patron-information .label:contains('Email (home):')").html('Primary Email:');
Style required Patron Attribute as Required
- Developer: Owen Leonard with Nicole Engard
- Purpose: You can mark an attribute required in the system preferences, but it doesn't highlight it in red. This will add the required class to the attribute.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Older Versions (default in at least 16.11+ ...)
//style attribute in red since it's required
$("#memberentry_patron_attributes label[for='patron_attr_4']").addClass("required");
Relabel Sort1 on Patron Record
- Developer: Lucas Gass, ByWater Solutions
- Purpose: This will allow you to relabel the sort 1 field on the patron add form and patron display to 'Township' (just replace with your own label).
- Status: Completed - updated 4/16/21 to prevent also changing sort1 in acquisitions
- Intranet or OPAC?: Intranet
- Version: Any
/* change sort1 label on member details page */
if ( $('#pat_moremember').length ) {
$('#patron-sort1 .label').text('Township:');
}
/* change sort1 label on member entry form page */
if ( $('#pat_memberentrygen').length ) {
$('label[for="sort1"]').text('Township:');
}
Remove Upcoming Events row from the messaging preferences table
- Developer: Liz Rea (NEKLS)
- Purpose: Remove the Upcoming Events row from the messaging prefs table. This was confusing because upcoming events notification requires additional software, but was always offered even if the additional software wasn't installed. This JQuery removes that row in the preferences table.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$("#memberentry_messaging_prefs tr:contains('Upcoming Events')").empty();
$("#patron-messaging-prefs tr:contains('Upcoming Events')").empty();
Remove Return All functionality from check out screen/Patron Detail page
- Developer: Liz Rea (NEKLS)
- Purpose: Since the Return All functionality is only partially complete (it doesn't process holds correctly when used, a big problem in our system) we have chosen to remove the column for Return all, and the associated button.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$("#finesholdsissues #issuest").find("tbody td:last-child,thead th:last-child").hide();
$("#finesholdsissues").find('input[id=return_all]').hide();
$("#patronlists #issuest").find("tbody td:last-child,thead th:last-child").hide();
Remove Delete link from the News items on the Staff home screen
- Developer: Liz Rea (NEKLS)
- Purpose: Some of our librarians were deleting news items, we wanted to remove the link.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(".newsfooter a:contains('Delete')").hide();
Adds Focus to Cataloging Search
- Developer: Liz Rea (NEKLS)
- Purpose: The cataloging search didn't seem to get focus after adding a bib. This adds that functionality.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.0.x (afaik)
$("#addbooks_search input[name=q]:eq(0)").focus();
Hide a field on Patron detail screen
- Developer: Liz Rea (NEKLS)
- Purpose: Hide a desired field on the Patron detail screen
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$("#patron-information li:contains('Mobile:')").hide();
- Developer: Marc Véron
- Purpose: Hide th menu in the left column to get more space for big table e.g. in Administration->Circulation and fine rules
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any - Does not work on Koha 21.05
if ((""+window.location).indexOf("smart-rules.pl")>=0) { $("#navmenu").hide(); $(".yui-t1 #yui-main .yui-b").css("margin-left", "1em"); }
Change the staff client's "Change Password" field to password type input
- Developer: Owen Leonard (Nelsonville Public Library)
- Purpose: Change the staff client's "Change Password" field to password type input. Useful if your staff client terminal is viewable by the public. This also removes Koha's default "suggested password" from the field.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.2
$(document).ready(function(){
$("#newpassword").parent().append("<input type=\"password\" value=\"\" size=\"20\" id=\"newpassword\" name=\"newpassword\">").end().remove();
});
Add additional searches to Intranet
- Developer: Magnus Enger, but based on "Add additional searches to OPAC" by Jared Camins-Esakov above
- Purpose: Adds additional searches to the Intranet Search type dropdown, in a specific place in the drop down
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
- Note: The goal here is to add the Dewey index after the "Subject as Phrase" index, and indent it to the same level as that index. Since matching is done on the values of elements in the list of options (and not on the text labels) this should work across translations too.
$('option[value="su,phr"]').after("<option value='Dewey-classification'> Dewey</option>");
Remove link to Holds to pull page
- Developer: Ian Walls
- Purpose: Removes "Holds to pull" link from the circulation page
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
- Note: Often, the Holds to pull list is deprecated for library use vs. the Holds Queue. This query removes the link in an effort to remove staff confusion. Sponsored by MassCat.
$("ul li:contains('Holds to pull')").remove();
Streamline Import Patrons page
- Developer: Daniel Grobani
- Purpose: removes unneeded fields and sets desired values
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: LLEK 4.0200019
// remove "default values" fieldset
$('form[action] legend:contains("Default values")').parent().remove();
// set record matching field to ID
$('fieldset:has(legend:contains("Field to use for record matching")) #matchpoint').val("ID");
// overwrite matching record
$('#overwrite_cardnumberno').attr('checked', 'false');
$('#overwrite_cardnumberyes').attr('checked', 'true');
// replace only included extended attributes
$('#ext_preserve_0').attr('checked', 'false');
$('#ext_preserve_1').attr('checked', 'true');
Point out there is a button for renewing items at bottom of patron page
- Developer: Jared Camins-Esakov, ByWater Solutions
- Purpose: Alerting staff to the fact that they can renew/return items directly from the patron record; particularly relevant for patrons with huge numbers of items checked out, where staff might forget about the renewal button at the bottom
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.4
$("#issuest").parent().prepend("<div id='renewref'>See below to renew all or selected items.</div>");
Don't Allow Checkout Overrides
- Developer: Scott Merrill , CAUSE
- Purpose: Removes the override option for circulation rules that block checkouts... right now, if you have a maximum line of X item type out to a patron type, you'll always get a prompt asking if you want to override, this removes the prompt
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.4+
$("#circ_needsconfirmation ul li:contains('This patron can\'t check out this
item per library circulation policy')").parent().siblings().hide();
Hide Streetnumber field on Patron edit screen
- Developer: Joy Nelson, ByWater Solutions
- Purpose: Remove the Street Number field from the patron edit screen.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.6+
$("#entryform #streetnumber").parent().hide();
Hide the Patron column in the Holds Que report
- Developer: Ed Veal, ByWater Solutions
- Purpose: Hides the Patron column in the Holds Que report but could be changed to hide any column within the report.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.6+
$("#holdst .hq-patron").hide();
Add a link to self checkout on intranet login screen
- Developer: Koha Community
- Purpose: Add a link to the built-in self checkout function to the intranet login screen
- Status: Completed
- Intranet
- Version: Any
$("#login .submit").parent().after("<p><a href=\"http://YOUR_KOHA_OPAC_URL/cgi-bin/koha/sco/sco-main.pl\" target=\"_blank\">Self-Checkout</a></p>");
Keyboard shortcuts to quickly change tab while showing or editing MARC records
- Developer: Stefano Bargioni (Pontificia Università della Santa Croce) - 2012-04-26
- Purpose: Keyboard shortcuts to change tab while showing or editing MARC records
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
// MARC bib edit
if (location.pathname.indexOf('cataloguing/addbiblio.pl')>-1) {
$(document).keydown(function(e) {
if (e.target.tagName == 'INPUT') return;
if (e.target.tagName == 'TEXTAREA') return;
var f = 0; // flag
var c = e.which; // code key pressed
if (c>=48 && c<=57) {f=1; c-=48;} // 0..9 keyboard
if (c>=96 && c<=105) {f=1; c-=96;} // 0..9 keypad
if (f==0) return;
var marc_sections = $('#addbibliotabs ul li a').text().replace(/[^0-9]/g,'');
var marc_section = marc_sections.indexOf(c);
if (marc_section == -1) return;
$($('#addbibliotabs ul li a')[marc_section]).click();
});
}
// MARC bib show
if (location.pathname.indexOf('catalogue/MARCdetail.pl')>-1) {
$(document).keydown(function(e) {
if (e.target.tagName == 'INPUT') return;
if (e.target.tagName == 'TEXTAREA') return;
var f = 0; // flag
var c = e.which; // code key pressed
if (c>=48 && c<=57) {f=1; c-=48;} // 0..9 keyboard
if (c>=96 && c<=105) {f=1; c-=96;} // 0..9 keypad
if (f==0) return;
var marc_sections = $('#bibliotabs ul li a').text().replace(/[^0-9]/g,'');
var marc_section = marc_sections.indexOf(c);
if (marc_section == -1) return;
$($('#bibliotabs ul li a')[marc_section]).click();
});
}
// MARC auth show
if (location.pathname.indexOf('authorities/detail.pl')>-1) {
$(document).keydown(function(e) {
if (e.target.tagName == 'INPUT') return;
if (e.target.tagName == 'TEXTAREA') return;
var f = 0; // flag
var c = e.which; // code key pressed
if (c>=48 && c<=57) {f=1; c-=48;} // 0..9 keyboard
if (c>=96 && c<=105) {f=1; c-=96;} // 0..9 keypad
if (f==0) return;
var marc_sections = $('#authoritiestabs ul li a').text().replace(/[^0-9]/g,'');
var marc_section = marc_sections.indexOf(c);
if (marc_section == -1) return;
$($('#authoritiestabs ul li a')[marc_section]).click();
});
}
// MARC auth edit
if (location.pathname.indexOf('authorities/authorities.pl')>-1) {
$(document).keydown(function(e) {
if (e.target.tagName == 'INPUT') return;
if (e.target.tagName == 'TEXTAREA') return;
var f = 0; // flag
var c = e.which; // code key pressed
if (c>=48 && c<=57) {f=1; c-=48;} // 0..9 keyboard
if (c>=96 && c<=105) {f=1; c-=96;} // 0..9 keypad
if (f==0) return;
var marc_sections = $('#authoritytabs ul li a').text().replace(/[^0-9]/g,'');
var marc_section = marc_sections.indexOf(c);
if (marc_section == -1) return;
$($('#authoritytabs ul li a')[marc_section]).click();
});
}
Hide SQL statement when running guided report
- Developer: Galen Charlton
- Purpose: Hide the SQL query when running a guided report
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.4.x and later
$("#sql_output").hide();
Set sort order to ascending call number if selecting call number search in the staff interface
- Developer: Galen Charlton
- Purpose: Set sort order to ascending call number if selecting call number search in the staff interface
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.0.x and later (tested in 3.8.x)
$("select.advsearch").change(function() {
var idx = $(this).val();
if (idx.substring(0, 7) == 'callnum') {
$("select#sort_by").val('call_number_asc');
}
});
Add a filter to the patron various tables in staff interface
- Developer: Christopher Brannon (Coeur d'Alene Public Library), based of original code by Kobi Lidershnider at http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/
- Purpose: To help find information in various tables, such as the Account and Pay fines portions of patron Fines, Edit items in cataloging, or the details screen for a bib in the staff catalog.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
//Add filter to various tables
$("#yui-main div[class='tabs-container'] table").attr("class","filterable"); //filter for fines
$("#yui-main div[id='cataloguing_additem_itemlist'] table").attr("class","filterable"); //filter for Edit items in cataloging
$("#yui-main div[id='bibliodetails'] table").attr("class","filterable"); //filter for bib items in staff catalog
$("<i>Filter: </i><input type='text' id='FilterTextBox' name='FilterTextBox' /><a href='#' class='clear' rel='nofollow'> Clear</a></p>").insertBefore("#yui-main table[class='filterable']");
$(".filterable tr:has(td)").each(function(){var t = $(this).text().toLowerCase();
$("<td class='indexColumn'></td>").hide().text(t).appendTo(this);
});//each tr
$("#FilterTextBox").keyup(function(){
var s = $(this).val().toLowerCase().split(" ");
//show all rows.
$(".filterable tr:hidden").show();
$.each(s, function(){
$(".filterable tr:visible .indexColumn:not(:contains('"
+ this + "'))").parent().hide();
});//each
});//key up.
$(".clear").click(function(){
$("#FilterTextBox").val("").keyup();
return false;
});
//end filters
Clean up patron details screen
- Developer: Christopher Brannon (Coeur d'Alene Public Library)
- Purpose: Remove unused lines in the Alternate address or Alternative contact sections of the Patron Details screen.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
//Condense Patron Display
$("#patron-alternate-address,#patron-alternative-contact").find("li").hide();
$("#patron-alternate-address li,#patron-alternative-contact li")
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='availablecontent'/>");
$("#patron-alternate-address,#patron-alternative-contact").find(".availablecontent").each(function() {
$(this).parent("li").show();
});
//end Condense Patron Display
Alert staff about missing email or phone upon checkout
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Purpose: Alert staff about missing email or phone upon checkout.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
- Note: Alert staff upon item checkout that a patron's email or phone is blank.
// Confirm that we're on the "Checking Out" page
myvar0 = /circulation\.pl/.test(window.location.pathname);
// is there a mailto: link on this page?
myvar1 = $('a[href*="mailto"]').length;
myvar2 = $("#nophonestored").length;
if(myvar0 != 0 && myvar1 == 0) {
alert('Patron email is blank!');
}
if(myvar0 != 0 && myvar2 != 0) {
alert('Phone number is missing!');
}
Alert inattentive staff to read patron notes
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Purpose: Alert staff about blank email upon checkout.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
- Note: Alert inattentive staff to read and resolve patron notes upon item checkout. This alert is repeated upon every page reload.
// alert any circulation notes
// Confirm that we're on the "Checking Out" page
myvar0 = /circulation\.pl/.test(window.location.pathname);
myvar4 = $('#circnotes').length;
if (myvar0 != 0 && myvar4 != 0) {
myvar5 = $('#circnotes span.circ-hlt').text();
alert(myvar5);
}
Add 'Hide/Unhide $0.00 balances' toggle button to fines screen
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: Creates a toggle button that hides or shows any lines from the patron fines table that have been paid in full.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.8
- Note: The button requires 2 parts. The first part adds a Jquery selector called 'contentIs.' The second statement creates the toggle button. For the button to work correctly you must include the statement to create the 'contentIs' selector.
//add the “contentIs” selector to return exact matches
$.expr[':'].contentIs = function(el, idx, meta) {
return $(el).text() === meta[3];
};
//end “contentIs” selector
//begin Zero Balance Button
//Adds a toggle button to the account tab on the patron fines screen that hides or shows any lines in a patron's account with an outstanding balance of zero
var new_btn = $('<button id="0hide">Hide/Unhide $0.00 balances</button>');
new_btn.insertBefore('#PatronAccountTable:first');
$('#0hide').click(function() {
$(".credit:contentIs(0.00)").parents("tr").toggle();
});
//end Zero Balance Button
Change Manual Credit to Add Note
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Purpose: Change the Manual Credit function to an Add Note function.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
- Note: Manual Credit was problematic for us, especially in reporting. Our staff used it only because of the notes field in order to give a reason when writing off a fine. Since the form assumes $0.00 upon submission, we just hide the amount field and then change the text on various elements.
//rename the tab from "Create manual credit" to "Add note"
$('a[href*="mancredit"]').text('Add note');
// Also if we're on the "Create manual credit" subpage:
myvar0 = /mancredit\.pl/.test(window.location.pathname);
if(myvar0 != 0) {
$("li:contains('Amount: ')").hide();
$("legend:contains('Manual credit')").text('Add note');
$("input[name='add']").val('Create note');
}
Remove 23:59 time dues from Circ and Catalogue when hourly loans are not in use
- Developer: Liz Rea (Catalyst IT)
- Purpose: Remove the time due from intranet detail and circulation pages.
- Intranet or OPAC?: Intranet
- Version: 3.8+
$("#issuest td:contains('23:59')").each(function() {
var text = $(this).text().replace('23:59', '');
$(this).text(text);
});
$(".datedue:contains('23:59')").each(function() {
var text = $(this).text().replace('23:59', '');
$(this).text(text);
});
Looks like it is obsolete since use of as_due_date added by Bug 11148
Force Staff to use Datepicker when altering due dates, renewal dates, and suspend until dates
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: Since incorrectly formatted due dates can be entered in the "specify due date", "renewal date", and "suspend until" input boxes (and incorrectly formatted dates can cause system errors), this jQuery forces staff to use the calendar datepicker to choose dates for these options.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.8
//BEGIN Force staff to use datepicker for altering due dates, renewal dates, and suspend unitl dates
$("#duedatespec").attr("readonly", "readonly");
$("#newduedate").attr("readonly", "readonly");
$("#suspend_until").attr("readonly", "readonly");
$(".hint:contains('Specify due date (MM/DD/YYYY):')").text('Use calendar button to choose new Due Date');
$("p:contains(Renewal due date:)").prepend('Use calendar button to choose ');
$(".hint:contains('Specify date on which to resume (MM/DD/YYYY):')").text('Use calendar button to specify the date when holds will resume');
//END Force staff to use datepicker for altering due dates, renewal dates, and suspend unitl dates
Hide some of the displayed fields when adding or editing an item
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: Hides selected fields in the "Add item" and "Edit item" pages.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10
- Note: Catalogers in our consortium want the default display of these screens to be shorter but they also need the ability to look at all fields if necessary. This example hides the 0, 1, 4, f, and j subfields. To remove different fields from the default display when the page loads add "li:contains(SUBFIELD -)" to the selector.
//BEGIN Hide and Show All Fields buttons for Catalogers
$(".yui-u #cataloguing_additem_newitem .rows li:contains('0 - '), li:contains('1 - '), li:contains('4 - '), li:contains('f - '), li:contains('j - ')").hide();
var new_btn = $('<button id="cataddhide">Show all fields</button>');
new_btn.prependTo('.yui-u #cataloguing_additem_newitem .rows');
$('#cataddhide').click(function(e) {
e.preventDefault();
$(".yui-u #cataloguing_additem_newitem .rows li:contains(' ')").show();
$('#cataddhide').fadeOut();
});
//END Show All Fields buttons for Catalogers
Preview OPAC syspref changes
- Developer: Jared Camins-Esakov, C & P Bibliography Services
- Purpose: Provides a preview for basic OPAC customizations on the OPAC syspref page.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10+ with bug 10405 and a special web server configuration
- Note: You will need to adjust the preview URLs for your particular installation. The URLs used in this sample were especially configured so that /cgi-bin/koha/opac/ would be forwarded to the OPAC. Also be aware that only part of the script goes in $(document).ready(..). To make this clear, I have included the $(document).ready(...) in the script.
function showPreview(url) {
document.getElementById('opac-preview').src = url;
$('#preview-loading').show();
$('#opac-preview').load(function () {
$('#opac-preview').show();
$('#region-opaccredits', $('#opac-preview').contents()).html($('#pref_opaccredits').val());
$('#region-opacheader', $('#opac-preview').contents()).html($('#pref_opacheader').val());
$('#opacmainuserblock', $('#opac-preview').contents()).html($('#pref_OpacMainUserBlock').val());
$('#opacmainuserblockmobile', $('#opac-preview').contents()).html($('#pref_OpacMainUserBlockMobile').val());
$('#region-opacnav', $('#opac-preview').contents()).html($('#pref_OpacNav').val());
$('#region-opacnavbottom', $('#opac-preview').contents()).html($('#pref_OpacNavBottom').val());
$('#noresultsfound', $('#opac-preview').contents()).html($('#pref_OPACNoResultsFound').val());
$('#opacresultssidebar', $('#opac-preview').contents()).html($('#pref_OPACResultsSidebar').val());
$('#region-opacusercss', $('#opac-preview').contents()).replaceWith('<style id="region-opacusercss" type="text/css">' + $('#pref_OPACUserCSS').val() + '</style>');
$('#region-opacuserjs', $('#opac-preview').contents()).replaceWith('<' + 'script id="region-opacuserjs" type="text/javascript">' + $('#pref_opacuserjs').val() + '<' + '/script>');
$('#preview-loading').hide();
});
}
$(document).ready(function () {
if ($('#pref_OpacNav').size() > 0) {
$('#doc3').after('<div class="navbar navbar-fixed-bottom" style="z-index: 10000;"><div id="preview-pane" class="navbar-inner"><h4 style="float: left; margin-right: 2em;">Preview changes</h4><div class="btn-group" data-toggle="buttons-radio"><button type="button" class="btn" id="preview-main">Main page</button><button type="button" class="btn" id="preview-results">Results</button><button type="button" class="btn" id="preview-details">Details</button><button type="button" class="btn active" id="preview-hide">Hide</button></div><img id="preview-loading" style="display: none;" src="/intranet-tmpl/prog/img/loading-small.gif"/><iframe id="opac-preview" style="height: 20em; width: 100%; display: none;"></iframe></div></div>');
$('#preview-main').click(function () {
showPreview('/cgi-bin/koha/opac/opac-main.pl');
});
$('#preview-results').click(function () {
showPreview('/cgi-bin/koha/opac/opac-search.pl?idx=&q=pqf%3D%40attr+1%3D_ALLRECORDS+%40attr+2%3D103+%22%22&branch_group_limit=');
});
$('#preview-details').click(function () {
showPreview('/cgi-bin/koha/opac/opac-detail.pl?biblionumber=1');
});
$('#preview-hide').click(function () {
$('#opac-preview').hide();
});
}
});
Populate Username with Cardnumber
- Developer: Ed Veal, ByWater Solutions
- Purpose: Copy cardnumber to username field on new patron form
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
//Causes the user cardnumber to auto populate to the Username.
$("#entryform #cardnumber").blur(function(){
$("#entryform #userid").val($("#entryform #cardnumber").val());
});
Validate patron data fields
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Purpose: Validate data when creating or editing patron records.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12
- Note: Koha performs only basic validation (i.e. required fields). This jQuery script replaces the default SAVE button with a VALIDATE button which runs a custom validation using regular expressions. Upon successful validation it submits the form data. NOTE - this script is very large and will require additional customization to fit your library, since it contains our library's unique patron categorycodes and our validation definitions. For example, we require 2 email addresses for all patrons, but allow the 2 addresses to be the same for only some categorycodes, while requiring them to be different for other categorycodes.
//hide the miniature EDIT links on the patron details screen
$("#patron-alternate-address").next('div').hide();
$("#patron-alternative-contact").next('div').hide();
$("#patron-messaging-prefs").next('div').hide();
$('div.yui-u div.action a:contains("Edit")').hide();
$('#patron-information a:contains("Edit")').hide();
// validate patron EDIT data by hiding the SAVE button, running an inline validation script, then submitting the form if it passes validation.
//we can secretly bypass validation if the shift key is pressed, so we bind the keydown event to a specific textarea in order to check for a pressed SHIFT key
$('textarea#patron_attr_4').keyup(function (e) {
if (e.which == 16) $.isShift = false;
}).keydown(function (e) {
if (e.which == 16) $.isShift = true;
});
// create the validation function
patronValidate = function () {
//if the shift key is pressed then skip validation
if ($.isShift) {
return check_form_borrowers();
} else {
//start with an empty alert message
var mes = "";
//get all our variables
var surname = $('input[id=surname]').val();
var firstname = $('input[id=firstname]').val();
var address = $('input[id=address]').val();
var city = $('input[id=city]').val();
var state = $('input[id=state]').val();
var zipcode = $('input[id=zipcode]').val();
var phone = $('input[id=phone]').val();
var phonepro = $('input[id=phonepro]').val();
var email = $('input[id=email]').val();
var emailpro = $('input[id=emailpro]').val();
var cardnumber = $('input[id=cardnumber]').val();
var categorycode = $('select[id=categorycode]').val();
var dateexpiry = $('input[id=to]').val();
var userid = $('input[id=userid]').val();
var school = $('select[id=patron_attr_3]').val();
var rnumber = $('textarea[id=patron_attr_2]').val();
//create our arrays for expiration dates and eRaider validation
var fullYear = ['ADMIN', 'EMPLOYEE', 'FACULTY', 'RETIRED', 'STAFF'];
var nonTTUHSC = ['CLINFAC', 'CONTRACTS', 'DEBTORS', 'FRIEND', 'PRECEPTOR', 'HOSPITAL'];
//create our regexes
// case-sensitive regexes
var cardnumberReg = /(^P[A-Z0-9]{5}$)|(^R[0-9]{8}$)/;
var stateReg = /^([A-Z]{2}$)/;
var useridReg = /^([a-z0-9_]{3,8})$/;
// case-insensitive regexes
var surnameReg = /^[a-zA-Z\-\\'\ ]+$/;
var firstnameReg = /^[a-zA-Z\-]+$/;
var cityReg = /^[a-zA-Z ]+$/;
var addressReg = /^(([0-9]{1,5}|POB|RT) .+)/;
var zipReg = /(^[0-9]{5}(-[0-9]{4})?$)/;
var phoneReg = /^([2-9][0-9]{2}-[0-9]{3}-[0-9]{4})$/;
var emailReg = /^([a-z0-9\-]+\.([a-z]\.)?[a-z\-]+@ttuhsc\.edu)$/i;
var emailReg2 = /^(.+@.+\.[a-z]{2,3})$/i;
var alumniReg = /^((11\/30\/20[0-9]{2})|(02\/15\/20[0-9]{2})|(06\/30\/20[0-9]{2}))$/;
var clinfacReg = /^(08\/31\/20[0-9]{2}$)/;
var higheredReg = /^(06\/30\/20[0-9]{2}$)/;
var hospitalReg = /^(12\/31\/20[0-8][0-9]$)/;
var studentReg = /^((05\/31\/20[0-9]{2})|(08\/15\/20[0-9]{2})|(12\/31\/20[0-8][0-9]))$/;
var rnumblankReg = /^$/
var rnumReg = /^(R[0-9]{8})$/;
// validate surname
if (!surnameReg.test(surname)) {
mes = mes + "\nLast name contains invalid characters.\n";
}
// validate firstname
if (!firstnameReg.test(firstname)) {
mes = mes + "\nFirst name contains invalid characters (e.g. spaces).\n";
}
// validate city
if (!cityReg.test(city)) {
mes = mes + "\nCity contains invalid characters.\n";
}
// validate street address
if (!addressReg.test(address)) {
mes = mes + "\nStreet address must begin with a number, POB or RT\n";
}
// validate state
if (!stateReg.test(state)) {
mes = mes + "\nState abbreviation must be exactly 2 uppercase characters.\n";
}
// validate zipcode
if (!zipReg.test(zipcode)) {
mes = mes + "\nZip code looks invalid.\n";
}
// validate primary phone
if (!phoneReg.test(phone)) {
mes = mes + "\nPrimary phone must be exactly XXX-XXX-XXXX\n";
}
// validate secondary phone
if (!phoneReg.test(phonepro)) {
mes = mes + "\nSecondary phone must be exactly XXX-XXX-XXXX\n";
}
// validate both email addresses
if (!emailReg2.test(email)) {
mes = mes + "\nPrimary email looks invalid.\n";
}
if (!emailReg2.test(emailpro)) {
mes = mes + "\nSecondary email looks invalid.\n";
}
/* some categorycodes require 2 email addresses
if ((nonTTUHSC.indexOf(categorycode) == -1 || categorycode == 'ALUMNI' ) && email == emailpro) {
mes = mes + "\nPatron class \'" +
categorycode + "\' requires 2 distinct email addresses.\n";
}*/
//validate the cardnumber
if (!cardnumberReg.test(cardnumber)) {
mes = mes + "\nCardnumber is invalid.\n";
}
//validate the userid if affiliated
if (nonTTUHSC.indexOf(categorycode) == -1 && !useridReg.test(userid)) {
mes = mes + "\nUsername \(eRaider\) must be lowercase letters and numbers only.\n";
}
//validate the school
if (school == '') {
mes = mes + "\nYou must chose a school or choose \'Other\'.\n";
}
//set or check dateexpiry based upon categorycode
if (fullYear.indexOf(categorycode) != -1) {
$('input[id=to]').val('12/31/2099');
}
if (categorycode == 'CLINFAC' && !clinfacReg.test(dateexpiry)) {
mes = mes + "\nClinical Faculty must expire on exactly 08\/31\/20xx.\n";
}
if (categorycode == 'HIGHERED' && !higheredReg.test(dateexpiry)) {
mes = mes + "\nResidents and Fellows must expire on exactly 06\/30\/20xx.\n";
}
if (categorycode == 'HOSPITAL' && !hospitalReg.test(dateexpiry)) {
mes = mes + "\nHospital employees must expire on exactly 12\/31\/20xx.\n";
}
if (categorycode == 'ALUMNI' && !alumniReg.test(dateexpiry)) {
mes = mes + "\nAlumni must expire on exactly 02\/15\/20xx, or 06\/30\/20xx, or 11\/30\/20xx.\n";
}
if (categorycode == 'STUDENT' && !studentReg.test(dateexpiry)) {
mes = mes + "\nStudents must expire on exactly 05\/31\/20xx, or 08\/15\/20xx, or 12\/31\/20xx.\n";
}
//R numbers are not required,
//but if used, they should validate
if (!rnumblankReg.test(rnumber) && !rnumReg.test(rnumber)) {
mes = mes + "\nR number must begin with \'R\' and be 8 digits.\n";
}
// display the alert
if (mes != "") {
alert(mes);
return false;
} else {
alert("All data looks good!");
// submit the validated form
check_form_borrowers();
}
}
};
// Hide the SAVE button, create the VALIDATE button
$('#entryform > fieldset.action').prepend('<input id="validate" type="submit" value="Validate" onclick="return patronValidate();" name="validate">');
$('#entryform input[name=save]').hide();
Validate patron data fields variation for v21.x
- Developers: Christopher Brannon - Coeur d'Alene Public Library / Cooperative Information Network
- Purpose: Validate data when creating or editing patron records.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.x
- Note: This is an update of the previous version. Just updated with changes for the more recent versions of Koha, and shows other validation variations.
/* Hide all miniture EDIT links on the patron details screen */
#pat_moremember #patron-information a.btn, #pat_moremember #patron-messaging-prefs a.btn, #pat_moremember #patron-library-details a.btn, #pat_moremember #patron-alternative-contact a.btn, #pat_moremember #patroninfo-heading a.btn {
display: none;
}
// create the validation function
patronValidate = function () {
//start with an empty alert message
var mes = "";
//get all our variables
var surname = $('input[id=surname]').val();
var firstname = $('input[id=firstname]').val();
var othernames = $('input[id=othernames]').val();
var maddress = $('input[id=address]').val();
var mcity = $('input[id=city]').val();
var mstate = $('input[id=state]').val();
var mzipcode = $('input[id=zipcode]').val();
var pphone = $('input[id=phone]').val();
var pemail = $('input[id=email]').val();
var paddress = $('input[id=B_address]').val();
var pcity = $('input[id=B_city]').val();
var pstate = $('input[id=B_state]').val();
var pzipcode = $('input[id=B_zipcode]').val();
var sphone = $('input[id=phonepro]').val();
var semail = $('input[id=emailpro]').val();
var smsphone = $('#SMSnumber').val();
//create our regexes
// case-sensitive regexes
var mstateReg = /^([A-Z]{2}$)/;
var pstateReg = /^([A-Z]{2}$)|^$/;
// case-insensitive regexes
var spaceReg = /^\s|\s$/;
var surnameReg = /^[a-zA-Z][a-zA-Z\-'\ \,]*[a-zA-Z]$/;
var firstnameReg = /^[a-zA-Z][a-zA-Z\-'\ \,]*[a-zA-Z]$/;
var mcityReg = /^[a-zA-Z][a-zA-Z \']+[a-zA-Z]$/;
var maddressReg = /^(([0-9]{1,5}|PO Box [0-9]*|(RR|HC|PSC|UNIT)\s[0-9]*\sBox).+)[a-zA-Z0-9\.]*$|ADDRESS UPDATE REQUIRED/;
var maddressTempReg = /^(202)\s.*(harrison)/i;
var mzipReg = /(^[0-9]{5}(-[0-9]{4})?$)/;
var pphoneReg = /^([2-9][0-9]{2}-[0-9]{3}-[0-9]{4})$|^NA$/;
var emailReg = /^([a-z0-9_-]+)([._-]([0-9a-z_-]+))*@([a-z0-9]+)([._-]([0-9a-z]+))*([.]([a-z0-9]+){2,4})$|^$/i;
var paddressReg = /^(([0-9]{1,5}|(RR|HC|PSC|UNIT)\s[0-9]*\sBox).+)[a-zA-Z0-9\.]*$|^$/;
var pcityReg = /^[a-zA-Z][a-zA-Z \']+[a-zA-Z]$|^$/;
var pzipReg = /(^[0-9]{5}(-[0-9]{4})?$)|^$/;
var sphoneReg = /^([2-9][0-9]{2}-[0-9]{3}-[0-9]{4})$|^$/;
// validate surname
if (!surnameReg.test(surname)) {
mes = mes + "\nLast name contains invalid characters.\n";
}
if (spaceReg.test(surname)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate firstname
if (!firstnameReg.test(firstname)) {
mes = mes + "\nFirst/Middle name(s) contains invalid characters.\n";
}
if (spaceReg.test(firstname)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate othernames
if (spaceReg.test(othernames)) {
mes = mes + "\nOther name contains a space at the beginning or end of the field.)\n";
}
// verify if birth date is blank when needed (This example test against our children categories, which all start with MINOR.)
if (($('input[name=dateofbirth]').val() == "") && ($("#categorycode_entry").val().match('^MINOR'))) {
mes = mes + "\nMinor category requires a birth date.\n";
}
// validate category (This test does not allow our self check category (SELF) to be saved.)
if ($("#categorycode_entry").val() == 'SELF') {
mes = mes + "\nPlease change Patron Category.\n";
}
// validate mail city
if (!mcityReg.test(mcity)) {
mes = mes + "\nMail city contains invalid characters.\n";
}
if (spaceReg.test(mcity)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate physical city
if (!pcityReg.test(pcity)) {
mes = mes + "\nPhysical city contains invalid characters. Leave blank if unused.\n";
}
if (spaceReg.test(pcity)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate mail street address
if (!maddressReg.test(maddress)) {
mes = mes + "\nMail street address not formatted properly (i.e. begins with number, PO Box, RR, HC, PSC or UNIT.)\n";
}
if (spaceReg.test(maddress)) {
mes = mes + "\nA space has been found at beginning or end of the mailing address.\n";
}
// validate physical street address
if (!paddressReg.test(paddress)) {
mes = mes + "\nPhysical street address not formatted properly (i.e. begins with number, RR, HC, PSC or UNIT. Cannot be PO Box. Leave blank if unused.)\n";
}
if (spaceReg.test(paddress)) {
mes = mes + "\nA space has been found at beginning or end of the physical address.)\n";
}
// check for duplicate addresses
if (maddress == paddress && maddressReg.test(maddress)) {
mes = mes + "\nAddresses can not be the same!\n";
}
// check for po box (PO Box 1737 with 83701 ZipCode is part of the Address Confientiality Program / Can't ask for Physical Address)
if ((maddress == 'PO Box 1737') && (mzipcode == '83701')) {
mes = mes;
} else if (maddress.substr(0,6) == "PO Box" && (paddress == "" || pcity == "" || pstate == "" || pzipcode == "")) {
mes = mes + "\nPhysical address required if Primary address is a PO Box!\n";
}
// validate mail state
if (!mstateReg.test(mstate)) {
mes = mes + "\nMail state abbreviation must be exactly 2 uppercase characters.\n";
}
if (spaceReg.test(mstate)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate physical state
if (!pstateReg.test(pstate)) {
mes = mes + "\nPhysical state abbreviation must be exactly 2 uppercase characters. Leave blank if unused.\n";
}
if (spaceReg.test(pstate)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate mail zipcode
if (!mzipReg.test(mzipcode)) {
mes = mes + "\nMail zip code must in entered like XXXXX[-XXXX].\n";
}
if (spaceReg.test(mzipcode)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate physical zipcode
if (!pzipReg.test(pzipcode)) {
mes = mes + "\nPhysical zip code must in entered like XXXXX[-XXXX]. Leave blank if unused.\n";
}
if (spaceReg.test(pzipcode)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate primary phone
if (!pphoneReg.test(pphone)) {
mes = mes + "\nPrimary phone must be exactly XXX-XXX-XXXX or NA\n";
}
if (spaceReg.test(pphone)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// validate secondary phone
if (!sphoneReg.test(sphone)) {
mes = mes + "\nSecondary phone must be exactly XXX-XXX-XXXX. Leave blank if unused.\n";
}
if (spaceReg.test(sphone)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// check for duplicate phone
if (pphone == sphone && pphone !="NA" && pphoneReg.test(pphone)) {
mes = mes + "\nPhone numbers can not be the same!\n";
}
// validate both email addresses
if (!emailReg.test(pemail)) {
mes = mes + "\nPrimary email looks invalid. Leave blank if unused.\n";
}
if (spaceReg.test(pemail)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
if (!emailReg.test(semail)) {
mes = mes + "\nSecondary email looks invalid. Leave blank if unused.\n";
}
if (spaceReg.test(semail)) {
mes = mes + "(A space has been found at beginning or end of the field.)\n";
}
// check for duplicate e-mail
if (pemail == semail && pemail !="") {
mes = mes + "\nE-mail addresses can not be the same!\n";
}
//check if SMS values are set correctly
if (smsphone != '' && smsphone.length != 12) {
mes = mes + "\nSMS phone number needs to be set correctly! (+1XXXXXXXXXX)\n";
}
// display the alert
if (mes != "") {
alert(mes);
return false;
} else {
// submit the validated form
if( check_form_borrowers() ){
$("#entryform").submit();
}
}
};
// Hide the SAVE button, create the VALIDATE button
$('#pat_memberentrygen #saverecord').replaceWith('<button id="validate" class="btn btn-small toggler" name="validate" style="margin-left: 0px;" onclick="return patronValidate();"><i class="fa fa-save"></i> Save</button>');
Brute force patron entry correction for v21.x
- Developers: Christopher Brannon - Coeur d'Alene Public Library / Cooperative Information Network
- Purpose: Correct patron data entry word by word as you type. This forces consistent data entry as you type, but allows for going back to correct for unusual cases.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.x
//Brute force patron entry correction (v21.05)
//Are you in the member edit page?
if ($('#pat_memberentrygen').length) {
//Correct data entry
function capitalizeWords(str) {
var words = str.split(' ');
if (words[words.length - 1].startsWith('Mc') || words[words.length - 1].startsWith('Mac') || words[words.length - 1].startsWith('DeA') || words[words.length - 1].startsWith('PO') || words[words.length - 1].startsWith('II') || words[words.length - 1].startsWith('III') || words[words.length - 1].startsWith('IV') || words[words.length - 1].contains("\'")) {
return words.join(' ');
} else {
words[words.length - 1] = words[words.length - 1].replace(/\b[\w']+\b/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
var newString = words.join(' ').replace(/D\'a/g,"d'A");
return newString;
}
}
function removePeriods(str) {
return str.replace(/\./g,'');
}
function fixAbbreviations(str) {
var words = str.split(' ');
words[words.length - 1] = words[words.length - 1].replace(" Av "," Ave ").replace("Avenue","Ave").replace(" Str ","St").replace("Street","St").replace("Place","Pl").replace("Circle","Cir").replace("Space","Sp").replace("Lane","Ln").replace("Drive","Dr");
var newString = words.join(' ');
return newString;
}
function makeUpperCase(str) {
return str.toUpperCase();
}
function digitsOnly(str) {
return str.replace(/[^0-9\.]/g,'');
}
function formatPhone(str) {
str.replace(/[^0-9\.]/g,'');
if (str.length == 3 || str.length == 7) {
return str + '-';
} else {
return str;
}
}
function formatPhoneNew(str) {
if (!str) return str;
var re = new RegExp(/[NA]/g);
if (re.test(str)) {
return str;
} else {
const phoneNumber = str.replace(/[^\d]/g, '');
const phoneNumberLength = phoneNumber.length;
if (phoneNumberLength < 4) return phoneNumber;
if (phoneNumberLength < 7) {
return `${phoneNumber.slice(0,3)}-${phoneNumber.slice(3)}`;
}
return `${phoneNumber.slice(0,3)}-${phoneNumber.slice(3,6)}-${phoneNumber.slice(6,10)}`;
}
}
//Capitalize and remove periods
$('#surname,#firstname,#address,#city,#B_address,#B_city,#altcontactsurname,#altcontactfirstname,#altcontactaddress1').on('keyup',function() {
$(this).val(capitalizeWords($(this).val()));
$(this).val(removePeriods($(this).val()));
});
//Fix Street Abbreviations
$('#address,#B_address,#altcontactaddress1').on('keyup',function() {
$(this).val(fixAbbreviations($(this).val()));
});
//Change to all uppercase
$('#state,#B_state,#altcontactstate').on('keyup',function(){
$(this).val(makeUpperCase($(this).val()));
});
//Limit to 2 characters
$('#state,#B_state,#altcontactstate').attr('maxlength',2);
//Limit to 5 digits
$('#zipcode,#B_zipcode,#altcontactzipcode').attr('maxlength',5).on('keyup',function(){
$(this).val(digitsOnly($(this).val()));
});
//Format phone number
$('#phone,#phonepro,#altcontactphone').attr('maxlength',12).on('keyup',function(){
$(this).val(formatPhoneNew($(this).val()));
});
}
//END Brute force patron entry correction (v21.05)
Hide Add Child from Patron Page
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Hide the add child button
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12+
$("a#addchild.btn.btn-small").hide();
Hide Duplicate from Patron Page
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Hide the duplicate button
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12+
$("a#duplicate.btn.btn-small").hide();
Hide Duplicate and Add Child from Patron Page
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Hide the duplicate and add child buttons
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10- and below
$("#addchild,#duplicate").closest("li").hide();
Rename Renew All Button
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Rename 'renew or return checked items' button
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10+
$("input[value='Renew or return checked items']").attr("value","Renew checked items");
$("input[value='Renew or Return checked items']").attr("value","Renew checked items");
Hide current location column in holdings table (3.10)
- Developer: Ed Veal, ByWater Solutions
- Purpose: Removes the Current location column in Holdings table
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10
$("#holdings tr td:nth-child(2)").remove();
$("#holdings tr th:nth-child(2)").remove();
Hide current location column in holdings table (3.12)
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Removes the Current location column in Holdings table
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12+
$("#holdings td.location").hide();
$("#holdings th:contains('Current location')").hide();
Hide Topic & Places Facets
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Removes the Current location column in Holdings table
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10+
$("li#su-geo_id").hide();
$("li#su-to_id").hide();
Select an attribute value by default
- Developer: Owen Leonard & Nicole C. Engard
- Purpose: This assumes that you have a patron attribute with an authorized value and selects a default value for you
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10+
$("#patron_attr_1").find("option[value='VALUEHERE']").attr("selected","selected");
Select an attribute value by default only on add patron add screen
- Developer: Lisette Scheer
- Purpose: This assumes you have a patron attribute with an authorized value and selects a default value for you only when creating a new patron (not duplicating or adding a child)
- Status:
- Intranet or OPAC?: Intranet
- Version: 19.05+
if (window.location.href.inxedOf("memberentry.pl?op=add") > -1) {
$("#patron_attr_1").val("VALUEHERE");}
Interrupt check-in process for hold/transfer confirmations
- Developer: Christopher Brannon
- Purpose: Stop staff from overlooking a hold/transfer confirmation during the check-in process.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10+
- Note: This will interrupt the process of check-in by taking the focus away from the check-in text box if a confirmation screen appears for holds or transfers. If another book is scanned, nothing will happen. I've also colored the print button green to draw attention to the message. This is the preferred button for us. You can change the color of a different button if your workflow is different.
//Check for Check-In Alerts
if ($('#return2,#hold-found1,#hold-found2,#item-transfer').length){
$("#barcode").blur();
$("input[class='print']").css({backgroundColor: 'lightgreen'});
}
//end Checking for Alerts
Passing Cardnumber/barcode through to UserID
- Developer: Ed Veal, ByWater Solutions
- Creation Date: 2013-10-17
- Purpose: Using Cardnumber/Barcode for UserId
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.8 and 3.10 (not tested in 3.12)
$("#entryform #cardnumber").blur(function(){
$("#entryform #userid").val($("#entryform #cardnumber").val());
});
Find string and add a span around it
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Add a class tag to an element without one by finding it. In this case find the string rcvd and add a around it.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10
$(document).ready(function(){
$('p').html(function(i,h){
return h.replace('(rcvd)', '<span class="receivedlabel">(rcvd)</span>');
});
});
Highlight patron's home library
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: Add a class tag to an element without one by finding it. In this case find the string rcvd and add a around it.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10
$(document).ready(function(){
//highlight the home library on the left of the patron record in red
$('ul').html(function(i,h){
return h.replace('<li>Home library:', '<li style="color: red; font-weight: bolder;">Home library:');
});
});
Hide price column on check out summary
- Developer: Nicole C. Engard, ByWater Solutions
- Purpose: This hides the Price column found when looking at patron's checkouts
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12
$("#issuest tr td:nth-child(8)").hide();
$("#issuest th:contains('Price')").hide();
$("#issuest tfoot tr td:nth-child(3)").hide();
Highlight return notice for items previously lost "Item was lost, now found"
- Developer: Chris Meech
- Purpose: Increase viability of returns notice for lost items -"Item was lost, now found"
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.10
//Highlight return notice Item was lost, now found
$(document).ready(function(){
$( ".problem:contains('Item was lost, now found')" ).css({"backgroundColor": "black", "color": "white", "font-size":"200%"})
});
Hide default framework in cataloging
- Developer: Olugbenga Adara, Projektlink Konsult Limited
- Creation Date: 2014-03-26
- Purpose: This will hide the Default Framework options on addbiblio.pl and addbooks.pl pages
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14 (AFAIK)
$("a[href$='frameworkcode=']").hide();
$("#Frameworks option[value=Default]").hide();
$('li.z3950searchFw:first').hide();
Allow only a supervisor to write off a fine
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Creation Date: 2014-04-11
- Purpose: Koha 3.12 does not allow for granular control over the Write Off functions. This code mimics supervisory control by hiding the Write Off All and Write Off buttons, then requiring the input of a secret supervisor code to unhide the Write Off button.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.12
//create the writeoffallow function
function writeoffallow() {
var superid = prompt('Enter your supervisor ID:');
// use your own secret code here in place of 9999
if (superid == '9999') {
$('input[type="submit"][value="Write off"]').show();
} else {
alert('Incorrect Supervisor ID');
}
}
//hide the Write Off All button
$('#woall').hide();
//hide the Write off button
$('input[type="submit"][value="Write off"]').hide();
//create the supervisor link
$('#payselected').after(' <a id="supervisor" href="#">Supervisor</a> ');
//assign the click handler
$("#supervisor").click(writeoffallow);
Allow only a supervisor to lift a manual restriction
- Developer: Paul Landers - Texas Tech University Health Sciences Center
- Creation Date: 2014-04-16
- Purpose: Koha 3.14 does not allow for granular control over the new Manual Restriction functions. This code mimics supervisory control by hiding the remove links, then requiring the input of a secret supervisor code to unhide the remove links.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//create the superlift function
function superlift() {
var superid = prompt('Enter your supervisor ID:');
// use your own secret code here in place of 9999
if (superid == '9999') {
$('a.remove_restriction').show();
} else {
alert('Incorrect Supervisor ID');
}
}
// hide the REMOVE RESTRICTION links
$('a.remove_restriction').hide();
// create the SUPERVISOR link
$('#add_manual_restriction').after(' | <a id="supervisor2" href="#">Supervisor</a> ');
//assign the click handler
$("#supervisor2").click(superlift);
// hide the Patron Flags section on the Patron Edit screen because we do not use them
$('legend:contains("Patron account flags")').parent().hide();
// hide the Patron Restrictions section on the Patron Edit screen
$('legend:contains("Patron restrictions")').parent().hide();
Change default encoding to MARC-8
- Developer: Nicole Engard, ByWater Solutions
- Creation Date: 2014-05-10
- Purpose: Make the default encoding when staging records Marc8 instead of UTF8
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
$(document).ready(function(){
if (window.location.href.indexOf("tools/stage-marc-import.pl") > -1) {
$("#encoding option[value='utf8']").removeAttr("selected");
$("#encoding option[value='MARC-8']").attr("selected","selected");
}
});
Focus on 'add to basket' instead of vendor search
- Developer: Nicole Engard, ByWater Solutions
- Creation Date: 2014-05-10
- Purpose: Move focus from search box on basket page and to the add item to basket area
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
$(document).ready(function(){
if (window.location.href.indexOf("acqui/basket.pl") > -1) {
$("input[name='supplier']").blur();
$("input[name='q']").focus();
}
});
Focus on add to list
- Developer: Nicole Engard, ByWater Solutions
- Creation Date: 2014-05-10
- Purpose: Add focus lists page and to the add item to list area
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
$(document).ready(function(){
if (window.location.href.indexOf("virtualshelves/shelves.pl") > -1) {
$("input[name='addbarcode']").focus();
}
});
Change default tab on the main page to Search
- Developer: Fridolin SOMERS, Biblibre and Nicole Engard, ByWater Solutions
- Creation Date: 2014-06-03
- Purpose: Makes it so that the tab fixed on the main page of the staff client is the 'search the catalog' tab.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.16
$(document).ready(function(){
if (window.location.href.indexOf("cgi-bin/koha/mainpage.pl") > -1) {
$("#header_search a[href='#catalog_search']").click();
}
});
Add hotkeys to staff client
- Developer: Mark Lesniak, Rahway Public Library
- Creation Date: 2014-06-25
- Purpose: Adds hot keys to the staff client
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
$(document).bind('keydown', function(e) {
// Shift + escape to return home (just escape in
// Google Chrome)
if(e.which === 27){
window.location.href = "http://" + document.domain; // Return to domain root
}
if(e.altKey){
switch (e.which)
{
// Alt + w = Print page
case 87:
printx_window("page");
break;
// Alt + p = Print Quickslip
case 80:
printx_window("qslip");
break;
// Alt + m = Print summary
case 77:
printx_window("slip");
break;
}
} // End alternate key
}); // End keypress bindings
Change "Available" to "Checked in or on hold"
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: Changes "XX Items available" to "XX Items checked in or on hold" in the search results in the staff client in the right hand column.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//BEGIN Change "available" in search results to "checked in/on hold"
$("#searchresults .availability strong:contains('available')").text(function () {
return $(this).text().replace("available", "checked in or waiting on hold");
});
//END Change "available" in search results to "checked in/on hold"
Hide locations/copies on Staff search results
- Developer: Christopher Brannon - Coeur d'Alene Public Library/CIN
- Purpose: Condenses copy information so staff don't have to scroll so much through search results.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//Condense Locations on Staff Catalog Results
$("#bookbag_form div[class='availability']").children("ul").hide();
$("#bookbag_form div[class='availability'] strong").wrap("<a class='viewLocations' />");
$("#bookbag_form div[class='availability'] strong").append("<span class='instruct'> (+)</span><span class='instruct' style='display: none;'> (-)</span>");
$("#bookbag_form div[class='availability']").parent("td").attr('width','290');
//Trigger for condensed locations
$(".viewLocations").click(function() {
$(this).find(".instruct").toggle();
$(this).parent().parent().find("ul").toggle("slow");
});
//end Condense Locations
Remove links for staff to change logged in location
- Developer: Christopher Brannon - Coeur d'Alene Public Library/CIN
- Purpose: Reduce the ability for staff to change their circing/cataloging location easily. This will not prevent staff from changing the home location in the patron edit screen.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//Remove library and label from login
$("#loginform label[for='branch']").hide();
$("#loginform #branch").hide();
//end Remove library from login
//Remove Set Library from Circulation page
$("#bd div[class='yui-u first'] li:contains('Set library')").hide();
//end Remove Set Library
//Remove Set Library from main page
$("#header ul[class='dropdown-menu'] li:contains('Set library')").hide();
//end Remove Set Library
Hide non-local copies when searching staff interface
- Developer: Nick Clemens, VOKAL
- Creation Date: 2014-03-29
- Purpose: Hides non-local copies, by logged in library, in staff search results and adds a button to show them
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//Add button to revert view
$("#catalog_results #selection_ops").append('<div class="btn-group"><a class="btn btn-mini" id="plain_old_results" href="#"> Brief/Full Results</a></div>');
$("#plain_old_results").click(function(){
$(".availability").children("ul").toggle();
$(".availability strong").toggle();
$(".availability .status").toggle();
$(".unavailable").toggle();
return false;
});
//Show only ‘Owned by [logged in library]’ or ‘No Local Copies’ in staff search results
var loglibnode=$(".loggedinusername").nextAll().eq(1);
var loglibtext=$.trim(loglibnode.text());
$(".availability").each(function(){
var ownedlocal=false;
var our_copy_item;
$(this).children("ul").each(function(){
our_copy_item=$(this).find('li:contains("'+loglibtext+'")')
if(our_copy_item.length){
ownedlocal=true;
$(this).parent('.availability').after("<ul>",our_copy_item,"</ul>");
}
});
$(this).append("<br>Click title for full availability");
if(ownedlocal){$(this).append("<p><span style='color:green; font-weight:bold;'>Local Copies:</span></p>");}
else{$(this).prepend('No Local Copies<p>');}
});
$(".availability").children("ul").hide();
$(".availability strong").hide();
$(".availability .status").hide();
$(".unavailable").hide();
Show Local Copy Status in Staff Search Results, Hide all others (Updated for 21.11)
- Developer: Ryan Sipes/Heather Braum (NEKLS), Christopher Brannon (Coeur d'Alene Public Library/CIN), Nick Clemens (VOKAL), Jason Robb (SEKLS)
- Creation Date: 2022-06-08
- Purpose: Version 21.11 added a class (.results_available_count) that broke the original code. This accommodates that new class and fixes an issue where the list item was not making it inside the ul element which results in a cleaner display.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14 - 21.11
//Show only 'Local copies [logged in library]' or 'No local copies'
var libcode = $('#logged-in-info-full .logged-in-branch-name').text();
$(".availability").each(function() {
var ownedlocal = false;
$(this).children("ul").hide().addClass('lctoggle');
$(this).children("ul").each(function() {
var local_copy_check = $(this).find('li:contains("'+libcode+'")');
var local_copy = $(local_copy_check).wrap("<ul class='localcopies'/>").parent();
if (local_copy.length) {
ownedlocal = true;
$(this).parent('.availability').append("<p class=><span style='color:#78A42F; font-weight:bolder;'>Local Copies:</span></p>").append(local_copy).removeClass('lctoggle');
}
});
if (ownedlocal === false) {
$(this).append("<p><span style='color:#FF5F42; font-weight:bold;'>No Local Copies </span></p>");
}
});
//Condense locations
$("#bookbag_form .results_available_count,div[class='availability'] strong").wrap("<a class='viewLocations' />");
$("#bookbag_form .results_available_count,div[class='availability'] strong").append("<span class='instruct'> (show all)</span><span class='instruct' style='display: none;'> (show local)</span>");
$("#bookbag_form div[class='availability']").parent("td").attr('width', '290');
//Trigger to expand/condense locations
$(".viewLocations").click(function() {
$(this).find(".instruct").toggle();
$(this).parent().parent().find(".lctoggle").toggle("slow");
});
Fix Subject Search Links
- Developer: Christopher Brannon - Coeur d'Alene Public Library/CIN
- Purpose: Subject search links in records break if the subject contains parenthesis. This jquery strips the parenthesis from the url link, making the link usable again.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//Fix subject search by striping parenthesis from url links
$('#catalogue_detail_biblio a[href*="su:"]').attr('href', function(_,v){
return v.replace(/(\w)(\(|\))(\w)/g,'$1 $3')
}).attr('href', function(_,v){
return v.replace(/(\(|\))/g,'')
});
//End fix subject search
Enhance Expiration Date on Patron Details Screen
- Developer: Christopher Brannon - Coeur d'Alene Public Library/CIN
- Purpose: Helps expired or soon to be expired date stand out on the Patron Details screen. The value in line 8 (+30) should reflect the same value you have set for NotifyBorrowerDeparture preference.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.14
//Enhance expiration date on patron details page
$("#patron-library-details li:contains('Expiration date: ')").attr('id','patronExpiration');
var ed=new Date();
var edat=( '0' + (ed.getDate()) ).slice( -2 );
var emon=( '0' + (ed.getMonth()+1) ).slice( -2 );
var eyear=ed.getFullYear();
var todaysDate=eyear+'-'+emon+'-'+edat;
ed.setDate(ed.getDate()+30);
edat=( '0' + (ed.getDate()) ).slice( -2 );
emon=( '0' + (ed.getMonth()+1) ).slice( -2 );
eyear=ed.getFullYear();
var expireSoon=eyear+'-'+emon+'-'+edat;
ed=new Date($("#patronExpiration").text().match(/\d{2}\/\d{2}\/\d{4}/g));
edat=( '0' + (ed.getDate()) ).slice( -2 );
emon=( '0' + (ed.getMonth()+1) ).slice( -2 );
eyear=ed.getFullYear();
var expireDate=eyear+'-'+emon+'-'+edat;
if(expireDate >= todaysDate && expireDate < expireSoon){
$("#patronExpiration").attr('style','color: red;').append(' <b><i>(Expires soon!)</i></b>');
}
if(expireDate < todaysDate){
$("#patronExpiration").attr('style','color: red;').append(' <b><i>(EXPIRED!)</i></b>');
};
//End enhance expiration date
Hide Check in Column on Checkout Table
- Developer: Christopher Brannon - Coeur d'Alene Public Library/CIN + Kyle Hall - ByWater Solutions
- Purpose: Hides the check in column in the patron checkout Ajax table. The check in feature in this screen tends to skip hold and transfer actions, which is why we hide it. Traditional jQuery can't catch adjust this table because the table is populated after the page is loaded, so it was necessary to watch for Ajax events. Thanks to Kyle Hall for figuring out the logistics with capturing the Ajax events for me. This code also disables the forgive fines checkbox and rewords the button below the table. The first function using "ajaxSend.dt" will catch elements in the rendered table structure before the table is populated. The function using "init.dt" will catch everything else once the table is populated.
- Creation Date: 2014-10-28
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.16
//Hide check-in column in patron account screens
$('#issues-table').on( 'ajaxSend.dt', function () {
$("#issues-table th:last-child").hide();
$("#issues-table #exemptfine").parent().hide();
$("#RenewCheckinChecked").html("<i class='icon-check'/> Renew checked items");
});
$('#issues-table').on( 'init.dt', function () {
$("#issues-table").find("tbody tr:gt(0) td:last-child").hide();
});
//end Hide check-in
Move overdue items to the top of the current checkouts table
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: In Koha 3.16 the new checkouts table sorts all of the patrons items by date checked out. This means that if the patron has any overdue items, they appear at the bottom of the table and if the patron has a lot of checkouts it can take a lot of scrolling to find the overdues. This code groups any overdue checkouts at the top of the table under a big pink banner that says "Patron has overdue items." It also, thanks to some advice from Christopher Brannon at CIN, disables the column sort on the due date column since that sort does not work correctly.
- Creation Date: 2014-11-06
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.16
//BEGIN Move overdues to the top of the table
$('#issues-table').on( 'init.dt', function () {
$("#issues-table:has(.overdue)").attr('od','overduetable');
if($("#issues-table").attr('od')) {
$("#issues-table tbody").attr("class","checkoutbody");
$('.checkoutbody tr:first').before('<tr id="overduetr"><td colspan="10" style="background-color:pink; font-size: x-large"><strong>Patron has overdue items</strong></td></tr>');
$("#issues-table .overdue").parents("tr").insertAfter("#overduetr");
};
$("#issues-table th:first").off("click").removeClass();
});
//END Move overdues to the top of the table
Move overdue items to the top of the current checkouts table (19.x)
- Developer: George H. Williams - Latah County Library District / VALNet library consortium / Christopher Brannon - Coeur d'Alene Public Library / CIN
- Creation Date: 2020-02-11
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.x
- Notes: This version builds off George's code above by highlighting the barcode in pink when there are overdues. It will also add functionality by removing the pink header and pink from the barcode, and removing the overdue message when there are no longer any overdues left.
//Enhance Overdues in Checkout Table
$('#issues-table').on( 'init.dt', function () {
var TableWidth = $('#issues-table th:last-child').index();
$('#issues-table').attr('rows',TableWidth);
if ($("#issues-table span").hasClass("overdue")) {
$("#issues-table thead").append('<tr id="overduetr"><th colspan=' + TableWidth + ' style="background-color:pink; font-size: x-large"><strong>Patron has overdue items</strong></th></tr>');
$("#issues-table .overdue").parents("tr").prependTo("#issues-table tbody");
}
$('#newonholdduedate').parents('td').show();
$('#exemptfine,label[for="exemptfine"]').hide();
});
jQuery.fn.extend({
CheckOverdue: function() {
if ($('#circ_circulation #circmessages span:contains("Overdues:")').is(':visible')) {
$('#circ_circulation #barcode').css('background-color','pink');
} else {
$('#circ_circulation #barcode').css('background-color','');
}
},
SetOverdue: function(x) {
if (x == 'show') {
$('#circ_circulation #circmessages span:contains("Overdues:")').parent('li').show();
$('#circ_circulation #overduetr,#pat_moremember #overduetr').show();
$('#circ_circulation #barcode').css('background-color','pink');
} else if (x == 'hide') {
$('#circ_circulation #circmessages span:contains("Overdues:")').parent('li').hide();
$('#circ_circulation #overduetr,#pat_moremember #overduetr').hide();
$('#circ_circulation #barcode').css('background-color','');
}
}
});
$('#circ_circulation').CheckOverdue();
$('#circ_circulation #RenewCheckinChecked,#circ_circulation #RenewAll,#pat_moremember #RenewCheckinChecked,#pat_moremember #RenewAll').on('click', function() {
CheckOverdue = 0;
$(this).SetOverdue('hide')
$(document).ajaxStop(function() {
$('span.overdue').each(function() {
$(this).SetOverdue('show')
});
});
});
//end Enhance Overdues
Move overdue items to the top of the current checkouts table (20.x)
- Developer: George H. Williams - Latah County Library District / VALNet library consortium / Christopher Brannon - Coeur d'Alene Public Library / CIN
- Creation Date: 2021-09-02
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 20.x
- Notes: This version modifies the 19.x version by dressing up the header more and adding bootstrap labels to each overdue line.
//Overdue badges for circulation.pl and moremember.pl
$('#issues-table').on( 'init.dt', function () {
$('#circ_circulation span.overdue,#pat_moremember span.overdue').prepend('<span class="label label-danger overdue-label">OVERDUE</span><br />');
});
//END Overdue badge for circulation.pl and moremember.pl
//Enhance Overdues in Checkout Table
$('#issues-table').on( 'init.dt', function () {
$('#issues-table').attr('rows','14');
if ($("#issues-table span").hasClass("overdue")) {
$("#issues-table thead").append('<tr id="overduetr"><th colspan="14"><div id="overdue-banner" style="color: #f54242; background-color: #f7f7f7; font-size: x-large; padding: 10px; border-radius: 5px; border: 2px solid #f54242;"><strong><i class="fa fa-clock-o" aria-hidden="true"></i> <i>Patron has overdue items</i> <i class="fa fa-clock-o" aria-hidden="true"></i></strong></div></th></tr>');
$("#issues-table .overdue").parents("tr").prependTo("#issues-table tbody");
}
$('#newonholdduedate').parents('td').show();
$('#exemptfine,label[for="exemptfine"]').hide();
});
jQuery.fn.extend({
CheckOverdue: function() {
if ($('#circ_circulation #circmessages span:contains("Overdues:")').is(':visible')) {
$('#circ_circulation #barcode').css('background-color','pink');
} else {
$('#circ_circulation #barcode').css('background-color','');
}
},
SetOverdue: function(x) {
if (x == 'show') {
$('#circ_circulation #circmessages span:contains("Overdues:")').parent('li').show();
$('#circ_circulation #overduetr,#pat_moremember #overduetr').show();
$('#circ_circulation #barcode').css('background-color','pink');
} else if (x == 'hide') {
$('#circ_circulation #circmessages span:contains("Overdues:")').parent('li').hide();
$('#circ_circulation #overduetr,#pat_moremember #overduetr').hide();
$('#circ_circulation #barcode').css('background-color','');
}
}
});
$('#circ_circulation').CheckOverdue();
$('#circ_circulation #RenewCheckinChecked,#circ_circulation #RenewAll,#pat_moremember #RenewCheckinChecked,#pat_moremember #RenewAll').on('click', function() {
CheckOverdue = 0;
$(this).SetOverdue('hide');
$(document).ajaxStop(function() {
$('span.overdue').each(function() {
$(this).SetOverdue('show');
});
});
});
$('#circ_circulation #duedatespec').on('blur', function() {
$('#circ_circulation #barcode').focus();
});
//end Enhance Overdues
Move filter bar to the top of the "Saved reports" table
- Developer: George H. Williams - Latah County Library District / VALNet library consortium
- Purpose: Moves the filter bar from the bottom of the "Saved reports" table to the top of that table.
- Creation Date: 2014-11-04
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.16
//BEGIN Move reports filter tool to top of reports table
$(window).bind("load", function() {
$("#table_reports_wrapper .bottom.pager").insertBefore("#table_reports");
});
//END Move reports filter tool to top of reports table
Relabel state to be Province
- Developer: Nicole Engard
- Purpose: Relabel state to be Province
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(document).ready(function(){
$("#memberentry_mainaddress label[for='state']").html("Province:");
$("#table_cities th:contains('State')").html("Province");
$("label[for='city_state']").html("Province:");
});
Hide sort fields from patron screen
- Developer: David Roberts (PTFS Europe)
- Creation Date: 2015-02-05
- Purpose: Hide sort 1 and sort 2 fields from patron registration
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.18
$("#memberentry_library_management label[for='sort1']").hide();
$("#memberentry_library_management label[for='sort2']").hide();
$("#memberentry_library_management #sort1").hide();
$("#memberentry_library_management #sort2").hide();
MARC21 documentation links while adding an authority
- Developer: Stefano Bargioni
- Creation Date: 2013-12-06
- Purpose: Show MARC21 documentation links while adding an authority
- Status: Complete. Will become unuseful when Bug 10941 will be pushed to master.
- Intranet or OPAC?: Intranet
- Version: 3.18
- Adaptations to other languages: Spanish.
if (location.pathname.indexOf('authorities/authorities.pl')>-1) {
var tags = $('div[id^=div_indicator_tag_]');
for (var i=0; i < tags.length; i++) {
var t = $(tags[i]);
var tag_name = t.attr('id').replace(/div_indicator_tag_/,'').substr(0,3);
t.find('span:first').after('<a href="#" class="marcdocs" title="LC MARC auth specifications" onclick="MARC21FieldAuth(\''+tag_name+'\'); return false"> ?</a>');
}
$('.marcdocs').css({'color':'blue','font-weight':'bold'});
}
function MARC21FieldAuth(tag_name) {
if (tag_name == '000') {
window.open("http://www.loc.gov/marc/authority/adleader.html");
}
else if (tag_name.search('09') == 0) {
window.open("http://www.loc.gov/marc/authority/ad09x.html");
}
else {
window.open("http://www.loc.gov/marc/authority/ad"+("000"+tag_name).slice(-3) + ".html");
}
}
Add search by biblionumber option to staff client search drop-down
- Developer: Indranil Das Gupta, L2C2 Technologies. (based on "Add additional searches to OPAC" by Jared Camins-Esakov)
- Purpose: To append a search by biblionumber option to the search options drop-down on staff client search page.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(document).ready(function(){
$("select[name='idx']").append("<option value='biblionumber'>Biblionumber</option>");
});
Hides Auto renew option
- Developer: Ed Veal
- Purpose: Hides the “Auto renew” option from the checkout screen
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: tested 3.18
// Hides the Auto-renew feature
$(document).ready(function(){
$("div.date-select label[for='auto_renew']").remove();
$("div.date-select input[id='auto_renew']").remove();
});
Show cost of checkouts on print slips
- Developer: Kyle M Hall
- Purpose: Shows what it would have cost to purchase all the items checked out today, based on the items.price field. This should work in the regular checkouts slip and also the quick slip.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: tested 3.18
First, add this to your checkedout block on your slip:
<span class="price" style="display: none;"><<items.price>></span>
items.replacementprice could also be used instead of items.price
Next, add this somewhere on the slip:
Cost of buying these items:<br/>
$<span id="price"></span><br/>
Cost of using the library:<br/>
Priceless!<br/>
Lastly, add this to the bottom of your slip:
<script type="text/javascript">
var x = document.getElementsByClassName("price");
var i;
var total = 0;
for (i = 0; i < x.length; i++) {
var cost = parseFloat( x[i].innerHTML );
if ( ! isNaN( cost ) ) {
total += cost;
}
}
document.getElementById("price").innerHTML = total.toFixed(2);
</script>
Show only last four digits of cardnumber on slip
- Developer: Kyle M Hall
- Purpose: Replace all but the last four digits of a cardnumber with asterisks on a print slip
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: tested 3.20
First, add this to your slip:
Cardnumber: <span id="cardnumber"><<borrowers.cardnumber>></span><br/>
Next, add this to the bottom of the slip:
<script type="text/javascript">
var cardnumber = document.getElementById("cardnumber");
var inner_html = cardnumber.innerHTML;
var length = inner_html.length - 4;
var last_four = inner_html.substring( length );
var stars = Array(length).join("*")
cardnumber.innerHTML = stars + last_four;
</script>
Copy Input to All Textboxes in Header Search
- Developer: Christopher Brannon
- Purpose: Copy your input in the header search to all four search boxes so you dont have to start over if you find you are on the wrong tab
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: tested 3.18
//Copy Header Search Input Box
$('#header_search input:not(.submit)').keyup(function() {
var txtClone = $(this).val();
$('#header_search #findborrower,#header_search #ret_barcode,#header_search #searchmember,#header_search #search-form').val(txtClone);
});
//End copy
Enhance No item with barcode message
- Developer: Christopher Brannon - Coeur dAlene Public Library - Cooperative Information Network
- Creation Date: 2016-03-01
- Purpose: Make messages alerting staff that item/barcode is not found stand out from other alerts
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: tested 3.18
//Enhance No item with barcode message
$("p.problem:contains('No item with barcode:')").parent("div").removeClass("alert").css("background-color","red").css("border","1px solid #e0c726").css("background","rgba(0, 0, 0, 0) -moz-linear-gradient(center top , #FAECEC 0%, #FAECEC 9%, #FC1B1B 89%, #FA2A2A 100%) repeat scroll 0 0");
//End Enhance
Copy mobile phone to SMS field
- Developer: Nicole Engard ByWater Solutions
- Creation Date: 2016-03-29
- Purpose: Take the contents of the mobile phone field and populate the SMS field with a +1 and the number
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.22
//Add the +1 to the SMS number field and SMS to fill in with Mobile
if ($("#memberentry_messaging_prefs input[id='SMSnumber']").val() == '' ) {
$("#entryform #mobile").blur(function(){
$("#memberentry_messaging_prefs input[id='SMSnumber']").val("+1"+$("#entryform #mobile").val());
});
}
Add a check/uncheck all libraries button to export.pl
- Developer: Nick Clemens. ByWater Solutions
- Creation Date: 2016-04-15
- Purpose: Add a button to allow for checking/unchecking all libraries on the export tool
- Status: Completed
- Intranet or OPAC?: Intranet
- Version:
$("#tools_export label:contains('Library:')").append("<button id='libcheck' type='button'>Uncheck all</button>");
$("#libcheck").click( function() {
if( $(this).text() == "Check all" ) {
$(".branchgriditem input").prop('checked',true);
$(this).text('Uncheck all');
}
else {
$(".branchgriditem input").prop('checked',false);
$(this).text('Check all');
}
Fill in default values for indicators and hide them from catalographers
- Developer: Joachim Ganseman. Koninklijk Conservatorium Brussel
- Creation Date: 2016-06-23
- Purpose: Speed up catalography by automatically filling in indicators for fields where they are always the same.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.05
if ( $("#cat_addbiblio") ) { // only do this in the addbiblio form
// Fill in default values for some indicators
$("input[name^='tag_028_indicator1']").val("2"); // Field 028 : Default to plate nr
$("input[name^='tag_028_indicator2']").val("0");
$("input[name^='tag_100_indicator1']").val("1"); // Field 100 : Default to Family Name
$("input[name^='tag_490_indicator1']").val("0"); // Field 490 : Default to untraced series
$("input[name^='tag_542_indicator1']").val("1"); // Field 542 : Default to publicly available info
$("input[name^='tag_650_indicator1']").val("0"); // Field 650 : Default to "undefined level, no thesaurus"
$("input[name^='tag_650_indicator2']").val("4");
$("input[name^='tag_700_indicator1']").val("1"); // Field 700 : Default to Family Name
// Now hide all indicator elements in the input form from the user.
$("input[class~='indicator']").hide();
}; // end if
Check validity of ISBN, ISSN, ISMN and URL before submitting the addbiblio form
- Developer: Joachim Ganseman. Koninklijk Conservatorium Brussel
- Creation Date: 2016-06-23
- Purpose: Avoid incorrect numbers or URLs to be added to the database.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.05
if ( $("#cat_addbiblio") ) // only do this in the addbiblio form
{
// add an additional event handler to the save buttons ( one already exists: .onOption() )
$("#saverecord, #saveandview, #saveanditems, #saveandcontinue").click( function( event ) {
var mes = "";
// run all tests as functions which might add a new error message to the existing ones
mes = test020a( mes );
mes = test022a( mes );
mes = test024a( mes );
mes = test856a( mes );
if (mes != "") {
alert(mes);
event.stopImmediatePropagation(); // block the other event handlers which trigger submission of the form
return false;
} else {
return true;
}
});
}; // end if in addbiblio form
/* Helper function to test whether ISBN is correctly prefixed 10- or 13-digit. Does not calculate checksum. */
// regex adapted from http://regexlib.com/REDetails.aspx?regexp_id=1640
var test020a = function( mes ) {
var ISBNregex = /^(97(8|9))?\d{9}(\d|X)$/;
$("[id^='tag_020_subfield_a']").each( function() { // loop over all ISBN fields
var value = $(this).val();
if (!value || value == "") { return true; }; // 'continue' statement
if (!ISBNregex.test(value)) {
$(this).addClass("subfield_not_filled"); // color the background of this field
mes += "Field 020$a: Invalid ISBN format! Please correct, or put it in subfield $z.\n";
} else {
$(this).removeClass("subfield_not_filled"); // reset background of this field
}
});
return mes;
};
/* Helper function to test whether ISSN is formatted as '1234-5678' */
var test022a = function( mes ) {
var ISSNregex = /^\d{4}-\d{3}(\d|X)$/;
$("[id^='tag_022_subfield_a']").each( function() { // loop over all ISSN fields
var value = $(this).val();
if (!value || value == "") { return true; }; // 'continue' statement
if (!ISSNregex.test(value)) {
$(this).addClass("subfield_not_filled");
mes += "Field 022$a: Invalid ISSN format! Please correct, or put it in subfield $y.\n";
} else {
$(this).removeClass("subfield_not_filled");
}
});
return mes;
};
/* Helper function to test whether ISMN is properly formatted */
// note: this assumes field 024 is only used for ISMN and not for any other std number.
var test024a = function( mes ) {
var ISMNregex = /^((9790)|M)\d{9}$/;
$("[id^='tag_024_subfield_a']").each( function() { // loop over all ISMN fields
var value = $(this).val();
if (!value || value == "") { return true; }; // 'continue' statement
if (!ISMNregex.test(value)) {
$(this).addClass("subfield_not_filled");
mes += "Field 024$a: Invalid ISMN format! Please correct, or put it in subfield $z.\n";
} else {
$(this).removeClass("subfield_not_filled");
}
});
return mes;
};
/* Helper function for formatting of URLs (currently only supporting https, http, ftp) */
// Regex adapted from http://regexlib.com/REDetails.aspx?regexp_id=1048
var test856u = function( mes ) {
var uriRegex = /^(((ht|f)tp(s?))\:\/\/)?((([a-zA-Z0-9_\-]{1,}\.)+[a-zA-Z]{2,})|((?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(\?(\.?\d)\.)){4}))(:[a-zA-Z0-9]+)?(\/[a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~]*)?$/;
$("[id^='tag_856_subfield_u']").each ( function() {
var value = $(this).val();
if (!value || value == "") { return true; }; // continue statement
if (!uriRegex.test(value)) {
$(this).addClass("subfield_not_filled");
mes += "Field 856$u: Invalid URL. \n";
} else {
$(this).removeClass("subfield_not_filled");
}
});
return mes;
};
Pass data from the addbiblio to the additem form
- Developer: Joachim Ganseman. Koninklijk Conservatorium Brussel
- Creation Date: 2016-06-23
- Purpose: Speed up catalography by automatically filling fields of the additem form with data from the addbiblio form.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.05
if ( $("#cat_addbiblio") ) { // only do this in the addbiblio form
// add an additional event handler to the save buttons: when saved, store data in browser.
$("#saverecord, #saveandview, #saveanditems, #saveandcontinue").click( function( event ) {
// copy values that need to be available in additem.pl to HTML5 sessionStorage (no need for cookies)
sessionStorage.setItem( "current_callnumber", $("[id^='tag_001_subfield_00']").val() ); // our callnumber is recorded in 001
sessionStorage.setItem( "current_accessrestriction", $("[id^='tag_506_subfield_a']").val() ); // our accessrestriction is recorded in 506
sessionStorage.setItem( "current_status", $("[id^='tag_583_subfield_l']").val() ); // our lost status is recorded in 583
return true;
}
}; // end if in the addbiblio form
if ( $("#cat_additem") ) { // only do this in the additem form.
// pre-fill the 952$1 "lost status". In Koha default settings, this is encoded as "1" in subfield 1.
$("[id^='tag_952_subfield_1']").val( (sessionStorage.getItem("current_status") == "LOST") ? "1" : "" );
// pre-fill the 952$7 "not for loan status". In Koha default settings, this is encoded as "1" in subfield 7.
$("[id^='tag_952_subfield_7']").val( (sessionStorage.getItem("current_accessrestriction") != "") ? "1" : "" );
// pre-fill the 952$o "full call number" field.
$("[id^='tag_952_subfield_o']").val( sessionStorage.getItem("current_callnumber") );
}; // end if in the additem form
Copy data entered in one field to another
- Developer: Joachim Ganseman. Koninklijk Conservatorium Brussel
- Creation Date: 2016-06-23
- Purpose: Speed up catalography by automatically filling in duplicated fields.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.05
// Example: in addbiblio form, copy data from field 001, once entered, into field 590$a
$("[id^='tag_001_subfield_00']").blur( function() {
$("[id^='tag_590_subfield_a']").val( $("[id^='tag_001_subfield_00']").val() );
});
Autofill catalographer information in the addbiblio form
- Developer: Joachim Ganseman. Koninklijk Conservatorium Brussel
- Creation Date: 2016-06-23
- Purpose: Automatically add data that records who did the catalography to a bibliographic record.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.05
if ( $("#cat_addbiblio") ) { // only do this in the addbiblio form
// put string "Catalography:" in field 583$a
$("[id^='tag_583_subfield_a']").val("Catalography:");
// copy login of the current user to field 583$k
$("[id^='tag_583_subfield_k']").val( $(".loggedinusername").text() );
// if not yet set, copy current date in yyyymmdd format to field 583$c
var yyyymmdd = (new Date()).toISOString().slice(0,10).replace(/-/g,""); // note: this is the GMT date!
var currentdate = $("[id^='tag_583_subfield_c']").val();
if (!currentdate || currentdate == "")
{
$("[id^='tag_583_subfield_c']").val(yyyymmdd);
}
}; // end if addbiblio
Remove "Pay selected" button from "Pay fines" tab in Fines module
- Developer: George H. Williams - Northeast Kansas Library System
- Purpose: Removes the "Pay selected" button - There is a bug in 3.22 (see https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15397) that is causing fee payment problems with the "Pay selected" button. This jQuery should remove that button until the bug can be fixed which should prevent new problems from being created
- Creation Date: 2016.07.18
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.22
//BEGIN Hides "Pay selected" button on the Pay fines tab in the Fines module
$('#payselected').hide();
//END
Change where the patron link on returns.pl points
- Developer: Jason Robb (SEKLS)
- Purpose: In the table generated by check-ins on returns.pl, the patron link directs to the moremember.pl for the patron. This code causes that link to instead point to circulation.pl for the patron.
- Creation Date: 8/11/2016
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.22
var0 = $('body').is("#circ_returns");
if(var0 !=0) {
$('a').each(function() {
this.href = this.href.replace('members/moremember.pl', 'circ/circulation.pl');
}
)}
Hide fields on add/edit items page based on field label
- Developer: Jason Robb (SEKLS)
- Purpose: Hides fields on the add/edit items screen (additem.pl). Streamlines workflow and prevents data from being entered into the wrong field.
- Creation Date: 8/11/2016
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 3.22
- Note: Some fields are hidden by default via the frameworks. I still included those in this as removing them in this manner also removes the extra space their absence creates which makes the screen look cleaner.
var0 = $('body').is("#cat_additem");
if(var0 !=0) {
$('span:contains("Source of classification or shelving scheme")').parent().parent().parent().hide();
$('span:contains("Materials specified (bound volume or other part)")').parent().parent().parent().hide();
$('span:contains("Use restrictions")').parent().parent().parent().hide();
$('span:contains("Uniform Resource Identifier")').parent().parent().parent().hide();
$('span:contains("Price effective from")').parent().parent().parent().hide();
$('span:contains("Price effective from")').parent().parent().parent().hide();
$('span:contains("Price effective from")').parent().parent().parent().hide();
$('span:contains("Inventory number")').parent().parent().parent().hide();
$('span:contains("Shelving control number")').parent().parent().parent().hide();
$('span:contains("Date last checked out")').parent().parent().parent().hide();
$('span:contains("Total Checkouts")').parent().parent().parent().hide();
$('span:contains("Total Renewals")').parent().parent().parent().hide();
$('span:contains("Total Holds")').parent().parent().parent().hide();
$('span:contains("Checked out")').parent().parent().parent().hide();
$('span:contains("Date last seen")').parent().parent().parent().hide();
$('span:contains("Coded location qualifier")').parent().parent().parent().hide();
}
Add clear and preset permission buttons to user permissions page (v16.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds permission clear and preset buttons to user permissions page.
- Creation Date: 2/21/2017
- Updated: 11/07/2019
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 16.x
//Permissions Quick Set
$('#pat_member-flags #permissionstree').before('<div class="btn-toolbar" id="permissions_toolbar" style="left: auto; width: 676px; position: static;"><button id="cleartree" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-square-o"></i> Clear All Flags</button><button id="setcirc" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Circ</button><button id="setmanager" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Manager</button><button id="copypref" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-clone"></i> Copy to (borrower #): </button> <input type="text" id="copypref_bor"></div>');
$( "#cleartree" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked');
$('#pat_member-flags li.collapsable').find('div').click();
});
$( "#setcirc" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked').removeAttr('disabled');
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #reserveforothers_place_holds, #flag-10, #reports_execute_reports').each(function() {
$(this).click();
$(this).closest('li.expandable').find('div').click();
});
});
$( "#setmanager" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked').removeAttr('disabled');
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #flag-6, #flag-9, #flag-10, #tools_inventory, #tools_items_batchmod, #reports_execute_reports').each(function() {
$(this).click();
$(this).closest('li.expandable').find('div').click();
});
});
//End Permissions Quick Set
Add clear and preset permission buttons to user permissions page (v19.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds permission clear and preset buttons to user permissions page.
- Creation Date: 10/17/2019
- Updated: 11/07/2019
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.x
//Permissions Quick Set
$('#pat_member-flags #permissionstree div.permissions').before('<div class="btn-toolbar" id="permissions_toolbar" style="left: auto; width: 676px; position: static;"><button id="cleartree" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-square-o"></i> Clear All Flags</button><button id="setcirc" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Circ</button><button id="setmanager" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Manager</button></div>');
$( "#cleartree" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked');
$('#pat_member-flags').find('a.togglechildren_off:visible').click();
});
$( "#setcirc" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked').removeAttr('disabled');
$('#pat_member-flags').find('a.togglechildren_off:visible').click();
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #reserveforothers_place_holds, #flag-10, #reports_execute_reports').each(function() {
$(this).click();
$(this).closest('div.parent').find('a.togglechildren_on:visible').click();
});
});
$( "#setmanager" ).click(function() {
$('#pat_member-flags input[name="flag"]').removeAttr('checked').removeAttr('disabled');
$('#pat_member-flags').find('a.togglechildren_off:visible').click();
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #flag-6, #flag-9, #flag-10, #tools_inventory, #tools_items_batchmod, #reports_execute_reports').each(function() {
$(this).click();
$(this).closest('div.parent').find('a.togglechildren_on:visible').click();
});
});
//End Permissions Quick Set
Add clear and preset permission buttons, and a copy button to user permissions page (v20.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds permission clear and preset buttons to user permissions page, plus a button to copy current permissions to another borrower via cardnumber.
- Instructions: Requires a public report (see below). report?id= must be updated with your report number.
- Creation Date: 04/17/2019
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 23.05
- Updated: 01/25/2024
- Update Notes: Updated target selection on save button for the copy and save permissions function. Class was changed on button after 23.05. Removed redundant clear permissions button as there is a link that does the same thing. Switched to api to grab borrowernumber rather than depending on a report. CB
//Permissions Quick Set (v23.05)
//Create Buttons
$('#pat_member-flags #permissionstree div.permissions').before('<div class="btn-toolbar" id="permissions_toolbar" style="left: auto; width: 676px; position: static;"><button id="setcircsingle" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Circ (Single Account)</button><button id="setcircshared" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Circ (Shared Account)</button><button id="setmanager" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-check-square-o"></i> Set Basic Manager</button><button id="copypref" type="button" style="font-size:12px; margin-left:5px;"><i class="fa fa-clone"></i> Copy Permissions to...</button></div>');
//Basic Circ Button Settings (Single Account)
$( "#setcircsingle" ).click(function() {
$( "#cleartree" ).click();
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #reserveforothers_place_holds, #flag-10, #suggestions_suggestions_manage, #tools_batch_upload_patron_images, #reports_execute_reports, #flag-17, #clubs_enroll, #cash_management_cashup, #cash_management_takepayment').each(function() {
$(this).click();
$(this).closest('div.parent').find('a.togglechildren_on:visible').click();
});
});
//Basic Circ Button Settings (Shared Account)
$( "#setcircshared" ).click(function() {
$( "#cleartree" ).click();
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #reserveforothers_place_holds, #flag-10, #suggestions_suggestions_manage, #tools_batch_upload_patron_images, #reports_execute_reports, #clubs_enroll, #cash_management_takepayment').each(function() {
$(this).click();
$(this).closest('div.parent').find('a.togglechildren_on:visible').click();
});
});
//Basic Manager Button Settings
$( "#setmanager" ).click(function() {
$( "#cleartree" ).click();
$('#pat_member-flags').find('#circulate_circulate_remaining_permissions, #circulate_force_checkout, #circulate_manage_restrictions, #flag-2, #flag-4, #flag-6, #flag-9, #flag-10, #suggestions_suggestions_manage, #tools_batch_upload_patron_images, #tools_inventory, #tools_items_batchmod, #reports_execute_reports, #flag-17, #clubs_enroll, #cash_management_cashup, #cash_management_takepayment').each(function() {
$(this).click();
$(this).closest('div.parent').find('a.togglechildren_on:visible').click();
});
});
//Copy Permissions Button Modal and Settings
$('#pat_member-flags').append('<div id="CopyPermissionsModal" class="modal fade" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><form method="post" action="submit"><input type="hidden" name="" value=""><div class="modal-header"><h3>Copy Permissions</h3></div><div id="CardNumberInfo" class="modal-body"><label for="infoCardNumber">Card Number (Target User): </label><input id="infoCardNumber" type="text" size="10"></div><div class="modal-footer"><button id="btnCopySave" type="button" class="btn btn-default" style="background-image: none; background-color: rgb(105, 162, 104);"><i class="fa fa-clone"></i> Copy & Save Permissions</button><button id="btnCopyCancel" data-dismiss="modal" aria-hidden="true" class="btn"><i class="fa fa-times"></i> Cancel</button></div> <!-- /.modal-footer --></form> <!-- /.confirm --></div> <!-- /.modal-content --></div> <!-- /.modal-dialog --></div>');
//Copy and Save if Enter is pressed
$('#CopyPermissionsModal').keypress(function(e){
if(e.keyCode==13) {
$('#btnCopySave').click();
return false;
}
});
//Open Modal
$('#pat_member-flags #copypref').on('click', function() {
$('#CopyPermissionsModal').modal('show');
$('#CopyPermissionsModal').on('shown.bs.modal', function () {
$('#infoCardNumber').focus();
});
});
//Change Borrower Number and Save
$('#pat_member-flags #btnCopySave').on('click', function () {
//Get patron data
var usrCardNumber = $('#infoCardNumber').val();
var usrBorrowerNumber;
var url = '/api/v1/patrons?cardnumber=' + usrCardNumber;
$.ajax({
async: false,
url: url,
success: function(data) {
usrBorrowerNumber = [data[0].patron_id];
}
});
$('#pat_member-flags #borrowernumber').val(usrBorrowerNumber);
$('#btnCopyCancel').click();
$('#pat_member-flags #permissions_toolbar button[type="submit"]').click();
});
//Create alert to display after permissions are copied.
$('#pat_moremember #patron-id').after('<h3><span id="PermissionsUpdate" style="display: none; color: red; background-color: yellow;"><b><i> Permissions copied to new user.</i><b></span></h3>');
//Display alert next to patron info showing permissions have been copied.
$('#pat_moremember').each(function() {
var referrer = document.referrer;
var URLParams = new URLSearchParams(window.location.search);
var URLBorrower = URLParams.get('borrowernumber');
var referrerBorrower = referrer.split("=").pop();
if ((referrer.indexOf("member-flags.pl") >= 0) && (URLBorrower != referrerBorrower)) {
$('#PermissionsUpdate').fadeIn().delay(3000).fadeOut();
}
});
//END Permissions Quick Set
- Developer: George Williams (NExpress)
- Purpose: Becasue the circulation rules table is 7 miles wide, it can be hard to follow which line you're looking at from one end of the table to the other. This jQuery creates a button to hide left hand navigation menu on the circulaiton and fine rules page so that if you don't need that menu you can fit more of the rules table on one screen.
- Creation Date: 3/30/2017
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: developed on 3.22.08 - Broken on 21.05
//BEGIN Create button to hide left hand navigation bar
$("#admin_smart-rules #navmenu").parent().prepend("<button id='navhide' type='button'>Hide admin column</button>");
$("#navhide").click( function() {
$("#navhide").hide();
$("#navmenu").hide();
$(".yui-t1 #yui-main .yui-b").css("margin-left", "1em");
});
//END
Move rows in the circulaiton and fine rules table to move it to the bottom with click
- Developer: George Williams (NExpress)
- Purpose: Becasue the circulation rules table is 7 miles wide, it can be hard to follow which line you're looking at from one end of the table to the other. This jQuery moves any row of the rules table to the bottom of the table in order to make it easier to for your eyes to track across the screen.
- Creation Date: 3/30/2017
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 3.22.08 - Tested and confirmed as working on 21.05
//BEGIN Click on circ rule to move it to the bottom of the table
$("#default-circulation-rules tr:contains(Edit)").click(function() {
$(this).insertBefore("#edit_row");
});
//END
Add drop down to filter circulation and fine rules table
- Developer: Joe Sikowitz, Fenway Library Organization
- Creation Date: 2019-05-03
- Purpose: Filters the Circulation and Fine Rules table by patron category so that it is easier to read.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
//Add the drop down with the patron category values
$("div.help").after("<label>Filter by Patron Category: <select id='rulesSearch'><option value='All Patron Categories'>All Patron Categories</option><option value='Patron Category 1'>Patron Category 1</option><option value='Patron Category 2'>Patron Category 2</option></select></label><br><br>");
//Triggered when a value is selected in the drop down
$("#rulesSearch").change(function(){
var optselect = $("#rulesSearch").val(); //Creates a variable from the value of the option chosen in drop down
$("#default-circulation-rules tbody tr").hide(); //Hides all rows in the table
$("#default-circulation-rules tbody tr:contains("+optselect+")").show(); //Shows the rows that contain the chosen value
if(optselect == "All Patron Categories"){$("#default-circulation-rules tbody tr").show();} //Shows all rows if 'All Patron Categories' is selected
});
Autofill "Hold expires on" date when placing a request in the staff client
- Developer: George Williams (NExpress)
- Purpose: Autofills the "Hold expires on date" with the date 1 year from today when placing a request from the staff client. There is a corresponding piece of jQuery for the OPAC in the OPAC section. The future date can be modified by changing the values in the day, month, and year variables.
- Creation Date: 3/30/2017
- Status: Completed - Can cause errors around Leap Day when jQuery calculates a nonexistent date (like 2/29/20201)
- Intranet or OPAC?: Intranet
- Version: Developed on 3.16
- Koha breadcrumbs: Catalog › TITLENAME › Place a hold on TITLENAME
//BEGIN Set newly placed holds in staff client to expire after one year if not filled
var holdtodate = new Date();
var day = ("0" + holdtodate.getDate()).slice(-2);
var month = ("0" + (holdtodate.getMonth() + 1)).slice(-2);
var year = ("0" + (holdtodate.getFullYear() + 1)).slice(-4);
var holdtill = (month) + "/" + (day) + "/" + (year);
$('#hold-request-form .holddateto').val(holdtill);
//END
Autofill "Hold expires on" date when placing a request in the staff client
- Developer: Lucas Gass (Bywater Solutions)
- Purpose: Autofills the "Hold expires on date" with the date 1 year from today when placing a request from the staff client. There is a corresponding piece of jQuery for the OPAC in the OPAC section. The future date can be modified by changing the values in the day, month, and year variables.
- Creation Date: 8/25/20
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.11
//BEGIN Set newly placed holds in staff client to expire after one year if not filled
$(document).ready(function() {
if ( $('#circ_request').length ) {
$.getScript( "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js" )
.done(function( script, textStatus ) {
$('#hold-request-form #to').val( moment().add(1, 'years').calendar() );
})
.fail(function( jqxhr, settings, exception ) {
console.log( 'Could not load MomentJS' );
});
}
});
//END
Force staff to select SMS provider and enter SMS number before checkboxes can be checked
- Developer: George Williams (NExpress)
- Purpose: There is a bug in Koha 16.11 that breaks patron messaging if SMS checkboxes are checked but no SMS provider is selected. This jQuery attempts to fix this by 1) disabling the checkboxes and SMS number entry if no provider is selected 2) clearing the SMS number and all SMS checkboxes if the provider is removed 3) forcing the SMS number to 10 numeric characters with no punctuation or spaces 4) moving the SMS provider and SMS number above the messaging preferences table so it is more intuitive for staff to enter that information first 5) and finally renaming the SMS labels from "SMS" to "Text message" because many staff at our libraries don't know what SMS means. There is corresponding jQuery for the OPAC below
- Creation Date: 4/10/2017
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 16.11.05
- Koha breadcrumbs: Home › Patrons › Add patron
- Koha breadcrumbs: Home › Patrons › PATRONNAME › Modify patron
//BEGIN SMS changes in the staff client
//BEGIN Hides SMS number and all SMS checkboxes when page is loaded
$("#SMSnumber").parent().hide();
$("#sms1, #sms2, #sms4, #sms5, #sms6").attr("disabled","disabled");
//BEGIN Show SMS number if provider is not null and clear number and all SMS checkboxes if the provider is changed to null
$("body").on("mousemove change click keyup", function(){
if($("#sms_provider_id").val() != ""){
$("#SMSnumber").parent().show("slow");
} else {
$("#SMSnumber").parent().hide("slow");
$("#SMSnumber").val("");
$("#smsbuttons").hide();
$("#sms1, #sms2, #sms4, #sms5, #sms6").attr("disabled", "disabled");
$("#sms1, #sms2, #sms4, #sms5, #sms6").prop("checked", false);
}
});
//BEGIN Enable SMS checkboxes only if SMS number is 10 digits and force SMS number entry to numerals only - no punctuation, alphanumeric characters, or spaces
$("#SMSnumber").attr('maxlength','10');
$('#SMSnumber').keydown(function (e) {
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
(e.keyCode == 65 && e.ctrlKey === true) ||
(e.keyCode >= 35 && e.keyCode <= 40)) {
return;
}
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
$("body").on("mousemove change click keyup", function(){
if($("#SMSnumber").val().length == 10){
$("#sms1, #sms2, #sms4, #sms5, #sms6").removeAttr("disabled");
$("#smsbuttons").show("slow");
} else {
$("#sms1, #sms2, #sms4, #sms5, #sms6").attr("disabled", "disabled");
$("#sms1, #sms2, #sms4, #sms5, #sms6").prop("checked", false);
$("#smsbuttons").hide("slow");
}
});
//BEGIN Move SMS stuff above the table so that the first fields that need to be filled out are the first ones that staff see
$("#memberentry_messaging_prefs > table").wrap('<div id="messagetable"></div>');
$("#memberentry_messaging_prefs label:contains('SMS number:')").parent().wrap('<div id="smsnumbermove"></div>');
$("#memberentry_messaging_prefs label:contains('SMS provider:')").parent().wrap('<div id="smsprovidermove"></div>');
$("#smsnumbermove").prependTo("#messagetable").parent();
$("#smsprovidermove").prependTo("#messagetable").parent();
//BEGIN Rename SMS "Text messaging" for the sake of staff who don't know what SMS stands for
$('#memberentry_messaging_prefs label, #memberentry_messaging_prefs th').each(function() {
var text = $(this).text();
$(this).text(text.replace('SMS', 'Text message'));
});
Allow to reorder automatic item modification by age rules
- Developer: Kidclamp
- Purpose: Reorder (move up) item modification rules
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$( document ).ready(function() {
$("#tools_automatic_item_modification_by_age #rules fieldset legend").each(function(){
$(this).prepend('<a class="moveup" href="#">Up</a> ');
});
$(".moveup").click(function(){
$(this).closest("fieldset").insertBefore( $(this).closest("fieldset").prev() );
});
});
Disable (more-or-less) Firefox Screenshots on all pages in Koha
- Developer: George Williams (NExpress)
- Purpose: Disables Firefox's new Screenshots button which includes a feature that saves screenshots to an unsecured location in the cloud.
- Creation Date: 09/14/2017
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 16.11
- Koha breadcrumbs: Home › *
- Note: If someone does try to use Firefox Screenshots and this jQuery is in Koha, Firefox Screenshots may start sending warning messages to the browser.
//BEGIN disable Firefox Screenshots whenever the mouse is moved
$('html').mousemove(function() {
$('#firefox-screenshots-preselection-iframe').remove();
});
//END
Hide non-local patrons on the "Update patron records" page
- Developer: George Williams (NExpress)
- Purpose: With 50+ branches it can be hard for staff to find the patrons from their library on the "Update patron records" screen. This hides all non-local-library patrons from the patron update screen. This includes an optional button so that those may actually need to see all of the patrons needing updates can see everyone if they choose.
- Creation Date: 11/29/2017
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 16.11
- Koha breadcrumbs: Home › Patrons › Update patron records
//BEGIN Hide patron update notices from other branches
$(window).load(function(){
var loglibnode=$("#logged-in-branch-name").text();
$('#pending_updates h3 a:not(:contains("('+loglibnode+'"))').parent().hide();
$('#pending_updates a:not(:contains("('+loglibnode+'"))').parent().next('.ui-accordion-content').hide();
});
//BEGIN Add button to show all pending patron updates (optional)
$('#yui-main > h2:contains(Update patron records)').parent().prepend("<button id='pudshow' type='button'>Show all pending updates</button>");
$("#pudshow").click( function() {
$("#pudshow").hide();
$('#pending_updates h3 a:not(:contains("('+loglibnode+'"))').parent().show();
});
Prevent over-write-offs
- Developer: George Williams (NExpress)
- Purpose: Now that we have partial write-offs staff can accidentally write-off an amount greater than the amount owed on an individual fee, thus adding a credit to the patron's account (community bug 20120). This prevents a write-off amount greater than the amount outstanding on an individual fee until such a time that this bug is patched.
- Creation Date: 2018.02.15
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 17.05.08
- Koha breadcrumbs: Home › Patrons › Pay fines for PATRONNAME › Write off an individual fine
//BEGIN Prevent over-write-offs
$("#amountwrittenoff").attr("type", "number");
$("#amountwrittenoff").attr("step", "any");
$("#amountwrittenoff").attr("min", "0");
$("#amountwrittenoff").attr("max", $("#amountwrittenoff").val());
Sort the SMS providers drop-down
- Developer: George Williams (NExpress)
- Purpose: The SMS provider drop-down is sorted in the order the provider was added rather than alphabetically by provider name. This makes it difficult for library staff to find providers not added the the list in alphabetical order. This jquery sorts the list alphabetically leaving "Unknown" at the top and maintaining any provider already selected if editing a patron record. Related to community bug 20439.
- Creation Date: 2018.05.07
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 17.05.10
- Koha breadcrumbs: Home › Patrons › PATRONNAME › Modify patron | Home › Patrons › Add patron
//BEGIN force SMS provider to sort alphabetically, put "Unknown" at top of list, and keep any pre-existing selection after sort is finished
$("#sms_provider_id option:contains('Unknown')").text(' Unknown');
$("#sms_provider_id").one( "click", function() {
var preselected = $('#sms_provider_id option:selected').val();
$("#sms_provider_id").html($('#sms_provider_id option').sort(function(x, y) {
return $(x).text().toUpperCase() < $(y).text().toUpperCase() ? -1 : 1;
}));
$("#sms_provider_id").val(preselected);
});
Hide unnecessary language tabs on Edit notice screen
- Developer: Magnus Enger
- Creation Date: 2018-06-06
- Purpose: If you have a number of languages activated on a server, and an instance that does not use all of them, you might want to hide the ones you do not use in the list of language tabs that show up when you edit a notice/slip.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 17.11
$("#tabs li").remove(":contains('es-ES')");
Preserve white spaces of Control Fields
- Developer: Stefano Bargioni
- Creation Date: 2018-06-22
- Purpose: Preserve white spaces of Control Fields in MARC view (bib and auth records), and show position of char on mouse hover.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 17.11 (also tested on 3.12, 3.18, 3.22)
if ( location.pathname.indexOf('catalogue/MARCdetail.pl')>-1 || location.pathname.indexOf('authorities/detail.pl')>-1 ) {
var tags = $('.tag_title:contains("00")'); // includes x00
for (var i = 0; i < tags.length; i++) {
var tag = tags[i];
if ($(tag).text().trim().indexOf('00')==0) { // apply only to 00x
var tag = tags[i];
var p = $(tag).parent().find('p');
// p.text() is divided in lines; the first one is "@", the last one is the tag value
var ts = p.text().trim().split('\n');
var ts_last = ts.length-1;
ts[ts_last] = ts[ts_last].replace(/^ +/,''); // left trim
// char by char
var tc = '';
for (var j = 0; j < ts[ts_last].length; j++) {
var c = ts[ts_last][j];
tc += '<span class="char_fixed" title="position '+j+'">'+c+'</span>';
}
p.html(' '+ts[0]+'<span class="white_space_pre">'+tc+'</span>');
$('.white_space_pre').css({"font-family":"monospace", "white-space":"pre"});
$('.char_fixed').css({'border':'1px solid lightgray', 'margin':'1px', 'padding':'2px'});
$('.char_fixed').tooltip({ "show": { "effect":"blind", "duration":800 } });
$('.char_fixed').hover(
function() {
$(this).css('background-color','yellow');
},
function() {
$(this).css('background-color','');
}
)
}
}
}
Hide JSON URL in Reports Table
- Developer: Andrew Fuerste-Henry
- Creation Date: 2018-09-19
- Purpose: Hide the column of JSON urls in the reports table
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
$("#table_reports td.report_json_url").hide();
$("#table_reports th:contains('JSON URL')").hide();
Copy Last 4 Digits of Card Number Into Password on Patron Creation
- Developer: Lucas Gass
- Creation Date: 2018-09-20
- Purpose: Autopopulate password with the last four digits of the cardnumber, does not work with AutoMemberNum
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
$(document).ready(function () {
if ( $('#pat_memberentrygen').length > 0 ) {
$("#cardnumber").on("keyup change", function() {
var cardNum = this.value;
var lastFour = cardNum.substring(cardNum.length-4, cardNum.length );
if (cardNum.length > 3){
$("#password, #password2").val(lastFour);
}
});
}
});
Copy Card Number Into Username
- Developer: Andrew Fuerste-Henry
- Creation Date: 2018-09-21
- Purpose: Autopopulate username with cardnumber, does not work with AutoMemberNum
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
$(document).ready(function () {
if ( $('#pat_memberentrygen').length > 0 ) {
$("#cardnumber").on("keyup change", function() {
var cardNum = this.value;
if (cardNum.length > 13){
$("#userid").val(cardNum);
}
});
}
});
Select preferred notice language in new patron page
- Developer: Fridolin Somers
- Creation Date: 2018-09-20
- Purpose: In new patron page, automatically select 'default' in preferred notice language, instead of current staff interface language
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 17.11
$(document).ready(function () {
$("body#pat_memberentrygen input[name='op'][value='insert']").parent().find("select[name='lang']").val("default").change();
});
input[name='op'][value='insert'] is to avoid changing existing value on edition of an existing patron, since page is the same has new patron creation.
Add button 'Exit without saving' when editing an authority record
- Developer: Stefano Bargioni (Pontificia Università della Santa Croce)
- Creation Date: 2018-11-14
- Purpose: Allow cataloguer to exit without saving modifications (or use browser button 'go back')
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
var authid = $('h1').text().replace(/[^0-9]/g,'');
$('#toolbar').append('<div class="btn-group">\
<a href="detail.pl?authid='+authid+'" id="exitauth" class="btn btn-default btn-sm" accesskey="z">\
<i class="fa fa-remove"></i> Exit without saving</a>\
</div>');
Payment Type Enhancement
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2018-11-29
- Purpose: Make the payment type required on payments, hide it on the Write off selected page (18.11), and ask for check number if check is chosen
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
if($("#pat_paycollect input[value='writeoff']").length) {
$('#pat_paycollect input[name="submitbutton"]').before('<button id="validate" class="btn btn-small toggler" name="validate" style="margin-left: 0px;" onclick="return validatePayType();"><i class="fa fa-pencil"></i> Confirm</button>');
$("#pat_paycollect #payment_type").parent('li').hide();
} else {
$('#pat_paycollect input[name="submitbutton"]').before('<button id="validate" class="btn btn-small toggler" name="validate" style="margin-left: 0px;" onclick="return validatePayType();"><i class="fa fa-money"></i> Confirm</button>');
}
$('#pat_paycollect input[name="submitbutton"]').hide();
// create the validation function
validatePayType = function () {
//start with an empty alert message
var mes = "";
// validate payment_type
if ($("#pat_paycollect #payment_type").val() == '' && !$("#pat_paycollect input[value='writeoff']").length) {
mes = mes + "\nPlease select a Payment Type.\n";
}
// grab Check Number
var checkNum='';
if ($("#pat_paycollect #payment_type").val() == 'CHECK') {
var checkNum=prompt("Check number");
$('#selected_accts_notes, #payment_note').val(function(index, value) {
if (checkNum == '' || checkNum === null) {
mes = mes + "\nCheck number not entered!\n";
return;
} else {
return 'Check #' + checkNum + '\n' + value;
}
});
}
// display the alert
if (mes != "") {
alert(mes);
return false;
} else {
// submit the validated form
if( $('#payindivfine').length ){
$('#payindivfine').submit();
} else if( $('#payfine').length ) {
$('#payfine').submit();
}
}
};
Holdings Enhancement
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2019-01-10
- Purpose: Show the number of items your library has listed in the current bib record
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
//Count items for your library in holdings
var loggedbranch = $('#circ_request span.logged-in-branch-code').html();
var loggedbranchname = $("span.logged-in-branch-name").html();
var countyouritems = 0;
$('#catalog_detail #holdings_table td.homebranch').each(function(){
var clone = $(this).clone();
clone.children().remove();
clone.text(clone.text().trim());
if (clone.text() == loggedbranchname) {
countyouritems++;
}
});
$('#catalog_detail a:contains("Holdings")').append(' (' + loggedbranchname + ' owns ' + countyouritems + ')');
//End count
Hold Pickup Enhancement
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2019-01-10
- Purpose: Show the number of hold requests that will be picked up at your library
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
//Count holds for your library in holds
var loggedbranch = $('#circ_request span.logged-in-branch-code').html();
var loggedbranchname = $("span.logged-in-branch-name").html();
var countyourholds = 0;
$('#circ_request input, #circ_request option:selected').each(function(){
if ($(this).val() == loggedbranch) {
countyourholds++;
}
});
$('#circ_request legend:contains("Existing holds")').append(' (' + countyourholds + ' to be picked up at ' + loggedbranchname + ')');
//End count
Holdings Count (All Libraries) Enhancement
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2019-01-11
- Purpose: Display counts of items for all libraries at the top of the holdings list
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
//Holding Count Summary
var byLibrary = {};
$('#catalog_detail #holdings_table td.homebranch').each(function(){
var LibraryName = $(this).clone();
LibraryName.children().remove();
LibraryName.text(LibraryName.text().trim());
if ( !(byLibrary.hasOwnProperty(LibraryName.text())) ) {
byLibrary[LibraryName.text()] = 0;
}
byLibrary[LibraryName.text()]++;
});
var LibrarySummary = "";
for (var i in byLibrary) {
LibrarySummary += i + ":" + byLibrary[i] + ", ";
}
LibrarySummary = LibrarySummary.substring(0,LibrarySummary.length - 2);
$('#catalog_detail #holdings').prepend('<b>Item counts: </b>' + LibrarySummary);
//End holding count summary
Hold Pickup Location Count (All Libraries) Enhancement
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2019-01-11
- Purpose: Display counts of items for pickup at each library at the top of the holds list
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.05
//Hold pickup location summary
var byLibrary = {};
$('#circ_request td:nth-child(7):contains("since")').each(function(){
var LibraryName = $(this).find('b').text().trim();
if ( !(byLibrary.hasOwnProperty(LibraryName)) ) {
byLibrary[LibraryName] = 0;
}
byLibrary[LibraryName]++;
});
$('#circ_request select[name="pickup"] option:selected').each(function(){
var LibraryName = $(this).text();
if ( !(byLibrary.hasOwnProperty(LibraryName)) ) {
byLibrary[LibraryName] = 0;
}
byLibrary[LibraryName]++;
});
var LibrarySummary = "";
for (var i in byLibrary) {
LibrarySummary += i + ":" + byLibrary[i] + ", ";
}
LibrarySummary = LibrarySummary.substring(0,LibrarySummary.length - 2);
$('#circ_request legend:contains("Existing holds")').after('<div style="margin-left: 15px; margin-top: 5px;"><b>Pickup location counts: </b>' + LibrarySummary + '</div>');
//End hold pickup location summary
Hold Pickup Location Count (All Libraries) Enhancement (v21.05)
- Developer: Christopher Brannon (CrispyBran) (Coeur d'Alene Public Library)
- Creation Date: 2022-06-03
- Purpose: Display counts of items for pickup at each library at the top of the holds list
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//Hold pickup location summary (v21.05)
if ($('#circ_request').length) {
var byLibrary = {};
$('#existing_holds input[name="pickup"]').each(function(){
var LibraryName = $(this).next('strong').text().trim();
console.log(LibraryName);
if ( !(byLibrary.hasOwnProperty(LibraryName)) ) {
byLibrary[LibraryName] = 0;
}
byLibrary[LibraryName]++;
});
$('#existing_holds select.pickup_location_dropdown option:selected').each(function(){
var LibraryName = $(this).text();
if ( !(byLibrary.hasOwnProperty(LibraryName)) ) {
byLibrary[LibraryName] = 0;
}
byLibrary[LibraryName]++;
});
var LibrarySummary = "";
for (var i in byLibrary) {
LibrarySummary += i + ' <span class="badge rounded-pill bg-dark" style="margin-left: 5px;">' + byLibrary[i] + '</span> / ';
}
LibrarySummary = LibrarySummary.substring(0,LibrarySummary.length - 2);
$('#existing_holds #toolbar').after('<div style="margin-left: 15px; margin-top: 5px;"><b>Pickup location counts: </b>' + LibrarySummary + '</div>');
}
//End hold pickup location summary
Set default filters for the inventory tool
- Developer: George Williams (Next Search Catalog)
- Purpose: Check the "Homebranch" radio button and select the logged in library as default item location filters when using the inventory tool.
- Creation Date: 2019.02.01
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 18.05.07
- Koha breadcrumbs: Home > Tools > Inventory
//BEGIN set defaults on inventory tool filters
$("#tools_inventory #inventory_form input[value='homebranch']").attr("checked","checked");
var invnode=$(".logged-in-branch-name").text().trim().substring(0, 5);
$('#tools_inventory #branchloop option:contains('+ invnode +')').attr("selected","selected");
//END
Add password randomizer to memberentry
- Developer: Jason Robb (SEKnFind/SEKLS)
- Purpose: Copies the password randomizer function from member-password to memberentry
- Creation Date: 2019-03-12
- Status: Completed. Temporary work-around for Bug 22485.
- Intranet or OPAC?: Intranet
- Version: 18.05.08
function generate_password() {
// Always generate a strong password
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var length = 3;
if (length < 8) length = 8;
var password = '';
for (var i = 0; i < length; i++) {
password += chars.charAt(Math.floor(Math.random() * chars.length));
}
return password;
}
$("body").on('click', "#fillrandom", function(e) {
e.preventDefault();
var password = '';
var pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{3,}/;
while (!pattern_regex.test(password)) {
password = generate_password();
}
$("#password").val(password);
$("#password").attr('type', 'text');
$("#password2").val(password);
$("#password2").attr('type', 'text');
});
//Adds link after second password box
$("#pat_memberentrygen #password2").after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">" + _("Click to fill with a randomly generated suggestion. ") + "<strong>" + _("Passwords will be displayed as text") + "</strong>.</a></div>");
Resize Z39.50 pop-up window when loaded
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: I have catalogers at multiple libraries using a wide variety of screen sizes who have complained about the default size of the Z39.50 pop-up window high resolution screens. As written this jQuery makes the height and width of the Z39.50 pop-up 90% of the screen size and pushes it to the top-left corner of the screen and then resizes the columns inside of the pop-up to 75% of the window height.
- Creation Date: 2019.07.12
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 18.05 - runs on 18.11
- Koha breadcrumbs: Home > Cataloging > Z39.50/SRU pop-up
//Cataloging > Z39.50/SRU pop-up
//BEGIN Resize Z39.50 window
if (document.location.href.indexOf('z3950_search.pl')>-1) window.resizeTo((screen.width * .9), (screen.height * .9)), window.moveTo(0, 0);
$(window).on('load resize', function(){
$('#cat_z3950_search .col-xs-6 .rows, #cat_z3950_search #z3950_search_targets').height($(this).height() * .75);
$('#cat_z3950_search .col-xs-6 .rows').css('overflow-y', 'scroll')
});
//END
Restrict ability to change branches to specific users
- Developer: Jason Robb (SEKnFind/SEKLS)
- Purpose: Prevents access to the 'Set Library' dropdown to specific users
- Creation Date: 2019-09-21
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11
//Prevent access to the 'Set Library' except for specific users
var loggedUser = $("#logged-in-info-full .loggedinusername").text();
var unrestrictedUsers = ['username1','username2','username3']; //add usernames here for those that need access
if ($.inArray(loggedUser, unrestrictedUsers) == -1) {
$('a[href*="selectbranchprinter.pl"]').hide();
}
Make Alerts (Pending Moderations) More Visible
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Moves the moderations that are pending from the bottom of the screen (which might be off screen) to above the news panel.
- Creation Date: 2019-10-03
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11
//Area Pending Move
$('#area-pending').prependTo('div.col-sm-3').css('border','1px solid #EEEEEE').css('margin','0.2em').css('width','auto').prepend('<h3 style="padding: 0.3em; background-color: #EEEEEE; margin: 0;"><span class="news_title">Alerts</span></h3>');
$('div.pending-info').css('margin','0.3em').css('background-color','yellow').css('opacity','0.75').css('border-radius','6px').css('padding','3px');
$('div.pending-info a').prepend('<i class="fa fa-bell"></i> ');
if ($('div.pending-info').is(':hidden')) {
$('#area-pending').hide();
}
//End Move
Enhance the visibility of statuses on the detail.pl page for staff (18.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network) with some code from George Williams
- Purpose: Adds icons and color to different statuses in the item detail page for easier readability.
- Creation Date: 2019-10-17
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11
- See Also: Featured on The Terrific Every-Other-Thursday Training Video S1E2: https://koha-us.org/learn/
//Status Enhance
$('.status .lost, .status .dmg').prepend('<i class="fa fa-exclamation-triangle"></i> ');
$('.status .intransit').css('color','darkorange').prepend('<i class="fa fa-truck"></i> ');
$('.status:contains("Not for loan")')
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='noloan'></span>");
$('.status .noloan, .status .wdn').css('color','#900').prepend('<i class="fa fa-ban"></i> ');
$('.status:contains("Item-level")')
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='ilreqeust'></span>");
$('.status .ilreqeust:not(:contains("Item-level"))').remove();
$('.status .ilreqeust').html('<p><i class="fa fa-info-circle"></i> There are Item-Level holds on this item.</p>');
$('.status .ilreqeust').next('a').hide();
$('.status:contains("Waiting at")')
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='waiting-hold'></span>");
$('.status .waiting-hold:not(:contains("Waiting at"))').remove();
$('.status .waiting-hold').css('color','darkorange').prepend('<i class="fa fa-clock-o"></i> ');
//End Enhance
Enhance the visibility of statuses on the detail.pl page for staff (19.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network) with some code from George Williams
- Purpose: Adds icons and color to different statuses in the item detail page for easier readability. (Updated for 19.11)
- Creation Date: 2020-06-22
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.11
- See Also: Featured on The Terrific Every-Other-Thursday Training Video S1E2: https://koha-us.org/learn/
//Status Enhance
//Items with Not for loan status need to have a wrapper for easy manipulation
$('.status:contains("Not for loan")').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='noloan'></span>");
//Items level hold info needs to have a wrapper for easy manipulation
$('.status:contains("There is an item level hold on this item (priority")').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='ilrequestlow'></span>");
//Waiting holds are wrapped for easy manipulation
$('.status:contains("Waiting at")').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='waiting-hold'></span>");
//Clean up and remove Item level hold wraps around empty spaces
$('.ilrequestlow').each(function() {
$(this).text($(this).text().trim());
});
$('.ilrequestlow:empty').remove();
//Clean up and remove Waiting hold wraps around empty spaces
$('.status .waiting-hold:not(:contains("Waiting at"))').remove();
//Just gets rid of a lot of hidden and useless white space. Does not change visual look.
$('.status').each(function() {
$(this).html($(this).html().replace(/\s+/g, " "));
});
//Lost and Damaged statuses get the triangle bang symbol
$('.status .lost, .status .dmg').prepend('<i class="fa fa-exclamation-triangle"></i> ');
//In Transit statues get the truck symbol and are colored orange
$('.status .intransit').css('color','darkorange').prepend('<i class="fa fa-truck"></i> ').append('<br />');
//Not for loan and Withdrawn statuses are given the crossed out (ban) symbol and colored red
$('.status .noloan, .status .wdn').css('color','#900').prepend('<i class="fa fa-ban"></i> ');
//Item level holds are given info circle symbol
$('.ilrequestlow').prepend('<i class="fa fa-info-circle"></i> ');
//Waiting hold statuses are given a clock symbol and colored dark orange
$('.status .waiting-hold').css('color','darkorange').prepend('<i class="fa fa-clock-o"></i> ');
//Start Hold for info on next line and indent - clean up readability
$('.status .waiting-hold').each(function() {
$(this).html($(this).html().replace(/Hold for:/g, "<br/><span style='margin-left: 20px;'></span>- Hold for:"));
});
//Start due date info on next line and indent - clean up readability
$('.status .datedue').each(function() {
$(this).html($(this).html().replace(/: due/g, "<br/><span style='margin-left: 20px;'></span>- Due"));
});
//End Enhance
Remove extra Amazon no image found when there is an image above it
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Makes the Amazon "no image" picture go away.
- Creation Date: 2019-11-04
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11
- Notes: This can't be done via css because a 1x1 image is loaded initially, and then either updated with an image or message. The method is a little more complex because Chrome and Firefox load at different speeds.
//Remove extra Amazon no image found placeholders on results
$('#catalog_results #bookbag_form a.p1 img[alt]').on("load", function() {
$(this).each(function() {
if ($(this).width() == 1) {
$(this).remove();
}
});
});
//End Remove extras
Remove or optionally hide "Collect from patron" drop-down and "Change to give" calculation from "Make a payment" tab
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: Some of our libraries do not want the "Collect from patron" input box and "Change to give" dialogue to appear on the "Make a payment" tab, and some of them do. The first bit of jQuery completly removes both of these items from the "Make a payment" tab for libraries that do not want them at all, the second option removes them but also inserts a button that can be clicked to make them appear if staff actually wants to use them.
- Creation Date: 2019.11.12
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05
- Koha breadcrumbs: Home > Patrons > Pay fines for PATRONNAME > Pay an individual fine /or/ Pay an amount toward all fines /or/ Pay an amount toward selected fines
Option 1 simply removes "Collect from patron" and "Change to give"
//Patrons > Pay fines for PATRONNAME > Pay an individual fine
//Hide "Collected from patron:" and "Change to give:" drop-downs
$('#pat_paycollect #change, #pat_paycollect #collected').parent().hide();
Option 2 hides "Collect from patron" and "Change to give" behind a button
//Patrons > Pay fines for PATRONNAME > Pay an individual fine /or/ Pay an amount toward all fines /or/ Pay an amount toward selected fines
//Hide "Collected from patron:" and "Change to give:" drop-downs but also add a button to make their appearance optional
$('#pat_paycollect #change, #pat_paycollect #collected').parent().hide();
$('#pat_paycollect #paid').parent().append("<li><label></label><button id='changecalc' type='button' class='btn btn-default' style='margin:10px 0px 0px 0px;'>Calculate change</button></li>");
$("#changecalc").click( function() {
$("#changecalc").hide();
$('#pat_paycollect #change, #pat_paycollect #collected').parent().show();
});
Optionally bypass Code Mirror on IntranetUserJS and OPACUserJS to make these preferences internally searchable again
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: Don't get me wrong - I like Code Mirror. However, now that Code Mirror has been added to IntranetUserJS and OPACUserJS, you can't use the browser's built in "Find on this page..." functions to search through the content in IntranetUserJS or OPACUserJS unless the text you're searching for is actually being displayed on the screen. This jQuery allows you to bypasses Code Mirror so you can search and edit both of these preferences in a simple input box rather than with the code mirror input box. Without too much trouble, this jQuery could also be modified to work with other using Code Mirror (like IntranetmainUserblock or OpacMainUserBlock or IntranetUserCSS etc.) until the Code Mirror search addons can be added to Koha.
- Creation Date: 2019.11.12
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05
- Koha breadcrumbs: Home > Administration > System preferences
//Administration > System preferences
//BEGIN add link to bypass Code Mirror on IntranetUserJS system preference
$('#expand_IntranetUserJS').text('Edit with Code Mirror');
$('#expand_IntranetUserJS').after('<p></p><a id="intranomirror" href="#pref_IntranetUserJS">Edit without Code Mirror</a>');
$("#intranomirror").click( function() {
$("#expand_IntranetUserJS, #intranomirror").hide();
$('#pref_IntranetUserJS').show();
});
$("#expand_IntranetUserJS").click( function() {
$("#intranomirror").hide();
});
//BEGIN add link to bypass Code Mirror on OPACUserJS system preference
$('#expand_OPACUserJS').text('Edit with Code Mirror');
$('#expand_OPACUserJS').after('<p></p><a id="opacnomirror" href="#pref_OPACUserJS">Edit without Code Mirror</a>');
$("#opacnomirror").click( function() {
$("#expand_OPACUserJS, #opacnomirror").hide();
$('#pref_OPACUserJS').show();
});
$("#expand_OPACUserJS").click( function() {
$("#opacnomirror").hide();
});
On cataloguing in add a new biblio record, add a label next to MARC tag title
- Developer: Emma Perks - BASE Library
- Purpose: Libraries may need to add an instruction, notice or warning for cataloguers adjacent to MARC 008 field
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
$(document).ready(function() {
var3 = $('body').is("#cat_addbiblio"); //Makes sure the change only happens on biblio
if(var3 !=0) {
$("[id^='tag_008']").prepend('<div style="float:right; margin-top: 10px;">Instruction</div>');
}}
Transportation cost matrix - move row to top of table
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: I have 53 libraries so the transportation cost matrix is a 53x53 table. To make it easier to follow the rows when I'm making changes, this jQuery causes a row to move to the top of the table when the library name in the "From\To" column of the table is clicked.
- Creation Date: 2019.11.26
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 18.11
- Version: 23.05 - tested and working
- Koha breadcrumbs: Home > Administration > Transport cost matrix
//Administration > Transportation cost matrix
//BEGIN Click on library name and row will move to the top of the table
$("#cost_matrix_form #transport-cost-matrix tr th:nth-child(1)").click(function() {
$(this).parent().insertAfter("#cost_matrix_form #transport-cost-matrix tbody tr:first");
});
Hide "Forgiven" credit type
- Developer: Caroline Cyr La Rose, inLibro
- Creation Date: 2019-11-29
- Purpose: Hide the "Forgiven" option in the manual credits to prevent staff from using it
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 18.05, still works in 19.05, but as of 19.11 you have to write FORGIVEN in capitals.
//Use this for 19.05 and earlier
$("#mancredit #type option[value='forgiven']").hide();
//Use this for 19.11 and later
$("#mancredit #type option[value='FORGIVEN']").hide();
Add link to go directly to a record by its biblionumber
- Developer: A. Longoria, Texas State Law Library
- Creation Date: 2019-12-17
- Purpose: This adds a "Go to Biblio" bookmarklet in the staff client that prompts the user for a biblionumber and goes to that record's details page
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11.06
// Add a "go to biblionumber" feature to the menu at the top left of each page.
var $topLevelMenu = $('#header').find('#toplevelmenu');
var goToBiblioUrl = '/cgi-bin/koha/catalogue/detail.pl?biblionumber=';
if ($topLevelMenu.length === 1) {
var $goToBiblioLink = $('<a />')
.attr('href', 'javascript:var biblio = prompt("Enter biblionumber:"); if (biblio) { window.location = "' + goToBiblioUrl + '" + biblio; }')
.html('<span class="fa fa-external-link"></span> Go to Biblio');
var $goToBiblioListItem = $('<li />').append($goToBiblioLink);
$topLevelMenu.append($goToBiblioListItem);
}
Move Check-in alerts to modals when needed
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Creation Date: 2019-12-19
- Purpose: This moves alerts to any modal that appears during check-in, so they are visible.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05
//Enhance Check-in Modals
$('#circ_returns div.alert').appendTo('#circ_returns div.modal-content');
//End Enhance Modals
Pre-select framework in Manage staged MARC records page
- Developer: Caroline Cyr La Rose
- Creation Date: 2020-01-10
- Purpose: This changes the default framework that is preselected when importing staged marc records
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05
$("#frameworks option[value='']").removeAttr("selected");
$("#frameworks option[value='YOURFRAMEWORKCODE']").attr("selected","selected");
Suppress CART location in item editor
- Developer: Christopher Brannon - Coeur d'Alene Public Library / CIN
- Purpose: Prevent staff from adding or duplicating the CART location when editing an item record.
- Creation Date: 2020-02-03
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.x
//Recently Return Selection Disable
$('#cat_additem select[id^="tag_952_subfield_c_"] option[value="CART"]').prop('disabled','true').remove();
//End Recently Return Selection Disable
Add button to copy Primary Phone to SMS Number in patron entry
- Developer: Lisette Scheer Latah County Library District / Valnet
- Purpose: Add button to copy Primary Phone to SMS Number in patron entry.
- Creation Date: 2020-03-04
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.x
//Add SMS Copy Phone Button
if (window.location.href.indexOf("memberentry.pl") > -1) {
$("#entryform #SMSnumber").parent().append("<button id='smscopy' type='button'>Copy Primary Phone</button>");
$("smscopy").click(function() {
$("#entryform #SMSnumber").val($("#entryform #phone").val());
});
}
//End Add SMS Copy Phone Button
Acquisitions - set default quantity to 1
- Developer: Caroline Cyr La Rose, inLibro
- Purpose: When you order, you always order at least 1. This changes the default quantity from 0 to 1
- Creation Date: 2020-03-16
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.05
//Acquisitions: Set default qty to 1
$( "#acq_neworderempty #quantity").val("1");
Serials - set default locale
- Developer: Caroline Cyr La Rose, inLibro
- Purpose: instead of having to always select your locale, this selects it by default. The example is with french (fre) substitute it with your local language
- Creation Date: 2020-03-16
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.05
//Serials: Choose default locale
$( "#ser_subscription-add #locale").val("fre");
Serials - check 'create an item record when receiving this serial' by default
- Developer: Caroline Cyr La Rose, inLibro
- Purpose: Most public libraries (here in any case) want to add items to serial records for most of their subscriptions. Instead of having to always select 'create an item record when receiving this serial', this selects it by default.
- Creation Date: 2020-03-17
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.05
//Serials: default to create an item record
$('#serialsadditems-no').prop('checked', 'false');
$('#serialsadditems-yes').prop('checked', 'true');
Alert on patron record if address 1/2 contains specified text
- Developer: Emma Perks, BASE Library
- Creation Date: 2020-05-29
- Purpose: This displays a pop-up dialog on all pages of the member record if the string exists in the address 1/2
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11
if ($('div.patroninfo > ul.patronbriefinfo > li.patronaddress1:contains("specify a text string here and enter the same into the patron address 1/2 field")').length > 0) {
alert('Message appears in a pop-up box');
}
Add line break and shelviing location label to holdings table on detail.pl
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: Adds a line break between home library and shelving location and adds label to shelving location
- Creation Date: 2020.06.01
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05; tested on 19.11
- Koha breadcrumbs: Home > Catalog > Details for TITLE
//Add break between home library and shelving location label
$('#catalog_detail .shelvingloc').prepend('<br /><br />Shelving location:<br />');
Highlight items in CART location on details page
- Developer: George Williams (NEKLS/Next Search Catalog)
- Purpose: Highlights the Home library cell in a table on the details page when an item has a "CART" shelving location. Works really well with 'Add line break and shelviing location label to holdings table on detail.pl.'
- Creation Date: 2020.06.01
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05 - also tested on 19.11
- Koha breadcrumbs: Home > Catalog > Details for TITLE
- Notes: Replace DESCRIPTION in '.shelvingloc:contains("DESCRIPTION")' with the description from your authorized value for CART from the LOC authorized values table
//Enhance "CART" shelving location
$('#catalog_detail .shelvingloc:contains("DESCRIPTION")').prepend('<i class="fa fa-exclamation-circle" style="color: #b30000;"></i> ').parent().css('background','#ffb3ff');
Always Show Checkouts Immediately
- Developer: Lucas Gass, ByWater Solutions
- Purpose: Always Show Checkouts Immediately without checking the box in the patron record
- Creation Date: 2020-07-09
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 19.11
$(document).ready(function() {
if ( typeof script !== 'undefined' && ! $.cookie("issues-table-load-immediately-" + script && $('#pat_moremember, #circ_circulation').length) ) {
$('#issues-table-load-now-button').click();
$.cookie("issues-table-load-immediately-" + script, true, { expires: 365 });
}
});
Add report number to report name
- Developer: George Williams (NEKLS / Next search catalog)
- Purpose: Adds the report number in parenthesis to the name of the report once the report has finished running
- Creation Date: 2020.07.09
- Status: Completed
- Intranet or OPAC?: INTRANET
- Version: Developed on 19.11
- Breadcrumbs: Home › Reports › Guided reports wizard > Saved reports > REPORTNAME Report
//BEGIN Add report number to the report name once a report has run
var url = $(location).attr('href');
if(url.indexOf("guided_reports.pl?reports=") != -1){
$('#rep_guided_reports_start .col-sm-10 main h1').addClass('addreportnumber');
$('input[name="param_name"]').parents().prev('h1').removeClass('addreportnumber');
$('.addreportnumber').first().append(" - (Report #" + $('#limitselect input[name="reports"]').val() + ")")
}
Enhance CART shelving location on details page
- Developer: George Williams (NEKLS / Next search catalog)
- Purpose: Adds shelving location label to details page, adds icon and changes cell color if shelving loction is CART
- Creation Date: 2020.08/02
- Status: Completed
- Intranet or OPAC?: INTRANET
- Version: Developed on 19.11
- Breadcrumbs: Home › Catalog › Details for TITLE
- See Also: Featured on The Terrific Every-Other-Thursday Training Video S1E1: https://koha-us.org/learn/
//Remove empty shelving location spans
$('#catalog_detail .shelvingloc').each(function(){
if( $(this).text().trim() === '' )
$(this).remove();
});
//Add doublespace between home library and shelving location and create text label (optional)
$('#catalog_detail .shelvingloc').prepend('<br /><br />Shelving location:<br />');
//Enhance "Recently returned" shelving location by adding a FA icon and changing the cell color (change "Recently returned" to match the description your library uses for the CART shelving location)
$('#catalog_detail .shelvingloc:contains("Recently returned")').prepend('<i class="fa fa-exclamation-circle" style="color: #b30000;"></i> ').parent().css('background','#ffb3ff');
Add Links to Collapse Messages on Patron Accounts
- Developer: Lisette Scheer
- Creation Date: 2020-08-13
- Purpose: Adds link to collapse/hide messages on the checkout screen and details screen.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.11
//-----------------------BEGIN ADD HIDE MESSAGE BUTTON-----------------------//
$(document).ready(function(){
if (window.location.href.indexOf("circ/circulation.pl") > -1) {
$("#messages .circ-hlt").addClass("hidden-message").show();
$("#messages .circ-hlt").parent().prepend("<a class='show-hidden-message' href=''>[Collapse Message]</a>");
$(".show-hidden-message").on('click', function() {
$(this). parent().children('.circ-hlt').hide();
$(this). parent().children('.show-hidden-message').hide();
return false;
});
}
});
$(document).ready(function(){
if (window.location.href.indexOf("members/moremember.pl") > -1) {
$("#messages .circ-hlt").addClass("hidden-message").show();
$("#messages .circ-hlt").parent().prepend("<a class='show-hidden-message' href=''>[Collapse Message]</a>");
$(".show-hidden-message").on('click', function() {
$(this). parent().children('.circ-hlt').hide();
$(this). parent().children('.show-hidden-message').hide();
return false;
});
}
});
//-----------------------END ADD HIDE MESSAGE BUTTON-----------------------//
Add Links to Collapse Notes on Patron Accounts
- Developer: Lisette Scheer
- Creation Date: 2020-08-13
- Purpose: Adds link to collapse/hide messages on the checkout screen.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.11
//-----------------------BEGIN ADD HIDE NOTE BUTTON-----------------------//
$(document).ready(function(){
if (window.location.href.indexOf("circ/circulation.pl") > -1) {
$("#circnotes .circ-hlt").addClass("hidden-note").show();
$("#circnotes .circ-hlt").parent().append("<a class='show-hidden-note' href=''>[Collapse Note]</a>");
$(".show-hidden-note").on('click', function() {
$(this). parent().children('.circ-hlt').hide();
$(this). parent().children('.show-hidden-note').hide();
return false;
});
}
});
//-----------------------END ADD HIDE NOTE BUTTON-----------------------//
Make 'Search main heading' the default when searching authorities
- Developer: Carlos Lopez
- Creation Date: 2020-09-03
- Purpose: Change the default search in authorities from 'Search main heading ($a only)' to 'Search main heading'
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 18.11.11
if (window.location.pathname == '/cgi-bin/koha/authorities/authorities-home.pl') {
$( "#header_search" ).tabs({ active: 1 });
}
Render patron messages as HTML and in Report notes
- Developer: George Williams (NEKLS / Next search catalog) with help from ByWater staff
- Purpose: Prior to Koha 16.11, you could use HTML markup in patron messages. From Koha 16.11 onwards, the HTML will not render in patron messages. This adds HTML rendering to existing messages and allows you to use HTML when creating new messages. Prior to Koha 18.11, you could use HTML markup in notes on SQL reports. From Koha 18.11 you can not. This adds HTML rendering to existing report notes and allows you to use HTML when creating new notes on reports.
- Creation Date: 2017.12 and 2019.03
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: Created on 16.11; tested and working on 19.11
- Notes: Once the function has been created, it can be applied to any element where you want HTML to render where it currently does not render
- Breadcrumbs: Home › Circulation › Checkouts › PATRONNAME; Home › Reports › Guided reports wizard › Saved reports; Home › Reports › Guided reports wizard › Saved reports › REPORTNAME Report
- See Also: Featured on The Terrific Every-Other-Thursday Training Video S1E4: https://koha-us.org/learn/
//BEGIN Creates to html function
$.fn.toHtml=function(){
return $(this).html($(this).text())
}
//BEGIN Changes messages back to HTML
$('#messages .circ-hlt').each(function() {
$(this).toHtml();
});
//BEGIN renders notes on reports in HTML
$("#rep_guided_reports_start .label:contains('Notes:')").parent().wrap("<div id='reportnotes'></div>");
$('#table_reports tr td:nth-child(7), #reportnotes').each(function() {
$(this).toHtml();
});
Make reports button on home page default to saved reports
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Reduce clicks to saved reports by changing the link for the reports button on the home page, and giving the reports page a full navigation menu to get to the other report options.
- Creation Date: 2020.10
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: 19.11
//Tweak Report Navigation
//Home › Reports › Guided reports wizard › Saved reports
$('#rep_guided_reports_start #navmenulist').replaceWith('<div id="navmenulist"><h5>Guided reports</h5><ul>
<li><a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports</a></li>
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build new</a></li>
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="current">Use saved</a></li>
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">Create from SQL</a></li>
</ul><h5>Statistics wizards</h5><ul>
<li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl">Acquisitions</a></li>
<li><a href="/cgi-bin/koha/reports/borrowers_stats.pl">Patrons</a></li>
<li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
<li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
<li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
<li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register</a></li>
<li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>
</ul><h5>Report plugins</h5><ul>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=report">Report plugins</a></li>
</ul><h5>Top lists</h5><ul>
<li><a href="/cgi-bin/koha/reports/bor_issues_top.pl">Patrons with the most checkouts</a></li>
<li><a href="/cgi-bin/koha/reports/cat_issues_top.pl">Most-circulated items</a></li>
</ul><h5>Inactive</h5><ul>
<li><a href="/cgi-bin/koha/reports/borrowers_out.pl">Patrons who haven\'t checked out</a></li>
<li><a href="/cgi-bin/koha/reports/catalogue_out.pl">Items with no checkouts</a></li>
</ul><h5>Other</h5><ul>
<li><a href="/cgi-bin/koha/reports/itemslost.pl">Lost items</a></li>
<li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
<li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
<li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
<li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li>
<li><a href="http://wiki.koha-community.org/wiki/SQL_Reports_Library" target="blank">Koha reports library</a></li>
</ul></div>');
$('#main_intranet-main a.icon_reports').attr('href', '/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved')
//End Report Navigation
Add Curbside Parking Slips to Patron Checkout Screen
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Alternative to the curbside plugin, this is a simple modification that will add a curbside pickup slip feature to the more menu in the checkout page.
- Creation Date: 2020.11
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: 19.11
- Notes: This jQuery requires a dedicated non-public report that outputs the looks up the borrowers table by borrowernumber and outputs firstname, surname, and cardnumber.
//Holds Waiting Count
var WaitingHereCount = 0;
var WaitingTotal = 0;
$('#circ_circulation #holdswaiting ul strong').each(function(){
if ($(this).hasClass('waitinghere')) {
WaitingHereCount++;
WaitingTotal++;
} else {
WaitingTotal++;
}
});
$('#circ_circulation #holdswaiting h4').text(function (_,txt) {
return txt.slice(0, -1);
}).prepend(WaitingTotal + ' ');
if (WaitingHereCount > 0) {
$('#circ_circulation #holdswaiting h4').append(' (' + WaitingHereCount + ' at this location)');
}
//End Holds Waiting Count
//Get patron name info (First,Last,CardNumber)
if ($('#circ_circulation').length) {
var CurrentBorrowerNumber = $('#add_message_form input[name="borrowernumber"]').val();
$.getJSON("/cgi-bin/koha/svc/report?id=1&sql_params=" + CurrentBorrowerNumber + ".json?_:" + new Date().getTime(), function(data) {
$.each(data, function(index, value) {
$('#circ_circulation').attr('data-patfirstname',value[0]);
$('#circ_circulation').attr('data-patlastname',value[1]);
$('#circ_circulation').attr('data-patcardnumber',value[2]);
});
});
}
//Curbside Slips
$('#circ_circulation').append('<div id="CurbsideModal" class="modal fade" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><form method="post" action="submit" onsubmit="return false;"><input type="hidden" name="" value=""><div class="modal-header"><h3>Curbside Pickup</h3></div><div id="CurbsideInfo" class="modal-body"></div><div class="modal-footer"><button id="btnCurbsidePrint" type="button" class="btn btn-default" style="background-image: none; background-color: rgb(105, 162, 104);"><i class="fa fa-print"></i> Print curbside slip</button><button id="btnCurbsideCancel" data-dismiss="modal" aria-hidden="true" class="btn"><i class="fa fa-times"></i> Cancel</button></div> <!-- /.modal-footer --></form> <!-- /.confirm --></div> <!-- /.modal-content --></div> <!-- /.modal-dialog --></div>');
$('#CurbsideModal').keypress(function(e){
if(e.keyCode==13)
$('#btnCurbsidePrint').click();
});
$('#circ_circulation #renewpatron').closest('ul').prepend('<li><a id="CINCurbside" href="#" data-original-title="" title="">Curbside Pickup</a></li>');
$('#circ_circulation #CINCurbside').on('click', function() {
var patFirstName = $('#circ_circulation').attr('data-patfirstname');
var patLastName = $('#circ_circulation').attr('data-patlastname');
var patCardNumber = $('#circ_circulation').attr('data-patcardnumber');
var patPartialName = patLastName;
var patFullName = '';
if (patFirstName !='') {
patPartialName += ', ' + patFirstName.match(/\b./g).join('');
patFullName += patFirstName + ' ';
}
patFullName += patLastName;
$('#CurbsideInfo').html('<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Libre Barcode 39"><div style="font-size: 150%">' + patPartialName + '<br /><div style="font-family:\'Libre Barcode 39\'; font-size: 42px;">*' + patCardNumber + '*</div><br />Parking Spot: <input id="infoParking" type="text" class="focus" size="1"><br /><br /> Vehicle: <input id="infoVehicle" type="text" class="focus" size="15"><hr></div>');
$('#CurbsideModal').modal('show');
});
$('#circ_circulation #btnCurbsidePrint').on('click', function () {
var infoParkingValue = $('#infoParking').val();
var infoVehicleValue = $('#infoVehicle').val();
var patHolds = 'No Holds';
if($('#holdswaiting h4').length > 0) {
patHolds = $('#holdswaiting h4').html();
}
$('#infoParking').replaceWith(infoParkingValue);
$('#infoVehicle').replaceWith(infoVehicleValue);
var CurbsideData = $('#CurbsideInfo').html();
CurbsideData += patHolds;
printCurbside(CurbsideData);
});
function printCurbside(elem) {
var myWindow=window.open('','','');
myWindow.document.write(elem);
myWindow.document.close();
myWindow.focus();
myWindow.print();
myWindow.close();
}
//End Curbside Slips
Preset branch dropdowns in reports to your branch
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Have report default branch dropdowns to your branch
- Creation Date: 2020.05
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: 19.11
- Notes: While you can always change the branch, if you are mostly running reports for your branch, this will save you a little time, especially if you are in a large consortium.
- See Also: Featured on The Terrific Every-Other-Thursday Training Video S1E7: https://koha-us.org/learn/
//Preset library dropdowns
var library_name = $.trim($('#user-menu span.logged-in-branch-name:first').text());
$('#rep_guided_reports_start').find('option').filter(function(index) {
return library_name === $(this).text();
}).attr("selected", "selected");
//End Preset
Change intranet background color for a specific branch
- Developer: Caroline Cyr La Rose, inLibro
- Purpose: Make sure staff notice that they are logged in at a specific branch by changing the intranet background color
- Creation Date: 2021-01
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: 20.05
- Note: In the code, change FPL for the branchcode of the specific branch; you can also change the colour, #ffccff is a very bright pink
$(document).ready(function() {
if ($("#logged-in-info-full .logged-in-branch-code").text() == "FPL"){
$("#logged-in-info-full .logged-in-branch-code").parents("body").css("background-color", "#ffccff");
}
});
Enhanced Search Facets for Staff
- Developer: Christopher Brannon - Coeur d'Alene Public Library / Cooperative Information Network
- Creation Date: 2020-04-01
- Purpose: Collapse and enhance the search facets, adding check boxes, making them responsive and cleaner
- Status: Completed
- Version: 19.11
//Revamp Facets
//Place headers around stray section titles so we can control these later.
$('#search-facets #availability_facet').contents().filter(function() {
return (this.nodeType === 3 && !/\S/.test(this.nodeValue));
}).wrap('<h5></h5>').end();
if($('#search-facets #availability_facet h5').text().trim().length < 1) {
$('#search-facets #availability_facet h5').remove();
}
$('#search-facets #availability_facet').contents().filter(function() {
return this.nodeType === 3;
}).wrap('<h5></h5>').end();
$('#search-facets').children('ul').children('li').children('span').each(function() {
$(this).replaceWith(function(){
return $("<h5 />").append($(this).contents());
});
});
//Add functionality to headers for visibility and collapsing/expanding sections, and show entire contents in section
$('#search-facets').children('ul').children('li').children('h5').wrap('<a class="viewSwitch" style="text-decoration: none; cursor: pointer;" />');
$('#search-facets a.viewSwitch h5').prepend('<i class="fa fa-caret-right" aria-hidden="true"></i> ');
$('#search-facets a.viewSwitch').parent().children('ul').wrap('<div class="contentsToggle" />');
$('#search-facets div.contentsToggle').hide();
$('#search-facets .contentsToggle').find('li.moretoggle').remove();
$('#search-facets .collapsible-facet').show().removeAttr('class').removeAttr('style');
$('#search-facets a.viewSwitch').click(function() {
$(this).parent().children('.contentsToggle').toggle('slow');
if ($(this).find('i').hasClass('fa-caret-right')) {
$(this).find('i').addClass('fa-caret-down').removeClass('fa-caret-right');
} else {
$(this).find('i').addClass('fa-caret-right').removeClass('fa-caret-down');
}
});
//Rebuild and replace facets with improved facets with checkboxes
$('#search-facets .facet-label a').removeAttr('title').attr('role','status').after(function() {
return $(this).clone().attr('role','label');
});
$('#search-facets a[role="status"]').html('<i class="fa fa-square-o" aria-hidden="true"></i> ');
$('#search-facets a[role="label"]').replaceWith(function() { return this.innerHTML; });
//Change facet checkbox to checked if in use
$('#search-facets a[title^="Remove facet"]').closest('li').contents().filter(function() {
return this.nodeType == 3 && this.nodeValue.trim();
}).remove();
$('#search-facets a[title^="Remove facet"]').each(function() {
$(this).prependTo($(this).siblings('span'));
});
$('#search-facets a[title^="Remove facet"]').html('<i class="fa fa-check-square" aria-hidden="true"></i> ');
//Expand sections that have active facets
$('#search-facets a[title^="Remove facet"]').closest('.contentsToggle').siblings('.viewSwitch').trigger('click');
//Add spinner to show that Koha is doing something after click
$('#search-facets a[title^="Remove facet"]').on('click', function() {
$(this).find('i').removeClass('fa-check-square').addClass('fa-spinner fa-spin');
});
$('#search-facets a[role="status"]').on('click', function() {
$(this).find('i').removeClass('fa-square-o').addClass('fa-spinner fa-spin');
});
//End Revamp Facets
STAFF Enhanced Suspended Hold Listings (v21.11)
- Developer: Christopher Brannon - Coeur d'Alene Public Library / Cooperative Information Network
- Creation Date: 2021-03-12
- Updated Date: 2022-09-12
- Purpose: Show suspended and delayed hold listings more clearly
- Status: Completed
- Version: 21.11
/*Ribbon for Suspended Holds*/
.RibbonRowAdjust {
height: 50px;
}
.SuspendRibbon, .DelayedRibbon {
height: 20px;
line-height: 20px;
padding-left: 15px;
position: absolute;
left: -9px;
top: 25px;
text-transform: uppercase;
color: white;
}
.SuspendRibbon:before, .SuspendRibbon:after, .DelayedRibbon:before, .DelayedRibbon:after {
content: "";
position: absolute;
}
.SuspendRibbon:before, .DelayedRibbon:before {
height: 0;
width: 0;
top: -8.5px;
left: 0.1px;
border-bottom: 9px solid black;
border-left: 9px solid transparent;
}
.SuspendRibbon:after, .DelayedRibbon:after {
height: 0;
width: 0;
right: -14.5px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
}
.SuspendRibbon {
width: 130px;
background: #f54242;
}
.SuspendRibbon:after{
border-left: 15px solid #f54242;
}
.DelayedRibbon {
width: 160px;
background: #f5ad42;
}
.DelayedRibbon:after{
border-left: 15px solid #f5ad42;
}
//Suspended Enhancement
//Regular Suspension on /cgi-bin/koha/reserve/request.pl
$('#circ_request button:contains("Unsuspend")').parents('tr').children('td:nth-child(2)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="SuspendRibbon"><i class="fa fa-hand-paper-o" aria-hidden="true"></i> Suspended</div>');
//Delayed Suspension on /cgi-bin/koha/reserve/request.pl
$('#circ_request input[name="reservedate"]').each(function() {
var fetchDate=new Date($(this).val());
var fetchDay=('0'+(fetchDate.getDate())).slice(-2);
var fetchMonth=('0'+(fetchDate.getMonth()+1)).slice(-2);
var fetchYear=fetchDate.getFullYear();
var reserveDate=fetchYear+fetchMonth+fetchDay;
fetchDate=new Date();
fetchDay=('0'+(fetchDate.getDate())).slice(-2);
fetchMonth=('0'+(fetchDate.getMonth()+1)).slice(-2);
fetchYear=fetchDate.getFullYear();
var todaysDate=fetchYear+fetchMonth+fetchDay;
if (reserveDate > todaysDate) {
$(this).parents("tr").children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="DelayedRibbon"> <i class="fa fa-calendar" aria-hidden="true"></i> After ' + $(this).val() + '</div>');
}
});
//Flag reservation dates on each row in --- before making changes to cell.
$('#holds-table').on( 'init.dt', function () {
$("#holds-table").find("th:contains('Hold date')").attr("id","DateColumn");
var dateColumn = $("#DateColumn").index() + 1;
$("#holds-table").find("td:nth-child(" + dateColumn + ")").addClass("reserveDate");
$(".reserveDate").each(function() {
var fetchDate=new Date($(this).text());
var fetchDay=('0'+(fetchDate.getDate())).slice(-2);
var fetchMonth=('0'+(fetchDate.getMonth()+1)).slice(-2);
var fetchYear=fetchDate.getFullYear();
var reserveDate=fetchYear+fetchMonth+fetchDay;
fetchDate=new Date();
fetchDay=('0'+(fetchDate.getDate())).slice(-2);
fetchMonth=('0'+(fetchDate.getMonth()+1)).slice(-2);
fetchYear=fetchDate.getFullYear();
var todaysDate=fetchYear+fetchMonth+fetchDay;
$(this).attr('todaysdate',todaysDate);
$(this).attr('reservedate',reserveDate);
});
//Regular Suspension on /cgi-bin/koha/members/moremember.pl
$('a.hold-resume').parents('tr').children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="SuspendRibbon"><i class="fa fa-hand-paper-o" aria-hidden="true"></i> Suspended</div>');
//Delayed Suspension on /cgi-bin/koha/members/moremember.pl
$(".reserveDate").each(function() {
if ($(this).attr("reservedate") > $(this).attr("todaysdate")) {
$(this).parents("tr").children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="DelayedRibbon"><i class="fa fa-calendar" aria-hidden="true"></i> After ' + $(this).text() + '</div>');
}
});
});
//End Suspended Enhancement
STAFF Enhanced Suspended/Scheduled Hold Listings (v23.05)
- Developer: Christopher Brannon - Coeur d'Alene Public Library / Cooperative Information Network
- Creation Date: 2024-01-12
- Updated Date: 2024-01-13
- Purpose: Show suspended, delayed, and scheduled hold listings more clearly
- Status: Completed
- Version: 23.05
/*Ribbon for Suspended Holds*/
.RibbonRowAdjust {
height: 50px;
}
.SuspendRibbon, .DelayedRibbon {
height: 20px;
line-height: 20px;
padding-left: 15px;
position: absolute;
left: -9px;
top: 25px;
text-transform: uppercase;
color: white;
}
.SuspendRibbon:before, .SuspendRibbon:after, .DelayedRibbon:before, .DelayedRibbon:after {
content: "";
position: absolute;
}
.SuspendRibbon:before, .DelayedRibbon:before {
height: 0;
width: 0;
top: -8.5px;
left: 0.1px;
border-bottom: 9px solid black;
border-left: 9px solid transparent;
}
.SuspendRibbon:after, .DelayedRibbon:after {
height: 0;
width: 0;
right: -14.5px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
}
.SuspendRibbon {
width: 130px;
background: #f54242;
}
.SuspendRibbon:after{
border-left: 15px solid #f54242;
}
.DelayedRibbon {
width: 160px;
background: #f5ad42;
}
.DelayedRibbon:after{
border-left: 15px solid #f5ad42;
}
//Get Today's Date
const date = new Date();
let day = ('0'+(date.getDate())).slice(-2);
let month = ('0'+(date.getMonth()+1)).slice(-2);
let year = date.getFullYear();
let GlobalCurrentDate = year+'-'+month+'-'+day;
let GlobalCompareCurrentDate = year.toString()+month.toString()+day.toString();
//END Get Today's Date
//Suspended/Scheduled Hold Enhancements (v23.05)
//Suspensions on /cgi-bin/koha/reserve/request.pl
if ($('#circ_request').length) {
//All Active Suspensions
$('tr.suspend').children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="SuspendRibbon"><i class="fa fa-hand-paper-o" aria-hidden="true"></i> Suspended</div>');
//Delayed Suspensions
$('tr.suspend input[id^="suspend_until"][value!=""]').each(function() {
var DelayDate = new Date($(this).val());
$(this).parents("tr").children('td:nth-child(1)').children('div.SuspendRibbon').replaceWith('<div class="DelayedRibbon"> <i class="fa fa-calendar" aria-hidden="true"></i> After ' + DelayDate.toLocaleDateString('en-US') + '</div>');
});
//Scheduled Holds
$('input[name="reservedate"]').each(function() {
let DisplayReserveDate = new Date($(this).val());
let reserveDay = ('0'+(DisplayReserveDate.getUTCDate())).slice(-2);
let reserveMonth = ('0'+(DisplayReserveDate.getUTCMonth()+1)).slice(-2);
let reserveYear = DisplayReserveDate.getUTCFullYear();
let CompareReserveDate = reserveYear+reserveMonth+reserveDay;
DisplayReserveDate = reserveMonth+'/'+reserveDay+'/'+reserveYear;
if (CompareReserveDate > GlobalCompareCurrentDate) {
$(this).parents("tr").children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="DelayedRibbon"><i class="fa fa-calendar" aria-hidden="true"></i> After ' + DisplayReserveDate + '</div>');
}
});
}
// Suspensions on /cgi-bin/koha/members/circulation.pl and /cgi-bin/koha/members/moremember.pl
if ($('#circ_circulation, #pat_moremember').length) {
$('#holds-table').on('init.dt', function () {
//All Active Suspensions
$('a.hold-resume').parents('tr').children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="SuspendRibbon"><i class="fa fa-hand-paper-o" aria-hidden="true"></i> Suspended</div>');
//Delayed Suspensions
$('a.hold-resume').parents('tr').each( function() {
let SuspendUntilDate = $(this).find('strong:contains("suspended")').parent('p').text().match(/\b(\d{2}\/\d{2}\/\d{4})/gm);
if (SuspendUntilDate) {
$(this).find('div.SuspendRibbon').replaceWith('<div class="DelayedRibbon"><i class="fa fa-calendar" aria-hidden="true"></i> After ' + SuspendUntilDate[0] + '</div>');
}
});
//Scheduled Holds
$('#holds-table').find('th:contains("Hold date")').attr('id','DateColumn');
var dateColumn = $('#DateColumn').index() + 1;
$('#holds-table').find('td:nth-child(' + dateColumn + ')').addClass('reserveDate');
$('.reserveDate:not(:has(>div))').each(function() {
let reserveDate = new Date($(this).text());
let reserveDay = ('0'+(reserveDate.getUTCDate())).slice(-2);
let reserveMonth = ('0'+(reserveDate.getUTCMonth()+1)).slice(-2);
let reserveYear = reserveDate.getUTCFullYear();
reserveDate = reserveYear+reserveMonth+reserveDay;
if (reserveDate > GlobalCompareCurrentDate) {
$(this).parents("tr").children('td:nth-child(1)').addClass('RibbonRowAdjust').css('position','relative').append('<div class="DelayedRibbon"><i class="fa fa-calendar" aria-hidden="true"></i> After ' + $(this).text() + '</div>');
}
});
});
}
//END Suspended/Scheduled Hold Enhancements
Make purchase suggestion links default to all libraries
- Developer: Lucas Gass
- Purpose: Make purchase suggestion links default to all libraries
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Any
function suggestionLinks (selector) {
let full_url = window.location.origin + $(`${selector}`).attr('href');
let suggestion_url = new URL( full_url );
let all_branches_path = suggestion_url.pathname + '?branchcode=__ANY__' + suggestion_url.hash;
$(`${selector}`).attr('href' , all_branches_path );
}
if ( $('#main_intranet-main').length && $('#suggestions_pending a').length ) {
suggestionLinks('#suggestions_pending a');
}
if ( $('#acq_acqui-home').length && $('#acqui_acqui_home_suggestions p a').length ) {
suggestionLinks('#acqui_acqui_home_suggestions p a');
}
if ( $('#navmenulist').length ) {
suggestionLinks('a[href*="/cgi-bin/koha/suggestion/suggestion.pl"]');
}
Bad E-mail Handler
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds buttons next to the primary e-mail field in memberentry.pl to quickly deal with bad e-mails. Will remove or leave the e-mail in the field, depending on the situation, and create a restriction on the account, copying the address in a message explaining the situation with that address.
- Creation Date: 6/10/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 21.05
- Breadcrumbs: Home › Patrons - Edit
//Expand debarred comment text box
$('#pat_memberentrygen #debarred_comment').after('<textarea id="debarred_comment" rows="3" cols="100" name="debarred_comment" class="noEnterSubmit" />').remove();
//Bad E-mail Process
if($('#pat_memberentrygen #email').val() !='') {
$('#email').after(' <button id="EmailDoesNotExist" type="button">Doesn\'t exist</button> <button id="EmailFull" type="button">Mailbox full</button> <button id="EmailBlocked" type="button">E-mail blocked/disabled</button>');
}
$('#pat_memberentrygen #EmailDoesNotExist').on('click', function() {
$('#restrictions_lgd').click();
$('#add_manual_restriction').click();
$('#debarred_comment').val($('#email').val() + ' removed from account. Server reports this address does not exist. Please update patron contact information.').focus().change();
$('#email').val('');
});
$('#pat_memberentrygen #EmailFull').on('click', function() {
$('#restrictions_lgd').click();
$('#add_manual_restriction').click();
$('#debarred_comment').val('Server reports mailbox ' + $('#email').val() + ' is full. We cannot send e-mails to this account. Patron needs to address the issue with this address or provide a working address.').focus().change();
});
$('#pat_memberentrygen #EmailBlocked').on('click', function() {
$('#restrictions_lgd').click();
$('#add_manual_restriction').click();
$('#debarred_comment').val('Server reports mailbox ' + $('#email').val() + ' is blocking our notifications or is disabled. We cannot send e-mails to this account. Patron needs to address the issue with this address or provide a working address.').focus().change();
});
//END Bad E-mail Process
Add notes to add record page and edit record page
- Developer: George Williams (NEKLS / Next search catalog)
- Purpose: Adds descriptions to the tabs on the Add/Edit record pages
- Creation Date: 6/10/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Breadcrumbs: Home › Cataloging › Add MARC record -and- Home › Cataloging › Editing TITLE
19.05 version
- Version: Developed on 19.05 / tested and working on 20.05
//BEGIN Add labels to Marc tabs on add record page and edit record page
$(".toolbar-tabs-container a[href='#tab0XX']").append("<br />Control and coded fields");
$("#tab0XX h3").append(" - Control and coded fields");
$(".toolbar-tabs-container a[href='#tab1XX']").append("<br />Main entry");
$("#tab1XX h3").append(" - Main entry");
$(".toolbar-tabs-container a[href='#tab2XX']").append("<br />Title and edition");
$("#tab2XX h3").append(" - Title and edition");
$(".toolbar-tabs-container a[href='#tab3XX']").append("<br />Physical description");
$("#tab3XX h3").append(" - Physical description");
$(".toolbar-tabs-container a[href='#tab4XX']").append("<br />Series");
$("#tab4XX h3").append(" - Series");
$(".toolbar-tabs-container a[href='#tab5XX']").append("<br />Notes");
$("#tab5XX h3").append(" - Notes");
$(".toolbar-tabs-container a[href='#tab6XX']").append("<br />Subject access");
$("#tab6XX h3").append(" - Subject access");
$(".toolbar-tabs-container a[href='#tab7XX']").append("<br />Added and linking entry");
$("#tab7XX h3").append(" - Added and linking entry");
$(".toolbar-tabs-container a[href='#tab8XX']").append("<br />Series added entry<br />and electronic access");
$("#tab8XX h3").append(" - Series added entry and electronic access");
$(".toolbar-tabs-container a[href='#tab9XX']").append("<br />Koha related");
$("#tab9XX h3").append(" - Koha related");
22.11 version
- Version: Updated for Koha 22.11
//Home > Cataloging > Add MARC record - (/cataloguing/addbiblio.pl)
//Home > Cataloging > Editing [biblio.title - etc.] (Record number [biblio.biblionumber]) - (/cataloguing/addbiblio.pl?biblionumber= [biblio.biblionumber])
//BEGIN Add labels to Marc tabs
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab0XX_panel"]').append('<br />Control and coded fields');
$('#cat_addbiblio #tab0XX_panel h3').append(' - Control and coded fields');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab1XX_panel"]').append('<br />Main entry');
$('#cat_addbiblio #tab1XX_panel h3').append(' - Main entry');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab2XX_panel"]').append('<br />Title and edition');
$('#cat_addbiblio #tab2XX_panel h3').append(' - Title and edition');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab3XX_panel"]').append('<br />Physical description');
$('#cat_addbiblio #tab3XX_panel h3').append(' - Physical description');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab4XX_panel"]').append('<br />Series');
$('#cat_addbiblio #tab4XX_panel h3').append(' - Series');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab5XX_panel"]').append('<br />Notes');
$('#cat_addbiblio #tab5XX_panel h3').append(' - Notes');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab6XX_panel"]').append('<br />Subject access');
$('#cat_addbiblio #tab6XX_panel h3').append(' - Subject access');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab7XX_panel"]').append('<br />Added and linking entry');
$('#cat_addbiblio #tab7XX_panel h3').append(' - Added and linking entry');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab8XX_panel"]').append('<br />Series added entry<br />and electronic access');
$('#cat_addbiblio #tab8XX_panel h3').append(' - Series added entry and electronic access');
$('#cat_addbiblio .toolbar-tabs-container a[href="#tab9XX_panel"]').append('<br />Koha related');
$('#cat_addbiblio #tab9XX_panel h3').append(' - Koha related');
Automatic Library Setting
- Developer: Christopher Brannon (Coeur d'Alene Public Library / CIN) (Passed on from unknown author)
- Purpose: Automatically default the branches dropdown in reports to the library you are logged in as.
- Creation Date: 6/23/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05 / tested and working on 20.05
//Preset library dropdowns
var library_name = $.trim($('#user-menu span.logged-in-branch-name:first').text());
$('#rep_guided_reports_start').find('option').filter(function(index) {
return library_name === $(this).text();
}).attr("selected", "selected");
//End Preset
Blocking Checkouts - Example 1
- Developer: Christopher Brannon (Coeur d'Alene Public Library / CIN)
- Purpose: Block checkouts in circulation based on patron categories
- Creation Date: 8/14/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 19.05 / tested and working on 20.05
- Notes: Example shows 2 categories (SELF and EONLY) that will be blocked from checkout. Replace with the categories of your choice.
//Disable check out for special accounts on circulation.pl
if ($('#circ_circulation li.patroncategory:contains("(SELF)"),#circ_circulation li.patroncategory:contains("(EONLY)")').length) {
$('li.patroncategory:contains("(SELF)"),#circ_circulation li.patroncategory:contains("(EONLY)")').css('color','red');
$('#mainform').replaceWith('<div id="jqnoissue"><h3>Cannot check out!</h3>This patron category cannot checkout items.</div>');
}
//END Disable check out for special accounts on circulation.pl
Blocking Checkouts - Example 2
- Developer: George Williams (Northeast Kansas Library System/ Next search catalog)
- Purpose: Prevents staff from overriding a blocked checkout if the borrower is in a specified category
- Creation Date: 8/1/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 20.05
- Notes: Change "WORD" to match a word or phrase that is unique to the borrower category description for which you want to block overrides
- Breadcrumbs: Home › Circulation › Checkouts › PATRONNAME
//BEGIN block circulation overrides if categories.description contains a specific word
$('#circ_circulation').each(function() {
if ($(".patroncategory:contains(WORD)", this).length && $("#circ_needsconfirmation", this).length) {
$('.patroncategory').css('background', 'pink').wrap('<h2></h2>');
$('#circ_needsconfirmation .approve').attr('disabled', 'disabled');
$('#circ_needsconfirmation .deny').after('<h2 style="background: pink;">You cannot check out physical items to a borrower with this borrower category under any circumstances.</h2>');
alert('Borrowers in this category are not allowed to check out these materials under any circumstances');
}
});
Photo ID Reader
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Add the ability to scan a photo ID (USA) and import basic info into new patron form.
- Creation Date: 9/20/2021
- Update Date: 9/13/2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 20.05 / Works with 21.05 / Updated for 22.05
- Notes: Currently works with Chrome and Firefox, and works for the Honeywell 7580g, Datalogic QD2430, and Zebra Symbol DS4308 scanners. Scanner must be a 2D scanner that can read PDF417 barcodes. Some debugging is in place in the console log to determine symbols being used in place of linefeeds. These symbols must be caught and replaced in order to work with your scanner (see section that mentions the above scanners for more details). There is also an area defined in the function that corrects issues found in IDs. For example, in this code, our city "Coeur d'Alene" appears in the barcode as "Coeur D Al". You can use similar code to correct other anomalies. Contact me if you have questions or need help figuring out how to get a scanner to work. UPDATE: Returns focus to surname field when done.
//Import data from Photo ID (v22.05)
$('#pat_memberentrygen #toolbar').append('<button class="btn btn-default toggler" id="btnScanPhotoID" name="scan" style="margin-right: 0px; margin-right: 5px;"><i class="fa fa-id-card-o"></i> Scan Photo ID</button>');
$('#pat_memberentrygen').append('<div id="PhotoIDModal" class="modal fade" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><form id="formID" method="post" action="submit" onsubmit="return false;"><div class="modal-header"><h3 class="modal-title">Scan Photo ID</h3></div><div class="modal-body"><textarea id="inputPhotoIDData" rows="1" cols="1" style="margin-left: -400px;"></textarea><span id="msgScan"></span></div><div id="ContentFooter" class="modal-footer"><button id="btnPhotoIDClose" data-dismiss="modal" aria-hidden="true" class="btn"><i class="fa fa-times"></i> Cancel</button></div></form></div></div></div>');
function ProcessPhotoID() {
//Close modal
$('#PhotoIDModal').modal('hide');
$('#PhotoIDModal').on('hidden.bs.modal', function () {
$('#msgScan').html('<h4>Scan Photo ID now...</h4>');
});
//Separate information into array
console.log($('#inputPhotoIDData').val());
var IDSegments = $('#inputPhotoIDData').val().split('\n');
function toTitleCase(str)
//NEED TO MAKE THIS FUNCTION OPTIONAL
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
//Fix city names that are incomplete
function FixCity(str) {
if (str == 'Coeur D Al') {
return 'Coeur d\'Alene';
} else {
return str;
}
}
//Process data
if (IDSegments != '') {
var usrLastName,usrFirstName,usrBirth,mStop,usrMailingAddress,usrMailingCity,usrMailingState,usrMailingZip,usrPhysicalAddress,usrPhysicalCity,usrPhysicalState,usrPhysicalZip;
for (i = 0; i < IDSegments.length; ++i) {
if (IDSegments[i].startsWith('DCS')) {
usrLastName = toTitleCase(IDSegments[i].slice(3));
if (usrLastName.substring(0,2) == 'Mc') {
usrLastName = 'Mc' + usrLastName.substring(2,3).toUpperCase() + usrLastName.substring(3);
}
if (usrLastName.substring(0,3) == 'Mac') {
$('label[for="surname"]').siblings('span.required').after('<span style="background-color: yellow; color: red; margin-left: 5px;"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Check capitalization</span>');
}
}
if (IDSegments[i].startsWith('DAC')) {
usrFirstName = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAD')) {
usrFirstName += ' ' + toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DBB')) {
usrBirth = IDSegments[i].slice(3);
usrBirth = usrBirth.substring(0,2) + '/' + usrBirth.substring(2,4) + '/' + usrBirth.substring(4,8);
}
if (IDSegments[i].startsWith('DAG')) {
usrMailingAddress = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAH')) {
usrMailingAddress += ' ' + toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAI')) {
usrMailingCity = FixCity(toTitleCase(IDSegments[i].slice(3)));
}
if (IDSegments[i].startsWith('DAJ')) {
usrMailingState = IDSegments[i].slice(3);
}
if (IDSegments[i].startsWith('DAK')) {
usrMailingZip = toTitleCase(IDSegments[i].slice(3,8));
}
if (IDSegments[i].startsWith('DAL')) {
usrPhysicalAddress = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAM')) {
usrPhysicalAddress += ' ' + toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAN')) {
usrPhysicalCity = FixCity(toTitleCase(IDSegments[i].slice(3)));
}
if (IDSegments[i].startsWith('DAO')) {
usrPhysicalState = IDSegments[i].slice(3);
}
if (IDSegments[i].startsWith('DAP')) {
usrPhysicalZip = toTitleCase(IDSegments[i].slice(3,8));
}
}
//Copy data to form fields
$('#surname').val(usrLastName).css('background-color','yellow');
$('#firstname').val(usrFirstName).css('background-color','yellow');
$('#dateofbirth').val(usrBirth).css('background-color','yellow');
$('#address').val(usrMailingAddress).css('background-color','yellow');
$('#city').val(usrMailingCity).css('background-color','yellow');
$('#state').val(usrMailingState).css('background-color','yellow');
$('#zipcode').val(usrMailingZip).css('background-color','yellow');
//If secondary address doesn't exist, it usually starts with @
if (typeof usrPhysicalAddress != 'undefined') {
$('#B_address').val(usrPhysicalAddress).css('background-color','yellow');
$('#B_city').val(usrPhysicalCity).css('background-color','yellow');
$('#B_state').val(usrPhysicalState).css('background-color','yellow');
$('#B_zipcode').val(usrPhysicalZip).css('background-color','yellow');
}
$('#surname').focus();
}
}
$('#pat_memberentrygen #btnScanPhotoID').on('click', function() {
var TimerActive = 0; //Reset timer
var ScanActive = 0;
$('#inputPhotoIDData').val('');
$('#msgScan').html('<h4>Scan Photo ID now...</h4>');
$('#PhotoIDModal').modal('show');
$('#PhotoIDModal').on('shown.bs.modal', function () {
$('#inputPhotoIDData').focus();
$('#inputPhotoIDData').unbind();
$('#inputPhotoIDData').keydown(function(event){
var code = (event.keyCode || event.which);
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
if (code == 120) { //Disable F9 so Firefox doesn't launch reader
return false;
}
});
$('#inputPhotoIDData').on('keyup', function() {
if (ScanActive == 0) { //Set Processing Message
$('#msgScan').html('<center><h4>Processing... please wait.</h4><svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px" viewBox="0 0 105 105" fill="#000"><circle cx="12.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="0s" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="12.5" cy="52.5" r="12.5" fill-opacity=".5"><animate attributeName="fill-opacity" begin="100ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="300ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="52.5" r="12.5"><animate attributeName="fill-opacity" begin="600ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="800ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="52.5" r="12.5"><animate attributeName="fill-opacity" begin="400ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="12.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="700ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="500ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="200ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle></svg></center>');
//Processing Graphic from https://github.com/SamHerbert/SVG-Loaders/tree/master/svg-loaders
ScanActive = 1;
}
if (TimerActive == 0) { //Time's up on input
TimerActive = 1;
setTimeout(function(){
console.log('Entire block of data: ');
console.log($('#inputPhotoIDData').val());
var checkStart = $('#inputPhotoIDData').val().startsWith('@'); //Check if beginning of barcode starts with @
if (checkStart) { //Was this a valid barcode?
ProcessPhotoID();
} else {
$('#msgScan').html('<center><h4>That doesn\'t look like a Photo ID. Try again.</h4></center>');
$('#inputPhotoIDData').val('');
TimerActive = 0;
ScanActive = 0;
}
}, 5000);
}
console.log(event.key);
//Convert to linefeed - ArrowDown for Honeywell 7580g / ArrowRight for Datalogic QD2430 / Alt for Zebra Symbol DS4308
if ((event.key == 'ArrowDown') || (event.key == 'ArrowRight') || (event.key == 'Alt')) {
$('#inputPhotoIDData').val($('#inputPhotoIDData').val() + '\n');
}
});
});
});
//END Import data from Photo ID
Photo ID Reader (v22.11)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Add the ability to scan a photo ID (USA) and import basic info into new patron form.
- Creation Date: 9/20/2021
- Update Date: 7/25/2023
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11
- Notes: Currently works with Chrome and Firefox, and works for the Honeywell 7580g, Datalogic QD2430, Star Micronics BSH-HR2081BT, and Zebra Symbol DS4308 scanners. Scanner must be a 2D scanner that can read PDF417 barcodes. Some debugging is in place in the console log to determine symbols being used in place of linefeeds. These symbols must be caught and replaced in order to work with your scanner (see section that mentions the above scanners for more details). There is also an area defined in the function that corrects issues found in IDs. For example, in this code, our city "Coeur d'Alene" appears in the barcode as "Coeur D Al". You can use similar code to correct other anomalies. Contact me if you have questions or need help figuring out how to get a scanner to work. This version is only for 22.11, which includes the flat picker for birth dates and the new middle name field. May work on Androids, but current tests show that iOS devices are not working. PDF417 will not transmit properly to web form field.
//Import data from Photo ID (v22.11)
$('#pat_memberentrygen #toolbar').append('<button class="btn btn-default toggler" id="btnScanPhotoID" name="scan" style="margin-right: 0px; margin-right: 5px;"><i class="fa fa-id-card-o"></i> Scan Photo ID</button>');
$('#pat_memberentrygen').append('<div id="PhotoIDModal" class="modal fade" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><form id="formID" method="post" action="submit" onsubmit="return false;"><div class="modal-header"><h3 class="modal-title">Scan Photo ID</h3></div><div class="modal-body"><textarea id="inputPhotoIDData" rows="1" cols="1" style="margin-left: -400px;"></textarea><span id="msgScan"></span></div><div id="ContentFooter" class="modal-footer"><button id="btnPhotoIDClose" data-dismiss="modal" aria-hidden="true" class="btn"><i class="fa fa-times"></i> Cancel</button></div></form></div></div></div>');
function ProcessPhotoID() {
//Close modal
$('#PhotoIDModal').modal('hide');
$('#PhotoIDModal').on('hidden.bs.modal', function() {
$('#msgScan').html('<h4>Scan Photo ID now...</h4>');
});
//Separate information into array
console.log($('#inputPhotoIDData').val());
var IDSegments = $('#inputPhotoIDData').val().split('\n');
function toTitleCase(str)
//NEED TO MAKE THIS FUNCTION OPTIONAL
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
//Fix city names that are incomplete
function FixCity(str) {
if (str == 'Coeur D Al') {
return 'Coeur d\'Alene';
} else {
return str;
}
}
//Process data
if (IDSegments != '') {
var usrLastName,usrFirstName,usrMiddleName,usrBirth,mStop,usrMailingAddress,usrMailingCity,usrMailingState,usrMailingZip,usrPhysicalAddress,usrPhysicalCity,usrPhysicalState,usrPhysicalZip;
for (i = 0; i < IDSegments.length; ++i) {
if (IDSegments[i].startsWith('DCS')) {
usrLastName = toTitleCase(IDSegments[i].slice(3));
if (usrLastName.substring(0,2) == 'Mc') {
usrLastName = 'Mc' + usrLastName.substring(2,3).toUpperCase() + usrLastName.substring(3);
}
if (usrLastName.substring(0,3) == 'Mac') {
$('label[for="surname"]').siblings('span.required').after('<span style="background-color: yellow; color: red; margin-left: 5px;"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Check capitalization</span>');
}
}
if (IDSegments[i].startsWith('DAC')) {
usrFirstName = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAD')) {
usrMiddleName = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DBB')) {
usrBirth = IDSegments[i].slice(3);
usrBirth = usrBirth.substring(0,2) + '/' + usrBirth.substring(2,4) + '/' + usrBirth.substring(4,8);
}
if (IDSegments[i].startsWith('DAG')) {
usrMailingAddress = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAH')) {
usrMailingAddress += ' ' + toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAI')) {
usrMailingCity = FixCity(toTitleCase(IDSegments[i].slice(3)));
}
if (IDSegments[i].startsWith('DAJ')) {
usrMailingState = IDSegments[i].slice(3);
}
if (IDSegments[i].startsWith('DAK')) {
usrMailingZip = toTitleCase(IDSegments[i].slice(3,8));
}
if (IDSegments[i].startsWith('DAL')) {
usrPhysicalAddress = toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAM')) {
usrPhysicalAddress += ' ' + toTitleCase(IDSegments[i].slice(3));
}
if (IDSegments[i].startsWith('DAN')) {
usrPhysicalCity = FixCity(toTitleCase(IDSegments[i].slice(3)));
}
if (IDSegments[i].startsWith('DAO')) {
usrPhysicalState = IDSegments[i].slice(3);
}
if (IDSegments[i].startsWith('DAP')) {
usrPhysicalZip = toTitleCase(IDSegments[i].slice(3,8));
}
}
//Copy data to form fields
$('#surname').val(usrLastName).css('background-color','yellow');
$('#firstname').val(usrFirstName).css('background-color','yellow');
$('#middle_name').val(usrMiddleName).css('background-color','yellow');
$('span.flatpickr_wrapper input').val(usrBirth).css('background-color','yellow');
$('#address').val(usrMailingAddress).css('background-color','yellow');
$('#city').val(usrMailingCity).css('background-color','yellow');
$('#state').val(usrMailingState).css('background-color','yellow');
$('#zipcode').val(usrMailingZip).css('background-color','yellow');
//If secondary address doesn't exist, it usually starts with @
if (typeof usrPhysicalAddress != 'undefined') {
$('#B_address').val(usrPhysicalAddress).css('background-color','yellow');
$('#B_city').val(usrPhysicalCity).css('background-color','yellow');
$('#B_state').val(usrPhysicalState).css('background-color','yellow');
$('#B_zipcode').val(usrPhysicalZip).css('background-color','yellow');
}
$('span.flatpickr_wrapper input').focus();
$('#surname').focus();
}
}
$('#pat_memberentrygen #btnScanPhotoID').on('click', function() {
var TimerActive = 0; //Reset timer
var ScanActive = 0;
$('#inputPhotoIDData').val('');
$('#msgScan').html('<h4>Scan Photo ID now...</h4>');
$('#PhotoIDModal').modal('show');
$('#PhotoIDModal').on('shown.bs.modal', function () {
$('#inputPhotoIDData').focus();
$('#inputPhotoIDData').unbind();
$('#inputPhotoIDData').keydown(function(event){
var code = (event.keyCode || event.which);
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
if (code == 120) { //Disable F9 so Firefox doesn't launch reader
return false;
}
});
$('#inputPhotoIDData').on('keyup', function() {
if (ScanActive == 0) { //Set Processing Message
$('#msgScan').html('<center><h4>Processing... please wait.</h4><svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px" viewBox="0 0 105 105" fill="#000"><circle cx="12.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="0s" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="12.5" cy="52.5" r="12.5" fill-opacity=".5"><animate attributeName="fill-opacity" begin="100ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="300ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="52.5" r="12.5"><animate attributeName="fill-opacity" begin="600ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="12.5" r="12.5"><animate attributeName="fill-opacity" begin="800ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="52.5" r="12.5"><animate attributeName="fill-opacity" begin="400ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="12.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="700ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="52.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="500ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle><circle cx="92.5" cy="92.5" r="12.5"><animate attributeName="fill-opacity" begin="200ms" dur="1s" values="1;.2;1" calcMode="linear" repeatCount="indefinite"/></circle></svg></center>');
//Processing Graphic from https://github.com/SamHerbert/SVG-Loaders/tree/master/svg-loaders
ScanActive = 1;
}
if (TimerActive == 0) { //Time's up on input
TimerActive = 1;
setTimeout(function(){
console.log('Entire block of data: ');
console.log($('#inputPhotoIDData').val());
var checkStart = $('#inputPhotoIDData').val().startsWith('@'); //Check if beginning of barcode starts with @
if (checkStart) { //Was this a valid barcode?
ProcessPhotoID();
} else {
$('#msgScan').html('<center><h4>That doesn\'t look like a Photo ID. Try again.</h4></center>');
$('#inputPhotoIDData').val('');
TimerActive = 0;
ScanActive = 0;
}
}, 5000);
}
console.log(event.key);
//Convert to linefeed - ArrowDown for Honeywell 7580g and Star Micronics BSH-HR2081BT / ArrowRight for Datalogic QD2430 / Alt for Zebra Symbol DS4308 // Enter for Zebra DS9308
if ((event.key == 'ArrowDown') || (event.key == 'ArrowRight') || (event.key == 'Alt') || (event.key == 'Enter')) {
$('#inputPhotoIDData').val($('#inputPhotoIDData').val() + '\n');
}
});
});
});
//END Import data from Photo ID
Quick Credential Reset
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Reset credentials with some quick set buttons on member-password.pl.
- Creation Date: 9/29/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 20.05
- Notes: This example resets the username to match the patron's card number, and the password to match the patron's last name in ALL CAPS.
//Quick Credential Reset
if( $('#pat_member-password').length ) {
//Create buttons
$('#newuserid').after(' <button id="ResetDefaults" type="button">Reset credentials to default</button>');
$('#newpassword').after(' <button id="ResetPassword" type="button">Reset password only</button>');
var usrBorrowerNumber = $('#borrowernumber').val();
//Get patron data
var url = '/api/v1/patrons?patron_id=' + usrBorrowerNumber;
let patronInfoArr;
$.ajax({
async: false,
url: url,
success: function(data) {
patronInfoArr = [data[0].firstname, data[0].surname, data[0].cardnumber];
}
});
//Set button functions
$('#ResetDefaults').on('click', function() {
$('#newuserid').val(patronInfoArr[2]);
$('#newpassword,#newpassword2').val(patronInfoArr[1].toUpperCase());
});
$('#ResetPassword').on('click', function() {
$('#newpassword,#newpassword2').val(patronInfoArr[1].toUpperCase());
});
}
//END Quick Credential Reset
Easy fill userid and password buttons
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Fill in passwords and userids on memberentry.pl and member-password.pl
- Creation Date: 10/05/2021
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 20.05
- Notes: This jQuery creates usernames and passwords based on fields already filled in on memberentry.pl and does the same on member-password.pl through the rest api.
//BEGIN Easy fill username options for add/edit borrower
//creates buttons
$("#pat_memberentrygen #userid").parent().append('<li style="padding-top: 10px"><label>Username<br />options:</label><div class="btn-group ezfill" style="padding-top: 15px"><button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">Username options <span class="caret"></span></button><ul class="dropdown-menu "><li><a id="clearid">Delete current username</a></li><li><a id="cardid">Use library card number for username</a></li><li><a id="nameid">Use firstname.lastname for username (Next default)</a></li></ul></div>');
//adds function to buttons
$("#cardid").click(function() {
$("#entryform #userid").val($("#entryform #cardnumber").val()).focus();
});
$("#nameid").click(function() {
$("#entryform #userid").val($("#entryform #firstname").val().toLowerCase().replace(/[^a-zA-Z 0-9]+/g, "").replace(" ", "") + '.' + $("#entryform #surname").val().toLowerCase().replace(/[^a-zA-Z 0-9]+/g, "").replace(" ", "")).focus();
});
$("#clearid").click(function() {
$("#entryform #userid").val("");
});
//BEGIN Easy fill password buttons for add/edit borrower
//creates buttons
$("#pat_memberentrygen #password2").parent().parent().append('<li><label>Password<br />options:</label><div class="btn-group ezfill"><button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">Password options <span class="caret"></span></button><ul class="dropdown-menu "><li><a id="deletepass">Clear current password data</a></li><li><a id="lnamepass">Use last name for password (case sensitive)</a></li><li><a id="phonepass">Use last 4 digits of phone for password</a></li><li><a id="townpass">Use name of town in lowercase letters</a></li><li><a id="birthpass">Use birthdate in format MMDDYYYY (no / marks)</a></li></ul></div>');
//adds function to buttons
$("#phonepass").click(function() {
$("#entryform #password, #entryform #password2").val($("#entryform #phone").val().slice(-4));
});
$("#lnamepass").click(function() {
$("#entryform #password, #entryform #password2").val($("#entryform #surname").val());
});
$("#townpass").click(function() {
$("#entryform #password, #entryform #password2").val($("#entryform #city").val().toLowerCase());
});
$("#birthpass").click(function() {
$("#entryform #password, #entryform #password2").val($("#entryform #dateofbirth").val().replace(/\//g, ''));
});
$("#deletepass").click(function() {
$("#entryform #password, #entryform #password2").val("");
});
//BEGIN Easy fill buttons for resetting username or password on change password page
if ($('#pat_member-password').length) {
//creates buttons
$('#newuserid').after('<div class="btn-group ezfill" style="padding-left: 15px;"><button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true" >Username options <span class="caret"></span></button><ul class="dropdown-menu "><li><a id="cardid_refill">Use library card number for username</a></li><li><a id="nameid_refill">Use firstname.lastname for username (Next default)</a></li></ul></div>');
$('#newpassword2').after('<div class="btn-group ezfill" style="padding-left: 15px;"><button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">Password options <span class="caret"></span></button><ul class="dropdown-menu "><li><a id="lnamepass_refill">Use last name for password (case sensitive)</a></li><li><a id="phonepass_refill">Use last 4 digits of phone for password</a></li><li><a id="townpass_refill">Use name of town in lowercase letters</a></li><li><a id="birthpass_refill">Use birthdate in format MMDDYYYY (no / marks)</a></li></ul></div>');
//gets borrower number from page
var usrBorrowerNumber = $('#borrowernumber').val();
//gets patron data from api
var url = '/api/v1/patrons?patron_id=' + usrBorrowerNumber;
let patronInfoArr;
$.ajax({
async: false,
url: url,
success: function(data) {
patronInfoArr = [data[0].firstname, data[0].surname, data[0].cardnumber, data[0].phone, data[0].city, data[0].date_of_birth];
}
});
//adds function to buttons
$('#nameid_refill').on('click', function() {
$('#newuserid').val(patronInfoArr[0].toLowerCase() + "." + patronInfoArr[1].toLowerCase());
});
$('#cardid_refill').on('click', function() {
$('#newuserid').val(patronInfoArr[2]);
});
$('#lnamepass_refill').on('click', function() {
$('#newpassword,#newpassword2').val(patronInfoArr[1]);
});
$('#phonepass_refill').on('click', function() {
$('#newpassword,#newpassword2').val(patronInfoArr[3].slice(-4));
});
$('#townpass_refill').on('click', function() {
$('#newpassword,#newpassword2').val(patronInfoArr[4].toLowerCase());
});
$('#birthpass_refill').on('click', function() {
$('#newpassword,#newpassword2').val((patronInfoArr[5].slice(5, 7)) + (patronInfoArr[5].slice(8, 10)) + (patronInfoArr[5].slice(0, 4)));
});
}
//adds hover function so you don't have to click a button to open it and again to trigger the function
$('.ezfill').mouseover(function() {
$(this).addClass("open");
});
Match the new "Allowed pickup location" dropdown to the logged in library
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Set
- Creation Date:
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Developed on 21.05
- Notes: Koha 21.05 has a new dropdown on request.pl called "Allowed pickup locations" that is set by default to the item's home library. This means that when you place an item specific request on an item, you must select the pickup location from the "Allowed pickup locations" dropdown unless you want to pick up the item at the item's home library. This code sets the pickup location to match the default "Pickup at:" location that is set for any "Hold next available item:" request.
//BEGIN Set item specific request dropdowns to current library
var reqcode = $(".logged-in-branch-code").first().text().trim();
var reqname = $(".logged-in-branch-name:first").text().trim();
$('#circ_request #hold-request-form #requestspecific tr td:last-child select option').val(reqcode);
$('#circ_request #hold-request-form #requestspecific tr td:last-child select option').text(reqname);
Highlight titles with holds in the search results table
- Developer: Barbara Glassford Johnson (Bedford Public Library)
- Creation Date: 10/30/2021
- Purpose: Highlight holds so that they are easier to spot - those with any value of 1 or more have css applied to them
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//BEGIN highlight titles with holds in search results list on search.pl//
if (window.location.href.indexOf("search.pl") > -1) {
$('[id^="reserve_"]:not(:contains("Holds (0)"))').css({"color": "#9e0000", "font-weight": "700"});
}
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Creation Date: 1/20/2022
- Purpose: Remove the navigation bar from any report results you print
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//Hide menus when printing report results (v21.05)
$('#rep_guided_reports_start .navbar').addClass('hidden-print');
//END Hide menus when printing report results
Delay displaying tabs until built
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Creation Date: 1/20/2022
- Purpose: Hide tables with tabs until the tabs are built and the page is done loading - instead of watching page being built with the list first and then being converted into tabs.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//Reveal these tables after tabs finished loading (see CSS) (v21.05)
$('#rep_guided_reports_start #tabs,#circ_circulation #patronlists,#acq_suggestion #suggestiontabs').css('display','block');
//END Reveal these tables after tabs finished loading (see CSS)
/* Hide these tables until tabs finished loading (v21.05) */
#rep_guided_reports_start #tabs, #circ_circulation #patronlists, #acq_suggestion #suggestiontabs {
display: none;
}
Change text of options on "Print" dropdown
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Change the text of the dropdown options on the "Print" button on the checkout page
- Creation Date: 2018
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: Staff often can't remember the difference between "Print summary," "Print slip," "Print quick slip" etc. This changes the text to make them more descriptive for staff at my libraries. The html could be customized to fit whatever works for your library.
//BEGIN rename print drop-downs
$('#toolbar #printsummary').html('Full page-summary');
$('#toolbar #printslip').html('Receipt-all checkouts');
$('#toolbar #printquickslip').html("Receipt-today's checkouts");
$('#toolbar #print_overdues').html('Full page-overdue items');
$('#toolbar #printcheckinslip').html("Reciept-today's checkins");
Change receipt printed by icon on checkout page
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Redirect the print icon on the checkout page from "Print slip" to "Print quick slip."
- Creation Date: 2018
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: Staff at my library wanted the printer icon on the checkouts page to activate the "Print quick slip" receipt instead of the "Print slip" receipt.
//BEGIN re-tool print and clear icon to do quick slip
$('#printclearscreen').hide();
$('#clearscreen').prepend('<span style="position: absolute; right: 43px; top: 0;" id="qprintclearscreen"><a href="#" title="Print today\'s checkouts and clear screen"><i class="fa fa-print"></i></a></span>');
$("#circ_circulation #qprintclearscreen").click(function() {
printx_window("qslip");
window.location.replace("/cgi-bin/koha/circ/circulation.pl");
});
Highlight print buttons in circulation modals
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Make print buttons on modals stand out during circulation for improved workflow.
- Creation Date: 2/10/2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: I've included an alternative CSS version. Don't need to use both.
//Check in alert enhancements (v21.05)
$('#hold-found1 button.print,#hold-found2 button.print, #return1 button.openWin, #return2 button.openWin, #item-transfer-modal button.openWin, #wrong-transfer-modal button.openWin').css('background-image','none').css('background-color','#69a268 !important');
//END Check in alert enhancements
/* Check in alert enhancements (v21.05) */
#hold-found1 button.print,#hold-found2 button.print, #return1 button.openWin, #return2 button.openWin, #item-transfer-modal button.openWin, #wrong-transfer-modal button.openWin {
background-image: none;
background-color: #69a268 !important;
}
Add html to the "No item barcode found" message
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Add html to the "No item barcode found" message on returns.pl
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: With different policies at 50+ libraries I wanted to add a "Best practices" document and some report links to help improve consistency with procedures to the "No item barcode found" message on returns.pl
//BEGIN add content to "No item with barcode" message
//Wraps a span around the message
$('.problem.ret_badbarcode').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).wrap("<span class='ibctext'></span>");
//Isolates the barcode number in the message
var noibcstring = $('.ibctext').text();
var noibc = noibcstring.substr(noibcstring.indexOf(": ") + 1).trim()
//Appends message to the "No item with barcode" message
//Replace "http://www.koha-us.org" with the website of your best practices document
//Replace "REPORT_NUMBER" with the numbers of the reports you want available for staff when they see this message
$('.static_checkin_messages .dialog.alert.audio-alert-warning .problem.ret_badbarcode:contains("No item with barcode:")').append('<br /><br /><a href="http://www.koha-us.org" target="_blank">What to do when \"No item with barcode\" occurs at checkin - best practices document</a><br /><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=REPORT_NUMBER&phase=Run+this+report¶m_name=Enter+barcode+number&sql_params=' + noibc + '&limit=500" target="_blank">Search for this barcode number in REPORT_NUMBER 1</a><br /><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Run+this+report&reports=REPORT_NUMBER&sql_params=' + noibc + '&limit=50" target="_blank">Search for this barcode number in REPORT_NUMBER 2</a>');
Remove the trailing / from titles
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Remove the trailing / at the end of titles in search results if there is nothing after it on the same line (author/contributor)
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: We removed the redundant author and contributor info on the title line in results. Since the / is commonly included in marc data, it remains and is unnecessary. You can find similar code for the OPAC below. This example does not include the record detail page, but could easily encompass that page as well. Consult the XSLTs for removal of redundant info on these pages.
//Remove trailing '/' from title in results (v21.05)
if ( $('#catalog_results').length) {
//$('.title_resp_stmt').remove(); This line is needed if you didn't remove it with the XSLT.
$('.title').each( function() {
var title_text = $(this).text();
var title_lastChar = title_text.charAt(title_text.length-2);
if ( title_lastChar == '/' ) {
var new_text = title_text.slice(0, -2);
$(this).text(new_text);
}
});
}
//END Remove trailing '/' from title in results
Embiggen the select boxes on the item search page
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Increase the height of the select boxes on the item search page
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: Updated to include two options - set the height to a specific number of rows or set the height to match the number of available choices.
Option 1 - Set the box height to a specific number of rows
//Embiggen item search fields to a specific height
$('#catalog_itemsearch #itemsearchform select[multiple="multiple"]').attr('size', '12');
Option 2 - Automatically set the select box to match the number of choices
//Embiggen item search fields to match the number of options available
$('#catalog_itemsearch #itemsearchform select[multiple="multiple"]').each(function() {
$(this).attr('size', $(this).find('option').length);
});
Lockdown Library Settings
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Remove the ability to change libraries in Koha unless you are a superlibrarian
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: Tested and working on 21.05
- Notes: Includes CSS code for login lockdown
/*Lockdown Login*/
#loginform #branch, #loginform label[for=branch], #loginform #desk_id, #loginform label[for=desk], #loginform #register_id, #loginform label[for=register_id] {
display: none;
}
//Disable library changing
if (!$('.loggedinusername').hasClass('is_superlibrarian')) {
//Remove Set Library from header menu
$('#user-menu ul.dropdown-menu li:contains("Set library")').remove();
//end Remove Set Library
//Remove Set Library from Circulation page
$('#circ_circulation-home ul.buttons-list li:contains("Set library")').remove();
//end Remove Set Library
}
//END Disable library changin
Self Registration Confirmation Slip
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Repurpose the Print Summary slip to create a self registration confirmation slip that can print information filled in online, ask for additional information, and provide a line for signing so this can be retained for document retention.
- Notes: Rebuilt for 22.05 and Firefox issues. Hijacking an existing slip proved to be problematic for this version of Koha and Firefox, so I reinvented this task by creating a totally new menu item/slip. This is more reliable.
- Creation Date: 2022
- Updated: 2023
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
//Online Registration Confirmation Slip through Print Summary (v22.05)
if($('ul.patronbriefinfo li.patroncategory').text().includes('SELF')){
//Build menu selection for a self registered patron
$('#printsummary').closest('ul').prepend('<li><a id="mnuSelfRegConf" href="#">Registration Confirmation</a></li>');
//Build Slip Info
//Gather patron information
var urlParams = new URLSearchParams(window.location.search);
var usrBorrowerNumber = urlParams.get('borrowernumber');
var infoRegConf;
//Get patron data
var url = '/api/v1/patrons?patron_id=' + usrBorrowerNumber;
let patronInfoArr;
$.ajax({
async: false,
url: url,
success: function(data) {
patronInfoArr = [data[0].firstname, data[0].surname, data[0].address, data[0].city, data[0].state, data[0].postal_code, data[0].altaddress_address, data[0].altaddress_city, data[0].altaddress_state, data[0].altaddress_postal_code, data[0].phone, data[0].secondary_phone, data[0].email, data[0].secondary_email, data[0].category_id];
}
});
if(patronInfoArr[14] == 'SELF'){
//Build page
infoRegConf = '<h3>Online Registration Confirmation</h3>';
infoRegConf += '<h5>Name</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[0] || '')+' '+(patronInfoArr[1] || '')+'</li></ul>';
infoRegConf += '<h5>Mailing Address</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[2] || 'None')+'</li><li style="list-style-type:none;">'+(patronInfoArr[3] || '')+', '+(patronInfoArr[4] || '')+' '+(patronInfoArr[5] || '')+'</li></ul>';
infoRegConf += '<h5>Physical Address (if differnt from mailing)</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[6] || 'None')+'</li><li style="list-style-type:none;">'+(patronInfoArr[7] || '')+', '+(patronInfoArr[8] || '')+' '+(patronInfoArr[9] || '')+'</li></ul>';
infoRegConf += '<h5>Primary Phone</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[10] || 'None')+'</li></ul>';
infoRegConf += '<h5>Secondary Phone</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[11] || 'None')+'</li></ul>';
infoRegConf += '<h5>Primary E-mail</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[12] || 'None')+'</li></ul>';
infoRegConf += '<h5>Secondary E-mail</h5><ul><li style="list-style-type:none;">'+(patronInfoArr[13] || 'None')+'</li></ul>';
//Gather extra info not included in online registration
infoRegConf += '<h5>ADDITIONAL INFORMATION</h5><div style="border-style:solid; padding: 2px;"><h5>Birth Date</h5><ul><br/><li style="list-style-type:none;">_____ / _____ / __________</li></ul><h5>Parent/Guardian Name (if under 18)</h5><ul><br/><li style="list-style-type:none;">_______________________________________</li></ul><h5>Relationship</h5><ul><li style="list-style-type:none;">Father / Mother / Guardian (circle one)</li></ul><h5>Contact preference</h5><ul><li style="list-style-type:none;">E-mail / Text (SMS) / Phone call</li><li style="list-style-type: none;">(Circle all that apply)</li></ul><h5>Do you want to receive the monthly e-newsletter?</h5><ul><li style="list-style-type:none;">Yes / No</li><li style="list-style-type: none;">(Circle one)</li></ul><br/>I, as an individual or as the parent/legal guardian of a child, shall comply with all library policies, accept responsibility for all materials borrowed from the library, and will give immediate notice of any change of address. If the card is lost or stolen, I understand I must notify the library immediately. If signing as the parent or legal guardian of a child, I understand that children have access to all materials in the library, and I accept responsibility for monitoring my child\'s access to print, media, and electronic formats, including the internet.<br/><br/><br/>_______________________________________<br/>Signature</div>';
}
$('#mnuSelfRegConf').on('click', function () {
printSelfRegConf(infoRegConf);
});
function printSelfRegConf(elem) {
var myWindow=window.open('','','');
myWindow.document.write(elem);
myWindow.document.close();
setTimeout(function(){
myWindow.focus();
myWindow.print();
myWindow.close();
},500);
}
}
//END Online Registration Confirmation Slip through Print Summary
Circulation rules modifications 3.0
- Developer: George Williams (Northeast Kansas Library System / Next Search Catalog)
- Purpose: Several modifications to the circulation rules matrix table
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
- Notes: This is at least the third version of this code. All of the smaller pieces can be added between the same "$('#default-circulation-rules').on('init.dt', function() { });" function to minimize the length of the code.
- Purpose: Adds a button to collapse the #navmenu div to the left of the rules matrix table so more of the table will fit on the screen.
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//BEGIN Create button to expand collapsed rule columns
$('#admin_smart-rules #navmenu').parent().prepend('<a href="#default-circulation-rules"><button id="allshows" type="button" style="margin: 5px">Show full width</button></a>');
$('#allshows').click(function() {
$('#navmenu, #allshows').hide();
$('.row .col-sm-10.col-sm-push-2').removeClass('col-sm-push-2');
$(window).trigger('resize');
});
});
Highlight row on hover
- Purpose: Moving the mouse over a row highlights that row.
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//BEGIN Highlight row on hover
$('#default-circulation-rules tr').hover(
function() {
$(this).addClass('highlighted-row');
},
function() {
$(this).removeClass('highlighted-row')
}
);
});
Click on row to move it to the bottom of the table
- Purpose: When you click on a row in the table, it will move to the bottom of the table right above the "Edit" row.
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//Click on row to move it to bottom
$('#default-circulation-rules tr:contains(Edit)').click(function() {
$(this).insertBefore('#default-circulation-rules #edit_row');
$(window).trigger('resize');
});
});
- Purpose: When you click on a cell in the footer, the table will sort based on the values in the column you've clicked on.
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//BEGIN Sort circulation rules by clicking on footer
$('#default-circulation-rules tfoot tr th').click(function() {
var table = $(this).parents('table').eq(0);
var rows = table.find("tbody tr").toArray().sort(comparer($(this).index()));
this.asc = !this.asc;
if (!this.asc) {
rows = rows.reverse();
}
for (var i = 0; i < rows.length; i++) {
table.append(rows[i]);
}
$("#default-circulation-rules #edit_row").insertBefore("tfoot");
$(window).trigger('resize');
});
function comparer(index) {
return function(a, b) {
var valA = getCellValue(a, index),
valB = getCellValue(b, index);
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB);
};
}
function getCellValue(row, index) {
return $(row).children('td').eq(index).text();
}
});
Collapse columns when the header is clicked - REQUIRES CSS
- Purpose: When you click on a cell in the header, that column will collapse to 15px wide allowing for more of the table to fit on the page.
- Dependency: Requires that you add the accompanying CSS to IntranetUserCSS.
IntranetUserCSS
/* -Administration › Circulation and fine rules- hides columns in circulation rules (requires accompanying jQuery) */
th.hiderule, td.hiderule {
min-width: 15px;
max-width: 15px;
text-indent: -9999px;
}
IntranetUserJS
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//BEGIN Hide unneeded columns in circulation rules by clicking on header (requires accompanying css)
$('#default-circulation-rules thead th').append('<br /><br /><span>Hide<br />Column</span>');
$('#default-circulation-rules thead th').click(function() {
var index = (this.cellIndex + 1);
var cells = $('#default-circulation-rules tr > :nth-child(' + index + ')');
cells.toggleClass('hiderule');
if ($(this).hasClass('hiderule')) {
$(this).find('span').html('+');
} else {
$(this).find('span').html('Hide<br />Column');
}
$(window).trigger('resize');
});
});
Pre-collapse specified columns
- Purpose: Automatically collapse columns you specify when the page loads.
- Dependency: Requires that you add the previous code (Collapse columns when the header is clicked - REQUIRES CSS).
- Notes: This following lists every column in this table in Koha 21.05 but only the columns I normally have auto-collapsed are collapsed. Add or remove comment marks ("//") to suit your needs.
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//Hide 'Patron category' row by default
//$('#default-circulation-rules th:nth-child(1), #default-circulation-rules td:nth-child(1)').addClass('hiderule');
//Hide 'Item type' row by default
//$('#default-circulation-rules th:nth-child(2), #default-circulation-rules td:nth-child(2)').addClass('hiderule');
//Hide 'Actions (1)' row by default
//$('#default-circulation-rules th:nth-child(3), #default-circulation-rules td:nth-child(3)').addClass('hiderule');
//Hide 'Note' row by default
//$('#default-circulation-rules th:nth-child(4), #default-circulation-rules td:nth-child(4)').addClass('hiderule');
//Hide 'Current checkouts allowed' row by default
//$('#default-circulation-rules th:nth-child(5), #default-circulation-rules td:nth-child(5)').addClass('hiderule');
//Hide 'Current on-site checkouts allowed' row by default
//$('#default-circulation-rules th:nth-child(6), #default-circulation-rules td:nth-child(6)').addClass('hiderule');
//Hide 'Loan period' row by default
//$('#default-circulation-rules th:nth-child(7), #default-circulation-rules td:nth-child(7)').addClass('hiderule');
//Hide 'Days mode' row by default
$('#default-circulation-rules th:nth-child(8), #default-circulation-rules td:nth-child(8)').addClass('hiderule');
//Hide 'Unit' row by default
//$('#default-circulation-rules th:nth-child(9), #default-circulation-rules td:nth-child(9)').addClass('hiderule');
//Hide 'Hard due date' row by default
//$('#default-circulation-rules th:nth-child(10), #default-circulation-rules td:nth-child(10)').addClass('hiderule');
//Hide 'Decreased loan period for high holds (day)' row by default
$('#default-circulation-rules th:nth-child(11), #default-circulation-rules td:nth-child(11)').addClass('hiderule');
//Hide 'Fine amount' row by default
//$('#default-circulation-rules th:nth-child(12), #default-circulation-rules td:nth-child(12)').addClass('hiderule');
//Hide 'Fine charging interval' row by default
//$('#default-circulation-rules th:nth-child(13), #default-circulation-rules td:nth-child(13)').addClass('hiderule');
//Hide 'When to charge' row by default
//$('#default-circulation-rules th:nth-child(14), #default-circulation-rules td:nth-child(14)').addClass('hiderule');
//Hide 'Fine grace period' row by default
//$('#default-circulation-rules th:nth-child(15), #default-circulation-rules td:nth-child(15)').addClass('hiderule');
//Hide 'Overdue fines cap (amount)' row by default
//$('#default-circulation-rules th:nth-child(16), #default-circulation-rules td:nth-child(16)').addClass('hiderule');
//Hide 'Cap fine at replacement price' row by default
$('#default-circulation-rules th:nth-child(17), #default-circulation-rules td:nth-child(17)').addClass('hiderule');
//Hide 'Suspension in days (day)' row by default
$('#default-circulation-rules th:nth-child(18), #default-circulation-rules td:nth-child(18)').addClass('hiderule');
//Hide 'Max. suspension duration (day)' row by default
$('#default-circulation-rules th:nth-child(19), #default-circulation-rules td:nth-child(19)').addClass('hiderule');
//Hide 'Suspension charging interval' row by default
$('#default-circulation-rules th:nth-child(20), #default-circulation-rules td:nth-child(20)').addClass('hiderule');
//Hide 'Renewals allowed (count)' row by default
//$('#default-circulation-rules th:nth-child(21), #default-circulation-rules td:nth-child(21)').addClass('hiderule');
//Hide 'Renewal period' row by default
//$('#default-circulation-rules th:nth-child(22), #default-circulation-rules td:nth-child(22)').addClass('hiderule');
//Hide 'No renewal before' row by default
$('#default-circulation-rules th:nth-child(23), #default-circulation-rules td:nth-child(23)').addClass('hiderule');
//Hide 'Automatic renewal' row by default
$('#default-circulation-rules th:nth-child(24), #default-circulation-rules td:nth-child(24)').addClass('hiderule');
//Hide 'No automatic renewal after' row by default
$('#default-circulation-rules th:nth-child(25), #default-circulation-rules td:nth-child(25)').addClass('hiderule');
//Hide 'No automatic renewal after (hard limit)' row by default
$('#default-circulation-rules th:nth-child(26), #default-circulation-rules td:nth-child(26)').addClass('hiderule');
//Hide 'Holds allowed (total)' row by default
//$('#default-circulation-rules th:nth-child(27), #default-circulation-rules td:nth-child(27)').addClass('hiderule');
//Hide 'Holds allowed (daily)' row by default
//$('#default-circulation-rules th:nth-child(28), #default-circulation-rules td:nth-child(28)').addClass('hiderule');
//Hide 'Holds per record (count)' row by default
//$('#default-circulation-rules th:nth-child(29), #default-circulation-rules td:nth-child(29)').addClass('hiderule');
//Hide 'On shelf holds allowed' row by default
//$('#default-circulation-rules th:nth-child(30), #default-circulation-rules td:nth-child(30)').addClass('hiderule');
//Hide 'OPAC item level holds' row by default
//$('#default-circulation-rules th:nth-child(31), #default-circulation-rules td:nth-child(31)').addClass('hiderule');
//Hide 'Article requests' row by default
$('#default-circulation-rules th:nth-child(32), #default-circulation-rules td:nth-child(32)').addClass('hiderule');
//Hide 'Rental discount (%)' row by default
$('#default-circulation-rules th:nth-child(33), #default-circulation-rules td:nth-child(33)').addClass('hiderule');
//Hide 'Actions (2)' row by default
//$('#default-circulation-rules th:nth-child(34), #default-circulation-rules td:nth-child(34)').addClass('hiderule');
//Replace the text with a + sign on pre-hidden columns
$("#default-circulation-rules > thead > tr > th.hiderule > span").html("+");
});
Automatically adjust the page for a super-wide browser size
- Purpose: When you load a browser that is wider than 2500px, this will hide the left hand navigation and embiggen all automatically pre-collapsed columns.
- Dependency: Requires that you add the previous code (Collapse columns when the header is clicked - REQUIRES CSS).
//BEGIN changes to smart-rules.pl
$('#default-circulation-rules').on('init.dt', function() {
//BEGIN expand when super large or multi screen sized page is loaded
if ($(window).width() > 2500) {
$('#navmenu, #allshows').hide();
$('.row .col-sm-10.col-sm-push-2').removeClass('col-sm-push-2');
$('.hiderule').removeClass();
$(window).trigger('resize');
}
});
Also Try - Extend staff searching to other sources
- Developer: Christopher Brannon (Coeur d'Alene Public Library / CIN)
- Purpose: Allows staff to continue searching for the same search criteria on preset links/sites set in the left navigation panel on the search results page.
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//Also Try (v21.05)
if($('#catalog_results').length){ //Check if you are on the search results page
var s = $('#breadcrumbs li').has('a[href="#"]').text().trim().match(/'(.*?)'/);
var searchCriteria = s[1]; //Setting variable with search criteria from the breadcrumbs line
$('aside').append('<br/><div id="search-also" style="border: 1px solid #b9d8d9; border-radius: 5px 5px 0 0;"><h4 style="background-color: #e6f0f2; border-bottom: 1px solid #b9d8d9; border-radius: 5px 5px 0 0; font-size: 90%; margin: 0; padding: 0.4em 0.2em; text-align: center;">Try your search in...</h4>'); //Setting header for new links in left navigation panel
$('#search-also').append('<a href="https://www.amazon.com/s?k=' + searchCriteria + '&i=stripbooks" target="_blank">Amazon Books</a><br/>'); //Start of some new links
$('#search-also').append('<a href="https://www.amazon.com/s?k=' + searchCriteria + '" target="_blank">Amazon (General Search)</a><br/>');
$('#search-also').append('<a href="https://www.fantasticfiction.com/search/?searchfor=author&keywords=' + searchCriteria + '" target="_blank">Fantastic Reads (Authors)</a><br/>');
$('#search-also').append('<a href="https://www.fantasticfiction.com/search/?searchfor=book&keywords=' + searchCriteria + '" target="_blank">Fantastic Reads (Books)</a><br/>');
$('#search-also').append('<a href="https://www.fantasticfiction.com/search/?searchfor=series&keywords=' + searchCriteria + '" target="_blank">Fantastic Reads (Series)</a><br/>');
$('#search-also').append('<a href="https://www.goodreads.com/search?utf8=%E2%9C%93&query=' + searchCriteria + '" target="_blank">GoodReads</a><br/>');
$('#search-also').append('<a href="https://www.google.com/search?q=' + searchCriteria + '" target="_blank">Google</a><br/><a href="https://www.google.com/search?tbm=bks&q=' + searchCriteria + '" target="_blank">Google Books</a><br/>');
$('#search-also').append('<a href="http://ww2.kdl.org/libcat/WhatsNext.asp?AuthorLastName=&AuthorFirstName=&SeriesName=&CategoryID=0&cmdSearch=Search&Search=1&grouping=&BookTitle=' + searchCriteria + '" target="_blank">What\'s Next (Books)</a><br/>');
$('#search-also').append('<a href="http://ww2.kdl.org/libcat/WhatsNext.asp?AuthorLastName=&AuthorFirstName=&CategoryID=0&cmdSearch=Search&Search=1&grouping=&BookTitle=&SeriesName=' + searchCriteria + '" target="_blank">What\'s Next (Series)</a><br/>');
if($('.logged-in-branch-code').first().text() == 'YOURBRANCHCODE') { //This link will only show for a specified branch
$('#search-also').append('<a href="YOUR LINK HERE">SPECIAL LINK 1</a>');
}
if($('.logged-in-branch-code').first().text() == 'ANOTHERBRANCHCODE') { //This link will only show for a different specified branch
$('#search-also').append('<a href="YOUR LINK HERE">SPECIAL LINK 2</a>');
}
$('#search-also').append('</div>');
$('aside').append('<br/><div id="search-catalogers" style="border: 1px solid #b9d8d9; border-radius: 5px 5px 0 0;"><h4 style="background-color: #e6f0f2; border-bottom: 1px solid #b9d8d9; border-radius: 5px 5px 0 0; font-size: 90%; margin: 0; padding: 0.4em 0.2em; text-align: center;">Catalogers search in...</h4>'); //New section for cataloger links
$('#search-catalogers').append('<a href="https://ts360.baker-taylor.com/_layouts/CommerceServer/QuickSearch.aspx?keyword=' + searchCriteria + '" target="_blank">Baker & Taylor</a><br/>');
$('#search-catalogers').append('<a href="https://www.blackstonelibrary.com/library/catalogsearch/result/?q=' + searchCriteria + '" target="_blank">Blackstone Library</a><br/>');
$('#search-catalogers').append('</div>');
}
//END Also Try
Prevent extra whitespace while editing item record
- Developer: George H. Williams (Next Search Catalog / Northeast Kansas Library System)
- Purpose: Prevent leading and trailing whitespace on item record - remove doublespaces - while editing item record
- Creation Date: 2022
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.05
//BEGIN Prevent leading and trailing whitespace on item record - remove doublespaces
$('.input_marceditor').on('blur', function() {
$(this).val(function(i, value) {
return value.replace(/\s+/g, ' ').trim();
});
});
//END Prevent leading and trailing whitespace on item record - remove doublespaces
FCV - Full cataloguing view in bibliographic or authority record
- Developer: Stefano Bargioni (Pontificia Università della Santa Croce)
- Purpose: Display the currently edited record in MARC professional view (compact or expanded)
- Creation Date: 2022-09-13
- Last Modification Date: 2023-05-30
- Status: Completed
- Gadget Version: 1.1
- Intranet or OPAC?: Intranet
- Koha Version: 20.11+
function show_marc_record_fcv(e) {
if (e.target.tagName == 'INPUT') return;
if (e.target.tagName == 'TEXTAREA') return;
var c = e.which; // code key pressed, f/F = 70; mouse click: 1
if (c != 70 && c != 1) return;
if (e.altKey || e.ctrlKey || e.metaKey) return; // do not act if a modifier key other than shift was also pressed - SB 2022-12-14
var fcv_compact_view = false;
if (e.shiftKey) fcv_compact_view = true;
if ($('#dialog_fcv_modal').hasClass('in')) {
$('#dialog_fcv_modal').modal('hide');
return;
}
$('#dialog_fcv_modal').modal(); // show the modal window
// close the modal window pressing 'f' or 'F' or 'esc' or button X
var H = [];
H.push('<table>');
// tags
var tags = $('.tagnum');
for (var i = 0; i < tags.length ; i++) {
var tag = tags[i];
// indicators
var indicators = $(tag).closest('li').find('.indicator');
var ind1 = $(indicators[0]).val() || ' ';
var ind2 = $(indicators[1]).val() || ' ';
// subfields
var subfields = $(tag).closest('li').find('.input_marceditor'); // include textareas
var fcv_f = 0;
for (var j = 0; j < subfields.length; j++) {
var s = subfields[j];
var sc = $(s).attr('id').substr(17,1)+' '; // subfield code
if ($(tag).text() < 10) sc = '';
else sc = '<span style="color:red">$'+sc+'</span>';
var v = $(s).val().trim();
v = v.replace(/</mg,'<');
if (v) {
if (fcv_f == 0) {
H.push('<tr><td class="fcv_tag" style="font-weight:bold">'+$(tag).text());
H.push('<td class="fcv_ind">'+ind1);
H.push('<td class="fcv_ind">'+ind2);
if (fcv_compact_view) H.push('<td style="font-family:monospace">'+sc+v);
else H.push('<td style="white-space:pre-wrap; font-family:monospace">'+sc+v);
fcv_f = 1;
}
else {
if (fcv_compact_view) H.push(' '+sc+v);
else H.push('<tr><td><td><td><td style="white-space:pre; font-family:monospace">'+sc+v);
}
}
}
}
H.push('<table>');
$('#dialog_fcv').html('').append(H.join('\n'));
}
if ($('body').is('#cat_addbiblio') || $('body').is('#auth_authorities')) {
var fcv_logo = '<img title="click or shift-click" id="fcv_logo" src="https://upload.wikimedia.org/wikipedia/commons/2/2b/Document_text_edit.svg" style="cursor:pointer; width:32px">';
$('#toolbar .btn-group:last').after('<span style="float:right; position:relative; top:5px; margin-right:5px">Press f (expanded) or F (compact) to toggle Full Cataloguing View '+fcv_logo+'</span>');
// setup and append a hidden modal window
$('body').append(' \
<div id="dialog_fcv_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> \
<div class="modal-dialog modal-lg" role="document"> \
<div class="modal-content"> \
<div class="modal-header"> \
<h5 class="modal-title" id="exampleModalLabel">Full Cataloguing View ' + fcv_logo + ' \
<button type="button" style="float:right" class="close" data-dismiss="modal" aria-label="Close"> \
<span aria-hidden="true" style="font-size:1.3em">×</span> \
</button> \
</h5> \
</div> \
<div class="modal-body" id="dialog_fcv"> \
... \
</div> \
<div class="modal-footer"> \
v. 1.1 (2023-05-30), Pontificia Università della Santa Croce - Licence: the same of Koha <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> \
</div> \
</div> \
</div> \
</div> \
');
// detect keypress or click events
$(document).keydown(show_marc_record_fcv);
$('#fcv_logo').on('click',show_marc_record_fcv);
}
Protect borrowers in a specific category from modification or deletion
- Developer: George Williams (Northeast Kansas Library System / Next Search Catalog)
- Purpose: Prevents staff from modifying or deleting members of a specific borrower category
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.11
- Notes: Change _put_category_name_here_ to match the name of the category on your system you wish to protect
//Prevent the modification of, deletion of, or circulation to everyone in a specific borrower category
$('#circ_circulation, #pat_moremember, #pat_memberentrygen, #pat_member-flags').each(function() {
if ($('.patroninfo .patroncategory:contains("_put_category_name_here_")', this).length) {
$('#deletepatron, #editpatron').remove();
$('#saverecord').attr('disabled','disabled').removeClass('btn btn-default').addClass('btn btn-danger').css("color", "white");
$('#circ_needsconfirmation .approve').remove();
$('#toolbar').before('<h1>This account can only be modified by a system administrator</h1>');
}
});
Display Calendar Events on Home Page
- Developer: Christopher Brannon (Coeur d'Alene Public Library/Cooperative Information Network)
- Purpose: Allows you to display the logged in library's upcoming closures from the Koha calendar. Requires sql report listed in notes.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 21.11
- Notes: Requires https://wiki.koha-community.org/wiki/SQL_Reports_Library#Closures_in_the_Next_4_Weeks_for_Specific_Library
- Notes: getJSON reports require you to specifically define each parameter - if it is a repeated parameter that you only enter once in Koha, you have to define it however many times it is used in the report.
//Library Closure Widget (v22.05)
if ( $('#main_intranet-main').length ) {
var branch = $('#logged-in-info-full .logged-in-branch-code').text();
$('#container-main .col-sm-3').prepend('<h3 style="padding: 0.3em; margin: 0;"><span class="closures_title">Upcoming closures</span></h3><div id="closures"></div>');
$.getJSON("/cgi-bin/koha/svc/report?id=981&sql_params=" + branch + "&sql_params=" + branch + "&sql_params=" + branch + "&sql_params=" + branch + "&sql_params=" + branch + "&sql_params=" + branch + "&sql_params=" + branch, function(data) {
let closureData = '<div class="closureData" style="margin: 0.3em; margin-bottom: 1em; background-color:#E6F0F2; opacity:0.75; border-radius:6px; padding:3px; border:2px solid #B9D8D9;">';
$.each(data, function(index, value) {
var newClosureDate = value[0];
console.log(index + '/' + value);
newClosureDate = newClosureDate.replace(/-/g,'‑');
if(index % 2==0){
closureData += '<div class="closureRow" style="display: table-row;">';
} else {
closureData += '<div class="closureRow" style="display: table-row; background-color:#d5dfe0;">';
}
closureData += '<div style="display: table-cell;"><strong>' + newClosureDate + ': </strong></div><div style="display: table-cell; width: 100%;"><em>' + value[1] + '</em></div></div>';
});
closureData += '</div>';
$('#closures').html( closureData );
});
}
//END Library Closure Widget
Add feedback to batch deletion confirmation screen
- Developer: Jason Robb (SEKLS)
- Purpose: Adds a yellow box below the "Your job has been enqueued!" notice that shows number of items in the job and links to a report to list out those items.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
- Notes: The "View list" link references this report: https://wiki.koha-community.org/wiki/SQL_Reports_Library#Get_list_of_deleted_items_from_background_job
if ($('body').is('#tools_batchMod-del')) {
var jobURL = $('a:contains("View detail of the enqueued job")').attr('href').split('id=');
var jobIDx = jobURL[1];
if (jobIDx.length) {
//Append notice with link to report that lists items
$('.message').last().after('<div class="dialog alert"><p><span id="recordcount" class="fa fa-spinner fa-spin"></i></span> item(s) queued for deletion. ( <a target="_blank" href="/cgi-bin/koha/reports/guided_reports.pl?reports=2929&phase=Run+this+report¶m_name=Deleted+item+Job+ID&sql_params=' + jobIDx +'"> View list </a> )');
//Add total_records count for the job to the appended message
$.get('/api/v1/jobs/' + jobIDx, function(result) {
$('#recordcount').replaceWith('<span>' + result.data.report.total_records + '</span>');
});
}
}
Replace series info in search results via biblio API to avoid tracing
- Developer: Jason Robb (SEKLS)
- Purpose: Replaces series info in search results to avoid traced headings in the search string
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
- Notes: This is a niche case but demonstrates how to use the biblio API endpoint to pull data into results
//Add Series to search results via API
if ( $('#catalog_results').length ) {
$('tr').each( function() {
let this_row = $(this);
let bnum = $(this).find('input').attr('value');
let url = `/api/v1/biblios/${bnum}`;
$(this_row.find(".series")).replaceWith("<span class='results_summary seriez'><span class='label'>Series: </span></span>");
if ( bnum ) {
$.ajax({
type: "GET",
accepts: {"*": "application/marc-in-json" },
url: url,
complete: function(data) {
let bibliodata = data.responseJSON.fields;
bibliodata.forEach( function(arrayItem) {
if ( Object.keys(arrayItem)[0] == '440' ) {
let the440a = arrayItem['440'].subfields[0].a;
let the440n = arrayItem['440'].subfields.map(function(element) { return element['n']; } ).join("");
let the440v = arrayItem['440'].subfields.map(function(element) { return element['v']; } ).join("");
$(`<span class="seriezfull"><a href="/cgi-bin/koha/catalogue/search.pl?idx=se&q=${the440a}">${the440a} </a> ${the440n}${the440v}</span>`).appendTo( this_row.find('.seriez') );
}
if ( Object.keys(arrayItem)[0] == '490' ) {
let the490a = arrayItem['490'].subfields[0].a;
let the490v = arrayItem['490'].subfields.map(function(element) { return element['v']; } ).join("");
$(`<span class="seriezfull"><a href="/cgi-bin/koha/catalogue/search.pl?idx=se&q=${the490a}">${the490a} </a> ${the490v}</span>`).appendTo( this_row.find('.seriez') );
}
});
}
});
}
});
}
Condense Acquisition Baskets
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Condense acquisition baskets so you don't have to scroll through mountains of closed baskets to get to your open ones.
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
- Notes: Adds a button at the top of the table to show/hide the closed baskets
//Condense Acquisition Baskets (v22.05)
if ( $('#acq_booksellers').length ) {
$('a:contains("Show")').addClass('btn btn-default').css('margin-bottom','5px').css('margin-right','5px').attr('id','btnShowAll');
$('#btnShowAll').after('<a id="btnShowClosed" class="btn btn-default" style="margin-bottom: 5px; ">Show/Hide closed active baskets</a>');
$('#acqui_order_supplierlist td:nth-child(9):not([data-order=""])').each(function() {
$(this).parent('tr').attr('status','closed').hide();
});
$('#btnShowClosed').on('click',function() {
$('tr[status="closed"]').toggle("slow");
});
}
//END Condense Acquisition Baskets (v22.05)
Set "Hold starts on" date in future for closed libraries
- Developer: George Williams (Next Search Catalog -- NEKLS)
- Purpose: Sets "Holds starts on" date into the future for libraries that are closed
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
- Notes: This could be modified to work with arrays if multiple libraries needed to be closed
//BEGIN Set "Hold starts on date" to a specific future date for a branch - makes past dates unavailable as hold starts on dates
//Set #reserve_date variable by inserting future date here
var reserve_date = ("mm/dd/yyyy");
//Set closed_branch_code variable by inserting branchcode here
var closed_branchcode = ("BRANCHCODE");
//Set closed branch name value
var closed_branch_name = ("Branch name");
//Set today's date as a variable
var tsnow = new Date($.now());
var tsday = ("0" + tsnow.getDate()).slice(-2);
var tsmonth = ("0" + (tsnow.getMonth() + 1)).slice(-2);
var tsyear = ("0" + (tsnow.getFullYear())).slice(-4);
var date_now = (tsmonth) + "/" + (tsday) + "/" + (tsyear);
//Set variable to get pre-selected branchcode from select2 element
var win_request=$('#circ_request #pickup option[selected="selected"]').val();
//Staff logged in at closed library
//If variable matches closed library, set default "Hold starts on" date to the day before reopening, hide that date, and make it required
if (win_request == closed_branchcode) {
$('#reserve_date').val(reserve_date).attr('required','true').parents('li').hide(); //inserts date, sets field to required, and hides input
}
//Staff logged in at an open library
//If someone changes the pickup dropdown to closed library, change the "Hold starts on" date to the set date, make it required, and set the flatpickr to use reserve_date as the minimum date allowed
//But reset everything when the pickup library is changed back to an open library
$('#circ_request #pickup').parent().change( function() {
var branch_name = $('#select2-pickup-container').text();
if (branch_name == closed_branch_name) {
$('#reserve_date').val(reserve_date);
$('#reserve_date').flatpickr({minDate: reserve_date}); //sets the minimum date for the datepicker for reopening
$('#reserve_date').attr('required','true'); //makes input required
$('#reserve_date').siblings().hide(); //hides extra "X" clear date icons created by messing with the flatpickr plugin
} else {
//Clears all settings if different library is chosen
$('#reserve_date').val('');
$('#reserve_date').removeAttr('required');
$('#reserve_date').show().parents().show();
$('#reserve_date').flatpickr({minDate: date_now}); //Sets minimum date back to today's date
$('#reserve_date').siblings().hide(); //hides extra "X" clear date icons created by messing with the flatpickr plugin
}
});
Put limit on "Add multiple copies of this item" button on additem.pl
- Developer: George Williams (Next Search Catalog -- NEKLS)
- Purpose: Sets a limit of 10 items at a time that can be added to a bibliographic record using the "Add multiple copies of this item" button
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.05
- Notes: The max number is set to 10 just as an example. It could be set to any number you like.
//Home > Cataloging > Edit TITLE > items (cataloguing/additem.pl?biblionumber=n)
//Limit the number of copies that can be added to a biblio using the "Add multiple copies of this item" button
$('#cat_additem #number_of_copies').attr('type','number').attr('max','10');
Transportation cost matrix - Highlight row on hover
- Developer: George Williams (Next Search Catalog -- NEKLS)
- Purpose: Highlights row on the transportation cost matrix on hover
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11
- Version: 23.05 - tested and working
//Home > Administration > Transport cost matrix (transport-cost-matrix.pl)
//Highlight row on hover
$('#transport-cost-matrix tr').hover(
function() {
$( this ).children().css('background','var(--c_medium_hov)');
}, function() {
$( this ).children().css('background','inherit');
}
);
Transportation cost matrix - Add button to open all input boxes in matrix
- Developer: George Williams (Next Search Catalog -- NEKLS)
- Purpose: Creates a button above the Transport cost matrix table that opens all of the closed input boxes on the table
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11
- Version: 23.05 - tested and working
- Notes: The number of clicks to open the input boxes manually = ((number of branches - 1)squared) * 2. This reduces that number to one single click.
//Home > Administration > Transport cost matrix (transport-cost-matrix.pl)
//Creates a button at the top of the table
$('#transport-cost-matrix').prepend('<button id="tcm_open">Open TCM inputs</button>');
//Adds function to that button
$('#tcm_open').click(function (event) {
event.preventDefault();
$('#transport-cost-matrix tr td div').trigger('click');
$(".disable_transport_cost").prop('checked' , false);
$(".cost_input").removeClass("disabled-transfer");
$(".cost_input").prop('disabled' , false);
});
Reminder to process old new books
- Developer: Andrew Fuerste-Henry
- Creation Date: 2023-02-01
- Purpose: Insert reminder on home page to remove items 6+ months old from New Books shelves
- Status: Completed
- Intranet or OPAC?: Intranet
- Version: 22.11
if ( $('#main_intranet-main').length ) {
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const t = new Date();
let today = t.getDate();
let year = t.getFullYear();
let mo = t.getMonth();
let pullnow = new Date(year, mo - 7, today);
let pullsoon = new Date(year, mo - 6, today);
if ( today < 5) {
$('#container-main .col-sm-3').prepend(`
<div id="pullreminder">
<h1>It's time to pull new books added in or before <span id="pullnow"></span>.</h1>
<img src="https://www.publicdomainpictures.net/pictures/450000/nahled/vintage-vogel-katze-illustration.jpg" width="200" height="235" alt="old book cat" />
</div`);
$("#pullreminder").css( { "border-style":"solid" , "border-width":"medium" , "border-color":"red" , "background-color":"white", "padding-top": "10px", "padding-left":"10px", "padding-bottom":"10px" , "padding-right": "10px" });
}
$('#pullnow').html(month[pullnow.getMonth()]);
if ( today > 27) {
$('#container-main .col-sm-3').prepend(`
<div id="pullreminder">
<h1>It's almost time to pull new books added in or before <span id="pullsoon"></span>.</h1>
<img src="https://www.publicdomainpictures.net/pictures/450000/nahled/vintage-vogel-katze-illustration.jpg" width="200" height="235" alt="old book cat" />
</div`);
$("#pullreminder").css( { "border-style":"solid" , "border-width":"medium" , "border-color":"red" , "background-color":"white", "padding-top": "10px", "padding-left":"10px", "padding-bottom":"10px" , "padding-right": "10px" });
}
$('#pullsoon').html(month[pullsoon.getMonth()]);
}
Style checkout area for restricted patrons
- Developer: Andrew Fuerste-Henry
- Creation Date: 2023-06-01
- Purpose: Add visual indicator to checkout when patron is in a category with restricted borrowing
- Status: Completed, needs adaptation to local categories and rules
- Intranet or OPAC?: Intranet
- Version: 22.11
if (
$(".patroncategory:contains(GUEST)").length && $('#pat_moremember, #circ_circulation').length) {
$(".patroncategory").css("color", "red");
$("#circ_circulation_issue").css("background-color", "#ffa242");
$(".circ_barcode").append('<div class="circ_rule_note">Up to 3 items</div>');
$(".circ_rule_note").css("font-weight", "normal");
}
Patron messaging preferences : Auto-check "Digests only" checkbox when "Text message" or "Email" checkbox is selected
- Developer: George H. Williams (Northeast Kansas Library System)
- Creation Date: 2023-10-30
- Purpose: Automatically checks the "Digests only" checkbox when "Text message" or "Email" checkbox is selected on Item Due and Advance Notice
- Status: Complete
- Intranet or OPAC?: Intranet
- Version: Developed on 22.11
//jQuery variable - all pages
//Creates URL variable
var url = $(location).attr('href');
//Home > Patrons > Add patron ([borrowercategory]) (members/memberentry.pl?op=add&categorycode=)
//Home > Patrons > [borrowername] ([borrowercardnumber]) > Modify patron ([borrowercategory]) (members/memberentry.pl?op=modify&destination=circ&borrowernumber=)
//Requires "jQuery variable - all pages > Creates URL variable"
//Force Item due and Advance notice to auto-select "Digests only" when "Text message" or "Email" is selected
if (url.indexOf('memberentry.pl') != -1) {
var email1_var = document.getElementById('email1');
var sms1_var = document.getElementById('sms1');
var email2_var = document.getElementById('email2');
var sms2_var = document.getElementById('sms2');
$('#email1, #sms1, #digest1').change(function() {
if( (email1_var.checked == true) || (sms1_var.checked == true) ) {
$('#digest1').prop('checked', 'true');
}
});
$('#email2, #sms2, #digest2').change(function() {
if( (email2_var.checked == true) || (sms2_var.