|
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 GetDebarments ); |
39 |
use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments ); |
| 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 109-114
if ( $op eq 'show' ) {
Link Here
|
| 109 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
111 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
| 110 |
my $borrower = $patron->unblessed; |
112 |
my $borrower = $patron->unblessed; |
| 111 |
my $attributes = $patron->extended_attributes; |
113 |
my $attributes = $patron->extended_attributes; |
|
|
114 |
my $patron_messages = Koha::Patron::Messages->search( |
| 115 |
{ |
| 116 |
'me.borrowernumber' => $patron->borrowernumber, |
| 117 |
} |
| 118 |
); |
| 119 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 112 |
$borrower->{patron_attributes} = $attributes->as_list; |
120 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 113 |
$borrower->{patron_attributes_count} = $attributes->count; |
121 |
$borrower->{patron_attributes_count} = $attributes->count; |
| 114 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
122 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
|
Lines 317-322
if ( $op eq 'show' ) {
Link Here
|
| 317 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
325 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
| 318 |
} |
326 |
} |
| 319 |
, |
327 |
, |
|
|
328 |
{ |
| 329 |
name => "message", |
| 330 |
type => "message_type", |
| 331 |
mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0, |
| 332 |
} |
| 333 |
, |
| 320 |
{ |
334 |
{ |
| 321 |
name => "debarred", |
335 |
name => "debarred", |
| 322 |
type => "date", |
336 |
type => "date", |
|
Lines 380-386
if ( $op eq 'do' ) {
Link Here
|
| 380 |
} |
394 |
} |
| 381 |
}; |
395 |
}; |
| 382 |
} |
396 |
} |
| 383 |
|
397 |
# If 'message' or 'add_message_type' is defined then delete both at the same time |
|
|
398 |
if ( grep { $_ eq 'message' } @disabled) { |
| 399 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 400 |
$patron->messages()->delete(); |
| 401 |
} |
| 384 |
$infos->{borrowernumber} = $borrowernumber; |
402 |
$infos->{borrowernumber} = $borrowernumber; |
| 385 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
403 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
| 386 |
if ( $@ ) { # FIXME We could provide better error handling here |
404 |
if ( $@ ) { # FIXME We could provide better error handling here |
|
Lines 419-425
if ( $op eq 'do' ) {
Link Here
|
| 419 |
} |
437 |
} |
| 420 |
$i++; |
438 |
$i++; |
| 421 |
} |
439 |
} |
|
|
440 |
|
| 441 |
# Handle patron messages |
| 442 |
my $message = $input->param('message'); |
| 443 |
my $branchcode = C4::Context::mybranch; |
| 444 |
my $message_type = $input->param('add_message_type'); |
| 445 |
|
| 446 |
Koha::Patron::Message->new( |
| 447 |
{ |
| 448 |
borrowernumber => $borrowernumber, |
| 449 |
branchcode => $branchcode, |
| 450 |
message_type => $message_type, |
| 451 |
message => $message, |
| 452 |
} |
| 453 |
)->store; |
| 422 |
} |
454 |
} |
|
|
455 |
|
| 423 |
$op = "show_results"; # We have process modifications, the user want to view its |
456 |
$op = "show_results"; # We have process modifications, the user want to view its |
| 424 |
|
457 |
|
| 425 |
# Construct the results list |
458 |
# Construct the results list |
|
Lines 430-435
if ( $op eq 'do' ) {
Link Here
|
| 430 |
if ( $patron ) { |
463 |
if ( $patron ) { |
| 431 |
my $category_description = $patron->category->description; |
464 |
my $category_description = $patron->category->description; |
| 432 |
my $borrower = $patron->unblessed; |
465 |
my $borrower = $patron->unblessed; |
|
|
466 |
my $patron_messages = Koha::Patron::Messages->search( |
| 467 |
{ |
| 468 |
'me.borrowernumber' => $patron->borrowernumber, |
| 469 |
} |
| 470 |
); |
| 471 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 433 |
$borrower->{category_description} = $category_description; |
472 |
$borrower->{category_description} = $category_description; |
| 434 |
my $attributes = $patron->extended_attributes; |
473 |
my $attributes = $patron->extended_attributes; |
| 435 |
$borrower->{patron_attributes} = $attributes->as_list; |
474 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 436 |
- |
|
|