Bugzilla – Attachment 134073 Details for
Bug 30622
Search for cardnumber needs to go directly to patron record when placing a hold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30622: Patron search when placing hold should redirect if cardnumber is entered
Bug-30622-Patron-search-when-placing-hold-should-r.patch (text/plain), 6.43 KB, created by
Jonathan Druart
on 2022-04-27 14:47:09 UTC
(
hide
)
Description:
Bug 30622: Patron search when placing hold should redirect if cardnumber is entered
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-04-27 14:47:09 UTC
Size:
6.43 KB
patch
obsolete
>From 080d97048d7e0681eea1910c2700c021c101a6cb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 27 Apr 2022 16:44:53 +0200 >Subject: [PATCH] Bug 30622: Patron search when placing hold should redirect if > cardnumber is entered > >When search a patron for placing a hold, if a cardnumber is entered we >should pick the patron and use it, instead of display the table result. > >This was a regression caused by bug 30063. > >Test plan: >- Place a hold on anything in staff >- Search for 42 or any other existing cardnumber in your database >--- > .../prog/en/includes/patron-search.inc | 49 ++++++++++++++----- > .../prog/en/modules/reserve/request.tt | 2 +- > 2 files changed, 38 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index de738dab2b9..3cf073ab301 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -195,6 +195,7 @@ > [%# Get the following parameters: %] > [%# - redirect_if_one_result: Redirect to the patron if the search returns only one result, note that it will not redirect if filters of the DT are used (this is a feature) %] > [%# - redirect_url: The URL to use, the borrowernumber parameter will be added %] >+[%# - redirect_if_attribute_equal: Name of the attribute to use for the redirect. Query using this attribute, before the normal search %] > [%# filter: Same as patron_search_table %] > [%# open_on_row_click: boolean, default off. Will allow to select a patron by clicking on the whole tr element %] > [%# columns: list of columns that will be displayed. Possible values are: 'checkbox', 'cardnumber', 'dateofbirth', 'address', 'name', 'name-address', 'branch', 'category', 'dateexpiry', 'borrowernotes, 'phone', 'checkouts', 'account_balance', 'action' %] >@@ -260,6 +261,18 @@ > getSearchByLocation( false ); > }); > >+ [% SWITCH filter %] >+ [% CASE 'suggestions_managers' %] >+ let patron_search_url = '/api/v1/suggestions/managers'; >+ [% CASE 'baskets_managers' %] >+ let patron_search_url = '/api/v1/acquisitions/baskets/managers'; >+ [% CASE 'funds_owners' %] >+ let patron_search_url = '/api/v1/acquisitions/funds/owners'; >+ [% CASE 'funds_users' %] >+ let patron_search_url = '/api/v1/acquisitions/funds/users'; >+ [% CASE %] >+ let patron_search_url = '/api/v1/patrons'; >+ [% END %] > $(document).ready(function(){ > > $("#info").hide(); >@@ -317,6 +330,7 @@ > return filters; > } > }; >+ > [% UNLESS default_sort_column %] > [% default_sort_column = "name" %] > [% END %] >@@ -324,18 +338,7 @@ > [% SET embed = ['extended_attributes'] %] > patrons_table = $("#[% table_id | html %]").kohaTable({ > "ajax": { >- [% SWITCH filter %] >- [% CASE 'suggestions_managers' %] >- "url": '/api/v1/suggestions/managers', >- [% CASE 'baskets_managers' %] >- "url": '/api/v1/acquisitions/baskets/managers', >- [% CASE 'funds_owners' %] >- "url": '/api/v1/acquisitions/funds/owners', >- [% CASE 'funds_users' %] >- "url": '/api/v1/acquisitions/funds/users', >- [% CASE %] >- "url": '/api/v1/patrons', >- [% END %] >+ "url": patron_search_url, > "dataSrc": function ( json ) { > [% IF redirect_if_one_result %] > // redirect if there is only 1 result. >@@ -716,6 +719,28 @@ > } > > function filter() { >+ [% IF redirect_if_attribute_equal %] >+ let filter = $("#search_patron_filter").val(); >+ if ( filter ) { >+ $.ajax({ >+ data: { cardnumber: filter, _match: 'exact' }, >+ type: 'GET', >+ url: patron_search_url, >+ success: function(data) { >+ if ( data.length == 1 ) { >+ let url = '[% redirect_url | url %]'.indexOf("?") != -1 >+ ? '[% redirect_url | url %]&borrowernumber=' + data[0].patron_id >+ : '[% redirect_url | url %]?borrowernumber=' + data[0].patron_id; >+ document.location.href = url; >+ return false; >+ } >+ }, >+ error: function() { >+ alert( _("An error occurred. Check the logs") ); >+ } >+ }); >+ } >+ [% END %] > $("#firstletter_filter").val(''); > $("#[% table_id | html %]_search_results").show(); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index f0b7fd16f06..38e2402aa5d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1601,7 +1601,7 @@ > table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]; > </script> > >- [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params %] >+ [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %] > <script> > $(document).ready(function() { > $("#holds_patronsearch").on("submit", filter); >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30622
:
134073
|
134451
|
134681