Bug 13894: Make reserve.pl not using C4::Members::Search

Important note: This will modify the UI.
The patron list will now be displayed in a table (instead of a select).

Test plan:
1/ Place a hold on a record
2/ Search for a patron
3/ Select a patron and submit
4/ The hold workflow should continue as previously

No behavior changes should be observed.

Works as expected.
Signed-off-by: Marc Veron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2015-03-23 14:43:24 +01:00 committed by Tomas Cohen Arazi
parent 1c8c8885f1
commit 0b350faa43
3 changed files with 68 additions and 23 deletions

View file

@ -37,7 +37,7 @@ sub search {
borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
borrowers.country, cardnumber, borrowers.dateexpiry,
borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
borrowers.userid, borrowers.dateofbirth,
borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
categories.description AS category_description, categories.category_type,
branches.branchname";
my $from = "FROM borrowers

View file

@ -6,6 +6,8 @@
<title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm holds</title>
[% END %]
[% INCLUDE 'doc-head-close.inc' %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'calendar.inc' %]
<script type="text/javascript">
// <![CDATA[
@ -24,6 +26,23 @@ $(document).ready(function() {
[% IF AutoResumeSuspendedHolds %]
$(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
[% END %]
var table = $("#table_borrowers").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
],
"aaSorting": [[ 2, "asc" ]],
"sDom": "t",
"iDisplayLength": -1
}));
$(table).find('tbody tr').filter(':has(:radio:checked)').end().click(function(event) {
$('#table_borrowers tbody tr').removeClass('selected');
$(this).addClass('selected');
if (event.target.type !== 'radio') {
$(':radio', this).attr('checked', 'true')
}
});
});
function check() {
@ -144,7 +163,7 @@ function checkMultiHold() {
$('#hold-request-form').preventDoubleFormSubmit();
[% UNLESS ( borrowernumber || borrower_list || noitems ) %]
[% UNLESS ( borrowernumber || borrowers || noitems ) %]
[% IF ( CircAutocompl ) %]
$( "#patron" ).autocomplete({
source: "/cgi-bin/koha/circ/ysearch.pl",
@ -218,7 +237,7 @@ function checkMultiHold() {
<div class="dialog alert"><h3>Patron not found</h3><p>No patron with this name, please, try another</p> </div>
[% END %]
<form id="holds_patronsearch" action="request.pl?biblionumber=[% biblionumber %]" method="post">
[% UNLESS borrower_list %]
[% UNLESS borrowers %]
<fieldset class="brief">
<label for="patron">Patron: </label>
<div class="hint">Enter patron card number or partial name:</div>
@ -228,16 +247,33 @@ function checkMultiHold() {
</fieldset>
[% ELSE %]
<fieldset>
<select size="7" name="borrowernumber">
[% FOREACH borrower IN borrower_list %]
<option value="[% borrower.borrowernumber %]">
[% borrower.surname -%], [% borrower.firstname -%]
... ( [% borrower.cardnumber -%] - [% borrower.categorycode -%] - [% borrower.branchcode %]
) ... [% borrower.address %]
</option>
<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 borrower IN borrowers %]
<tr>
<td><input type="radio" name="borrowernumber" value="[% borrower.borrowernumber %]" /></td>
<td>[% borrower.surname %], [% borrower.firstname %]</td>
<td>[% borrower.cardnumber %]</td>
<td>[% borrower.categorycode %]</td>
<td>[% borrower.branchcode %]</td>
<td>[% borrower.address %]</td>
</tr>
[% END %]
</select>
<input type="hidden" name="biblionumber" value="[% biblionumber %]" /><fieldset class="action"><input type="submit" value="Select" /></fieldset></fieldset>
</tbody>
</table>
<input type="hidden" name="biblionumber" value="[% biblionumber %]" />
<fieldset class="action"><input type="submit" value="Select" /></fieldset>
</fieldset>
[% END %]
[% IF ( multi_hold ) %]

View file

@ -40,6 +40,7 @@ use C4::Items;
use C4::Koha;
use C4::Circulation;
use C4::Dates qw/format_date/;
use C4::Utils::DataTables::Members;
use C4::Members;
use C4::Search; # enabled_staff_search_views
use Koha::DateUtils;
@ -102,18 +103,26 @@ if ( $action eq 'move' ) {
}
if ($findborrower) {
my $borrowers = Search($findborrower, 'cardnumber');
if ($borrowers && @$borrowers) {
if ( @$borrowers == 1 ) {
$borrowernumber_hold = $borrowers->[0]->{'borrowernumber'};
}
else {
$template->param( borrower_list => sort_borrowerlist($borrowers));
my $borrower = C4::Members::GetMember( cardnumber => $findborrower );
if ( $borrower ) {
$borrowernumber_hold = $borrower->{borrowernumber};
} else {
my $dt_params = { iDisplayLength => -1 };
my $results = C4::Utils::DataTables::Members::search(
{
searchmember => $findborrower,
dt_params => $dt_params,
}
);
my $borrowers = $results->{patrons};
if ( scalar @$borrowers == 1 ) {
$borrowernumber_hold = $borrower->[0]->{borrowernumber};
} elsif ( @$borrowers ) {
$template->param( borrowers => $borrowers );
} else {
$messageborrower = "'$findborrower'";
}
}
}
# If we have the borrowernumber because we've performed an action, then we