Bug 8020 [3.8.x/MASTER] - update git build script to 3.9
[koha.git] / admin / aqbudget_owner_search.pl
blob5c73e9eb4869c805803b36d3d682a3b7e83e4c19
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
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 strict;
23 #use warnings; FIXME - Bug 2505
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_owner_search.tmpl",
36 query => $input,
37 type => "intranet",
38 authnotrequired => 0,
39 flagsrequired => { acquisition => 'budget_modify' },
40 debug => 1,
44 my $theme = $input->param('theme') || "default";
46 # only used if allowthemeoverride is set
47 my $member = $input->param('member');
48 my $orderby = $input->param('orderby');
50 my $op = $input->param('op');
51 $template->param( $op || else => 1, );
53 $orderby = "surname,firstname" unless $orderby;
54 $member =~ s/,//g; #remove any commas from search string
55 $member =~ s/\*/%/g;
56 if ( $member eq '' ) {
57 $template->param( results => 0 );
58 } else {
59 $template->param( results => 1 );
62 my ( $count, $count2, $results );
63 my @resultsdata;
64 my $toggle = 0;
66 if ( $member ) {
67 my $results= Search($member,"surname");
69 foreach my $res (@$results) {
71 my $perms = haspermission( $res->{'userid'} );
72 my $subperms = get_user_subpermissions ($res->{'userid'} );
75 # if the member has 'acqui' permission set, then display to table.
76 if ( $perms->{superlibrarian} == 1 ||
77 $perms->{acquisition} == 1 ||
78 $subperms->{acquisition}->{'budget_manage'} ||
79 $subperms->{acquisition}->{'budget_modify'} ||
80 $subperms->{acquisition}->{'budget_add_del'} ) {
82 $count2++;
83 #find out stats
84 # my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $res->{'borrowerid'} );
85 #This looks unused and very unuseful
86 my $guarantorinfo = uc( $res->{'surname'} ) . " , " . ucfirst( $res->{'firstname'} );
87 my $budget_owner_name = $res->{'firstname'} . ' ' . $res->{'surname'}, my $budget_owner_id = $res->{'borrowernumber'};
89 my %row = (
90 borrowernumber => $res->{'borrowernumber'},
91 cardnumber => $res->{'cardnumber'},
92 surname => $res->{'surname'},
93 firstname => $res->{'firstname'},
94 categorycode => $res->{'categorycode'},
95 branchcode => $res->{'branchcode'},
96 guarantorinfo => $guarantorinfo,
97 budget_owner_id => $budget_owner_id,
98 budget_owner_name => $budget_owner_name,
99 # odissue => "$od/$issue",
100 # fines => $fines,
101 # borrowernotes => $res->{'borrowernotes'}
103 push( @resultsdata, \%row );
108 $template->param(
109 member => $member,
110 numres => $count2,
111 resultsloop => \@resultsdata
114 output_html_with_http_headers $input, $cookie, $template->output;