Bugzilla – Attachment 94395 Details for
Bug 23838
Add ability to view item renew history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23838: Add renewals modal
Bug-23838-Add-renewals-modal.patch (text/plain), 7.94 KB, created by
Andrew Isherwood
on 2019-10-18 08:59:39 UTC
(
hide
)
Description:
Bug 23838: Add renewals modal
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2019-10-18 08:59:39 UTC
Size:
7.94 KB
patch
obsolete
>From 4601c2f4274c87837dfd87b5b25c05962b181d9a Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 18 Oct 2019 08:56:21 +0100 >Subject: [PATCH] Bug 23838: Add renewals modal > >This patch adds the display of the renewals modal when appropriate. A >"View" link is displayed next to renewals that have logs associated with >them. Clicking the link opens the modal that displays the logged >renewals. >--- > .../en/includes/patron-renewal-modal-strings.inc | 7 ++++++ > .../prog/en/includes/patron-renewal-modal.inc | 18 +++++++++++++++ > .../prog/en/modules/members/readingrec.tt | 11 ++++++++- > .../intranet-tmpl/prog/js/patron-renewal-modal.js | 26 ++++++++++++++++++++++ > members/readingrec.pl | 20 +++++++++++++++++ > 5 files changed, 81 insertions(+), 1 deletion(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal-strings.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/patron-renewal-modal.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal-strings.inc >new file mode 100644 >index 0000000000..c13e6bb8b7 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal-strings.inc >@@ -0,0 +1,7 @@ >+<script> >+ var note = _("Note"); >+ var out_of = _("out of"); >+ var renewals_logged = _("renewals have been logged") >+ var renewed_on = _("Renewed on"); >+ var by = _("by"); >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal.inc >new file mode 100644 >index 0000000000..096759e68a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-renewal-modal.inc >@@ -0,0 +1,18 @@ >+<div id="patronRenewals" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="patronRenewalsLabel" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="patronRenewalsLabel"> Item renewals</h3> >+ </div> >+ <div class="modal-body"> >+ <div id="retrieving" class="alert" style="display:none">Retrieving renewals...</div> >+ <div id="incomplete" class="alert" style="display:none"></div> >+ <ul id="results" style="display:none"></ul> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> >+ </div> >+</div> >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..7c94072207 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >@@ -87,7 +87,13 @@ > </td> > > <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% issue.itemnumber | uri %]&biblionumber=[% issue.biblionumber | uri %]&bi=[% issue.biblioitemnumber | uri %]#item[% issue.itemnumber | uri %]">[% issue.barcode | html %]</a></td> >- <td>[% issue.renewals | html %]</td> >+ <td> >+ [% issue.renewals | html %] >+ [% itemid = issue.itemnumber %] >+ [% IF logged_items.$itemid %] >+ [ <a class="patron_renewals_view" data-renewals=[% issue.renewals | html %] data-itemid="[% itemid | html %]" data-patronid="[% patron.borrowernumber | html %]" href="#">View</a> ] >+ [% END %] >+ </td> > <td> > <span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates with_hours => 1 %]</span> > </td> >@@ -129,6 +135,9 @@ > [% Asset.js("js/members-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'columns_settings.inc' %] >+ [% INCLUDE 'patron-renewal-modal.inc' %] >+ [% INCLUDE 'patron-renewal-modal-strings.inc' %] >+ [% Asset.js("js/patron-renewal-modal.js") | $raw %] > <script id="js"> > $(document).ready(function() { > var columns_settings = [% ColumnsSettings.GetColumns('members', 'checkouthistory', 'checkouthistory-table', 'json') %]; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/patron-renewal-modal.js b/koha-tmpl/intranet-tmpl/prog/js/patron-renewal-modal.js >new file mode 100644 >index 0000000000..21733feca7 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/patron-renewal-modal.js >@@ -0,0 +1,26 @@ >+$(document).ready(function(){ >+ // Display the modal containing patron renewals details >+ $('.patron_renewals_view').on('click', function(e) { >+ e.preventDefault(); >+ $('#patronRenewals #incomplete').html('').hide(); >+ $('#patronRenewals #results').html('').hide(); >+ $('#patronRenewals').modal({show:true}); >+ var renewals = $(this).data('renewals'); >+ var itemid = $(this).data('itemid'); >+ var patronid = $(this).data('patronid'); >+ $('#patronRenewals #retrieving').show(); >+ $.get('/api/v1/patrons/'+patronid+'/renewals?item_id='+itemid+'&embed=patron,renewed_by', function(data) { >+ if (data.length < renewals) { >+ $('#patronRenewals #incomplete').append(note + ': ' + data.length + ' ' + out_of + ' ' + renewals + ' ' + renewals_logged).show(); >+ } >+ var items = data.map(function(item) { >+ return createLi(item); >+ }); >+ $('#patronRenewals #retrieving').hide(); >+ $('#patronRenewals #results').append(items).show(); >+ }); >+ }); >+ function createLi(renewal) { >+ return '<li>' + renewed_on + ' <span style="font-weight:bold">' + renewal.timestamp + '</span> ' + by + ' <span style="font-weight:bold">' + renewal.renewed_by.firstname + ' ' + renewal.renewed_by.surname + '</li>'; >+ } >+}); >diff --git a/members/readingrec.pl b/members/readingrec.pl >index 7dd71f8fce..bc84fe9452 100755 >--- a/members/readingrec.pl >+++ b/members/readingrec.pl >@@ -25,10 +25,12 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > > use C4::Auth; >+use C4::Context; > use C4::Output; > use C4::Members; > use List::MoreUtils qw/any uniq/; > use Koha::DateUtils; >+use Koha::ActionLogs; > > use Koha::Patrons; > use Koha::Patron::Categories; >@@ -60,6 +62,7 @@ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log > my $order = 'date_due desc'; > my $limit = 0; > my $issues = (); >+my $logged_item_ids = {}; > # Do not request the old issues of anonymous patron > if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){ > # use of 'eq' in the above comparison is intentional -- the >@@ -67,6 +70,22 @@ if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){ > $template->param( is_anonymous => 1 ); > } else { > $issues = GetAllIssues($patron->borrowernumber,$order,$limit); >+ # Establish if: >+ # a) renewal logging is turned on >+ # b) which of the issued items have corresponding renewal logs in the >+ # action logs >+ # This will determine whether we should show the "View" renewals link >+ # A hashref of all log entries relating to renewals - ensures each item >+ # id only appears once, it also aids lookup >+ if (C4::Context->preference("RenewalLog")) { >+ my $patron_renew_logs = Koha::ActionLogs->search( >+ { object => $patron->borrowernumber, action => 'RENEWAL' }, >+ { columns => [ qw/info/ ] } >+ )->unblessed; >+ foreach my $log(@{$patron_renew_logs}) { >+ $logged_item_ids->{$log->{info}} = 1; >+ } >+ } > } > > # barcode export >@@ -99,6 +118,7 @@ $template->param( > patron => $patron, > readingrecordview => 1, > loop_reading => $issues, >+ logged_items => $logged_item_ids > ); > output_html_with_http_headers $input, $cookie, $template->output; > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23838
:
94394
|
94395
|
94635
|
94636
|
94663
|
94664
|
94676
|
94681
|
94682
|
94683
|
94684
|
94685
|
95466
|
95467
|
95468
|
95469
|
95470
|
95471
|
95472
|
96186
|
96187
|
96188
|
96189
|
96190
|
131892
|
131914
|
131915
|
133945
|
133946
|
133966
|
133967
|
133968
|
134890
|
134891
|
134892
|
137167
|
137168
|
137169
|
138007
|
138019
|
138020
|
138021
|
138022
|
138039
|
138040
|
138041
|
138042
|
138043