|
Lines 368-380
sub apply_print_notice_charge {
Link Here
|
| 368 |
return; |
368 |
return; |
| 369 |
} |
369 |
} |
| 370 |
|
370 |
|
| 371 |
# Check for borrowernumber |
371 |
# Validate borrowernumber is numeric to prevent injection |
| 372 |
unless ($message->{borrowernumber}) { |
372 |
unless ($message->{borrowernumber} && $message->{borrowernumber} =~ /^\d+$/) { |
| 373 |
warn "No borrowernumber in message for print notice charge"; |
373 |
warn "Invalid or missing borrowernumber in message for print notice charge"; |
| 374 |
return; |
374 |
return; |
| 375 |
} |
375 |
} |
| 376 |
|
376 |
|
| 377 |
# Skip if patron not found |
377 |
# Validate branchcode format if present |
|
|
378 |
if (defined $message->{branchcode} && $message->{branchcode} !~ /^[A-Za-z0-9_-]*$/) { |
| 379 |
warn "Invalid branchcode format in message: " . $message->{branchcode}; |
| 380 |
return; |
| 381 |
} |
| 382 |
|
| 383 |
# Validate letter_code format if present |
| 384 |
if (defined $message->{letter_code} && $message->{letter_code} !~ /^[A-Za-z0-9_-]*$/) { |
| 385 |
warn "Invalid letter_code format in message: " . $message->{letter_code}; |
| 386 |
return; |
| 387 |
} |
| 388 |
|
| 389 |
# Skip if patron not found (using validated borrowernumber) |
| 378 |
my $patron = Koha::Patrons->find($message->{borrowernumber}); |
390 |
my $patron = Koha::Patrons->find($message->{borrowernumber}); |
| 379 |
unless ($patron) { |
391 |
unless ($patron) { |
| 380 |
warn "Patron " . $message->{borrowernumber} . " not found for print notice charge"; |
392 |
warn "Patron " . $message->{borrowernumber} . " not found for print notice charge"; |
|
Lines 387-397
sub apply_print_notice_charge {
Link Here
|
| 387 |
library_id => $message->{branchcode}, |
399 |
library_id => $message->{branchcode}, |
| 388 |
}); |
400 |
}); |
| 389 |
|
401 |
|
|
|
402 |
# Log successful charge application |
| 403 |
if ($result) { |
| 390 |
cronlogaction({ |
404 |
cronlogaction({ |
| 391 |
action => 'Print notice charge', |
405 |
action => 'Print notice charge', |
| 392 |
info => "Applied charge for patron " . $message->{borrowernumber} . |
406 |
info => "Applied charge for patron " . $message->{borrowernumber} . |
| 393 |
" notice " . ($message->{letter_code} || 'unknown') |
407 |
" notice " . ($message->{letter_code} || 'unknown') . |
|
|
408 |
" (charge ID: " . $result->id . ")" |
| 394 |
}); |
409 |
}); |
|
|
410 |
} |
| 395 |
}; |
411 |
}; |
| 396 |
|
412 |
|
| 397 |
if ($@) { |
413 |
if ($@) { |
| 398 |
- |
|
|