Koha/members/member.pl
Nick Clemens c7a7e45812 Bug 15812: Use patron search in place of circ search
The 'Checkout' search hijacks some of the DataTables searching code used for 'Search patrons'
Rather than try to implement the search again on another page, we can simply send the user
to the patron search if the cardnumber is not found

Additionally, this patch adds a 'Check out' button to the patron search results to allow
going to checkotus directly

To test:
1 - Apply patch
2 - Perform a 'Checkout' search from the header
3 - Note that:
    For a cardnumber, you are redirected directly to checkouts page for the borrower
    For a search with one result, you are redirected directly to the checkout page for the borrower
    For a search with many results, you are redirected to the patron search results
    and there is a 'Checkout' button under the cardnumber
4 - Confirm circulation page works as expected (i.e. checkout to a patron)

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: George Williams <george@nekls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-10-14 09:19:30 +02:00

84 lines
2.9 KiB
Perl
Executable file

#!/usr/bin/perl
#script to do a borrower enquiry/bring up borrower details etc
#written 20/12/99 by chris@katipo.co.nz
# Copyright 2000-2002 Katipo Communications
# Copyright 2013 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
use CGI qw( -utf8 );
use Koha::List::Patron qw( GetPatronLists );
use Koha::Patrons;
my $input = CGI->new;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/member.tt",
query => $input,
type => "intranet",
flagsrequired => {borrowers => 'edit_borrowers'},
});
my $theme = $input->param('theme') || "default";
my $searchmember = $input->param('searchmember');
my $quicksearch = $input->param('quicksearch') // 0;
my $circsearch = $input->param('circsearch') // 0;
if ( $quicksearch and $searchmember && !$circsearch ) {
my $branchcode;
if ( C4::Context::only_my_library ) {
my $userenv = C4::Context->userenv;
$branchcode = $userenv->{'branch'};
}
my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
if (
$patron
and ( ( $branchcode and $patron->branchcode eq $branchcode )
or ( not $branchcode ) )
)
{
print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber );
exit;
}
}
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
my $view = $input->request_method() eq "GET" && !$circsearch ? "show_form" : "show_results";
$template->param(
patron_lists => [ GetPatronLists() ],
searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'),
searchtype => scalar $input->param('searchtype') || 'contain',
searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
view => $view,
circsearch => $circsearch,
);
output_html_with_http_headers $input, $cookie, $template->output;