|
Lines 31-42
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; |
| 37 |
use Koha::Patron::Categories; |
38 |
use Koha::Patron::Categories; |
| 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; |
|
|
41 |
use Koha::Patron::Messages; |
| 40 |
|
42 |
|
| 41 |
my $input = CGI->new; |
43 |
my $input = CGI->new; |
| 42 |
my $op = $input->param('op') || 'show_form'; |
44 |
my $op = $input->param('op') || 'show_form'; |
|
Lines 107-112
if ( $op eq 'show' ) {
Link Here
|
| 107 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
109 |
if ( $logged_in_user->can_see_patron_infos( $patron ) ) { |
| 108 |
my $borrower = $patron->unblessed; |
110 |
my $borrower = $patron->unblessed; |
| 109 |
my $attributes = $patron->extended_attributes; |
111 |
my $attributes = $patron->extended_attributes; |
|
|
112 |
my $patron_messages = Koha::Patron::Messages->search( |
| 113 |
{ |
| 114 |
'me.borrowernumber' => $patron->borrowernumber, |
| 115 |
} |
| 116 |
); |
| 117 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 110 |
$borrower->{patron_attributes} = $attributes->as_list; |
118 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 111 |
$borrower->{patron_attributes_count} = $attributes->count; |
119 |
$borrower->{patron_attributes_count} = $attributes->count; |
| 112 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
120 |
$max_nb_attr = $borrower->{patron_attributes_count} if $borrower->{patron_attributes_count} > $max_nb_attr; |
|
Lines 315-320
if ( $op eq 'show' ) {
Link Here
|
| 315 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
323 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
| 316 |
} |
324 |
} |
| 317 |
, |
325 |
, |
|
|
326 |
{ |
| 327 |
name => "message", |
| 328 |
type => "message_type", |
| 329 |
mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0, |
| 330 |
} |
| 331 |
, |
| 318 |
{ |
332 |
{ |
| 319 |
name => "debarred", |
333 |
name => "debarred", |
| 320 |
type => "date", |
334 |
type => "date", |
|
Lines 378-384
if ( $op eq 'do' ) {
Link Here
|
| 378 |
} |
392 |
} |
| 379 |
}; |
393 |
}; |
| 380 |
} |
394 |
} |
| 381 |
|
395 |
# If 'message' or 'add_message_type' is defined then delete both at the same time |
|
|
396 |
if ( grep { $_ eq 'message' } @disabled) { |
| 397 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 398 |
$patron->messages()->delete(); |
| 399 |
} |
| 382 |
$infos->{borrowernumber} = $borrowernumber; |
400 |
$infos->{borrowernumber} = $borrowernumber; |
| 383 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
401 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
| 384 |
if ( $@ ) { # FIXME We could provide better error handling here |
402 |
if ( $@ ) { # FIXME We could provide better error handling here |
|
Lines 417-422
if ( $op eq 'do' ) {
Link Here
|
| 417 |
} |
435 |
} |
| 418 |
$i++; |
436 |
$i++; |
| 419 |
} |
437 |
} |
|
|
438 |
# Créer un bloc pour enregistrer en bdd l'update de la table patron_messages + sécurité : 'si' tel champ est remplit alors.... etc |
| 439 |
my $patron_messages = Koha::Patron::Messages->search( |
| 440 |
{ |
| 441 |
'me.borrowernumber' => $patron->borrowernumber, |
| 442 |
} |
| 443 |
); |
| 444 |
if ( defined $patron_messages ) { |
| 445 |
if ( defined $infos ) { |
| 446 |
my $message = $input->param('message'); |
| 447 |
my $borrowernumber = $patron->borrowernumber; |
| 448 |
my $branchcode = C4::Context::mybranch; |
| 449 |
my $message_type = $input->param('add_message_type'); |
| 450 |
|
| 451 |
Koha::Patron::Message->new( |
| 452 |
{ |
| 453 |
borrowernumber => $borrowernumber, |
| 454 |
branchcode => $branchcode, |
| 455 |
message_type => $message_type, |
| 456 |
message => $message, |
| 457 |
} |
| 458 |
)->store; |
| 459 |
$template->param( message_type => $message_type ); |
| 460 |
} |
| 461 |
} |
| 420 |
} |
462 |
} |
| 421 |
$op = "show_results"; # We have process modifications, the user want to view its |
463 |
$op = "show_results"; # We have process modifications, the user want to view its |
| 422 |
|
464 |
|
|
Lines 428-433
if ( $op eq 'do' ) {
Link Here
|
| 428 |
if ( $patron ) { |
470 |
if ( $patron ) { |
| 429 |
my $category_description = $patron->category->description; |
471 |
my $category_description = $patron->category->description; |
| 430 |
my $borrower = $patron->unblessed; |
472 |
my $borrower = $patron->unblessed; |
|
|
473 |
my $patron_messages = Koha::Patron::Messages->search( |
| 474 |
{ |
| 475 |
'me.borrowernumber' => $patron->borrowernumber, |
| 476 |
} |
| 477 |
); |
| 478 |
$borrower->{patron_messages} = $patron_messages->as_list; |
| 431 |
$borrower->{category_description} = $category_description; |
479 |
$borrower->{category_description} = $category_description; |
| 432 |
my $attributes = $patron->extended_attributes; |
480 |
my $attributes = $patron->extended_attributes; |
| 433 |
$borrower->{patron_attributes} = $attributes->as_list; |
481 |
$borrower->{patron_attributes} = $attributes->as_list; |
| 434 |
- |
|
|