|
Lines 31-36
use C4::Auth qw( get_template_and_user );
Link Here
|
| 31 |
use C4::Koha qw( GetAuthorisedValues ); |
31 |
use C4::Koha qw( GetAuthorisedValues ); |
| 32 |
use C4::Members; |
32 |
use C4::Members; |
| 33 |
use C4::Output qw( output_html_with_http_headers ); |
33 |
use C4::Output qw( output_html_with_http_headers ); |
|
|
34 |
use C4::Context; |
| 34 |
use Koha::DateUtils qw( dt_from_string ); |
35 |
use Koha::DateUtils qw( dt_from_string ); |
| 35 |
use Koha::List::Patron qw( GetPatronLists ); |
36 |
use Koha::List::Patron qw( GetPatronLists ); |
| 36 |
use Koha::Libraries; |
37 |
use Koha::Libraries; |
|
Lines 38-43
use Koha::Patron::Categories;
Link Here
|
| 38 |
use Koha::Patron::Debarments qw( AddDebarment DelDebarment ); |
39 |
use Koha::Patron::Debarments qw( AddDebarment DelDebarment ); |
| 39 |
use Koha::Patrons; |
40 |
use Koha::Patrons; |
| 40 |
use List::MoreUtils qw(uniq); |
41 |
use List::MoreUtils qw(uniq); |
|
|
42 |
use Koha::Patron::Messages; |
| 41 |
|
43 |
|
| 42 |
my $input = CGI->new; |
44 |
my $input = CGI->new; |
| 43 |
my $op = $input->param('op') || 'show_form'; |
45 |
my $op = $input->param('op') || 'show_form'; |
|
Lines 111-116
if ( $op eq 'cud-show' || $op eq 'show' ) {
Link Here
|
| 111 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
113 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
| 112 |
my $borrower = $patron->unblessed; |
114 |
my $borrower = $patron->unblessed; |
| 113 |
my $attributes = $patron->extended_attributes; |
115 |
my $attributes = $patron->extended_attributes; |
|
|
116 |
my $patron_messages = Koha::Patron::Messages->search( |
| 117 |
{ |
| 118 |
'me.borrowernumber' => $patron->borrowernumber, |
| 119 |
} |
| 120 |
); |
| 121 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 114 |
$borrower->{patron_attributes} = $attributes->as_list; |
122 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 115 |
$borrower->{patron_attributes_count} = $attributes->count; |
123 |
$borrower->{patron_attributes_count} = $attributes->count; |
| 116 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
124 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
|
Lines 322-327
if ( $op eq 'cud-show' || $op eq 'show' ) {
Link Here
|
| 322 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
330 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
| 323 |
} |
331 |
} |
| 324 |
, |
332 |
, |
|
|
333 |
{ |
| 334 |
name => "message", |
| 335 |
type => "message_type", |
| 336 |
mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0, |
| 337 |
} |
| 338 |
, |
| 325 |
{ |
339 |
{ |
| 326 |
name => "debarred", |
340 |
name => "debarred", |
| 327 |
type => "date", |
341 |
type => "date", |
|
Lines 392-398
if ( $op eq 'cud-do' ) {
Link Here
|
| 392 |
} |
406 |
} |
| 393 |
}; |
407 |
}; |
| 394 |
} |
408 |
} |
| 395 |
|
409 |
# If 'message' or 'add_message_type' is defined then delete both at the same time |
|
|
410 |
if ( grep { $_ eq 'message' } @disabled) { |
| 411 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 412 |
$patron->messages()->delete(); |
| 413 |
} |
| 396 |
$infos->{borrowernumber} = $borrowernumber; |
414 |
$infos->{borrowernumber} = $borrowernumber; |
| 397 |
eval { $patron->set($infos)->store; }; |
415 |
eval { $patron->set($infos)->store; }; |
| 398 |
if ( $@ ) { # FIXME We could provide better error handling here |
416 |
if ( $@ ) { # FIXME We could provide better error handling here |
|
Lines 433-439
if ( $op eq 'cud-do' ) {
Link Here
|
| 433 |
push @errors, { error => $@ } if $@; |
451 |
push @errors, { error => $@ } if $@; |
| 434 |
} |
452 |
} |
| 435 |
} |
453 |
} |
|
|
454 |
|
| 455 |
# Handle patron messages |
| 456 |
my $message = $input->param('message'); |
| 457 |
my $branchcode = C4::Context::mybranch; |
| 458 |
my $message_type = $input->param('add_message_type'); |
| 459 |
|
| 460 |
Koha::Patron::Message->new( |
| 461 |
{ |
| 462 |
borrowernumber => $borrowernumber, |
| 463 |
branchcode => $branchcode, |
| 464 |
message_type => $message_type, |
| 465 |
message => $message, |
| 466 |
} |
| 467 |
)->store; |
| 436 |
} |
468 |
} |
|
|
469 |
|
| 437 |
$op = "show_results"; # We have process modifications, the user want to view its |
470 |
$op = "show_results"; # We have process modifications, the user want to view its |
| 438 |
|
471 |
|
| 439 |
# Construct the results list |
472 |
# Construct the results list |
|
Lines 444-449
if ( $op eq 'cud-do' ) {
Link Here
|
| 444 |
if ( $patron ) { |
477 |
if ( $patron ) { |
| 445 |
my $category_description = $patron->category->description; |
478 |
my $category_description = $patron->category->description; |
| 446 |
my $borrower = $patron->unblessed; |
479 |
my $borrower = $patron->unblessed; |
|
|
480 |
my $patron_messages = Koha::Patron::Messages->search( |
| 481 |
{ |
| 482 |
'me.borrowernumber' => $patron->borrowernumber, |
| 483 |
} |
| 484 |
); |
| 485 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 447 |
$borrower->{category_description} = $category_description; |
486 |
$borrower->{category_description} = $category_description; |
| 448 |
my $attributes = $patron->extended_attributes; |
487 |
my $attributes = $patron->extended_attributes; |
| 449 |
$borrower->{patron_attributes} = $attributes->as_list; |
488 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 450 |
- |
|
|