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
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
26 use C4::Dates qw/format_date/;
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",
38 flagsrequired => { acquisition => 'budget_modify' },
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
55 if ( $member eq '' ) {
56 $template->param( results => 0 );
58 $template->param( results => 1 );
61 my ( $count, $count2, $results );
66 my $dbh = C4::Context->dbh;
67 my $sth = $dbh->prepare(
68 qq| SELECT * from borrowers where surname like ? or firstname like ? or cardnumber like ? |
71 $sth->execute( "$member%", "$member%", "$member%", );
72 my $results = $sth->fetchall_arrayref({});
74 foreach my $res (@$results) {
76 my $perms = haspermission( $dbh, $res->{'userid'} );
77 my $subperms = get_user_subpermissions ($res->{'userid'} );
80 # if the member has 'acqui' permission set, then display to table.
81 if ( $perms->{superlibrarian} == 1 ||
82 $perms->{acquisition} == 1 ||
83 $subperms->{acquisition}->{'budget_manage'} ||
84 $subperms->{acquisition}->{'budget_modify'} ||
85 $subperms->{acquisition}->{'budget_add_del'} ) {
89 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $res->{'borrowerid'} );
90 my $guarantorinfo = uc( $res->{'surname'} ) . " , " . ucfirst( $res->{'firstname'} );
91 my $budget_owner_name = $res->{'firstname'} . ' ' . $res->{'surname'}, my $budget_owner_id = $res->{'borrowernumber'};
96 borrowernumber => $res->{'borrowernumber'},
97 cardnumber => $res->{'cardnumber'},
98 surname => $res->{'surname'},
99 firstname => $res->{'firstname'},
100 categorycode => $res->{'categorycode'},
101 branchcode => $res->{'branchcode'},
102 guarantorinfo => $guarantorinfo,
103 budget_owner_id => $budget_owner_id,
104 budget_owner_name => $budget_owner_name,
105 odissue => "$od/$issue",
107 # borrowernotes => $res->{'borrowernotes'}
109 $toggle = ( $toggle++ % 2 eq 0 ? 1 : 0 );
110 push( @resultsdata, \%row );
118 resultsloop => \@resultsdata
121 output_html_with_http_headers $input, $cookie, $template->output;