From f3b8f17395f05548c87129d286a3f49d0b171e0b 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. Signed-off-by: Maksim Sen Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../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 44cdb94df9..163fb136e0 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:

-
    - [% FOREACH patron_message IN patron_messages %] -
  • - [% IF(patron_message.message_type == "L") %] - - [% ELSE %] - - [% END %] - [% patron_message.message_date | $KohaDates %] - [% Branches.GetName( patron_message.branchcode ) %] - [% IF patron_message.manager_id %] - ( [% patron_message.get_column('manager_firstname') %] [% patron_message.get_column('manager_surname') %] ) + + [% IF ( patron_messages ) %] +
    +

    Messages:

    +
      + [% FOREACH patron_message IN patron_messages %] +
    • + [% IF(patron_message.message_type == "L") %] + + [% ELSE %] + [% END %] - "[% patron_message.message | html %]" - - [% IF patron_message.branchcode == branchcode OR Koha.Preference('AllowAllMessageDeletion') %] - Delete - [% END %] -
    • - [% END %] -
    - Add a new message -
    + [% patron_message.message_date | $KohaDates %] + [% Branches.GetName( patron_message.branchcode ) %] + [% IF patron_message.manager_id %] + ( [% patron_message.get_column('manager_firstname') %] [% patron_message.get_column('manager_surname') %] ) + [% END %] + "[% patron_message.message | html %]" +
    + [% IF patron_message.branchcode == branchcode OR Koha.Preference('AllowAllMessageDeletion') %] + Delete + [% END %] +
  • + [% END %] +
+ Add a new message +
+ [% END %] [% IF ( flagged ) %]
diff --git a/members/moremember.pl b/members/moremember.pl index 0f7eddd428..f898adb5f6 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.39.5