Lines 1-89
Link Here
|
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# script to find owner and users for a budget |
4 |
|
5 |
# Copyright 2008-2009 BibLibre SARL |
6 |
# |
7 |
# This file is part of Koha. |
8 |
# |
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. |
13 |
# |
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. |
17 |
# |
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. |
21 |
|
22 |
use Modern::Perl; |
23 |
|
24 |
use C4::Auth ; |
25 |
use C4::Output; |
26 |
use CGI qw ( -utf8 ); |
27 |
use C4::Dates qw/format_date/; |
28 |
use C4::Members; |
29 |
|
30 |
my $input = new CGI; |
31 |
|
32 |
my $dbh = C4::Context->dbh; |
33 |
|
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, |
41 |
} |
42 |
); |
43 |
|
44 |
# only used if allowthemeoverride is set |
45 |
my $type = $input->param('type'); |
46 |
my $member = $input->param('member') // ''; |
47 |
|
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 ); |
54 |
} |
55 |
|
56 |
my @resultsdata; |
57 |
|
58 |
if ( $member ) { |
59 |
my $results = Search($member, "surname"); |
60 |
|
61 |
foreach my $res (@$results) { |
62 |
my $perms = haspermission( $res->{'userid'} ); |
63 |
my $subperms = get_user_subpermissions( $res->{'userid'} ); |
64 |
|
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} ) |
69 |
{ |
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'}, |
77 |
); |
78 |
push( @resultsdata, \%row ); |
79 |
} |
80 |
} |
81 |
} |
82 |
|
83 |
$template->param( |
84 |
type => $type, |
85 |
member => $member, |
86 |
resultsloop => \@resultsdata |
87 |
); |
88 |
|
89 |
output_html_with_http_headers $input, $cookie, $template->output; |