[Koha-patches] [PATCH] New Messaging System.

Colin Campbell colin.campbell at ptfs-europe.com
Sat Jul 25 11:03:09 CEST 2009


  This system is indended to replace the old opacnotes
  and borrowernotes fields in the borrowers table.
  This system allows an unlimited number of Libraran and OPAC notes to be
  attached to a borrower. Each note has a message, a message type,
  the data it was created, and which library created it.
  Each message can only be deleted by the library that created it unless the syspref
  AllowAllMessageDeletion has been set.

  This system may be used simultaneously with the old notes system and does not affect it in any way.

  A new database table (messages) was added for this feature.

  The System also allows for pre-defined notes for Borrower records

  To use these, just create authorised values with the category BOR_NOTES
  where the Authorized Value is the short description shown in the pulldown,
  and the description is the text that should be in the note.

  Original Author: PTFS Contractor <dbavousett at ptfs.com>

  This work co-sponsered by Middletown Township Public Library, Middletown, NJ, USA
     and East Brunswick Public Library, East Brunswick, NJ, USA

Signed-off-by: Colin Campbell <colin.campbell at ptfs-europe.com>
---
 C4/Members.pm                                      |  142 +++++++++++++++++++-
 admin/systempreferences.pl                         |    1 +
 circ/add_message.pl                                |   55 ++++++++
 circ/circulation.pl                                |   14 ++
 circ/del_message.pl                                |   53 ++++++++
 installer/data/mysql/en/mandatory/sysprefs.sql     |    1 +
 .../1-Obligatoire/unimarc_standard_systemprefs.sql |    1 +
 installer/data/mysql/kohastructure.sql             |   14 ++
 installer/data/mysql/updatedatabase.pl             |   17 +++
 .../prog/en/modules/circ/circulation.tmpl          |   89 ++++++++++++-
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl |   12 ++
 opac/opac-user.pl                                  |    5 +
 12 files changed, 400 insertions(+), 4 deletions(-)
 create mode 100755 circ/add_message.pl
 create mode 100755 circ/del_message.pl

diff --git a/C4/Members.pm b/C4/Members.pm
index b2ce916..5525b60 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -75,6 +75,11 @@ BEGIN {
 		&GetBorrowersWithIssuesHistoryOlderThan
 
 		&GetExpiryDate
+
+		&AddMessage
+		&DeleteMessage
+		&GetMessages
+		&GetMessagesCount
 	);
 
 	#Modify data
@@ -93,7 +98,7 @@ BEGIN {
 		&AddMember
 		&add_member_orgs
 		&MoveMemberToDeleted
-		&ExtendMemberSubscriptionTo 
+		&ExtendMemberSubscriptionTo
 	);
 
 	#Check data
@@ -2045,6 +2050,141 @@ sub DebarMember {
     
 }
 
