From c6a2168d6ec379a3854bd6216e373bf2f317c4d4 Mon Sep 17 00:00:00 2001 From: MJ Ray Date: Fri, 6 Apr 2012 12:14:35 +0100 Subject: [PATCH] C4/Reserves.pm: log reservation actions catalogue/issuehistory.tt: link to viewlog for circulation log tools/viewlog.tt: add HOLD and UNHOLD actions, move results table nearer top tools/viewlog.pl: be more cautious in assuming info field in CIRCULATION is an itemnumber http://bugs.koha-community.org/show_bug.cgi?id=6890 --- C4/Reserves.pm | 22 +++ .../prog/en/modules/catalogue/issuehistory.tt | 2 + .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 160 ++++++++++---------- tools/viewlog.pl | 27 +++- 4 files changed, 123 insertions(+), 88 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 930d524..cf9f446 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -4,6 +4,7 @@ package C4::Reserves; # 2006 SAN Ouest Provence # 2007-2010 BibLibre Paul POULAIN # 2011 Catalyst IT +# Copyright 2012 software.coop and MJ Ray # # This file is part of Koha. # @@ -29,6 +30,7 @@ use C4::Members; use C4::Items; use C4::Circulation; use C4::Accounts; +use C4::Log; # for _koha_notify_reserve use C4::Members::Messaging; @@ -197,6 +199,9 @@ sub AddReserve { $found, $waitingdate, $expdate ); + # Record the fact that this book was reserved. + logaction( 'CIRCULATION', 'HOLD', $biblionumber, 'Borrower '.$borrowernumber ); + # Send e-mail to librarian if syspref is active if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){ my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); @@ -968,6 +973,11 @@ sub CancelReserve { "; $sth = $dbh->prepare($query); $sth->execute( $item, $borr ); + + # Record the fact that this book was unreserved. + logaction( 'CIRCULATION', 'UNHOLD', $biblio, 'Borrower '.$borr ); + # FIXME: should look up biblionumber if not given + } else { # removing a reserve record.... @@ -1015,6 +1025,9 @@ sub CancelReserve { $sth = $dbh->prepare($query); $sth->execute( $biblio, $borr ); + # Record the fact that this book was unreserved. + logaction( 'CIRCULATION', 'UNHOLD', $biblio, 'Borrower '.$borr ); + # now fix the priority on the others.... _FixPriority( $biblio, $borr ); } @@ -1084,6 +1097,9 @@ sub ModReserve { $sth = $dbh->prepare($query); $sth->execute( $biblio, $borrower ); + # Record the fact that this book was unreserved. + logaction( 'CIRCULATION', 'UNHOLD', $biblio, 'Borrower '.$borrower ); + } elsif ($rank =~ /^\d+/ and $rank > 0) { my $query = " @@ -1104,6 +1120,9 @@ sub ModReserve { } } + # Record the fact that this book was unreserved. + logaction( 'CIRCULATION', 'HOLD', $biblio, 'Modify hold for borrower '.$borrower ); + _FixPriority( $biblio, $borrower, $rank); } } @@ -1169,6 +1188,9 @@ sub ModReserveFill { $sth = $dbh->prepare($query); $sth->execute( $biblionumber, $resdate, $borrowernumber ); + # Record the fact that this book was unreserved. + logaction( 'CIRCULATION', 'UNHOLD', $biblionumber, 'Borrower '.$borrowernumber ); + # now fix the priority on the others (if the priority wasn't # already sorted!).... unless ( $priority == 0 ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt index 14d823c..ab81a52 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -77,6 +77,8 @@ [% END %] +

See also: circulation log for [% title |html %]

+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 8449341..b1e04c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -29,6 +29,85 @@
[% IF ( CAN_user_reports ) %]

Browse system logs

+ [% IF ( do_it ) %] + [% IF ( total ) %] +

[% total %] lines found.

