Bug 17386: Simplify code
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 4 Oct 2016 12:58:13 +0000 (13:58 +0100)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Mon, 10 Oct 2016 14:08:20 +0000 (14:08 +0000)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
opac/opac-user.pl
opac/sco/sco-main.pl

index e5dff6c..e2b3d67 100644 (file)
@@ -1,13 +1,15 @@
-<div class="alert alert-info">
-    <h3>Messages for you</h3>
-    <ul>
-        [% FOREACH message IN patron_messages %]
-            <li>
-                <strong>[% message.message %]</strong><br>
-                &nbsp;&nbsp;&nbsp;<i>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) %]</i>
-            </li>
-        [% END %]
+[% IF patron_messages.count OR opacnote %]
+    <div class="alert alert-info">
+        <h3>Messages for you</h3>
+        <ul>
+            [% FOREACH message IN patron_messages %]
+                <li>
+                    <strong>[% message.message %]</strong><br>
+                    &nbsp;&nbsp;&nbsp;<i>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) %]</i>
+                </li>
+            [% END %]
 
-        [% IF ( opacnote ) %]<li>[% opacnote %]</li>[% END %]
-    </ul>
-</div>
+            [% IF ( opacnote ) %]<li>[% opacnote %]</li>[% END %]
+        </ul>
+    </div>
+[% END %]
index 5a857f3..b7ac6f9 100644 (file)
@@ -40,9 +40,8 @@ Using this account is not recommended because some parts of Koha will not functi
                         </div>
                     [% END %]
 
-                    [% IF ( bor_messages ) %]
-                        [% INCLUDE 'opac-note.inc' %]
-                    [% END %]
+                    [% INCLUDE 'opac-note.inc' %]
+
                     <h2>Hello, [% INCLUDE 'patron-title.inc' category_type = BORROWER_INFO.category_type firstname = BORROWER_INFO.firstname surname = BORROWER_INFO.surname othernames = BORROWER_INFO.othernames cardnumber = BORROWER_INFO.cardnumber %]
                     </h2>
 
index e3b5413..3e5d7f4 100644 (file)
                         [% IF ( patronid ) %]
                             [% IF ( validuser ) %]
                                 <div class="alert alert-info">You are logged in as [% borrowername %].</div>
-                                [% IF ( bor_messages ) %]
-                                    [% INCLUDE 'opac-note.inc' %]
-                                [% END %]
+                                [% INCLUDE 'opac-note.inc' %]
                             [% END %]
 
                             [% IF ( nouser ) %]
index 7eb8749..0ac78de 100755 (executable)
@@ -308,16 +308,6 @@ my $patron_messages = Koha::Patron::Messages->search(
         message_type => 'B',
     }
 );
-if ( $patron_messages->count ) {
-    $template->param( bor_messages => 1 );
-}
-
-if ( $borr->{'opacnote'} ) {
-  $template->param( 
-    bor_messages => 1,
-    opacnote => $borr->{'opacnote'},
-  );
-}
 
 if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor')
     || C4::Context->preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') )
@@ -336,6 +326,7 @@ if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor'
 $template->param(
     borrower                 => $borr,
     patron_messages          => $patron_messages,
+    opacnote                 => $borr->{opacnote},
     patronupdate             => $patronupdate,
     OpacRenewalAllowed       => C4::Context->preference("OpacRenewalAllowed"),
     userview                 => 1,
index 8d2a1ae..0a59d3b 100755 (executable)
@@ -257,18 +257,10 @@ if ($borrower->{cardnumber}) {
             message_type => 'B',
         }
     );
-    if ( $patron_messages->count ) {
-        $template->param( bor_messages => 1,
-            patron_messages => $patron_messages,
-        );
-    }
-
-    if ( $borrower->{'opacnote'} ) {
-        $template->param(
-            bor_messages => 1,
-            opacnote => $borrower->{'opacnote'},
-        );
-    }
+    $template->param(
+        patron_messages => $patron_messages,
+        opacnote => $borrower->{opacnote},
+    );
 
     my $inputfocus = ($return_only      == 1) ? 'returnbook' :
                      ($confirm_required == 1) ? 'confirm'    : 'barcode' ;