Bugzilla – Attachment 126627 Details for
Bug 29275
Use the API to render checkout history for a biblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29275: Use the API to fetch checkouts information
Bug-29275-Use-the-API-to-fetch-checkouts-informati.patch (text/plain), 15.86 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-20 21:36:10 UTC
(
hide
)
Description:
Bug 29275: Use the API to fetch checkouts information
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-20 21:36:10 UTC
Size:
15.86 KB
patch
obsolete
>From e89a3d25eba62bef0e9b6029da0c8c02cc40b6db Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 20 Oct 2021 18:18:33 -0300 >Subject: [PATCH] Bug 29275: Use the API to fetch checkouts information > >This patch changes issuehistory.pl so it leverages on the API for >fetching checkouts information in the template. > >Workflow changes: This development splits the 'current' checkouts and >the 'past' checkouts in two different tables. > >Terminology could be revisited by native english speakers. > >To test: >1. Have records with and without current/past checkouts >2. Notice how the Checkouts history tab presents the information on each > case. >=> SUGGESTION: Keep each of them open on separate tabs for comparing >3. Apply this patchset and its dependencies >4. Restart plack, run: > $ koha-plack --restart kohadev >5. Follow the same steps you followed for those open tabs, in new ones >=> SUCCESS: What you see makes sense, information is displayed as it >used to, with the different tables now. >6. Try searching on the datatables >=> SUCCESS: Search works correctly! >7. Revisit the new texts I added >=> SUGGESTION: If you have better wordings, submit a patch, or just >comment on the bug so I do it inline. >8. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > catalogue/issuehistory.pl | 29 +- > .../prog/en/modules/catalogue/issuehistory.tt | 277 +++++++++++++----- > 2 files changed, 211 insertions(+), 95 deletions(-) > >diff --git a/catalogue/issuehistory.pl b/catalogue/issuehistory.pl >index 8d17dc933a..add7cb2d40 100755 >--- a/catalogue/issuehistory.pl >+++ b/catalogue/issuehistory.pl >@@ -24,8 +24,6 @@ use C4::Output qw( output_html_with_http_headers ); > > use C4::Search qw( enabled_staff_search_views ); > use C4::Serials qw( CountSubscriptionFromBiblionumber ); >-use Koha::Checkouts; >-use Koha::Old::Checkouts; > > use Koha::Biblios; > >@@ -40,29 +38,18 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > ); > > my $biblionumber = $query->param('biblionumber'); >+my $biblio = Koha::Biblios->find($biblionumber); > >-my @checkouts = Koha::Checkouts->search( >- { biblionumber => $biblionumber }, >- { >- join => 'item', >- order_by => 'timestamp', >- } >-); >-my @old_checkouts = Koha::Old::Checkouts->search( >- { biblionumber => $biblionumber }, >- { >- join => 'item', >- order_by => 'timestamp', >- } >+$template->param( >+ current_checkouts_count => $biblio->current_checkouts->count, >+ past_checkouts_count => $biblio->old_checkouts->count, >+ biblio => $biblio, > ); > >-my $biblio = Koha::Biblios->find( $biblionumber ); >- >+# variables for biblio-view-menu.inc > $template->param( >- checkouts => [ @checkouts, @old_checkouts ], >- biblio => $biblio, >- issuehistoryview => 1, >- C4::Search::enabled_staff_search_views, >+ issuehistoryview => 1, >+ C4::Search::enabled_staff_search_views, > subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber), > ); > >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 ca7cf67acb..af99c8282b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt >@@ -45,75 +45,64 @@ > [% SET show_patron_column = Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %] > > <div class="searchresults"> >- [% IF checkouts %] >- <h4>Checked out [% checkouts.size | html %] times</h4> >- <table id="table_issues"> >- <thead><tr> >- [% IF show_patron_column %] >+[% IF current_checkouts_count + past_checkouts_count > 0 %] >+ <h3>Checked out [% current_checkouts_count + past_checkouts_count | html %] times</h3> >+ >+ <h4>Current checkouts</h4> >+[% IF current_checkouts_count > 0 %] >+ <table id="current_checkouts"> >+ <thead><tr> >+ [% IF show_patron_column %] > <th>Patron</th> >- [% END %] >+ [% END %] > <th>Barcode</th> > <th>Checked out from</th> >- [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >+ [% IF Koha.Preference('RecordStaffUserOnCheckout') %] > <th>Checked out by</th> >- [% END %] >+ [% END %] > <th>Renewed</th> > <th>Checkout on</th> > <th>Due date</th> >- <th>Checkin on</th> >- </tr></thead> >- <tbody> >- [% FOREACH checkout IN checkouts %] >- <tr> >- [% IF show_patron_column %] >- <td> >- [% IF checkout.patron %][%# Not set for deleted patron records %] >- [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %] >- [% END %] >- </td> >- [% END %] >- <td> >- [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %] >- <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% checkout.item.biblionumber | uri %]&itemnumber=[% checkout.item.itemnumber | uri %]">[% checkout.item.barcode | html %]</a> >- [% ELSE %] >- >- [% END %]</td> >- <td>[% IF checkout.branchcode %] >- [% Branches.GetName( checkout.branchcode ) | html %] >- [% ELSE %] >- >- [% END %]</td> >- [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >- <td>[% IF checkout.issuer_id %] >- <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer_id | uri %]"> >- [% INCLUDE 'patron-title.inc' patron=checkout.issuer %] >- </a> >- [% END %]</td> >- [% END %] >- <td>[% IF checkout.renewals %] >- Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1 %]</small> >- [% END %] >- [% ELSE %] >- No >- [% END %]</td> >- <td data-order="[% checkout.issuedate | html %]"> >- [% checkout.issuedate |$KohaDates with_hours => 1 %] >- </td> >- <td data-order="[% checkout.date_due | html %]"> >- [% checkout.date_due |$KohaDates with_hours => 1 %] >- </td> >- <td data-order="[% checkout.returndate | html %]"> >- [% checkout.returndate |$KohaDates with_hours => 1 %] >- </td> >- </tr> >+ </tr></thead> >+ </table> >+[% ELSE %] >+ <div class="dialog message"> >+ <p>Not currently checked out.</p> >+ </div> >+[% END %] >+ >+ <h4>Past checkouts</h4> >+ >+[% IF past_checkouts_count > 0 %] >+ <table id="old_checkouts"> >+ <thead><tr> >+ [% IF show_patron_column %] >+ <th>Patron</th> >+ [% END %] >+ <th>Barcode</th> >+ <th>Checked out from</th> >+ [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >+ <th>Checked out by</th> > [% END %] >- </tbody> >- </table> >- [% ELSE %] >- <div class="dialog message"><p> >- <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out.</p></div> >+ <th>Renewed</th> >+ <th>Checkout on</th> >+ <th>Due date</th> >+ <th>Checkin on</th> >+ </tr></thead> >+ </table> >+[% ELSE %] >+ <div class="dialog message"> >+ <p>No past checkouts.</p> >+ </div> >+[% END %] > >- [% END %] >+[% ELSE %] >+ <div class="dialog message"> >+ <p> >+ <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out. >+ </p> >+ </div> >+[% END %] > </div> > > </main> >@@ -129,22 +118,162 @@ > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'columns_settings.inc' %] >+[% INCLUDE 'js-date-format.inc' %] >+[% INCLUDE 'js-patron-format.inc' %] > <script id="js"> > $(document).ready(function() { >- var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'checkoutshistory-table', 'json') %]; >- [% UNLESS show_patron_column %] >- // Remove the patron column definition >- columns_settings.splice(0,1); >- [% END %] >- var table = KohaTable("table_issues", { >- "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', >- [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >- "aaSorting": [[ 5, "desc" ]], >- [% ELSE %] >- "aaSorting": [[ 4, "desc" ]], >- [% END %] >- "sPaginationType": "full_numbers" >- }, columns_settings); >+ var show_patron_column = [% IF show_patron_column %]1[% ELSE %]0[% END %]; >+ var show_issuer_column = [% IF Koha.Preference('RecordStaffUserOnCheckout') %]1[% ELSE %]0[% END %]; >+ var default_sort_column = 3 + show_patron_column + show_issuer_column; >+ var current_checkouts = $("#current_checkouts").api({ >+ "ajax": { >+ "url": '/api/v1/biblios/[% biblio.biblionumber | uri %]/checkouts' >+ }, >+ "header_filter": true, >+ "embed": [ >+ "issuer", >+ "item", >+ "library", >+ "patron" >+ ], >+ "order": [ [ default_sort_column, "desc" ] ], >+ "columns": [ >+ [% IF show_patron_column %] >+ { >+ "data": "patron.firstname:patron.surname:patron.cardnumber", >+ "render": function(data, type, row, meta) { >+ return $patron_to_html( row.patron, { display_cardnumber: true, url: true } ); >+ } >+ }, >+ [% END %] >+ { >+ "data": "item.external_id", >+ "render": function(data, type, row, meta) { >+ if ( data != null ) { >+ return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+row.item.biblio_id+'&itemnumber='+row.item_id+'">'+row.item.external_id + '</a>'; >+ } >+ else { >+ return ''; >+ } >+ } >+ }, >+ { >+ "data": "library.name", >+ "render": function(data) { >+ return escape_str(data); >+ } >+ }, >+ [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >+ { >+ "data": "issuer.firstname:issuer.surname:issuer.cardnumber", >+ "render": function(data, type, row, meta) { >+ return (row.issuer) ? $patron_to_html( row.issuer, { display_cardnumber: true, url: true } ) : ''; >+ } >+ }, >+ [% END %] >+ { >+ "data": "renewals", >+ "render": function( data, type, row ) { >+ var res = ( data > 0 ) ? _("Yes") : _("No"); >+ if ( data > 0 && row.last_renewed_date != null ) { >+ res += ', <small>' + _("last on:") + ' ' + $datetime(row.last_renewed_date) + '</small>'; >+ } >+ >+ return res; >+ } >+ }, >+ { >+ "data": "checkout_date", >+ "render": function(data) { >+ return $datetime(data); >+ } >+ }, >+ { >+ "data": "due_date", >+ "render": function(data) { >+ return $datetime(data); >+ } >+ } >+ ] >+ }); >+ >+ var old_checkouts = $("#old_checkouts").api({ >+ "ajax": { >+ "url": '/api/v1/biblios/[% biblio.biblionumber | uri %]/checkouts?checked_in=1' >+ }, >+ "header_filter": true, >+ "embed": [ >+ "issuer", >+ "item", >+ "library", >+ "patron" >+ ], >+ "order": [ [ default_sort_column, "desc" ] ], >+ "columns": [ >+ [% IF show_patron_column %] >+ { >+ "data": "patron.firstname:patron.surname:patron.cardnumber", >+ "render": function(data, type, row, meta) { >+ return $patron_to_html( row.patron, { display_cardnumber: true, url: true } ); >+ } >+ }, >+ [% END %] >+ { >+ "data": "item.external_id", >+ "render": function(data, type, row, meta) { >+ if ( data != null ) { >+ return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+encodeURIComponent(row.item.biblio_id)+'&itemnumber='+row.item_id+'">'+row.item.external_id + '</a>'; >+ } >+ else { >+ return ''; >+ } >+ } >+ }, >+ { >+ "data": "library.name", >+ "render": function(data) { >+ return escape_str(data); >+ } >+ }, >+ [% IF Koha.Preference('RecordStaffUserOnCheckout') %] >+ { >+ "data": "issuer.firstname:issuer.surname:issuer.cardnumber", >+ "render": function(data, type, row, meta) { >+ return (row.issuer) ? $patron_to_html( row.issuer, { display_cardnumber: true, url: true } ) : ''; >+ } >+ }, >+ [% END %] >+ { >+ "data": "renewals", >+ "render": function( data, type, row ) { >+ var res = ( data > 0 ) ? _("Yes") : _("No"); >+ if ( data > 0 && row.last_renewed_date != null ) { >+ res += ', <small>' + _("last on:") + ' ' + $datetime(row.last_renewed_date) + '</small>'; >+ } >+ >+ return res; >+ } >+ }, >+ { >+ "data": "checkout_date", >+ "render": function(data) { >+ return $datetime(data); >+ } >+ }, >+ { >+ "data": "due_date", >+ "render": function(data) { >+ return $datetime(data); >+ } >+ }, >+ { >+ "data": "checkin_date", >+ "render": function(data) { >+ return $datetime(data); >+ } >+ } >+ ] >+ }); > }); > </script> > [% END %] >-- >2.32.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 29275
:
126626
|
126627
|
126628
|
126634
|
126635
|
126636
|
127701
|
127702
|
127703
|
127704
|
127894
|
127895
|
127896
|
127897
|
128001
|
128002
|
128003
|
131333
|
131334
|
131335