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

(-)a/C4/Circulation.pm (+4 lines)
Lines 1971-1976 sub MarkIssueReturned { Link Here
1971
                                  WHERE borrowernumber = ?
1971
                                  WHERE borrowernumber = ?
1972
                                  AND itemnumber = ?");
1972
                                  AND itemnumber = ?");
1973
    $sth_del->execute($borrowernumber, $itemnumber);
1973
    $sth_del->execute($borrowernumber, $itemnumber);
1974
1975
    if ( C4::Context->preference('StoreLastBorrower') ) {
1976
        $dbh->do("UPDATE items SET last_returned_by = ? WHERE itemnumber = ?", undef, ( $borrowernumber, $itemnumber ) );
1977
    }
1974
}
1978
}
1975
1979
1976
=head2 _debar_user_on_return
1980
=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 212-217 $template->param( Link Here
212
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
212
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
213
    subtitle            => $subtitle,
213
    subtitle            => $subtitle,
214
    hidepatronname      => $hidepatronname,
214
    hidepatronname      => $hidepatronname,
215
    StoreLastBorrower   => C4::Context->preference('StoreLastBorrower'),
215
);
216
);
216
$template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items );
217
$template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items );
217
218
(-)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 1043-1048 CREATE TABLE `items` ( -- holdings/item information Link Here
1043
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1045
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1044
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1046
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1045
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1047
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1048
  `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item
1046
  `stack` tinyint(1) default NULL,
1049
  `stack` tinyint(1) default NULL,
1047
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1050
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1048
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1051
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
Lines 1081-1086 CREATE TABLE `items` ( -- holdings/item information Link Here
1081
  KEY `itemcallnumber` (`itemcallnumber`),
1084
  KEY `itemcallnumber` (`itemcallnumber`),
1082
  KEY `items_location` (`location`),
1085
  KEY `items_location` (`location`),
1083
  KEY `items_ccode` (`ccode`),
1086
  KEY `items_ccode` (`ccode`),
1087
  KEY `last_returned_by` (`last_returned_by`),
1084
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1088
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1085
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1089
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1086
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
1090
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 420-422 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
420
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short');
420
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short');
421
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','1','Enable or disable the ability to use Koha Plugins.','','YesNo');
421
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','1','Enable or disable the ability to use Koha Plugins.','','YesNo');
422
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice');
422
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice');
423
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 6661-6666 if ( CheckVersion($DBversion) ) { Link Here
6661
   SetVersion ($DBversion);
6661
   SetVersion ($DBversion);
6662
}
6662
}
6663
6663
6664
$DBversion = "3.11.00.XXX";
6665
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6666
   $dbh->do("ALTER TABLE items ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
6667
   $dbh->do("ALTER TABLE items ADD INDEX ( last_returned_by )");
6668
   $dbh->do("ALTER TABLE items ADD FOREIGN KEY ( last_returned_by ) REFERENCES  borrowers ( borrowernumber )");
6669
6670
   $dbh->do("ALTER TABLE deleteditems ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
6671
   $dbh->do("ALTER TABLE deleteditems ADD INDEX ( last_returned_by )");
6672
   $dbh->do("ALTER TABLE deleteditems ADD FOREIGN KEY ( last_returned_by ) REFERENCES  borrowers ( borrowernumber )");
6673
6674
   $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')");
6675
6676
   print "Upgrade to $DBversion done ( Add syspref StoreLastBorrower )\n";
6677
   SetVersion ($DBversion);
6678
}
6664
6679
6665
=head1 FUNCTIONS
6680
=head1 FUNCTIONS
6666
6681
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 533-538 OPAC: Link Here
533
                  track: "Track"
533
                  track: "Track"
534
                  no: "Don't track"
534
                  no: "Don't track"
535
            - links that patrons click on
535
            - links that patrons click on
536
        -
537
            - pref: StoreLastBorrower
538
              default: 0
539
              choices:
540
                  yes: Store
541
                  no: "Don't store"
542
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
536
543
537
    Shelf Browser:
544
    Shelf Browser:
538
        -
545
        -
(-)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