From 613a06f35682cfac55ba59198d4b9dd7828a93a6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 5 Nov 2012 14:35:23 -0500 Subject: [PATCH] Bug 9011 - Add the ability to store the last patron to return an item Content-Type: text/plain; charset="utf-8" --- C4/Circulation.pm | 4 ++++ catalogue/moredetail.pl | 3 ++- installer/data/mysql/kohastructure.sql | 4 ++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ .../prog/en/modules/catalogue/moredetail.tt | 1 + 7 files changed, 35 insertions(+), 1 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 5cbc211..72048b5 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1952,6 +1952,10 @@ sub MarkIssueReturned { WHERE borrowernumber = ? AND itemnumber = ?"); $sth_del->execute($borrowernumber, $itemnumber); + + if ( C4::Context->preference('StoreLastBorrower') ) { + $dbh->do("UPDATE items SET last_returned_by = ? WHERE itemnumber = ?", undef, ( $borrowernumber, $itemnumber ) ); + } } =head2 _debar_user_on_return diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 66d731b..b8c1b99 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -193,7 +193,7 @@ foreach my $item (@items){ $item->{borrowersurname} = $curr_borrower->{'surname'}; } } - + } $template->param(count => $data->{'count'}, subscriptionsnumber => $subscriptionsnumber, @@ -211,6 +211,7 @@ $template->param( z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)), subtitle => $subtitle, hidepatronname => $hidepatronname, + StoreLastBorrower => C4::Context->preference('StoreLastBorrower'), ); $template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items ); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 29ee782..0e9d7b8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -756,6 +756,7 @@ CREATE TABLE `deleteditems` ( `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w) `datelastborrowed` date default NULL, -- the date the item was last checked out `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done) + `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item `stack` tinyint(1) default NULL, `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7) `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4) @@ -791,6 +792,7 @@ CREATE TABLE `deleteditems` ( KEY `delitembibnoidx` (`biblionumber`), KEY `delhomebranch` (`homebranch`), KEY `delholdingbranch` (`holdingbranch`) + KEY `del_last_returned_by` (`last_returned_by`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1041,6 +1043,7 @@ CREATE TABLE `items` ( -- holdings/item information `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w) `datelastborrowed` date default NULL, -- the date the item was last checked out/issued `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done) + `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item `stack` tinyint(1) default NULL, `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7) `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4) @@ -1078,6 +1081,7 @@ CREATE TABLE `items` ( -- holdings/item information KEY `itemcallnumber` (`itemcallnumber`), KEY `items_location` (`location`), KEY `items_ccode` (`ccode`), + KEY `last_returned_by` (`last_returned_by`), CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE, CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index a4e4102..c236768 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -386,3 +386,4 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7ab48ee..6058ae6 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6020,6 +6020,22 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.09.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE items ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen"); + $dbh->do("ALTER TABLE items ADD INDEX ( last_returned_by )"); + $dbh->do("ALTER TABLE items ADD FOREIGN KEY ( last_returned_by ) REFERENCES borrowers ( borrowernumber )"); + + $dbh->do("ALTER TABLE deleteditems ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen"); + $dbh->do("ALTER TABLE deleteditems ADD INDEX ( last_returned_by )"); + $dbh->do("ALTER TABLE deleteditems ADD FOREIGN KEY ( last_returned_by ) REFERENCES borrowers ( borrowernumber )"); + + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo')"); + + print "Upgrade to $DBversion done ( Add syspref StoreLastBorrower )\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 1a9fa09..1728d59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -498,6 +498,13 @@ OPAC: - pref: AnonymousPatron class: integer - as the Anonymous Patron (for anonymous suggestions and reading history) + - + - pref: StoreLastBorrower + default: 0 + choices: + yes: Store + no: "Don't store" + - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron. Shelf Browser: - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index 5234e28..0270250 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -201,6 +201,7 @@
  • Last seen:[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %] 
  • Last borrowed:[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %] 
  • + [% IF ( StoreLastBorrower && ITEM_DAT.last_returned_by ) %]
  • Last returned by: [% ITEM_DAT.last_returned_by %] 
  • [% END %] [% IF ( ITEM_DAT.card0 ) %]
  • Last borrower: [% ITEM_DAT.card0 %] 
  • [% END %] [% IF ( ITEM_DAT.card1 ) %]
  • Previous borrower: [% ITEM_DAT.card1 %] 
  • [% END %] [% IF ( ITEM_DAT.card2 ) %]
  • Previous borrower: [% ITEM_DAT.card2 %] 
  • [% END %] -- 1.7.2.5