View | Details | Raw Unified | Return to bug 30063
Collapse All | Expand All

(-)a/Koha/Patron.pm (+8 lines)
Lines 1206-1211 sub get_overdues { Link Here
1206
    );
1206
    );
1207
}
1207
}
1208
1208
1209
sub overdues { my $self = shift; return $self->get_overdues(@_); }
1210
1209
=head3 get_routing_lists
1211
=head3 get_routing_lists
1210
1212
1211
my $routinglists = $patron->get_routing_lists
1213
my $routinglists = $patron->get_routing_lists
Lines 2054-2059 sub safe_to_delete { Link Here
2054
    return Koha::Result::Boolean->new(1);
2056
    return Koha::Result::Boolean->new(1);
2055
}
2057
}
2056
2058
2059
sub account_balance {
2060
    my ($self) = @_;
2061
    return $self->account->balance;
2062
}
2063
2064
2057
=head2 Internal methods
2065
=head2 Internal methods
2058
2066
2059
=head3 _type
2067
=head3 _type
(-)a/api/v1/swagger/definitions/patron.yaml (+10 lines)
Lines 333-338 properties: Link Here
333
      - integer
333
      - integer
334
      - "null"
334
      - "null"
335
    description: Number of checkouts
335
    description: Number of checkouts
336
  overdues_count:
337
    type:
338
      - integer
339
      - "null"
340
    description: Number of overdued checkouts
341
  account_balance:
342
    type:
343
      - number
344
      - "null"
345
    description: Balance of the patron's account
336
additionalProperties: false
346
additionalProperties: false
337
required:
347
required:
338
  - surname
348
  - surname
(-)a/api/v1/swagger/paths/patrons.yaml (+2 lines)
Lines 386-391 Link Here
386
    x-koha-embed:
386
    x-koha-embed:
387
      - extended_attributes
387
      - extended_attributes
388
      - checkouts+count
388
      - checkouts+count
389
      - overdues+count
390
      - account_balance
389
  post:
391
  post:
390
    x-mojo-to: Patrons#add
392
    x-mojo-to: Patrons#add
391
    operationId: addPatron
393
    operationId: addPatron
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-3 / +29 lines)
Lines 106-111 Link Here
106
                            [% CASE 'borrowernotes' %]<th>Notes</th>
106
                            [% CASE 'borrowernotes' %]<th>Notes</th>
107
                            [% CASE 'phone' %]<th>Phone</th>
107
                            [% CASE 'phone' %]<th>Phone</th>
108
                            [% CASE 'checkouts' %]<th>Checkouts</th>
108
                            [% CASE 'checkouts' %]<th>Checkouts</th>
109
                            [% CASE 'account_balance' %]<th>Fines</th>
109
                            [% CASE 'action' %]<th>&nbsp;</th>
110
                            [% CASE 'action' %]<th>&nbsp;</th>
110
                        [% END %]
111
                        [% END %]
111
                    [% END %]
112
                    [% END %]
Lines 225-231 Link Here
225
                        return json.data;
226
                        return json.data;
226
                    }
227
                    }
227
                },
228
                },
228
                embed: ['extended_attributes', 'checkouts+count'],
229
                embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'],
229
                "drawCallback": function( settings ) {
230
                "drawCallback": function( settings ) {
230
                    var api = this.api();
231
                    var api = this.api();
231
                    var data = api.data();
232
                    var data = api.data();
Lines 385-393 Link Here
385
                                "searchable": false,
386
                                "searchable": false,
386
                                "orderable": false,
387
                                "orderable": false,
387
                                "render": function( data, type, row, meta ) {
388
                                "render": function( data, type, row, meta ) {
388
                                    return escape_str(row.checkouts_count);
389
                                    if ( row.overdues_count ) {
390
                                        return "<span class='overdue'><strong>"+row.overdues_count + "</strong></span>";
391
                                    } else {
392
                                        return "0 / " + row.checkouts_count;
393
                                    }
389
                                }
394
                                }
390
                            }
395
                            }
396
                            [% CASE 'account_balance' %]
397
                            {
398
                                "data": "",
399
                                "searchable": false,
400
                                "orderable": false,
401
                                "render": function( data, type, row, meta ) {
402
                                    let r = "<span style='text-align: right; display: block;'><a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber="+row.patron_id+"\">";
403
                                    let balance_str = row.account_balance || 0;
404
                                    balance_str = balance_str.escapeHtml().format_price();
405
                                    if ( row.account_balance < 0 ) {
406
                                        // FIXME Format price here
407
                                        r += "<span class='credit'>" + balance_str + "</span>";
408
                                    } else if ( row.account_balance > 0 ) {
409
                                        r += "<span class='debit'><strong>" + balance_str  + "</strong></span>"
410
                                    } else {
411
                                        r += balance_str;
412
                                    }
413
                                    r += "</a></span>";
414
                                    return r;
415
                                }
416
                            }
417
391
                            [% CASE 'action' %]
418
                            [% CASE 'action' %]
392
                            {
419
                            {
393
                                "data": function( row, type, val, meta ) {
420
                                "data": function( row, type, val, meta ) {
394
- 

Return to bug 30063