+=head2 AddMessage
+
+=over 4
+
+AddMessage( $borrowernumber, $message_type, $message, $branchcode );
+
+Adds a message to the messages table for the given borrower.
+
+Returns:
+  True on success
+  False on failure
+
+=back
+
+=cut
+
+sub AddMessage {
+    my ( $borrowernumber, $message_type, $message, $branchcode ) = @_;
+
+    my $dbh  = C4::Context->dbh;
+
+    if ( ! ( $borrowernumber && $message_type && $message && $branchcode ) ) {
+      return;
+    }
+
+    my $query = "INSERT INTO messages ( borrowernumber, branchcode, message_type, message ) VALUES ( ?, ?, ?, ? )";
+    my $sth = $dbh->prepare($query);
+    $sth->execute( $borrowernumber, $branchcode, $message_type, $message );
+
+    return 1;
+}
+
+=head2 GetMessages
+
+=over 4
+
+GetMessages( $borrowernumber, $type );
+
+$type is message type, B for borrower, or L for Librarian.
+Empty type returns all messages of any type.
+
+Returns all messages for the given borrowernumber
+
+=back
+
+=cut
+
+sub GetMessages {
+    my ( $borrowernumber, $type, $branchcode ) = @_;
+
+    if ( ! $type ) {
+      $type = '%';
+    }
+
+    my $dbh  = C4::Context->dbh;
+
+    my $query = "SELECT
+                  branches.branchname,
+                  messages.*,
+                  DATE_FORMAT( message_date, '%m/%d/%Y' ) AS message_date_formatted,
+                  messages.branchcode LIKE '$branchcode' AS can_delete
+                  FROM messages, branches
+                  WHERE borrowernumber = ?
+                  AND message_type LIKE ?
+                  AND messages.branchcode = branches.branchcode
+                  ORDER BY message_date DESC";
+    my $sth = $dbh->prepare($query);
+    $sth->execute( $borrowernumber, $type ) ;
+    my @results;
+
+    while ( my $data = $sth->fetchrow_hashref ) {
+        push @results, $data;
+    }
+    return \@results;
+
+}
+
+=head2 GetMessages
+
+=over 4
+
+GetMessagesCount( $borrowernumber, $type );
+
+$type is message type, B for borrower, or L for Librarian.
+Empty type returns all messages of any type.
+
+Returns the number of messages for the given borrowernumber
+
+=back
+
+=cut
+
+sub GetMessagesCount {
+    my ( $borrowernumber, $type, $branchcode ) = @_;
+
+    if ( ! $type ) {
+      $type = '%';
+    }
+
+    my $dbh  = C4::Context->dbh;
+
+    my $query = "SELECT COUNT(*) as MsgCount FROM messages WHERE borrowernumber = ? AND message_type LIKE ?";
+    my $sth = $dbh->prepare($query);
+    $sth->execute( $borrowernumber, $type ) ;
+    my @results;
+
+    my $data = $sth->fetchrow_hashref;
+    my $count = $data->{'MsgCount'};
+
+    return $count;
+}
+
+
+
+=head2 DeleteMessage
+
+=over 4
+
+DeleteMessage( $message_id );
+
+=back
+
+=cut
+
+sub DeleteMessage {
+    my ( $message_id ) = @_;
+
+    my $dbh = C4::Context->dbh;
+
+    my $query = "DELETE FROM messages WHERE message_id = ?";
+    my $sth = $dbh->prepare($query);
+    $sth->execute( $message_id );
+
+}
+
 END { }    # module clean-up code here (global destructor)
 
 1;
diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index 4a84b13..c32df90 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -162,6 +162,7 @@ $tabsysprefs{BranchTransferLimitsType}       = "Circulation";
 $tabsysprefs{AllowNotForLoanOverride}        = "Circulation";
 $tabsysprefs{RenewalPeriodBase}              = "Circulation";
 $tabsysprefs{FilterBeforeOverdueReport}      = "Circulation";
+$tabsysprefs{AllowAllMessageDeletion}        = "Circulation";
 
 # Staff Client
 $tabsysprefs{TemplateEncoding}        = "StaffClient";
