Bug 30055: Use /acquisitions/baskets/managers for basket's manager

Test plan:
Add a manager to a basket

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Séverine Queune <severine.queune@bulac.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2022-02-09 12:38:18 +01:00 committed by Fridolin Somers
parent 29eb48537d
commit 4ee46be97e
5 changed files with 67 additions and 65 deletions

View File

@ -0,0 +1,62 @@
package Koha::REST::V1::Acquisitions::Baskets;
# 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 Mojo::Base 'Mojolicious::Controller';
use Try::Tiny qw( catch try );
=head1 NAME
Koha::REST::V1::Acquisitions::Baskets
=head1 API
=head2 Class methods
=head3 list
Controller function that handles baskets
=cut
=head3 list_managers
Return the list of possible orders' managers
=cut
sub list_managers {
my $c = shift->openapi->valid_input or return;
return try {
my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('acquisition.order_manage');
my $patrons = $c->objects->search( $patrons_rs );
return $c->render(
status => 200,
openapi => $patrons
);
}
catch {
$c->unhandled_exception($_);
};
}
1;

View File

@ -1,64 +0,0 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright 2014 BibLibre
#
# 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 CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
use C4::Members;
use Koha::Patron::Categories ;
my $input = CGI->new;
my $dbh = C4::Context->dbh;
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
{ template_name => "common/patron_search.tt",
query => $input,
type => "intranet",
flagsrequired => { acquisition => 'order_manage' },
}
);
my $q = $input->param('q') || '';
my $op = $input->param('op') || '';
my $referer = $input->referer();
# If this script is called by acqui/basket.pl
# the patrons to return should be superlibrarian or have the order_manage
# acquisition flag.
my $search_patrons_with_acq_perm_only =
( $referer =~ m|acqui/basket.pl| )
? 1 : 0;
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
$template->param(
patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
columns => ['cardnumber', 'name', 'branch', 'category', 'action'],
json_template => 'acqui/tables/members_results.tt',
selection_type => 'add',
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );

View File

@ -65,6 +65,8 @@ definitions:
vendor:
$ref: ./definitions/vendor.yaml
paths:
/acquisitions/baskets/managers:
$ref: paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers
/acquisitions/funds:
$ref: ./paths/acquisitions_funds.yaml#/~1acquisitions~1funds
/acquisitions/orders:

View File

@ -1010,7 +1010,7 @@
function UserSearchPopup(f) {
window.open(
"/cgi-bin/koha/acqui/add_user_search.pl",
"/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=baskets_managers",
'UserSearchPopup',
'width=840, height=500, scrollbars=yes, toolbar=no,'
);

View File

@ -167,6 +167,8 @@
[% SWITCH filter %]
[% CASE 'suggestions_managers' %]
"url": '/api/v1/suggestions/managers'
[% CASE 'baskets_managers' %]
"url": '/api/v1/acquisitions/baskets/managers'
[% CASE %]
"url": '/api/v1/patrons'
[% END %]