Bugzilla – Attachment 130609 Details for
Bug 30063
Make the main patron search use the /patrons REST API route
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30063: Overdues count
Bug-30063-Overdues-count.patch (text/plain), 5.37 KB, created by
Jonathan Druart
on 2022-02-15 10:31:15 UTC
(
hide
)
Description:
Bug 30063: Overdues count
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-15 10:31:15 UTC
Size:
5.37 KB
patch
obsolete
>From e4ccf73422b9764d0cd9e1d88b4c6f629e87beb9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 11 Feb 2022 10:58:14 +0100 >Subject: [PATCH] Bug 30063: Overdues count > >--- > Koha/Patron.pm | 8 +++++ > api/v1/swagger/definitions/patron.yaml | 10 ++++++ > api/v1/swagger/paths/patrons.yaml | 2 ++ > .../prog/en/includes/patron-search.inc | 31 +++++++++++++++++-- > 4 files changed, 49 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 9968d363505..416e1a3f155 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1206,6 +1206,8 @@ sub get_overdues { > ); > } > >+sub overdues { my $self = shift; return $self->get_overdues(@_); } >+ > =head3 get_routing_lists > > my $routinglists = $patron->get_routing_lists >@@ -2054,6 +2056,12 @@ sub safe_to_delete { > return Koha::Result::Boolean->new(1); > } > >+sub account_balance { >+ my ($self) = @_; >+ return $self->account->balance; >+} >+ >+ > =head2 Internal methods > > =head3 _type >diff --git a/api/v1/swagger/definitions/patron.yaml b/api/v1/swagger/definitions/patron.yaml >index d23129b1add..77b1cb03955 100644 >--- a/api/v1/swagger/definitions/patron.yaml >+++ b/api/v1/swagger/definitions/patron.yaml >@@ -333,6 +333,16 @@ properties: > - integer > - "null" > description: Number of checkouts >+ overdues_count: >+ type: >+ - integer >+ - "null" >+ description: Number of overdued checkouts >+ account_balance: >+ type: >+ - number >+ - "null" >+ description: Balance of the patron's account > additionalProperties: false > required: > - surname >diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml >index 17fe506fffb..b3be0826588 100644 >--- a/api/v1/swagger/paths/patrons.yaml >+++ b/api/v1/swagger/paths/patrons.yaml >@@ -386,6 +386,8 @@ > x-koha-embed: > - extended_attributes > - checkouts+count >+ - overdues+count >+ - account_balance > post: > x-mojo-to: Patrons#add > operationId: addPatron >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 3f8e6752eee..8efb1e2a290 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -106,6 +106,7 @@ > [% CASE 'borrowernotes' %]<th>Notes</th> > [% CASE 'phone' %]<th>Phone</th> > [% CASE 'checkouts' %]<th>Checkouts</th> >+ [% CASE 'account_balance' %]<th>Fines</th> > [% CASE 'action' %]<th> </th> > [% END %] > [% END %] >@@ -225,7 +226,7 @@ > return json.data; > } > }, >- embed: ['extended_attributes', 'checkouts+count'], >+ embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'], > "drawCallback": function( settings ) { > var api = this.api(); > var data = api.data(); >@@ -385,9 +386,35 @@ > "searchable": false, > "orderable": false, > "render": function( data, type, row, meta ) { >- return escape_str(row.checkouts_count); >+ if ( row.overdues_count ) { >+ return "<span class='overdue'><strong>"+row.overdues_count + "</strong></span>"; >+ } else { >+ return "0 / " + row.checkouts_count; >+ } > } > } >+ [% CASE 'account_balance' %] >+ { >+ "data": "", >+ "searchable": false, >+ "orderable": false, >+ "render": function( data, type, row, meta ) { >+ let r = "<span style='text-align: right; display: block;'><a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber="+row.patron_id+"\">"; >+ let balance_str = row.account_balance || 0; >+ balance_str = balance_str.escapeHtml().format_price(); >+ if ( row.account_balance < 0 ) { >+ // FIXME Format price here >+ r += "<span class='credit'>" + balance_str + "</span>"; >+ } else if ( row.account_balance > 0 ) { >+ r += "<span class='debit'><strong>" + balance_str + "</strong></span>" >+ } else { >+ r += balance_str; >+ } >+ r += "</a></span>"; >+ return r; >+ } >+ } >+ > [% CASE 'action' %] > { > "data": function( row, type, val, meta ) { >-- >2.25.1
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 30063
:
130608
|
130609
|
130610
|
130611
|
130612
|
130613
|
130614
|
130615
|
132387
|
132552
|
132731
|
132732
|
132733
|
132734
|
132735
|
132736
|
132737
|
132738
|
132739
|
132740
|
132741
|
132742
|
132743
|
132744
|
132745
|
132746
|
132747
|
132748
|
132749
|
132759
|
132760
|
132761
|
132762
|
132763
|
132764
|
132765
|
132766
|
132767
|
132768
|
132769
|
132770
|
132771
|
132772
|
132773
|
132774
|
132775
|
132776
|
132777
|
132958