Bug 6510 - [REVISED] Sort by in intranet search alters search and number of hits
[koha.git] / members / mancredit.pl
blob7d57fa5a247eaa5beb988eea3895d461b01223cb
1 #!/usr/bin/perl
3 #written 11/1/2000 by chris@katipo.oc.nz
4 #script to display borrowers account details
7 # Copyright 2000-2002 Katipo Communications
8 # Copyright 2010 BibLibre
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use strict;
26 use warnings;
28 use C4::Auth;
29 use C4::Output;
30 use CGI;
32 use C4::Members;
33 use C4::Branch;
34 use C4::Accounts;
35 use C4::Items;
37 my $input=new CGI;
39 my $borrowernumber=$input->param('borrowernumber');
41 #get borrower details
42 my $data=GetMember('borrowernumber' => $borrowernumber);
43 my $add=$input->param('add');
45 if ($add){
46 if(checkauth($input)) {
47 my $barcode = $input->param('barcode');
48 my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
49 my $desc = $input->param('desc');
50 my $note = $input->param('note');
51 my $amount = $input->param('amount') || 0;
52 $amount = -$amount;
53 my $type = $input->param('type');
54 manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
55 print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
57 } else {
58 my ($template, $loggedinuser, $cookie)
59 = get_template_and_user({template_name => "members/mancredit.tmpl",
60 query => $input,
61 type => "intranet",
62 authnotrequired => 0,
63 flagsrequired => {borrowers => 1, updatecharges => 1},
64 debug => 1,
65 });
67 if ( $data->{'category_type'} eq 'C') {
68 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
69 my $cnt = scalar(@$catcodes);
70 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
71 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
74 $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' );
75 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
76 $template->param( picture => 1 ) if $picture;
78 $template->param(
79 borrowernumber => $borrowernumber,
80 firstname => $data->{'firstname'},
81 surname => $data->{'surname'},
82 cardnumber => $data->{'cardnumber'},
83 categorycode => $data->{'categorycode'},
84 category_type => $data->{'category_type'},
85 categoryname => $data->{'description'},
86 address => $data->{'address'},
87 address2 => $data->{'address2'},
88 city => $data->{'city'},
89 state => $data->{'state'},
90 zipcode => $data->{'zipcode'},
91 country => $data->{'country'},
92 phone => $data->{'phone'},
93 email => $data->{'email'},
94 branchcode => $data->{'branchcode'},
95 branchname => GetBranchName($data->{'branchcode'}),
96 is_child => ($data->{'category_type'} eq 'C'),
98 output_html_with_http_headers $input, $cookie, $template->output;