Bug 13199: Add missing notices for several installations
[koha.git] / admin / aqbudget_user_search.pl
blob1bef1530a16174e08e870d79eabe459f45e5f3ee
1 #!/usr/bin/perl
3 # script to find owner and users for a budget
5 # Copyright 2008-2009 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 C4::Auth ;
25 use C4::Output;
26 use CGI;
27 use C4::Dates qw/format_date/;
28 use C4::Members;
30 my $input = new CGI;
32 my $dbh = C4::Context->dbh;
34 my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
35 { template_name => "admin/aqbudget_user_search.tt",
36 query => $input,
37 type => "intranet",
38 authnotrequired => 0,
39 flagsrequired => { acquisition => 'budget_modify' },
40 debug => 1,
44 # only used if allowthemeoverride is set
45 my $type = $input->param('type');
46 my $member = $input->param('member') // '';
48 $member =~ s/,//g; #remove any commas from search string
49 $member =~ s/\*/%/g;
50 if ( $member eq '' ) {
51 $template->param( results => 0 );
52 } else {
53 $template->param( results => 1 );
56 my @resultsdata;
58 if ( $member ) {
59 my $results = Search($member, "surname");
61 foreach my $res (@$results) {
62 my $perms = haspermission( $res->{'userid'} );
63 my $subperms = get_user_subpermissions( $res->{'userid'} );
65 # if the member has 'acqui' permission set, then display to table.
66 if ( $perms->{superlibrarian} == 1 ||
67 $perms->{acquisition} == 1 ||
68 exists $subperms->{acquisition} )
70 my %row = (
71 borrowernumber => $res->{'borrowernumber'},
72 cardnumber => $res->{'cardnumber'},
73 surname => $res->{'surname'},
74 firstname => $res->{'firstname'},
75 categorycode => $res->{'categorycode'},
76 branchcode => $res->{'branchcode'},
78 push( @resultsdata, \%row );
83 $template->param(
84 type => $type,
85 member => $member,
86 resultsloop => \@resultsdata
89 output_html_with_http_headers $input, $cookie, $template->output;