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>.
28 use C4::Members::Attributes qw(GetBorrowerAttributes);
30 use Koha::Patron::Categories;
35 my $borrowernumber = $input->param('borrowernumber');
36 my $patron = Koha::Patrons->find( $borrowernumber );
38 print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
41 my $borrower = $patron->unblessed;
43 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/notices.tt",
47 flagsrequired => {borrowers => 'edit_borrowers'},
51 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
52 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
54 # Allow resending of messages in Notices tab
55 my $op = $input->param('op') || q{};
56 if ( $op eq 'resend_notice' ) {
57 my $message_id = $input->param('message_id');
58 my $message = C4::Letters::GetMessage( $message_id );
59 if ( $message->{borrowernumber} = $borrowernumber ) {
61 if ( $message->{message_transport_type} eq 'print' ) {
62 my $dbh = C4::Context->dbh();
63 my $statement = 'UPDATE message_queue SET message_transport_type = ? WHERE message_id = ?';
64 my $sth = $dbh->prepare( $statement );
65 $sth->execute( 'email', $message_id );
66 warn "XXX force message_transport_type $message_id";
68 C4::Letters::ResendMessage( $message_id );
69 # redirect to self to avoid form submission on refresh
70 print $input->redirect("/cgi-bin/koha/members/notices.pl?borrowernumber=$borrowernumber");
74 # Getting the messages
75 my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
77 if (C4::Context->preference('ExtendedPatronAttributes')) {
78 my $attributes = GetBorrowerAttributes($borrowernumber);
80 ExtendedPatronAttributes => 1,
81 extendedattributes => $attributes
87 QUEUED_MESSAGES => $queued_messages,
88 borrowernumber => $borrowernumber,
91 output_html_with_http_headers $input, $cookie, $template->output;