Bug 19258: Preventing warns when paying a fine or charge from Pay selected button
[koha.git] / members / notices.pl
blob9f0ab11623ec892cfc70ff67bbefb326b06b28ed
1 #!/usr/bin/perl
3 # Displays sent notices for a given borrower
5 # Copyright (c) 2009 BibLibre
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use strict;
23 #use warnings; FIXME - Bug 2505
24 use C4::Auth;
25 use C4::Output;
26 use CGI qw ( -utf8 );
27 use C4::Members;
28 use C4::Letters;
29 use C4::Members::Attributes qw(GetBorrowerAttributes);
30 use Koha::Patrons;
32 my $input=new CGI;
35 my $borrowernumber = $input->param('borrowernumber');
36 my $patron = Koha::Patrons->find( $borrowernumber );
37 unless ( $patron ) {
38 print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
39 exit;
41 my $borrower = $patron->unblessed;
43 my ($template, $loggedinuser, $cookie)
44 = get_template_and_user({template_name => "members/notices.tt",
45 query => $input,
46 type => "intranet",
47 authnotrequired => 0,
48 flagsrequired => {borrowers => 1},
49 debug => 1,
50 });
52 $template->param( $borrower );
53 $template->param( picture => 1 ) if $patron->image;
55 # Allow resending of messages in Notices tab
56 my $op = $input->param('op') || q{};
57 if ( $op eq 'resend_notice' ) {
58 my $message_id = $input->param('message_id');
59 my $message = C4::Letters::GetMessage( $message_id );
60 if ( $message->{borrowernumber} = $borrowernumber ) {
61 C4::Letters::ResendMessage( $message_id );
62 # redirect to self to avoid form submission on refresh
63 print $input->redirect("/cgi-bin/koha/members/notices.pl?borrowernumber=$borrowernumber");
67 # Getting the messages
68 my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
70 if (C4::Context->preference('ExtendedPatronAttributes')) {
71 my $attributes = GetBorrowerAttributes($borrowernumber);
72 $template->param(
73 ExtendedPatronAttributes => 1,
74 extendedattributes => $attributes
78 $template->param(%$borrower);
79 $template->param( adultborrower => 1 ) if ( $borrower->{category_type} eq 'A' || $borrower->{category_type} eq 'I' );
80 $template->param(
81 QUEUED_MESSAGES => $queued_messages,
82 borrowernumber => $borrowernumber,
83 sentnotices => 1,
84 categoryname => $patron->category->description,
85 RoutingSerials => C4::Context->preference('RoutingSerials'),
87 output_html_with_http_headers $input, $cookie, $template->output;