Bug 13007: DBIC updates
[koha.git] / acqui / aqbasketuser_search.pl
blob660fd499e120ff06b6f015321d5d747bab0ec4c9
1 #!/usr/bin/perl
3 # script to find a basket user
5 # Copyright 2012 BibLibre SARL
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use Modern::Perl;
24 use CGI qw ( -utf8 );
25 use C4::Auth;
26 use C4::Output;
27 use C4::Members;
29 my $input = new CGI;
31 my $dbh = C4::Context->dbh;
33 my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
34 { template_name => "acqui/aqbasketuser_search.tt",
35 query => $input,
36 type => "intranet",
37 authnotrequired => 0,
38 flagsrequired => { acquisition => 'order_manage' },
42 my $q = $input->param('q') || '';
43 my $op = $input->param('op') || '';
45 if( $op eq "do_search" ) {
46 my $results = C4::Members::Search( $q, "surname");
48 my @users_loop;
49 my $nresults = 0;
50 foreach my $res (@$results) {
51 my $perms = haspermission( $res->{userid} );
52 my $subperms = get_user_subpermissions( $res->{userid} );
54 if( $perms->{superlibrarian} == 1
55 || $perms->{acquisition} == 1
56 || $subperms->{acquisition}->{'order_manage'} ) {
57 my %row = (
58 borrowernumber => $res->{borrowernumber},
59 cardnumber => $res->{cardnumber},
60 surname => $res->{surname},
61 firstname => $res->{firstname},
62 categorycode => $res->{categorycode},
63 branchcode => $res->{branchcode},
65 push( @users_loop, \%row );
66 $nresults ++;
70 $template->param(
71 q => $q,
72 nresults => $nresults,
73 users_loop => \@users_loop,
77 output_html_with_http_headers( $input, $cookie, $template->output );