From f3834f7ebe7d537f7c13276f3437d841dc0465bc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Feb 2022 09:39:12 +0100 Subject: [PATCH] Bug 30063: Number of checkouts MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine Queune Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- api/v1/swagger/definitions/patron.yaml | 5 ++++ api/v1/swagger/paths/patrons.yaml | 1 + .../prog/en/includes/patron-search.inc | 30 ++++++++++++++++--- .../prog/en/modules/members/search.tt | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/api/v1/swagger/definitions/patron.yaml b/api/v1/swagger/definitions/patron.yaml index 3d7e60b884..9185b90a51 100644 --- a/api/v1/swagger/definitions/patron.yaml +++ b/api/v1/swagger/definitions/patron.yaml @@ -344,6 +344,11 @@ properties: description: patron's extended attributes items: $ref: "patron_extended_attribute.yaml" + checkouts_count: + type: + - integer + - "null" + description: Number of checkouts additionalProperties: false required: - surname diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index 5b2b953372..7afce6892b 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -385,6 +385,7 @@ - acquisition: "order_manage" x-koha-embed: - extended_attributes + - checkouts+count 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 d088ebc2e5..16681de048 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -105,6 +105,7 @@ [% CASE 'dateexpiry' %]Expires on [% CASE 'borrowernotes' %]Notes [% CASE 'phone' %]Phone + [% CASE 'checkouts' %]Checkouts [% CASE 'action' %]  [% END %] [% END %] @@ -153,8 +154,8 @@ return map; }, {}); - [% IF Koha.Preference('ExtendedPatronAttributes') %] - let extended_attribute_types = [% To.json(attribute_type_codes || []) | $raw %]; + [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] + let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; [% END %] @@ -189,7 +190,7 @@ [% FOR search_field IN search_fields.split(',') %] {"me.[% search_field | html %]":{"like":"%"+filter+"%"}}, [% END %] - [% IF Koha.Preference('ExtendedPatronAttributes') %] + [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] { "extended_attributes.value": { "like": "%" + filter + "%" }, "extended_attributes.code": extended_attribute_types @@ -202,6 +203,7 @@ [% default_sort_column = "name" %] [% END %] [% SET order_column_index = 0 %] + [% SET embed = ['extended_attributes'] %] patrons_table = $("#[% table_id | html %]").kohaTable({ "ajax": { [% SWITCH filter %] @@ -228,7 +230,6 @@ return json.data; } }, - embed: ['extended_attributes'], "drawCallback": function( settings ) { var api = this.api(); var data = api.data(); @@ -255,6 +256,17 @@ [% order_column_index = loop.count - 1%] [% END %] [% SWITCH column %] + [% CASE 'checkbox' %] + { + "data": "borrowernumber", + "searchable": true, + "orderable": true, + "render": function( data, type, row, meta ) { + return "" + _("Select patron") + "", + } + } [% CASE 'cardnumber' %] { "data": "cardnumber", @@ -373,6 +385,15 @@ return escape_str(data); } } + [% CASE 'checkouts' %][% embed.push('checkouts+count') %] + { + "data": "", + "searchable": false, + "orderable": false, + "render": function( data, type, row, meta ) { + return escape_str(row.checkouts_count); + } + } [% CASE 'action' %] { "data": function( row, type, val, meta ) { @@ -391,6 +412,7 @@ [% UNLESS loop.last %],[% END %] [% END %] ], + 'embed': [% To.json(embed) | $raw %], "order": [[ [% order_column_index | html %], "asc" ]], 'bAutoWidth': false, 'sPaginationType': 'full_numbers', diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt index 1374918a2a..0106acc4ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt @@ -28,7 +28,7 @@ [% MACRO jsinclude BLOCK %] - [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => extended_attribute_types, columns => columns, filter => filter, selection_type => selection_type, callback => callback %] + [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, selection_type => selection_type, callback => callback %] [% END %] [% SET popup_window = 1 %] -- 2.39.5