Bugfix: Correcting conditional for branch code check
[koha.git] / admin / aqbudget_owner_search.pl
bloba8f9405792da8b44182a33fa638add0b44d013f1
1 #!/usr/bin/perl
3 # script to find a guarantor
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 with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
22 use strict;
23 use C4::Auth ;
24 use C4::Output;
25 use CGI;
26 use C4::Dates qw/format_date/;
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 => "admin/aqbudget_owner_search.tmpl",
35 query => $input,
36 type => "intranet",
37 authnotrequired => 0,
38 flagsrequired => { acquisition => 'budget_modify' },
39 debug => 1,
43 my $theme = $input->param('theme') || "default";
45 # only used if allowthemeoverride is set
46 my $member = $input->param('member');
47 my $orderby = $input->param('orderby');
49 my $op = $input->param('op');
50 $template->param( $op || else => 1, );
52 $orderby = "surname,firstname" unless $orderby;
53 $member =~ s/,//g; #remove any commas from search string
54 $member =~ s/\*/%/g;
55 if ( $member eq '' ) {
56 $template->param( results => 0 );
57 } else {
58 $template->param( results => 1 );
61 my ( $count, $count2, $results );
62 my @resultsdata;
63 my $toggle = 0;
65 if ( $member ) {
66 my $results= SearchMember($member,"surname",undef,undef,undef);
68 foreach my $res (@$results) {
70 my $perms = haspermission( $res->{'userid'} );
71 my $subperms = get_user_subpermissions ($res->{'userid'} );
74 # if the member has 'acqui' permission set, then display to table.
75 if ( $perms->{superlibrarian} == 1 ||
76 $perms->{acquisition} == 1 ||
77 $subperms->{acquisition}->{'budget_manage'} ||
78 $subperms->{acquisition}->{'budget_modify'} ||
79 $subperms->{acquisition}->{'budget_add_del'} ) {
81 $count2++;
82 #find out stats
83 # my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $res->{'borrowerid'} );
84 #This looks unused and very unuseful
85 my $guarantorinfo = uc( $res->{'surname'} ) . " , " . ucfirst( $res->{'firstname'} );
86 my $budget_owner_name = $res->{'firstname'} . ' ' . $res->{'surname'}, my $budget_owner_id = $res->{'borrowernumber'};
88 my %row = (
89 borrowernumber => $res->{'borrowernumber'},
90 cardnumber => $res->{'cardnumber'},
91 surname => $res->{'surname'},
92 firstname => $res->{'firstname'},
93 categorycode => $res->{'categorycode'},
94 branchcode => $res->{'branchcode'},
95 guarantorinfo => $guarantorinfo,
96 budget_owner_id => $budget_owner_id,
97 budget_owner_name => $budget_owner_name,
98 # odissue => "$od/$issue",
99 # fines => $fines,
100 # borrowernotes => $res->{'borrowernotes'}
102 push( @resultsdata, \%row );
107 $template->param(
108 member => $member,
109 numres => $count2,
110 resultsloop => \@resultsdata
113 output_html_with_http_headers $input, $cookie, $template->output;