Bugzilla – Attachment 132543 Details for
Bug 30094
Rewrite the patron search when requesting an article with the REST API route
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30094: Make the patron search from request-article.pl use the REST API
Bug-30094-Make-the-patron-search-from-request-arti.patch (text/plain), 9.79 KB, created by
Jonathan Druart
on 2022-03-30 08:24:52 UTC
(
hide
)
Description:
Bug 30094: Make the patron search from request-article.pl use the REST API
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-03-30 08:24:52 UTC
Size:
9.79 KB
patch
obsolete
>From 2b276ef5a1286ffd915e67971c5bf416342c7a41 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 14 Feb 2022 15:13:17 +0100 >Subject: [PATCH] Bug 30094: Make the patron search from request-article.pl use > the REST API > >Reuse what has been done before to implement the patron search using the >REST API route, when requesting an article > >Test plan: >Request an article for a patron and confirm that the search is working >correctly. >--- > circ/request-article.pl | 31 ++---- > .../prog/en/modules/circ/request-article.tt | 103 ++++-------------- > 2 files changed, 31 insertions(+), 103 deletions(-) > >diff --git a/circ/request-article.pl b/circ/request-article.pl >index 6a6e63c1d2c..a9724749dc4 100755 >--- a/circ/request-article.pl >+++ b/circ/request-article.pl >@@ -21,7 +21,6 @@ use Modern::Perl; > > use C4::Output qw( output_and_exit output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); >-use C4::Utils::DataTables::Members; > use C4::Search qw( enabled_staff_search_views ); > use C4::Serials qw( CountSubscriptionFromBiblionumber ); > use Koha::Biblios; >@@ -46,7 +45,7 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( > my $action = $cgi->param('action') || q{}; > my $biblionumber = $cgi->param('biblionumber'); > my $patron_cardnumber = $cgi->param('patron_cardnumber'); >-my $patron_id = $cgi->param('patron_id'); >+my $patron_id = $cgi->param('borrowernumber'); > > my $biblio = Koha::Biblios->find($biblionumber); > output_and_exit( $cgi, $cookie, $template, 'unknown_biblio') >@@ -105,28 +104,7 @@ if ( $action eq 'create' ) { > ); > } > }; >- >-} >- >-if ( !$patron && $patron_cardnumber ) { >- my $results = C4::Utils::DataTables::Members::search( >- { >- searchmember => $patron_cardnumber, >- dt_params => { iDisplayLength => -1 }, >- } >- ); >- >- my $patrons = $results->{patrons}; >- >- if ( scalar @$patrons == 1 ) { >- $patron = Koha::Patrons->find( $patrons->[0]->{borrowernumber} ); >- } >- elsif (@$patrons) { >- $template->param( patrons => $patrons ); >- } >- else { >- $template->param( no_patrons_found => $patron_cardnumber ); >- } >+ undef $patron; > } > > if ( $patron && !$patron->can_request_article ) { >@@ -145,6 +123,11 @@ $template->param( > patron => $patron, > subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber), > C4::Search::enabled_staff_search_views, >+ attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') >+ ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] >+ : [] >+ ), > ); > >+ > output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >index 618a3c62f01..46f02428013 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >@@ -3,6 +3,7 @@ > [% USE Context %] > [% USE KohaDates %] > [% USE Branches %] >+[% USE Categories %] > [% USE ItemTypes %] > [% USE AuthorisedValues %] > [% USE Price %] >@@ -10,6 +11,10 @@ > [% SET article_requests_view = 1 %] > [% SET biblionumber = biblio.biblionumber %] > [% INCLUDE 'doc-head-open.inc' %] >+[% SET libraries = Branches.all %] >+[% SET categories = Categories.all.unblessed %] >+[% SET columns = ['name', 'address', 'cardnumber', 'dateofbirth', 'category', 'branch', 'phone'] %] >+[% PROCESS "patron-search.inc" %] > <title>Request article › Circulation › Koha</title> > [% INCLUDE 'doc-head-close.inc' %] > </head> >@@ -96,52 +101,12 @@ > [% END %] > </div> > [% END %] >- [% IF no_patrons_found %] >- <div class="dialog alert"> >- <h3>Patron not found</h3> >- <p>No patron with this name, please, try another</p> >- </div> >- [% ELSIF patrons %] >- <form id="article_request_patron_results" method="post"> >- <fieldset> >- <table id="table_borrowers"> >- <thead> >- <tr> >- <th></th> >- <th>Name</th> >- <th>Cardnumber</th> >- <th>Category</th> >- <th>Library</th> >- <th>Address</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH patron IN patrons %] >- <tr> >- <td><input type="radio" name="patron_id" value="[% patron.borrowernumber | html %]"/></td> >- <td>[% patron.surname | html %], [% patron.firstname | html %]</td> >- <td>[% patron.cardnumber | html %]</td> >- <td>[% patron.categorycode | html %]</td> >- <td>[% patron.branchcode | html %]</td> >- <td>[% patron.address | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" /> >- <fieldset class="action"><input type="submit" value="Select" /></fieldset> >- </fieldset> >- </form> >- [% ELSIF !patron %] >- <form id="article_requests_patronsearch" action="request-article.pl" method="post"> >- <fieldset class="brief"> >- <label for="patron">Patron: </label> >- <div class="hint">Enter patron card number or partial name:</div> >- <input type="text" size="40" id="patron" class="focus" name="patron_cardnumber" /> >- <input type="submit" value="Search" /> >- <input type="hidden" name="biblionumber" value="[% biblio.id | html %]" /> >- </fieldset> >- </form> >+ [% UNLESS patron %] >+ <fieldset class="brief"> >+ <label>Search patrons</label> >+ [% PROCESS patron_search_filters_simple %] >+ [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %] >+ </fieldset> > [% ELSE %] > [% IF biblio.can_article_request( patron ) %] > [% IF article_request_fee > 0 %] >@@ -396,39 +361,6 @@ > }); > > $(document).ready(function() { >- if ( $( "#patron" ).size() ){ >- $( "#patron" ).autocomplete({ >- source: "/cgi-bin/koha/circ/ysearch.pl", >- minLength: 3, >- select: function( event, ui ) { >- $( "#patron" ).val( ui.item.cardnumber ); >- $( "#holds_patronsearch" ).submit(); >- return false; >- } >- }) >- .data( "ui-autocomplete" )._renderItem = function( ul, item ) { >- return $( "<li></li>" ) >- .data( "ui-autocomplete-item", item ) >- .append( >- "<a>" >- + ( item.surname ? item.surname.escapeHtml() : "" ) >- + ", " >- + ( item.firstname ? item.firstname.escapeHtml() : "" ) >- + " (" + ( item.cardnumber ? item.cardnumber.escapeHtml() : "" ) + ")" >- + " " >- + "<small>" >- + ( item.address ? item.address.escapeHtml() : "" ) >- + " " >- + ( item.city ? item.city.escapeHtml() : "" ) >- + " " >- + ( item.zipcode ? item.zipcode.escapeHtml() : "" ) >- + " " >- + ( item.country ? item.country.escapeHtml() : "" ) >- + "</small>" >- + "</a>" ) >- .appendTo( ul ); >- }; >- } > > $( ".ar-update-branchcode" ).on('focus', function(){ > previous_branchcode = this.value; >@@ -503,6 +435,19 @@ > } > }); > </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/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, >+ redirect_if_one_result => 1, >+ redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, >+ %] >+ > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >-- >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 30094
:
130607
|
132543
|
132689
|
132729
|
132730