[Koha-patches] [PATCH] Placed a Revision History tab on the moremember.tmpl

Colin Campbell colin.campbell at ptfs-europe.com
Sat Jul 25 00:37:00 CEST 2009


From: David Birmingham <dbirmingham at ptfs.com>

The moremember.tmpl had additional patron info at the
bottom of the page such as "Checked out" and "On Holds".
I added a "Revision History" tab that shows brief info
about the librarian who added or modified the patron record,
what he or she did, and when it happened.

Sponsored by East Brunswick Public Library, East Brunswick, NJ USA

Signed-off-by: J. David Bavousett <dbavousett at ptfs.com>
Signed-off-by: Colin Campbell <colin.campbell at ptfs-europe.com>
---
 C4/Members.pm                                      |   45 ++++++++++++++++++--
 .../prog/en/modules/members/moremember.tmpl        |   24 ++++++++++
 members/moremember.pl                              |   13 ++++++
 3 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/C4/Members.pm b/C4/Members.pm
index b2ce916..1a13c67 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -59,22 +59,24 @@ BEGIN {
 		&GetSortDetails
 		&GetTitles
 
-    &GetPatronImage
-    &PutPatronImage
-    &RmPatronImage
+		&GetPatronImage
+		&PutPatronImage
+		&RmPatronImage
 
 		&GetMemberAccountRecords
 		&GetBorNotifyAcctRecord
 
 		&GetborCatFromCatType 
 		&GetBorrowercategory
-    &GetBorrowercategoryList
+		&GetBorrowercategoryList
 
 		&GetBorrowersWhoHaveNotBorrowedSince
 		&GetBorrowersWhoHaveNeverBorrowed
 		&GetBorrowersWithIssuesHistoryOlderThan
 
 		&GetExpiryDate
+
+                &GetMemberRevisions
 	);
 
 	#Modify data
@@ -1298,6 +1300,41 @@ sub GetExpiryDate {
     return sprintf("%04d-%02d-%02d", Add_Delta_YM(@date,0,$enrolmentperiod));
 }
 
+=head2 GetMemberRevisions
+
+=over 4
+
+$revisions = &GetMemberRevisions($borrowernumber);
+
+Looks up addition/modification occurences of a patron's
+account by library staff via the action_logs table.
+Uses patron's borrowernumber for database selection.
+
+&GetMemberRevisions returns a reference-to array where each element
+is a reference-to-hash whose keys are the fields of the action_logs
+table.
+
+=cut
+
+#'
+sub GetMemberRevisions {
+
+    my ($borrowernumber) = @_;
+    my $dbh = C4::Context->dbh;
+    my $sth;
+    my $select = "
+    SELECT *
+      FROM action_logs
+      WHERE object=?
+    ";
+    $sth = $dbh->prepare($select);
+    $sth->execute($borrowernumber);
+    my $data = $sth->fetchall_arrayref({});
+    ($data) and return ($data);
+
+    return undef;
+}
+
 =head2 checkuserpassword (OUEST-PROVENCE)
 
 check for the password and login are not used
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
index d3deaf9..1b0a169 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
@@ -366,6 +366,7 @@ if (nodename =="barcodes[]"){
 		<li><a href="#checkedout">Checked Out</a></li>
 		<li><a href="#finesandcharges">Fines &amp; Charges</a></li>
 		<li><a href="#onhold">On Hold</a></li>
+		<li><a href="#revisionhistory">Revision History</a></li>
 	</ul>
 	
 <div id="finesandcharges">
@@ -377,6 +378,29 @@ if (nodename =="barcodes[]"){
     <!-- /TMPL_IF -->
 </div>
 
+<div id="revisionhistory">
+    <h2>Revision History</h2>
+    <!-- TMPL_IF NAME="revisionloop" -->
+      <table id="revisionst">
+        <thead><tr>
+          <th>Staff</th>
+          <th>Action</th>
+          <th>Date/Time</th>
+        </tr></thead>
+        <tbody><!-- TMPL_LOOP NAME="revisionloop" -->
+          <tr>
+          <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="staffnumber" -->" title="display detail for this librarian.">
+          <!-- TMPL_VAR NAME="staffnumber" --> </a></td>
+          <td><!-- TMPL_VAR NAME="staffaction" --></td>
+          <td><!-- TMPL_VAR NAME="timestamp" --></td>
+          </tr>
+        <!-- /TMPL_LOOP --></tbody>
+      </table>
+    <!-- TMPL_ELSE -->
+      <p>Patron has no revisions.</p>
+    <!-- /TMPL_IF -->
+</div>
+
 <div id="checkedout">
     <h2>Checked Out</h2>
     <!-- TMPL_IF NAME="issueloop" -->
diff --git a/members/moremember.pl b/members/moremember.pl
index 494121f..dd7c9fe 100755
--- a/members/moremember.pl
+++ b/members/moremember.pl
@@ -319,6 +319,19 @@ if ($borrowernumber) {
     $template->param( reservloop => \@reservloop );
 }
 
+# extract staff activity on patron record
+my $revisions = &GetMemberRevisions($borrowernumber);
+my $revision_count = scalar(@$revisions);
+my @revisiondata;
+for ( my $i = 0; $i < $revision_count; $i++) {
+  my %row = %{ $revisions->[$i] };
+  $row{'staffnumber'} = $revisions->[$i]{'user'};
+  $row{'staffaction'} = $revisions->[$i]{'action'};
+  $row{'timestamp'} = $revisions->[$i]{'timestamp'};
+  push( @revisiondata, \%row );
+}
+$template->param( revisionloop => \@revisiondata );
+
 # current alert subscriptions
 my $alerts = getalert($borrowernumber);
 foreach (@$alerts) {
-- 
1.6.2.5




More information about the Koha-patches mailing list