|
Lines 3-9
Link Here
|
| 3 |
#written 11/1/2000 by chris@katipo.oc.nz |
3 |
#written 11/1/2000 by chris@katipo.oc.nz |
| 4 |
#script to display borrowers account details |
4 |
#script to display borrowers account details |
| 5 |
|
5 |
|
| 6 |
|
|
|
| 7 |
# Copyright 2000-2002 Katipo Communications |
6 |
# Copyright 2000-2002 Katipo Communications |
| 8 |
# Copyright 2010 BibLibre |
7 |
# Copyright 2010 BibLibre |
| 9 |
# |
8 |
# |
|
Lines 35-52
use C4::Items;
Link Here
|
| 35 |
use Koha::Items; |
34 |
use Koha::Items; |
| 36 |
use Koha::Patrons; |
35 |
use Koha::Patrons; |
| 37 |
use Koha::Patron::Categories; |
36 |
use Koha::Patron::Categories; |
| 38 |
use Koha::Token; |
37 |
use Koha::Account::CreditTypes; |
| 39 |
|
38 |
|
| 40 |
my $input=new CGI; |
39 |
use Koha::Token; |
| 41 |
|
40 |
|
| 42 |
my ($template, $loggedinuser, $cookie) = get_template_and_user( |
41 |
my $input = new CGI; |
|
|
42 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 43 |
{ |
43 |
{ |
| 44 |
template_name => "members/mancredit.tt", |
44 |
template_name => "members/mancredit.tt", |
| 45 |
query => $input, |
45 |
query => $input, |
| 46 |
type => "intranet", |
46 |
type => "intranet", |
| 47 |
authnotrequired => 0, |
47 |
authnotrequired => 0, |
| 48 |
flagsrequired => { borrowers => 'edit_borrowers', |
48 |
flagsrequired => { |
| 49 |
updatecharges => 'remaining_permissions' } |
49 |
borrowers => 'edit_borrowers', |
|
|
50 |
updatecharges => 'remaining_permissions' |
| 51 |
} |
| 50 |
} |
52 |
} |
| 51 |
); |
53 |
); |
| 52 |
|
54 |
|
|
Lines 54-78
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
Link Here
|
| 54 |
my $borrowernumber = $input->param('borrowernumber'); |
56 |
my $borrowernumber = $input->param('borrowernumber'); |
| 55 |
my $patron = Koha::Patrons->find($borrowernumber); |
57 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 56 |
|
58 |
|
| 57 |
output_and_exit_if_error( $input, $cookie, $template, |
59 |
output_and_exit_if_error( |
| 58 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
60 |
$input, $cookie, |
| 59 |
|
61 |
$template, |
| 60 |
my $add = $input->param('add'); |
62 |
{ |
|
|
63 |
module => 'members', |
| 64 |
logged_in_user => $logged_in_user, |
| 65 |
current_patron => $patron |
| 66 |
} |
| 67 |
); |
| 61 |
|
68 |
|
| 62 |
if ($add){ |
69 |
my $library_id = |
|
|
70 |
C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 63 |
|
71 |
|
|
|
72 |
my $add = $input->param('add'); |
| 73 |
if ($add) { |
| 64 |
output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) |
74 |
output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) |
| 65 |
unless Koha::Token->new->check_csrf( { |
75 |
unless Koha::Token->new->check_csrf( |
|
|
76 |
{ |
| 66 |
session_id => scalar $input->cookie('CGISESSID'), |
77 |
session_id => scalar $input->cookie('CGISESSID'), |
| 67 |
token => scalar $input->param('csrf_token'), |
78 |
token => scalar $input->param('csrf_token'), |
| 68 |
}); |
79 |
} |
|
|
80 |
); |
| 69 |
|
81 |
|
| 70 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
82 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
| 71 |
# Here we are trusting librarians not to hack the system |
83 |
# Here we are trusting librarians not to hack the system |
| 72 |
my $barcode = $input->param('barcode'); |
84 |
my $barcode = $input->param('barcode'); |
| 73 |
my $item_id; |
85 |
my $item_id; |
| 74 |
if ($barcode) { |
86 |
if ($barcode) { |
| 75 |
my $item = Koha::Items->find({barcode => $barcode}); |
87 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 76 |
$item_id = $item->itemnumber if $item; |
88 |
$item_id = $item->itemnumber if $item; |
| 77 |
} |
89 |
} |
| 78 |
my $description = $input->param('desc'); |
90 |
my $description = $input->param('desc'); |
|
Lines 80-109
if ($add){
Link Here
|
| 80 |
my $amount = $input->param('amount') || 0; |
92 |
my $amount = $input->param('amount') || 0; |
| 81 |
my $type = $input->param('type'); |
93 |
my $type = $input->param('type'); |
| 82 |
|
94 |
|
| 83 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
95 |
$patron->account->add_credit( |
| 84 |
|
96 |
{ |
| 85 |
$patron->account->add_credit({ |
97 |
amount => $amount, |
| 86 |
amount => $amount, |
98 |
description => $description, |
| 87 |
description => $description, |
99 |
item_id => $item_id, |
| 88 |
item_id => $item_id, |
100 |
library_id => $library_id, |
| 89 |
library_id => $library_id, |
101 |
note => $note, |
| 90 |
note => $note, |
102 |
type => $type, |
| 91 |
type => $type, |
103 |
user_id => $logged_in_user->id, |
| 92 |
user_id => $logged_in_user->id, |
104 |
interface => C4::Context->interface |
| 93 |
interface => C4::Context->interface |
105 |
} |
| 94 |
}); |
106 |
); |
| 95 |
|
107 |
|
| 96 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
108 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
| 97 |
$patron->account->reconcile_balance; |
109 |
$patron->account->reconcile_balance; |
| 98 |
} |
110 |
} |
| 99 |
|
111 |
|
| 100 |
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); |
112 |
print $input->redirect( |
|
|
113 |
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); |
| 114 |
exit; |
| 115 |
} |
| 116 |
else { |
| 117 |
|
| 118 |
my @credit_types = Koha::Account::CreditTypes->search_with_library_limits( |
| 119 |
{ can_be_added_manually => 1 }, |
| 120 |
{}, $library_id ); |
| 101 |
|
121 |
|
| 102 |
} else { |
|
|
| 103 |
$template->param( |
122 |
$template->param( |
| 104 |
patron => $patron, |
123 |
patron => $patron, |
| 105 |
finesview => 1, |
124 |
credit_types => \@credit_types, |
| 106 |
csrf_token => Koha::Token->new->generate_csrf( |
125 |
finesview => 1, |
|
|
126 |
csrf_token => Koha::Token->new->generate_csrf( |
| 107 |
{ session_id => scalar $input->cookie('CGISESSID') } |
127 |
{ session_id => scalar $input->cookie('CGISESSID') } |
| 108 |
), |
128 |
), |
| 109 |
); |
129 |
); |
| 110 |
- |
|
|