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

(-)a/C4/Circulation.pm (+4 lines)
Lines 2001-2006 sub MarkIssueReturned { Link Here
2001
                                  WHERE borrowernumber = ?
2001
                                  WHERE borrowernumber = ?
2002
                                  AND itemnumber = ?");
2002
                                  AND itemnumber = ?");
2003
    $sth_del->execute($borrowernumber, $itemnumber);
2003
    $sth_del->execute($borrowernumber, $itemnumber);
2004
2005
    if ( C4::Context->preference('StoreLastBorrower') ) {
2006
        $dbh->do("UPDATE items SET last_returned_by = ? WHERE itemnumber = ?", undef, ( $borrowernumber, $itemnumber ) );
2007
    }
2004
}
2008
}
2005
2009
2006
=head2 _debar_user_on_return
2010
=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
$template->{'VARS'}->{'searchid'} = $query->param('searchid');
218
$template->{'VARS'}->{'searchid'} = $query->param('searchid');
(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 862-867 CREATE TABLE `deleteditems` ( Link Here
862
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
862
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
863
  `datelastborrowed` date default NULL, -- the date the item was last checked out
863
  `datelastborrowed` date default NULL, -- the date the item was last checked out
864
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
864
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
865
  `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item
865
  `stack` tinyint(1) default NULL,
866
  `stack` tinyint(1) default NULL,
866
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
867
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
867
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
868
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
Lines 899-904 CREATE TABLE `deleteditems` ( Link Here
899
  KEY `delhomebranch` (`homebranch`),
900
  KEY `delhomebranch` (`homebranch`),
900
  KEY `delholdingbranch` (`holdingbranch`),
901
  KEY `delholdingbranch` (`holdingbranch`),
901
  KEY `itype_idx` (`itype`)
902
  KEY `itype_idx` (`itype`)
903
  KEY `del_last_returned_by` (`last_returned_by`)
902
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
904
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
903
905
904
--
906
--
Lines 1154-1159 CREATE TABLE `items` ( -- holdings/item information Link Here
1154
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1156
  `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1155
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1157
  `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1156
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1158
  `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1159
  `last_returned_by` int(11) DEFAULT NULL, -- the last borrower to return an item
1157
  `stack` tinyint(1) default NULL,
1160
  `stack` tinyint(1) default NULL,
1158
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1161
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1159
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1162
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
Lines 1193-1198 CREATE TABLE `items` ( -- holdings/item information Link Here
1193
  KEY `items_location` (`location`),
1196
  KEY `items_location` (`location`),
1194
  KEY `items_ccode` (`ccode`),
1197
  KEY `items_ccode` (`ccode`),
1195
  KEY `itype_idx` (`itype`),
1198
  KEY `itype_idx` (`itype`),
1199
  KEY `last_returned_by` (`last_returned_by`),
1196
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1200
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1197
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1201
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1198
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
1202
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 430-432 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V Link Here
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
433
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 (+14 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7072
   $dbh->do("ALTER TABLE items ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
7073
   $dbh->do("ALTER TABLE items ADD INDEX ( last_returned_by )");
7074
7075
   $dbh->do("ALTER TABLE deleteditems ADD last_returned_by INT( 11 ) NULL DEFAULT NULL AFTER datelastseen");
7076
   $dbh->do("ALTER TABLE deleteditems ADD INDEX ( last_returned_by )");
7077
7078
   $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')");
7079
7080
   print "Upgrade to $DBversion done ( Add syspref StoreLastBorrower )\n";
7081
   SetVersion ($DBversion);
7082
}
7083
7070
=head1 FUNCTIONS
7084
=head1 FUNCTIONS
7071
7085
7072
=head2 TableExists($table)
7086
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 551-556 OPAC: Link Here
551
                  track: "Track"
551
                  track: "Track"
552
                  no: "Don't track"
552
                  no: "Don't track"
553
            - links that patrons click on
553
            - links that patrons click on
554
        -
555
            - pref: StoreLastBorrower
556
              default: 0
557
              choices:
558
                  yes: Store
559
                  no: "Don't store"
560
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
554
561
555
    Shelf Browser:
562
    Shelf Browser:
556
        -
563
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (+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 212-217 Link Here
212
213
213
                <li><span class="label">Last seen:</span>[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %]&nbsp;</li>
214
                <li><span class="label">Last seen:</span>[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %]&nbsp;</li>
214
                <li><span class="label">Last borrowed:</span>[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %]&nbsp;</li>
215
                <li><span class="label">Last borrowed:</span>[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %]&nbsp;</li>
216
                [% 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 %]
215
                [% 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 %]
217
                [% 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 %]
216
                [% 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 %]
218
                [% 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 %]
217
                [% 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 %]
219
                [% 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 %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt (+2 lines)
Lines 61-66 Link Here
61
            <input type="submit" value="Immediate deletion" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
61
            <input type="submit" value="Immediate deletion" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
62
        </form>
62
        </form>
63
    [% END %]
63
    [% END %]
64
65
        [% IF StoreLastBorrower %]<p>Please note, the last person to return an item is tracked for the management of items returned damaged.</p>[% END %]
64
    </div>
66
    </div>
65
</div>
67
</div>
66
</div>
68
</div>
(-)a/opac/opac-privacy.pl (-1 / +1 lines)
Lines 68-73 $template->param( 'Ask_data' => '1', Link Here
68
                    'firstname' => $borr->{'firstname'},
68
                    'firstname' => $borr->{'firstname'},
69
                    'surname' => $borr->{'surname'},
69
                    'surname' => $borr->{'surname'},
70
                    'privacyview' => 1,
70
                    'privacyview' => 1,
71
    'StoreLastBorrower' => C4::Context->preference('StoreLastBorrower'),
71
);
72
);
72
73
73
output_html_with_http_headers $query, $cookie, $template->output;
74
output_html_with_http_headers $query, $cookie, $template->output;
74
- 

Return to bug 9011