+ + + + + + + + + + [% FOREACH loopro IN looprow %] + [% UNLESS ( loop.odd ) %][% ELSE %][% END %] + + + + + + + + + [% END %] +
DateLibrarianModuleActionObjectInfo
[% loopro.timestamp %] + [% IF ( module == 'CIRCULATION' ) %] + [% loopro.user %] + [% ELSE %] + [% loopro.user %] + [% END %] + [% loopro.module %][% loopro.action %] + [% IF ( module == 'MEMBERS' ) %] + member [% loopro.object %] + [% ELSE %] + [% IF ( module == 'CIRCULATION' ) %] + + [% IF ( loopro.object ) %] + member [% loopro.object %] + [% END %] + + [% ELSE %] + [% IF ( module == 'CATALOGUING' ) %] + [% IF ( info == 'item' ) %] + Item [% loopro.object %] + [% ELSE %] + biblio [% loopro.object %] + [% END %] + [% ELSE %] + [% IF ( module == 'SERIAL' ) %] + [% loopro.object %] + [% ELSE %] + [% IF ( module == 'AUTHORITIES' ) %] + auth [% loopro.object %] + [% ELSE %] + [% loopro.object %] + [% END %] + [% END %] + [% END %] + [% END %] + [% END %] + + [% IF ( loopro.CIRCULATIONITEM ) %] + Item [% loopro.info |html %] + [% ELSE %] + [% loopro.info |html %] + [% END %] +
+ [% ELSE %] +
+ No log found + [% IF ( CATALOGUING ) %] + for Bibliographic Record [% object %] + [% END %] + [% IF ( MEMBERS ) %] + for [% INCLUDE 'patron-title.inc' %] + [% END %] + . +
+ [% END %] + [% END %]
[% IF ( do_it ) %] @@ -64,6 +143,8 @@ + +
  • @@ -135,85 +216,6 @@
  • [% END %] - [% IF ( do_it ) %] - [% IF ( total ) %] -

    [% total %] lines found.

    - - - - - - - - - - [% FOREACH loopro IN looprow %] - [% UNLESS ( loop.odd ) %][% ELSE %][% END %] - - - - - - - - - [% END %] -
    DateLibrarianModuleActionObjectInfo
    [% loopro.timestamp %] - [% IF ( module == 'CIRCULATION' ) %] - [% loopro.user %] - [% ELSE %] - [% loopro.user %] - [% END %] - [% loopro.module %][% loopro.action %] - [% IF ( module == 'MEMBERS' ) %] - member [% loopro.object %] - [% ELSE %] - [% IF ( module == 'CIRCULATION' ) %] - - [% IF ( loopro.object ) %] - member [% loopro.object %] - [% END %] - - [% ELSE %] - [% IF ( module == 'CATALOGUING' ) %] - [% IF ( info == 'item' ) %] - Item [% loopro.object %] - [% ELSE %] - biblio [% loopro.object %] - [% END %] - [% ELSE %] - [% IF ( module == 'SERIAL' ) %] - [% loopro.object %] - [% ELSE %] - [% IF ( module == 'AUTHORITIES' ) %] - auth [% loopro.object %] - [% ELSE %] - [% loopro.object %] - [% END %] - [% END %] - [% END %] - [% END %] - [% END %] - - [% IF ( loopro.CIRCULATION ) %] - Item [% loopro.info |html %] - [% ELSE %] - [% loopro.info |html %] - [% END %] -
    - [% ELSE %] -
    - No log found - [% IF ( CATALOGUING ) %] - for Bibliographic Record [% object %] - [% END %] - [% IF ( MEMBERS ) %] - for [% INCLUDE 'patron-title.inc' %] - [% END %] - . -
    - [% END %] - [% END %]
    diff --git a/tools/viewlog.pl b/tools/viewlog.pl index d42503e..8ea463d 100755 --- a/tools/viewlog.pl +++ b/tools/viewlog.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # Copyright 2010 BibLibre -# Copyright 2011 MJ Ray and software.coop +# Copyright 2011-2012 MJ Ray and software.coop # # This file is part of Koha. # @@ -116,14 +116,23 @@ if ($do_it) { @data=@$results; my $total = scalar @data; foreach my $result (@data){ - if ($result->{'info'} eq 'item'||$result->{module} eq "CIRCULATION"){ - # get item information so we can create a working link - my $itemnumber=$result->{'object'}; - $itemnumber=$result->{'info'} if ($result->{module} eq "CIRCULATION"); - my $item=GetItem($itemnumber); - $result->{'biblionumber'}=$item->{'biblionumber'}; - $result->{'biblioitemnumber'}=$item->{'biblionumber'}; - } + if ( + $result->{'info'} eq 'item' + || ( ( $result->{module} eq "CIRCULATION" ) + && ( $result->{'info'} =~ /^\d+$/ ) ) + ) + { + + # get item information so we can create a working link + my $itemnumber = $result->{'object'}; + if ( $result->{module} eq "CIRCULATION" ) { + $itemnumber = $result->{'info'}; + $result->{CIRCULATIONITEM} = 1; + } + my $item = GetItem($itemnumber); + $result->{'biblionumber'} = $item->{'biblionumber'}; + $result->{'biblioitemnumber'} = $item->{'biblionumber'}; + } } if ( $output eq "screen" ) { -- 1.7.2.5