View | Details | Raw Unified | Return to bug 9011
Collapse All | Expand All

(-)a/C4/Circulation.pm (+4 lines)
Lines 1962-1967 sub MarkIssueReturned { Link Here
1962
                                  WHERE borrowernumber = ?
1962
                                  WHERE borrowernumber = ?
1963
                                  AND itemnumber = ?");
1963
                                  AND itemnumber = ?");
1964
    $sth_del->execute($borrowernumber, $itemnumber);
1964
    $sth_del->execute($borrowernumber, $itemnumber);
1965
1966
    if ( C4::Context->preference('StoreLastBorrower') ) {
1967
        $dbh->do("UPDATE items SET last_returned_by = ? WHERE itemnumber = ?", undef, ( $borrowernumber, $itemnumber ) );
1968
    }
1965
}
1969
}
1966
1970
1967
=head2 _debar_user_on_return
1971
=head2 _debar_user_on_return
(-)a/Koha/Template/Plugin/KohaBorrowers.pm (+44 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::KohaBorrowers;
2
3
# Copyright ByWater Solutions 2013
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Context;
26
27
=pod
28
29
This plugin contains TT helper functions related to borrowers
30
31
=cut
32
33
sub BorrowernumberToCardnumber {
34
    my ( $self, $borrowernumber ) = @_;
35
36
    my $sql = "SELECT cardnumber FROM borrowers WHERE borrowernumber = ?";
37
    my $sth = C4::Context->dbh->prepare( $sql );
38
    $sth->execute( $borrowernumber );
39
    my ( $cardnumber ) = $sth->fetchrow_array();
40
    
41
    return $cardnumber;
42
}
43
44
1;
(-)a/catalogue/moredetail.pl (+1 lines)
Lines 211-216 $template->param( Link Here
211
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
211
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
212
    subtitle            => $subtitle,
212
    subtitle            => $subtitle,
213
    hidepatronname      => $hidepatronname,
213
    hidepatronname      => $hidepatronname,
214
    StoreLastBorrower   => C4::Context->preference('StoreLastBorrower'),
214
);
215
);
215
$template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items );
216
$template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items );
216
217
(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 756-761 CREATE TABLE `deleteditems` ( Link Here
756
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
756
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
757
  `datelastborrowed` date default NULL, -- the date the item was last checked out
757
  `datelastborrowed` date default NULL, -- the date the item was last checked out
758
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
758
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
759
  `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item
759
  `stack` tinyint(1) default NULL,
760
  `stack` tinyint(1) default NULL,
760
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
761
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
761
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
762
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
Lines 792-797 CREATE TABLE `deleteditems` ( Link Here
792
  KEY `delitembibnoidx` (`biblionumber`),
793
  KEY `delitembibnoidx` (`biblionumber`),
793
  KEY `delhomebranch` (`homebranch`),
794
  KEY `delhomebranch` (`homebranch`),
794
  KEY `delholdingbranch` (`holdingbranch`)
795
  KEY `delholdingbranch` (`holdingbranch`)
796
  KEY `del_last_returned_by` (`last_returned_by`)
795
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
797
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
796
798
797
--
799
--
Lines 1042-1047 CREATE TABLE `items` ( -- holdings/item information Link Here
1042
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1044
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1043
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1045
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1044
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1046
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1047
  `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item
1045
  `stack` tinyint(1) default NULL,
1048
  `stack` tinyint(1) default NULL,
1046
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1049
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1047
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1050
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
Lines 1080-1085 CREATE TABLE `items` ( -- holdings/item information Link Here
1080
  KEY `itemcallnumber` (`itemcallnumber`),
1083
  KEY `itemcallnumber` (`itemcallnumber`),
1081
  KEY `items_location` (`location`),
1084
  KEY `items_location` (`location`),
1082
  KEY `items_ccode` (`ccode`),
1085
  KEY `items_ccode` (`ccode`),
1086
  KEY `last_returned_by` (`last_returned_by`),
1083
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1087
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1084
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1088
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1085
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
1089
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 411-413 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
411
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');
411
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');
412
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');
412
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');
413
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');
413
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');
414
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');
(-)a/installer/data/mysql/updatedatabase.pl (+15 lines)
Lines 6399-6404 if ( CheckVersion($DBversion) ) { Link Here
6399
    SetVersion($DBversion);
6399
    SetVersion($DBversion);
6400
}
6400
}
6401
6401
6402
$DBversion = "3.11.00.XXX";
6403
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6404
   $dbh->do("ALTER TABLE items ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
6405
   $dbh->do("ALTER TABLE items ADD INDEX ( last_returned_by )");
6406
   $dbh->do("ALTER TABLE items ADD FOREIGN KEY ( last_returned_by ) REFERENCES  borrowers ( borrowernumber )");
6407
6408
   $dbh->do("ALTER TABLE deleteditems ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
6409
   $dbh->do("ALTER TABLE deleteditems ADD INDEX ( last_returned_by )");
6410
   $dbh->do("ALTER TABLE deleteditems ADD FOREIGN KEY ( last_returned_by ) REFERENCES  borrowers ( borrowernumber )");
6411
6412
   $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')");
6413
6414
   print "Upgrade to $DBversion done ( Add syspref StoreLastBorrower )\n";
6415
   SetVersion ($DBversion);
6416
}
6402
6417
6403
=head1 FUNCTIONS
6418
=head1 FUNCTIONS
6404
6419
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 510-515 OPAC: Link Here
510
            - pref: AnonymousPatron
510
            - pref: AnonymousPatron
511
              class: integer
511
              class: integer
512
            - as the Anonymous Patron (for anonymous suggestions and reading history)
512
            - as the Anonymous Patron (for anonymous suggestions and reading history)
513
        -
514
            - pref: StoreLastBorrower
515
              default: 0
516
              choices:
517
                  yes: Store
518
                  no: "Don't store"
519
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
513
520
514
    Shelf Browser:
521
    Shelf Browser:
515
        -
522
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE KohaBorrowers %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Catalog &rsaquo; Item details for [% title %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield %][% END %]</title>
3
<title>Koha &rsaquo; Catalog &rsaquo; Item details for [% title %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield %][% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 201-206 Link Here
201
202
202
                <li><span class="label">Last seen:</span>[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %]&nbsp;</li>
203
                <li><span class="label">Last seen:</span>[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %]&nbsp;</li>
203
                <li><span class="label">Last borrowed:</span>[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %]&nbsp;</li>
204
                <li><span class="label">Last borrowed:</span>[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %]&nbsp;</li>
205
                [% IF ( StoreLastBorrower && ITEM_DAT.last_returned_by ) %]<li><span class="label">Last returned by:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.last_returned_by %]">[% KohaBorrowers.BorrowernumberToCardnumber( ITEM_DAT.last_returned_by ) %]</a>&nbsp;</li>[% END %]
204
                [% IF ( ITEM_DAT.card0 ) %]<li><span class="label">Last borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower0 %]">[% ITEM_DAT.card0 %]</a>&nbsp;</li>[% END %]
206
                [% IF ( ITEM_DAT.card0 ) %]<li><span class="label">Last borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower0 %]">[% ITEM_DAT.card0 %]</a>&nbsp;</li>[% END %]
205
                [% IF ( ITEM_DAT.card1 ) %]<li><span class="label">Previous borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower1 %]">[% ITEM_DAT.card1 %]</a>&nbsp;</li>[% END %]
207
                [% IF ( ITEM_DAT.card1 ) %]<li><span class="label">Previous borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower1 %]">[% ITEM_DAT.card1 %]</a>&nbsp;</li>[% END %]
206
                [% IF ( ITEM_DAT.card2 ) %]<li><span class="label">Previous borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower2 %]">[% ITEM_DAT.card2 %]</a>&nbsp;</li>[% END %]
208
                [% IF ( ITEM_DAT.card2 ) %]<li><span class="label">Previous borrower:</span> <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% ITEM_DAT.borrower2 %]">[% ITEM_DAT.card2 %]</a>&nbsp;</li>[% END %]
207
- 

Return to bug 9011