From 7967019ef43344b7350bc8f9aba49e3152964760 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 4 Apr 2018 16:33:34 +0000 Subject: [PATCH] Bug 20518 - Don't show "Messages" header and link on patron details if there are no messages This patch modifies the patron detail page so that the "Messages" header is not displayed if there are no messages. Unrelated: A minor change was made to moremember.pl to quiet an error in the log, "Use of uninitialized value $print in string eq at members/moremember.pl line 219." To test, apply the patch and open the detail page for a patron who has no messages. There should be no "Messages" header or "add message" link. Add a message to the patron's account. The message should appear, along with the "Messages" header and "add message" link. The error logs should show no errors. --- .../prog/en/modules/members/moremember.tt | 51 ++++++++++++---------- members/moremember.pl | 6 ++- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 44cdb94..163fb13 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -63,31 +63,34 @@ [% END %] -
-

Messages:

- + Add a new message +
+ [% END %] [% IF ( flagged ) %]
diff --git a/members/moremember.pl b/members/moremember.pl index 0f7eddd..f898adb 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -216,7 +216,7 @@ my $library = Koha::Libraries->find( $data->{branchcode})->unblessed; @{$data}{keys %$library} = values %$library; # merge in all branch columns # FIXME This is really ugly, we should pass the library instead # If printing a page, send the account informations to the template -if ($print eq "page") { +if (defined $print and $print eq "page") { my $accts = Koha::Account::Lines->search( { borrowernumber => $patron->borrowernumber, amountoutstanding => { '>' => 0 } }, { order_by => { -desc => 'accountlines_id' } } @@ -328,6 +328,9 @@ my $patron_messages = Koha::Patron::Messages->search( } ); +if( $patron_messages->count > 0 ){ + $template->param( patron_messages => $patron_messages ); +} # Display the language description instead of the code # Note that this is certainly wrong @@ -353,7 +356,6 @@ $template->param( PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, relatives_issues_count => $relatives_issues_count, relatives_borrowernumbers => \@relatives, - patron_messages => $patron_messages, ); output_html_with_http_headers $input, $cookie, $template->output; -- 2.1.4