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 111-116
if ( $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 319-324
if ( $op eq 'show' ) {
Link Here
|
319 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
327 |
mandatory => ( grep /opacnote/, @mandatoryFields ) ? 1 : 0, |
320 |
} |
328 |
} |
321 |
, |
329 |
, |
|
|
330 |
{ |
331 |
name => "message", |
332 |
type => "message_type", |
333 |
mandatory => ( grep /message/, @mandatoryFields ) ? 1 : 0, |
334 |
} |
335 |
, |
322 |
{ |
336 |
{ |
323 |
name => "debarred", |
337 |
name => "debarred", |
324 |
type => "date", |
338 |
type => "date", |
Lines 382-388
if ( $op eq 'do' ) {
Link Here
|
382 |
} |
396 |
} |
383 |
}; |
397 |
}; |
384 |
} |
398 |
} |
385 |
|
399 |
# If 'message' or 'add_message_type' is defined then delete both at the same time |
|
|
400 |
if ( grep { $_ eq 'message' } @disabled) { |
401 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
402 |
$patron->messages()->delete(); |
403 |
} |
386 |
$infos->{borrowernumber} = $borrowernumber; |
404 |
$infos->{borrowernumber} = $borrowernumber; |
387 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
405 |
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; |
388 |
if ( $@ ) { # FIXME We could provide better error handling here |
406 |
if ( $@ ) { # FIXME We could provide better error handling here |
Lines 421-426
if ( $op eq 'do' ) {
Link Here
|
421 |
} |
439 |
} |
422 |
$i++; |
440 |
$i++; |
423 |
} |
441 |
} |
|
|
442 |
# Créer un bloc pour enregistrer en bdd l'update de la table patron_messages + sécurité : 'si' tel champ est remplit alors.... etc |
443 |
my $patron_messages = Koha::Patron::Messages->search( |
444 |
{ |
445 |
'me.borrowernumber' => $patron->borrowernumber, |
446 |
} |
447 |
); |
448 |
if ( defined $patron_messages ) { |
449 |
if ( defined $infos ) { |
450 |
my $message = $input->param('message'); |
451 |
my $borrowernumber = $patron->borrowernumber; |
452 |
my $branchcode = C4::Context::mybranch; |
453 |
my $message_type = $input->param('add_message_type'); |
454 |
|
455 |
Koha::Patron::Message->new( |
456 |
{ |
457 |
borrowernumber => $borrowernumber, |
458 |
branchcode => $branchcode, |
459 |
message_type => $message_type, |
460 |
message => $message, |
461 |
} |
462 |
)->store; |
463 |
$template->param( message_type => $message_type ); |
464 |
} |
465 |
} |
424 |
} |
466 |
} |
425 |
$op = "show_results"; # We have process modifications, the user want to view its |
467 |
$op = "show_results"; # We have process modifications, the user want to view its |
426 |
|
468 |
|
Lines 432-437
if ( $op eq 'do' ) {
Link Here
|
432 |
if ( $patron ) { |
474 |
if ( $patron ) { |
433 |
my $category_description = $patron->category->description; |
475 |
my $category_description = $patron->category->description; |
434 |
my $borrower = $patron->unblessed; |
476 |
my $borrower = $patron->unblessed; |
|
|
477 |
my $patron_messages = Koha::Patron::Messages->search( |
478 |
{ |
479 |
'me.borrowernumber' => $patron->borrowernumber, |
480 |
} |
481 |
); |
482 |
$borrower->{patron_messages} = $patron_messages->as_list; |
435 |
$borrower->{category_description} = $category_description; |
483 |
$borrower->{category_description} = $category_description; |
436 |
my $attributes = $patron->extended_attributes; |
484 |
my $attributes = $patron->extended_attributes; |
437 |
$borrower->{patron_attributes} = $attributes->as_list; |
485 |
$borrower->{patron_attributes} = $attributes->as_list; |
438 |
- |
|
|