Jonathan Druart
551721f702
This patch will rewrite some of our patron searches to make them use the REST API routes (and so the powerful the DataTables wrapper which will bring all the nice DT feature to filter, sort, etc.) The patron searches we will take into account here are those that we use to select a patron in a pop-up: * Guarantor * Suggestion's manager * Patron's card * Serial routing list * Users to notify when order is received * Manager of an acquisition basket * Owner and users of a fund Regarding permissions there are two main problematics: * Filter a patron set by patrons having a specific subpermissions (in case of adding a manager to a suggestion or when we deal with acquisition and funds). We added a new Koha::Patrons->filter_by_have_subpermission method that will take in parameter a subpermission. To make thing transparent for the callers we are adding new routes, like /suggestions/managers to list the possible managers of suggestions. * Restrict/allow access to the default patron searches /patrons We need to access it when a logged in patron does not have borrowers permission. Ideally we need a separate "search_borrowers" subpermissions but it's considered outside the scope of this change. For each patch you will take care of testing the different permissions that are into effect (either for the logged in patron or the patrons returned by the search). The tables should contain the same columns as prior to this patch, except for "categories" and "library". We have the filter on top of the page and so we need to add them to the table as new columns if they weren't there before. Test plan (for this patch): Search for guarantor and select Test plan (for all patches): Add/Select patrons from the correct place where you can search for patrons, play extensively with the filters/pagination/etc Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Séverine Queune <severine.queune@bulac.fr> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
51 lines
2 KiB
PHP
51 lines
2 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.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>
|