From 4d309effcdf59113e5d4e0161c6314398250566b Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 31 Oct 2019 10:35:15 +0000 Subject: [PATCH] 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 --- C4/Circulation.pm | 11 +++++++++++ C4/Members.pm | 6 ++++-- Koha/Checkout.pm | 15 +++++++++++++++ Koha/Illbackends/BLDSS | 1 + Koha/Illbackends/FreeForm | 1 + .../prog/en/modules/catalogue/issuehistory.tt | 10 ++++++++++ .../intranet-tmpl/prog/en/modules/members/readingrec.tt | 6 ++++++ 7 files changed, 48 insertions(+), 2 deletions(-) create mode 120000 Koha/Illbackends/BLDSS create mode 120000 Koha/Illbackends/FreeForm diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c3629c2472..6a8519e691 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1418,6 +1418,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; + } + } + $issue = Koha::Checkouts->find( { itemnumber => $item_object->itemnumber } ); if ($issue) { $issue->set($issue_attributes)->store; diff --git a/C4/Members.pm b/C4/Members.pm index eb5dbfb4e2..c0e103c40e 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -277,16 +277,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"; diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index f789de6d8d..830d086202 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -90,6 +90,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 @@ -101,6 +115,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', diff --git a/Koha/Illbackends/BLDSS b/Koha/Illbackends/BLDSS new file mode 120000 index 0000000000..95e9e7ea7f --- /dev/null +++ b/Koha/Illbackends/BLDSS @@ -0,0 +1 @@ +/home/koha-koha/illbackends/BLDSS \ No newline at end of file diff --git a/Koha/Illbackends/FreeForm b/Koha/Illbackends/FreeForm new file mode 120000 index 0000000000..05911ec0ff --- /dev/null +++ b/Koha/Illbackends/FreeForm @@ -0,0 +1 @@ +/home/koha-koha/illbackends/FreeForm \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt index 9320d9251a..2e08809249 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -37,6 +37,9 @@ [% END %] Barcode Checked out from + [% IF Koha.Preference('RecordIssuer') %] + Checked out by + [% END %] Renewed Checkout on Due date @@ -63,6 +66,13 @@ [% ELSE %]   [% END %] + [% IF Koha.Preference('RecordIssuer') %] + [% IF checkout.issuer %] + + [% checkout.issued_by.firstname | html %] [% checkout.issued_by.surname | html %] + + [% END %] + [% END %] [% IF checkout.renewals %] Yes[% IF checkout.lastreneweddate %], last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1 %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt index 6d7ae6b829..a7d3a0b7aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt @@ -58,6 +58,9 @@ Number of renewals Checked out on Checked out from + [% IF Koha.Preference('RecordIssuer') %] + Checked out by + [% END %] Date due Return date @@ -92,6 +95,9 @@ [% issue.issuedate |$KohaDates with_hours => 1 %] [% Branches.GetName( issue.branchcode ) | html %] + [% IF Koha.Preference('RecordIssuer') %] + [% issue.firstname | html %] [% issue.surname | html %] + [% END %] [% IF issue.date_due %] [% issue.date_due |$KohaDates with_hours => 1 %] -- 2.11.0