Bug 23916: Record and display item issuer

This patch adds the recording and display of the item issuer. This
behaviour is governed by the RecordIssuer syspref, if disabled (the
default), no recording or display of issuer will take place.

Signed-off-by: Ben Veasey <B.T.Veasey@lboro.ac.uk>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Andrew Isherwood 2020-03-02 11:04:59 +00:00 committed by Jonathan Druart
parent d01f78e2d5
commit eb283d13fa
5 changed files with 46 additions and 2 deletions

View File

@ -1520,6 +1520,17 @@ sub AddIssue {
auto_renew => $auto_renew ? 1 : 0,
};
# Get ID of logged in user. if called from a batch job,
# no user session exists and C4::Context->userenv() returns
# the scalar '0'. Only do this is the syspref says so
if ( C4::Context->preference('RecordIssuer') ) {
my $userenv = C4::Context->userenv();
my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
if ($usernumber) {
$issue_attributes->{issuer} = $usernumber;
}
}
# In the case that the borrower has an on-site checkout
# and SwitchOnSiteCheckouts is enabled this converts it to a regular checkout
$issue = Koha::Checkouts->find( { itemnumber => $item_object->itemnumber } );

View File

@ -276,16 +276,18 @@ sub GetAllIssues {
'SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
FROM issues
LEFT JOIN items on items.itemnumber=issues.itemnumber
LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
WHERE borrowernumber=?
WHERE issues.borrowernumber=?
UNION ALL
SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
FROM old_issues
LEFT JOIN items on items.itemnumber=old_issues.itemnumber
LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
WHERE borrowernumber=? AND old_issues.itemnumber IS NOT NULL
WHERE old_issues.borrowernumber=? AND old_issues.itemnumber IS NOT NULL
order by ' . $order;
if ($limit) {
$query .= " limit $limit";

View File

@ -106,6 +106,20 @@ sub patron {
return Koha::Patron->_new_from_dbic( $patron_rs );
}
=head3 issued_by
my $issued_by = $checkout->issued_by
Return the patron by whom the checkout was done
=cut
sub issued_by {
my ( $self ) = @_;
my $issued_by_rs = $self->_result->issuer;
return Koha::Patron->_new_from_dbic( $issued_by_rs );
}
=head3 to_api_mapping
This method returns the mapping for representing a Koha::Checkout object
@ -117,6 +131,7 @@ sub to_api_mapping {
return {
issue_id => 'checkout_id',
borrowernumber => 'patron_id',
issuer => 'issuer_id',
itemnumber => 'item_id',
date_due => 'due_date',
branchcode => 'library_id',

View File

@ -37,6 +37,9 @@
[% END %]
<th>Barcode</th>
<th>Checked out from</th>
[% IF Koha.Preference('RecordIssuer') %]
<th>Checked out by</th>
[% END %]
<th>Renewed</th>
<th class='title-string'>Checkout on</th>
<th class='title-string'>Due date</th>
@ -63,6 +66,13 @@
[% ELSE %]
&nbsp;
[% END %]</td>
[% IF Koha.Preference('RecordIssuer') %]
<td>[% IF checkout.issuer %]
<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer | uri %]">
[% checkout.issued_by.firstname | html %] [% checkout.issued_by.surname | html %]
</a>
[% END %]</td>
[% END %]
<td>[% IF checkout.renewals %]
Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1 %]</small>
[% END %]

View File

@ -58,6 +58,9 @@
<th>Number of renewals</th>
<th class="title-string">Checked out on</th>
<th>Checked out from</th>
[% IF Koha.Preference('RecordIssuer') %]
<th>Checked out by</th>
[% END %]
<th class="title-string">Date due</th>
<th class="title-string">Return date</th>
</tr>
@ -94,6 +97,9 @@
<span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates with_hours => 1 %]</span>
</td>
<td>[% Branches.GetName( issue.branchcode ) | html %]</td>
[% IF Koha.Preference('RecordIssuer') %]
<td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
[% END %]
<td>
[% IF issue.date_due %]
<span title="[% issue.date_due | html %]">[% issue.date_due |$KohaDates with_hours => 1 %]</span>