Lines 42-49
use C4::Branch;
Link Here
|
42 |
use C4::Members::Attributes qw(GetBorrowerAttributes); |
42 |
use C4::Members::Attributes qw(GetBorrowerAttributes); |
43 |
|
43 |
|
44 |
our $input = CGI->new; |
44 |
our $input = CGI->new; |
45 |
our $writeoff_sth; |
|
|
46 |
our $add_writeoff_sth; |
47 |
|
45 |
|
48 |
our ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
46 |
our ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
49 |
{ template_name => 'members/pay.tmpl', |
47 |
{ template_name => 'members/pay.tmpl', |
Lines 108-131
add_accounts_to_template();
Link Here
|
108 |
|
106 |
|
109 |
output_html_with_http_headers $input, $cookie, $template->output; |
107 |
output_html_with_http_headers $input, $cookie, $template->output; |
110 |
|
108 |
|
111 |
sub writeoff { |
|
|
112 |
my ( $accountlines_id, $itemnum, $accounttype, $amount ) = @_; |
113 |
my $manager_id = 0; |
114 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
115 |
|
116 |
# if no item is attached to fine, make sure to store it as a NULL |
117 |
$itemnum ||= undef; |
118 |
get_writeoff_sth(); |
119 |
$writeoff_sth->execute( $accountlines_id ); |
120 |
|
121 |
my $acct = getnextacctno($borrowernumber); |
122 |
$add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
123 |
|
124 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
125 |
|
126 |
return; |
127 |
} |
128 |
|
129 |
sub add_accounts_to_template { |
109 |
sub add_accounts_to_template { |
130 |
|
110 |
|
131 |
my ( $total, undef, undef ) = GetMemberAccountRecords($borrowernumber); |
111 |
my ( $total, undef, undef ) = GetMemberAccountRecords($borrowernumber); |
Lines 271-293
sub payselected {
Link Here
|
271 |
print $input->redirect($redirect); |
251 |
print $input->redirect($redirect); |
272 |
return; |
252 |
return; |
273 |
} |
253 |
} |
274 |
|
|
|
275 |
sub get_writeoff_sth { |
276 |
|
277 |
# lets prepare these statement handles only once |
278 |
if ($writeoff_sth) { |
279 |
return; |
280 |
} else { |
281 |
my $dbh = C4::Context->dbh; |
282 |
|
283 |
# Do we need to validate accounttype |
284 |
my $sql = 'Update accountlines set amountoutstanding=0 ' |
285 |
. 'WHERE accountlines_id=?'; |
286 |
$writeoff_sth = $dbh->prepare($sql); |
287 |
my $insert = |
288 |
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,manager_id)} |
289 |
. q{values (?,?,?,now(),?,'Writeoff','W',?)}; |
290 |
$add_writeoff_sth = $dbh->prepare($insert); |
291 |
} |
292 |
return; |
293 |
} |
294 |
- |