Removing fines getting from user search on budgets administration
[koha.git] / admin / aqbudget_owner_search.pl
1 #!/usr/bin/perl
2
3 # script to find a guarantor
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 with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
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;
28
29 my $input = new CGI;
30
31 my $dbh = C4::Context->dbh;
32
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,
40     }
41 );
42
43 my $theme = $input->param('theme') || "default";
44
45 # only used if allowthemeoverride is set
46 my $member  = $input->param('member');
47 my $orderby = $input->param('orderby');
48
49 my $op = $input->param('op');
50 $template->param( $op || else => 1, );
51
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 );
59 }
60
61 my ( $count, $count2, $results );
62 my @resultsdata;
63 my $toggle = 0;
64
65 if ( $member ) {
66         my $results= SearchMember($member,"surname",undef,undef,undef);
67
68     foreach my $res (@$results) {
69
70         my $perms = haspermission( $res->{'userid'} );
71         my $subperms =  get_user_subpermissions  ($res->{'userid'} );
72
73
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'}  ) {
80
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'};
87
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'}
101             );
102             push( @resultsdata, \%row );
103         }
104     }
105 }
106
107 $template->param(
108     member => $member,
109     numres => $count2,
110     resultsloop => \@resultsdata
111 );
112
113 output_html_with_http_headers $input, $cookie, $template->output;