Lines 53-61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
53 |
} |
53 |
} |
54 |
); |
54 |
); |
55 |
|
55 |
|
56 |
my $writeoff_sth; |
|
|
57 |
my $add_writeoff_sth; |
58 |
|
59 |
my @names = $input->param; |
56 |
my @names = $input->param; |
60 |
|
57 |
|
61 |
my $borrowernumber = $input->param('borrowernumber'); |
58 |
my $borrowernumber = $input->param('borrowernumber'); |
Lines 90-96
if ($writeoff_all) {
Link Here
|
90 |
my $itemno = $input->param('itemnumber'); |
87 |
my $itemno = $input->param('itemnumber'); |
91 |
my $account_type = $input->param('accounttype'); |
88 |
my $account_type = $input->param('accounttype'); |
92 |
my $amount = $input->param('amountoutstanding'); |
89 |
my $amount = $input->param('amountoutstanding'); |
93 |
writeoff( $accountno, $itemno, $account_type, $amount ); |
90 |
WriteOff( $borrowernumber, $accountno, $itemno, $account_type, $amount, $branch ); |
94 |
} |
91 |
} |
95 |
|
92 |
|
96 |
for (@names) { |
93 |
for (@names) { |
Lines 109-131
add_accounts_to_template();
Link Here
|
109 |
|
106 |
|
110 |
output_html_with_http_headers $input, $cookie, $template->output; |
107 |
output_html_with_http_headers $input, $cookie, $template->output; |
111 |
|
108 |
|
112 |
sub writeoff { |
|
|
113 |
my ( $accountnum, $itemnum, $accounttype, $amount ) = @_; |
114 |
my $manager_id = 0; |
115 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
116 |
|
117 |
# if no item is attached to fine, make sure to store it as a NULL |
118 |
$itemnum ||= undef; |
119 |
get_writeoff_sth(); |
120 |
$writeoff_sth->execute( $accountnum, $borrowernumber ); |
121 |
|
122 |
my $acct = getnextacctno($borrowernumber); |
123 |
$add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id ); |
124 |
|
125 |
UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); |
126 |
|
127 |
return; |
128 |
} |
129 |
|
109 |
|
130 |
sub add_accounts_to_template { |
110 |
sub add_accounts_to_template { |
131 |
|
111 |
|
Lines 204-210
sub writeoff_all {
Link Here
|
204 |
my $itemno = $input->param("itemnumber$value"); |
184 |
my $itemno = $input->param("itemnumber$value"); |
205 |
my $amount = $input->param("amount$value"); |
185 |
my $amount = $input->param("amount$value"); |
206 |
my $accountno = $input->param("accountno$value"); |
186 |
my $accountno = $input->param("accountno$value"); |
207 |
writeoff( $accountno, $itemno, $accounttype, $amount ); |
187 |
WriteOff( $borrowernumber, $accountno, $itemno, $accounttype, $amount, $branch ); |
208 |
} |
188 |
} |
209 |
} |
189 |
} |
210 |
|
190 |
|
Lines 270-292
sub payselected {
Link Here
|
270 |
print $input->redirect($redirect); |
250 |
print $input->redirect($redirect); |
271 |
return; |
251 |
return; |
272 |
} |
252 |
} |
273 |
|
|
|
274 |
sub get_writeoff_sth { |
275 |
|
276 |
# lets prepare these statement handles only once |
277 |
if ($writeoff_sth) { |
278 |
return; |
279 |
} else { |
280 |
my $dbh = C4::Context->dbh; |
281 |
|
282 |
# Do we need to validate accounttype |
283 |
my $sql = 'Update accountlines set amountoutstanding=0 ' |
284 |
. 'WHERE accountno=? and borrowernumber=?'; |
285 |
$writeoff_sth = $dbh->prepare($sql); |
286 |
my $insert = |
287 |
q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,manager_id)} |
288 |
. q{values (?,?,?,now(),?,'Writeoff','W',?)}; |
289 |
$add_writeoff_sth = $dbh->prepare($insert); |
290 |
} |
291 |
return; |
292 |
} |
293 |
- |