[Koha-patches] [PATCH] Borrower Messages Bugfix

Kyle M Hall kyle.m.hall at gmail.com
Wed May 12 17:00:25 CEST 2010


Improper use of C4::Members::GetMessages triggered Attention box
on circulation.pl at all times.

Fixing this error causes the entire message area to be hidden, including
the 'Add a new message' link. Effectively, if there is no way to add a
message for a borrower unless there is a message for the borrower already.

To remedy this, I added an 'Add Message' button to the circ toolbar.
---
 C4/Members.pm                                      |    9 ++++++---
 circ/circulation.pl                                |    5 ++---
 .../intranet-tmpl/prog/en/css/staff-global.css     |    2 +-
 .../prog/en/includes/circ-toolbar.inc              |    8 ++++++--
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/C4/Members.pm b/C4/Members.pm
index 30e9f2d..4a34ab0 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -2098,11 +2098,14 @@ sub GetMessages {
 
 =over 4
 
-GetMessagesCount( $borrowernumber, $type );
+GetMessagesCount( $borrowernumber[, $type][, $branchcode] );
 
 $type is message type, B for borrower, or L for Librarian.
 Empty type returns all messages of any type.
 
+$branchcode is the branchcode for the given library.
+Empty branchcode returns messages for all libraries.
+
 Returns the number of messages for the given borrowernumber
 
 =back
@@ -2110,7 +2113,7 @@ Returns the number of messages for the given borrowernumber
 =cut
 
 sub GetMessagesCount {
-    my ( $borrowernumber, $type, $branchcode ) = @_;
+    my ( $borrowernumber, $type ) = @_;
 
     if ( ! $type ) {
       $type = '%';
@@ -2120,7 +2123,7 @@ sub GetMessagesCount {
 
     my $query = "SELECT COUNT(*) as MsgCount FROM messages WHERE borrowernumber = ? AND message_type LIKE ?";
     my $sth = $dbh->prepare($query);
-    $sth->execute( $borrowernumber, $type ) ;
+    $sth->execute( $borrowernumber, $type );
     my @results;
 
     my $data = $sth->fetchrow_hashref;
diff --git a/circ/circulation.pl b/circ/circulation.pl
index 4b67920..9b18b8c 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -636,11 +636,10 @@ if ( C4::Context->preference("memberofinstitution") ) {
 }
 
 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
-if($lib_messages_loop){ $template->param(flagged => 1 ); }
+if ( GetMessagesCount( $borrowernumber, 'L' ) ){ $template->param(flagged => 1 ); }
 
 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
-if($bor_messages_loop){ $template->param(flagged => 1 ); }
-
+if ( GetMessagesCount( $borrowernumber, 'B' ) ){ $template->param(flagged => 1 ); }
 # Computes full borrower address
 my (undef, $roadttype_hashref) = &GetRoadTypes();
 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index 13ac2c7..3eccee5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -863,7 +863,7 @@ fieldset.rows .inputnote {
 	background-repeat : no-repeat;
 }
 
-#duplicate a {
+#duplicate a, #addnote a {
 	padding-left : 34px;
 	background-image: url("../../img/toolbar-duplicate.gif");
 	background-position : center left;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
index 47815d7..3a0da48 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
@@ -33,6 +33,9 @@ function update_child() {
 <!-- /TMPL_IF -->
 }
 
+function addMessage() {
+	$("#add_message_form").show();
+}
 	// prepare DOM for YUI Toolbar
 
 	 $(document).ready(function() {
@@ -86,7 +89,8 @@ function update_child() {
 	
 	    <!-- TMPL_IF name="adultborrower" -->new YAHOO.widget.Button("addchild");<!-- /TMPL_IF -->
 	    new YAHOO.widget.Button("editpatron");
-	    new YAHOO.widget.Button("addnote");
+	    var messageButton = new YAHOO.widget.Button("addnote");
+	    messageButton.on("click", addMessage );
         <!-- TMPL_IF NAME="StaffMember" --><!-- TMPL_IF NAME="CAN_user_staffaccess" --> new YAHOO.widget.Button("changepassword");  <!-- /TMPL_IF-->
             <!-- TMPL_ELSE--> new YAHOO.widget.Button("changepassword"); <!-- /TMPL_IF -->
 	    new YAHOO.widget.Button("printslip");
@@ -125,7 +129,7 @@ function update_child() {
 	<!-- /TMPL_IF -->
 	<!-- TMPL_IF NAME="CAN_user_borrowers" -->
 	<!-- TMPL_IF name="adultborrower" --><li><a id="addchild" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;category_type=C">Add child</a></li><!-- /TMPL_IF -->
-<!--	<li><a id="addnote" href="/cgi-bin/koha/members/addnotes.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Add Note</a></li> -->
+	<li><a id="addnote">Add Message</a></li>
 <!-- TMPL_IF NAME="StaffMember" --><!-- TMPL_IF NAME="CAN_user_staffaccess" --> <li><a id="changepassword" href="/cgi-bin/koha/members/member-password.pl?member=<!-- TMPL_VAR NAME="borrowernumber" -->">Change Password</a></li><!-- /TMPL_IF-->
           <!-- TMPL_ELSE--> <li><a id="changepassword" href="/cgi-bin/koha/members/member-password.pl?member=<!-- TMPL_VAR NAME="borrowernumber" -->">Change Password</a></li><!-- /TMPL_IF -->	
 	  <!-- /TMPL_IF -->
-- 
1.5.6.5




More information about the Koha-patches mailing list