diff --git a/circ/circulation.pl b/circ/circulation.pl index fa8e5b138e..d093c00f72 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -34,6 +34,7 @@ use C4::Dates qw/format_date/; use C4::Branch; # GetBranches use C4::Koha; # GetPrinter use C4::Circulation; +use C4::Utils::DataTables::Members; use C4::Members; use C4::Biblio; use C4::Search; @@ -202,25 +203,30 @@ if ( $print eq 'yes' && $borrowernumber ne '' ) { # STEP 2 : FIND BORROWER # if there is a list of find borrowers.... # -my $borrowerslist; my $message; if ($findborrower) { - my $borrowers = Search($findborrower, 'cardnumber') || []; - my $categories = GetBorrowercategoryList; - $categories->[0]->{first} = 1; - $template->param( categories => $categories ); - - if ( @$borrowers == 0 ) { - $query->param( 'findborrower', '' ); - $message = "'$findborrower'"; - } - elsif ( @$borrowers == 1 ) { - $borrowernumber = $borrowers->[0]->{'borrowernumber'}; - $query->param( 'borrowernumber', $borrowernumber ); - $query->param( 'barcode', '' ); - } - else { - $borrowerslist = $borrowers; + my $borrower = C4::Members::GetMember( cardnumber => $findborrower ); + if ( $borrower ) { + $borrowernumber = $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 = $borrowers->[0]->{borrowernumber}; + $query->param( 'borrowernumber', $borrowernumber ); + $query->param( 'barcode', '' ); + } elsif ( @$borrowers ) { + $template->param( borrowers => $borrowers ); + } else { + $query->param( 'findborrower', '' ); + $message = "'$findborrower'"; + } } } @@ -417,25 +423,6 @@ if ($borrowernumber) { if ( $borrower->{'category_type'} eq 'A' ); } -my @values; -my %labels; -my $selectborrower; -if ($borrowerslist) { - foreach ( - sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'}) - } @$borrowerslist - ) - { - push @values, $_->{'borrowernumber'}; - $labels{ $_->{'borrowernumber'} } = -"$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} "; - } - $selectborrower = { - values => \@values, - labels => \%labels, - }; -} - #title my $flags = $borrower->{'flags'}; foreach my $flag ( sort keys %$flags ) { @@ -586,7 +573,6 @@ $template->param( stickyduedate => $stickyduedate, duedatespec => $duedatespec, message => $message, - selectborrower => $selectborrower, totaldue => sprintf('%.2f', $total), inprocess => $inprocess, is_child => ($borrowernumber && $borrower->{'category_type'} eq 'C'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 0576020e21..9f17a20783 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -44,7 +44,7 @@ var relatives_borrowernumbers = new Array(); var MSG_ADD_MESSAGE = _("Add a new message"); var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% IF ( borrowernumber ) %]if($.cookie("holdfor") != [% borrowernumber %]){ $.cookie("holdfor",null, { path: "/", expires: 0 }); }[% ELSE %]$.cookie("holdfor",null, { path: "/", expires: 0 });[% END %] -[% UNLESS ( borrowernumber ) %][% UNLESS ( selectborrower ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %] +[% UNLESS ( borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %] // On-site checkout function toggle_onsite_checkout(){ @@ -83,6 +83,23 @@ $(document).ready(function() { $("#onsite_checkout").click(function(){ toggle_onsite_checkout(); }); + + 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') + } + }); + }); //]]> @@ -100,7 +117,7 @@ $(document).ready(function() { Checkouts [% END %] -[% IF ( selectborrower ) %] +[% IF ( $borrowers ) %]
@@ -500,19 +517,34 @@ No patron matched [% message %] -
  1. - - -
  2. -
-

+ + + + + + + + + + + + + [% FOREACH borrower IN borrowers %] + + + + + + + + + [% END %] + +
NameCardnumberCategoryLibraryAddress
[% borrower.surname %], [% borrower.firstname %][% borrower.cardnumber %][% borrower.categorycode %][% borrower.branchcode %][% borrower.address %]
+
-[% ELSE %] +[% ELSE %] @@ -878,7 +910,7 @@ No patron matched [% message %]
-[% UNLESS ( selectborrower ) %][% IF ( borrowernumber ) %]
+[% UNLESS ( borrowers ) %][% IF ( borrowernumber ) %]
[% INCLUDE 'circ-menu.inc' %]
[% END %][% END %]