From c98124c2a8335e19a3808fe4fbe5622a8080354c Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 16 May 2019 11:56:52 +0200 Subject: [PATCH] Bug 15219: Fix relatives checkouts Send all borrowernumbers to /svc/checkouts instead of only the last one --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 5 +---- svc/checkouts | 16 +++++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index ca4f10ba39..5aee3b5fb6 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -730,10 +730,7 @@ $(document).ready(function() { "bServerSide": ServerSideCheckoutsTables, "sAjaxSource": "/cgi-bin/koha/svc/checkouts", "fnServerParams": function (aoData) { - for (i in relatives_borrowernumbers) { - var borrowernumber = relatives_borrowernumbers[i]; - aoData.push({ "name": "borrowernumber", "value": borrowernumber }); - } + aoData.push({ "name": "borrowernumber", "value": relatives_borrowernumbers }); }, "bPaginate": true, "sPaginationType": "full", diff --git a/svc/checkouts b/svc/checkouts index dfc03b78d7..981c7e8b01 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -45,7 +45,13 @@ unless (haspermission($userid, { circulate => 'circulate_remaining_permissions' exit 0; } -my @borrowernumber = $input->multi_param('borrowernumber'); +my @borrowernumbers; +my $borrowernumber = $input->param('borrowernumber'); +if ($borrowernumber) { + push @borrowernumbers, $borrowernumber; +} else { + @borrowernumbers = $input->multi_param('borrowernumber[]'); +} my $offset = $input->param('iDisplayStart'); my $count = $input->param('iDisplayLength'); @@ -125,13 +131,13 @@ my $sql = ' '; my $borrowernumber_sql = 'borrowernumber'; -if ( @borrowernumber == 1 ) { +if ( @borrowernumbers == 1 ) { $borrowernumber_sql .= ' = ?'; } else { - $borrowernumber_sql .= ' IN (' . join( ',', ('?') x @borrowernumber ) . ') '; + $borrowernumber_sql .= ' IN (' . join( ',', ('?') x @borrowernumbers ) . ') '; } $sql .= $borrowernumber_sql; -push( @parameters, @borrowernumber ); +push( @parameters, @borrowernumbers ); $sql .= " $orderby"; @@ -257,7 +263,7 @@ print $input->header( -type => 'application/json', -charset => 'UTF-8' ); my $sEcho = $input->param('sEcho'); my ($iTotalRecords) = $dbh->selectrow_array( "SELECT COUNT(*) FROM issues WHERE $borrowernumber_sql", undef, - @borrowernumber); + @borrowernumbers); my $response = { iTotalRecords => $iTotalRecords, -- 2.20.1