Koha/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc
Martin Renvoize d5608b8ff0
Bug 21978: Add support for middle name
This patch adds the new 'Middle name' field to the patron record.

To test:
1) Apply patches
2) Update database, restart all and clear the browser cache
3) Load a patron in the staff module
4) Confirm you can see and edit the new 'Middle name' field
5) Confirm the new middle name data displays on patron details
6) Confirm the new middle name data displays on patron search results
7) Confirm the new middle name data displays everywhere patron names are
   displayed.
8) Confirm the new middle name data displays on the OPAC
9) Confirm the 'Middle name' field appears in the OPAC borrower
   modification screens
10) Edit sysprefs `BorrowerMandatoryFields`, `BorrowerUnwantedFields`,
    `SelfModificationBorrowerUnwantedField`, `PatronSelfModificationMandatoryField`,
    `PatronSelfRegistrationBorrowerMandatoryField` and
    `PatronSelfRegistrationBorrowerUnwantedField` to confirm you can make
    the new field required or hidden.
11) Verify that DefaultPatronSearchFields contains the new field if you
    already had 'firstname' in the field list
12) Enable PatronAutoComplete system preference
13) Type patrons surname into checkout or patron search but don't hit
    return
14) Confirm the patrons middle name is displayed in the preview
15) Go to tools > patron lists and attempt to add a patron to a list
16) Patrons middle name should appear in the autocomplete here too

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-06-24 12:24:11 -03:00

55 lines
2.1 KiB
PHP

<script>
(function() {
/**
* Format the patron response from a Koha RESTful API request.
* @param {Object} patron The patron json object as returned from the Koha RESTful API
* @param {Object} config A configuration object
* Valid keys are: `invert_name`, `display_cardnumber` and `url`
* @return {string} The formatted HTML string
*/
window.$patron_to_html = function( patron, config ) {
if ( patron === undefined ) {
return ''; // empty string for no patron
}
var title = null;
if ( patron.title != null && patron.title != '' ) {
title = '<span class="patron-title">' + escape_str(patron.title) + '</span>';
}
var name;
var firstname = escape_str(patron.firstname);
var surname = escape_str(patron.surname);
if ( patron.middle_name != null && patron.middle_name != '' ) {
firstname += ' ' + escape_str(patron.middle_name);
}
if ( patron.other_name != null && patron.other_name != '' ) {
firstname += ' (' + escape_str(patron.other_name) + ')';
}
if ( config && config.invert_name ) {
name = surname + ( firstname ? ', ' + firstname : '' );
}
else {
name = firstname + ' ' + surname;
}
if ( config && config.display_cardnumber ) {
name = name + ' (' + escape_str(patron.cardnumber) + ')';
}
if (config && config.url) {
if ( config.url === 'circulation_reserves' ) {
name = '<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber='+ encodeURIComponent(patron.patron_id) +'#reserves">' + name + '</a>';
}
else {
name = '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='+ encodeURIComponent(patron.patron_id) +'">' + name + '</a>';
}
}
return name;
};
})();
</script>