Bug 30063: Number of checkouts
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 11 Feb 2022 08:39:12 +0000 (09:39 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 4 Apr 2022 07:47:00 +0000 (09:47 +0200)
Signed-off-by: Séverine Queune <severine.queune@bulac.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
api/v1/swagger/definitions/patron.yaml
api/v1/swagger/paths/patrons.yaml
koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt

index 3d7e60b..9185b90 100644 (file)
@@ -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
index 5b2b953..7afce68 100644 (file)
         - acquisition: "order_manage"
     x-koha-embed:
       - extended_attributes
+      - checkouts+count
   post:
     x-mojo-to: Patrons#add
     operationId: addPatron
index d088ebc..16681de 100644 (file)
                             [% CASE 'dateexpiry' %]<th>Expires on</td>
                             [% CASE 'borrowernotes' %]<th>Notes</th>
                             [% CASE 'phone' %]<th>Phone</th>
+                            [% CASE 'checkouts' %]<th>Checkouts</th>
                             [% CASE 'action' %]<th>&nbsp;</th>
                         [% END %]
                     [% END %]
             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 %]
 
     </script>
                         [% 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
                 [% default_sort_column = "name" %]
             [% END %]
             [% SET order_column_index = 0 %]
+            [% SET embed = ['extended_attributes'] %]
             patrons_table = $("#[% table_id | html %]").kohaTable({
                 "ajax": {
                     [% SWITCH filter %]
                         return json.data;
                     }
                 },
-                embed: ['extended_attributes'],
                 "drawCallback": function( settings ) {
                     var api = this.api();
                     var data = api.data();
                             [% order_column_index = loop.count - 1%]
                         [% END %]
                         [% SWITCH column %]
+                            [% CASE 'checkbox' %]
+                            {
+                                "data": "borrowernumber",
+                                "searchable": true,
+                                "orderable": true,
+                                "render": function( data, type, row, meta ) {
+                                    return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : "";
+
+                                    return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />",
+                                }
+                            }
                             [% CASE 'cardnumber' %]
                             {
                                 "data": "cardnumber",
                                     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 ) {
                         [% UNLESS loop.last %],[% END %]
                     [% END %]
                 ],
+                'embed': [% To.json(embed) | $raw %],
                 "order": [[ [% order_column_index | html %], "asc" ]],
                 'bAutoWidth': false,
                 'sPaginationType': 'full_numbers',
index 1374918..0106acc 100644 (file)
@@ -28,7 +28,7 @@
 </div>
 
 [% 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 %]