$(document).ready(function() {
let checkouts_count = 0;
let current_item;
function addResult(type, code, data) {
let result = '';
if (type == 'danger') {
result += '
';
} else if (type == 'warning') {
result += '
';
} else if (type == 'info') {
result += '
';
} else {
result += '
';
}
if (code == 'NOT_FOUND') {
result += _("Item '%s' not found").format(data);
} else if (code == 'RENEW_ISSUE') {
result += _("Item will be renewed").format(data);
} else if (code == 'OTHER_CHARGES') {
result += _("Your account currently has outstanding charges of '%s'").format(data);
} else if (code == 'DEBT') {
result += _("Your account is currently in debt by '%s'").format(data);
} else if (code == 'ISSUED_TO_ANOTHER') {
result += _("This item appears to be checked out to another patron, please return it to the desk");
} else if (code == 'RESERVED' || code == 'RESERVED_WAITING') {
result += _("This item appears to be on hold for another patron, please return it to the desk");
} else if (code == 'TOO_MANY') {
result += _("You have reached the maximum number of checkouts allowed on your account");
} else if (code == 'AGE_RESTRICTION') {
result += _("This item is age restricted");
} else if (code == 'NO_MORE_RENEWALS') {
result += _("Maximum renewals reached for this item");
} else if (code == 'NOT_FOR_LOAN') {
result += _("This item is not normally for loan, please select another or ask at the desk");
} else if (code == 'WTHDRAWN') {
result += _("This item is marked withdrawn, please select another or ask at the desk");
} else if (code == 'EMPTY') {
result += _("Please enter the barcode for the item you wish to checkout");
} else {
result += _("Message code '%s' with data '%s'").format(code, data);
}
result += '
';
$('#availabilityResult').append(result);
};
function addCheckout(checkout) {
// Alert that checkout was successful
$('#checkoutResults').replaceWith('
' + _("Item '%s' was checked out").format(current_item.external_id) + '
');
// Cleanup input and unset readonly
$('#checkout_barcode').val("").prop("readonly", false).focus();
// Display checkouts table if not already visible
$('#checkoutsTable').show();
// Add checkout to checkouts table
$("#checkoutsTable > tbody").append(
"