diff --git a/circ/add_message.pl b/circ/add_message.pl
new file mode 100755
index 0000000..b80ade4
--- /dev/null
+++ b/circ/add_message.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+# Copyright 2009 PTFS Inc.
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use warnings;
+
+use CGI;
+
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::Members;
+use C4::Accounts;
+use C4::Stats;
+use C4::Koha;
+use C4::Overdues;
+use C4::Branch;    # GetBranches
+
+my $input = new CGI;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {   template_name   => "circ/circulation.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { borrowers => 1 },
+        debug           => 1,
+    }
+);
+
+my $borrowernumber   = $input->param('borrowernumber');
+my $branchcode       = $input->param('branchcode');
+my $message_type     = $input->param('message_type');
+my $borrower_message = $input->param('borrower_message');
+
+AddMessage( $borrowernumber, $message_type, $borrower_message, $branchcode );
+
+print $input->redirect(
+    "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
diff --git a/circ/circulation.pl b/circ/circulation.pl
index 986b10c..c7c38cb 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -643,6 +643,9 @@ if ( C4::Context->preference("memberofinstitution") ) {
 
 $template->param(
     issued_itemtypes_count_loop => \@issued_itemtypes_count_loop,
+    lib_messages_loop		=> GetMessages( $borrowernumber, 'L', $branch ),
+    bor_messages_loop		=> GetMessages( $borrowernumber, 'B', $branch ),
+    all_messages_del		=> C4::Context->preference('AllowAllMessageDeletion'),
     findborrower                => $findborrower,
     borrower                    => $borrower,
     borrowernumber              => $borrowernumber,
@@ -692,6 +695,17 @@ if ($stickyduedate) {
 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
 $template->param( picture => 1 ) if $picture;
 
+# get authorised values with type of BOR_NOTES
+my @canned_notes;
+my $dbh = C4::Context->dbh;
+my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "BOR_NOTES"');
+$sth->execute();
+while ( my $row = $sth->fetchrow_hashref() ) {
+  push @canned_notes, $row;
+}
+if ( scalar( @canned_notes ) ) {
+  $template->param( canned_bor_notes_loop => \@canned_notes );
+}
 
 $template->param(
     debt_confirmed            => $debt_confirmed,
diff --git a/circ/del_message.pl b/circ/del_message.pl
new file mode 100755
index 0000000..fcf32a7
--- /dev/null
+++ b/circ/del_message.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+# Copyright 2009 PTFS Inc.
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use warnings;
+
+use CGI;
+
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::Members;
+use C4::Accounts;
+use C4::Stats;
+use C4::Koha;
+use C4::Overdues;
+use C4::Branch;    # GetBranches
+
+my $input = new CGI;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {   template_name   => "circ/circulation.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { borrowers => 1 },
+        debug           => 1,
+    }
+);
+
+my $borrowernumber = $input->param('borrowernumber');
+my $message_id     = $input->param('message_id');
+
+DeleteMessage($message_id);
+
+print $input->redirect(
+    "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index a978fad..8a9031a 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -245,3 +245,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
index 424b716..5fc3d71 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -247,3 +247,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('v
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Autoriser l''affichage MARC labellis des notices bibliographiques','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Autoriser l''affichage de la vue MARC des notices bibliographiques','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Ne pas lancer le rapport sur les retards tant qu''il n''y a pas de filtre','','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 2b2e0c9..6bb1197 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2366,6 +2366,20 @@ CREATE TABLE `item_circulation_alert_preferences` (
   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `messages`
+--
+
+CREATE TABLE `messages` (
+  `message_id` int(11) NOT NULL auto_increment,
+  `borrowernumber` int(11) NOT NULL,
+  `branchcode` varchar(4) default NULL,
+  `message_type` varchar(1) NOT NULL,
+  `message` text NOT NULL,
+  `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`message_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 58497c8..0145282 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2467,6 +2467,23 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
 }
 
+$DBversion = "3.01.00.038";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
+    $dbh->do('DROP TABLE messages');
+    $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
+        `borrowernumber` int(11) NOT NULL,
+        `branchcode` varchar(4) default NULL,
+        `message_type` varchar(1) NOT NULL,
+        `message` text NOT NULL,
+        `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+        PRIMARY KEY (`message_id`)
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+
+	print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
+    SetVersion ($DBversion);
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
index 050c72c..dc94179 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -51,6 +51,20 @@ $.tablesorter.addParser({
 	 });
 //]]>
 </script>
+
+<script>
+function showhide(id){
+  if (document.getElementById){
+    obj = document.getElementById(id);
+    if (obj.style.display == "none"){
+      obj.style.display = "";
+    } else {
+      obj.style.display = "none";
+    }
+  }
+}
+</script>
+
 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
 </head>
 <body>
@@ -60,6 +74,7 @@ $.tablesorter.addParser({
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo;<!-- TMPL_IF NAME="borrowernumber" --> <a href="/cgi-bin/koha/circ/circulation.pl">Checkouts</a> &rsaquo; <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --><!-- TMPL_ELSE --> <strong>Checkouts</strong><!-- /TMPL_IF --></div>
 
+
 <!-- TMPL_IF NAME="CGIselectborrower" -->
 <div id="doc" class="yui-t7">
 
@@ -79,6 +94,41 @@ $.tablesorter.addParser({
 <!-- /TMPL_IF -->
 
 <!--  INITIAL BLOC : PARAMETERS & BORROWER INFO -->
+<div style="display: none;" id="add_message">
+<form method="post" action="/cgi-bin/koha/circ/add_message.pl" id="message_form" name="message_f">
+<fieldset id="borrower_messages">
+    <legend>Leave A Message</legend>
+    <p>
+            <label for="message_type">Add A Message For</label>
+          <select name="message_type" id="message_type">
+            <option value="L">Other Librarians</option>
+            <option value="B"><!-- TMPL_VAR name="firstname" --></option>
+        </select>
+    </p>
+    <!-- TMPL_IF NAME="canned_bor_notes_loop" -->
+        <p>
+                <label for="canned_notes">Canned Notes: </label>
+                <select name="type" id="type" onchange="this.form.borrower_message.value=this.options[this.selectedIndex].value;">
+                    <option value=''>Select Note</option>
+                    <!-- TMPL_LOOP NAME="canned_bor_notes_loop" -->
+                    <option value="<!-- TMPL_VAR NAME="lib" -->"><!--TMPL_VAR NAME="authorised_value" --></option>
+                    <!-- /TMPL_LOOP -->
+                </select>
+        </p>
+    <!-- /TMPL_IF -->
+    <p>
+        <textarea rows="3" cols="60" name="borrower_message" id="borrower_message" ></textarea>
+    </p>
+    <p>
+        <input type="submit" value="Save Message" />
+    </p>
+
+        <input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
+        <input type="hidden" name="branchcode" value="<!-- TMPL_VAR NAME="branch" -->" />
+</fieldset>
+</form>
+</div>
+
 <!-- TMPL_IF NAME="dateexpiry" --><div class="dialog message">Patron's account has been renewed until <!-- TMPL_VAR NAME="dateexpiry" --></div><!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="NEEDSCONFIRMATION" -->
 <div class="yui-g">
@@ -259,7 +309,12 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
 <!-- TMPL_IF NAME="flagged" -->
 <div class="yui-u first">
 <!-- TMPL_ELSE -->
-<div><!-- /TMPL_IF --><form method="post" action="/cgi-bin/koha/circ/circulation.pl" name="mainform">
+<div>
+
+<!-- /TMPL_IF -->
+
+
+<form method="post" action="/cgi-bin/koha/circ/circulation.pl" name="mainform">
 <fieldset id="circ_circulation_issue">
     <label for="barcode">Checking out to <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --> (<!-- TMPL_VAR NAME="cardnumber" -->) </label>
 	<div class="hint">Enter item barcode:</div>
@@ -393,7 +448,7 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
 			<div id="holdswaiting" class="circmessage">
 		    <h4>Holds waiting:</h4>
 			        <!-- TMPL_LOOP NAME="WaitingReserveLoop" -->
-			            <ul> 
+			            <ul>
 			                <li> <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a> (<!-- TMPL_VAR NAME="itemtype"-->), <!-- TMPL_IF NAME="author" -->by <!-- TMPL_VAR NAME="author"--><!-- /TMPL_IF --> Hold placed on <!-- TMPL_VAR NAME="reservedate"-->.
 			            <!-- TMPL_IF NAME="waitingat" -->
 			                <br /><!-- TMPL_IF NAME="waitinghere" --><strong class="waitinghere"><!-- TMPL_ELSE --><strong><!-- /TMPL_IF -->Waiting at <!-- TMPL_VAR NAME="waitingat" --></strong>
@@ -408,9 +463,37 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
 			<h4>Notes:</h4>
             <p><span class="circ-hlt"><!-- TMPL_VAR name="notesmsg" --></span></p>
 			</div>
+
+
     <!-- /If notes --><!-- /TMPL_IF -->
      <!-- /If flagged --><!-- /TMPL_IF -->
 
+	<div id="messages" class="circmessage">
+		<h4>Messages:</h4>
+		<ul>
+			<!--TMPL_LOOP NAME="lib_messages_loop" -->
+				<li>
+					<span class="circ-hlt">
+						<!--TMPL_VAR NAME="message_date_formatted"-->
+						<!--TMPL_VAR NAME="branchcode"-->
+						<i>"<!--TMPL_VAR NAME="message"-->"</i>
+					</span>
+					<!-- TMPL_IF NAME="can_delete" -->
+						<a href='/cgi-bin/koha/circ/del_message.pl?message_id=<!--TMPL_VAR NAME="message_id" -->&borrowernumber=<!--TMPL_VAR NAME="borrowernumber" -->'>[Delete]</a>
+					<!-- TMPL_ELSE -->
+						<!-- TMPL_IF NAME="all_messages_del" -->
+							<a href='/cgi-bin/koha/circ/del_message.pl?message_id=<!--TMPL_VAR NAME="message_id" -->&borrowernumber=<!--TMPL_VAR NAME="borrowernumber" -->'>[Delete]</a>
+						<!-- /TMPL_IF -->
+					<!-- /TMPL_IF -->
+				</li>
+			<!-- /TMPL_LOOP -->
+			<!--TMPL_LOOP NAME="bor_messages_loop" -->
+				<li><span class=""><!--TMPL_VAR NAME="message_date_formatted"--> <!--TMPL_VAR NAME="branchcode"--> <i>"<!--TMPL_VAR NAME="message"-->"</i></span> <!-- TMPL_IF NAME="can_delete" --><a href='/cgi-bin/koha/circ/del_message.pl?message_id=<!--TMPL_VAR NAME="message_id" -->&borrowernumber=<!--TMPL_VAR NAME="borrowernumber" -->'>[Delete]</a><!-- /TMPL_IF --></li>
+			<!-- /TMPL_LOOP -->
+
+			<a href="#" onclick="showhide('add_message'); return(false);">Add A New Message</a>
+		</ul>
+	</div>
 
 </div>
 </div>
@@ -506,7 +589,7 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
 		<!-- /TMPL_IF -->
     </tr>
     <!-- /TMPL_LOOP --> <!-- /loop todayissues -->
-    <!-- /if todayissues --><!-- /TMPL_IF --> 
+    <!-- /if todayissues --><!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="previssues" -->
 <!-- TMPL_IF NAME="todayissues" --><tr><th colspan="8"><a name="previous" id="previous"></a>Previous checkouts</th></tr><!-- TMPL_ELSE -->
 <tr><th class="{sorter: false}" colspan="8"><a name="previous" id="previous"></a>Previous checkouts</th></tr></thead>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
index 06f3c69..a19c94a 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
@@ -75,11 +75,23 @@ $.tablesorter.addParser({
     <div id="yui-main">
     <div class="yui-b"><div class="yui-g">
 	<div id="userdetails" class="container">
+
+	<!-- TMPL_IF NAME="bor_messages" -->
+	       <div class="dialog message">
+	               <h3>Messages For You</h3>
+	               <ul>
+	                       <!--TMPL_LOOP NAME="bor_messages_loop" -->
+	                               <li>On <!--TMPL_VAR NAME="message_date_formatted"--> <!--TMPL_VAR NAME="branchname"--> wrote <i>"<!--TMPL_VAR NAME="message"-->"</i></li>
+	                        <!-- /TMPL_LOOP -->
+	               </ul>
+	       </div>
+	<!-- /TMPL_IF -->
     <!-- TMPL_LOOP NAME="BORROWER_INFO" -->
         <h2>Hello, <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --> <span class="hint">(<a href="/cgi-bin/koha/opac-main.pl?logout.x=1">Click here</a> if you're not <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" -->)</span></h2>
         
 		<!-- TMPL_IF NAME="patronupdate" --><div class="dialog message"><h3>Thank you!</h3><p>Your corrections have been submitted to the library, and a staff member will update your record as soon as possible.</p></div><!-- /TMPL_IF -->
 		
+
         <!-- TMPL_IF NAME="opacnote"-->
 		<div class="dialog message">
             <h3>Message from the library</h3>
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index 708ba7f..fd6c0ba 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -259,7 +259,12 @@ if (C4::Context->preference("OPACAmazonCoverImages") or
         $template->param(JacketImages=>1);
 }
 
+if ( GetMessagesCount( $borrowernumber, 'B' ) ) {
+	$template->param( bor_messages => 1 );
+}
+
 $template->param(
+    bor_messages_loop	=> GetMessages( $borrowernumber, 'B', 'NONE' ),
     waiting_count      => $wcount,
     textmessaging      => $borr->{textmessaging},
     patronupdate => $patronupdate,
-- 
1.6.2.5




More information about the Koha-patches mailing list