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

(-)a/Koha/Item.pm (+50 lines)
Lines 1443-1448 sub columns_to_str { Link Here
1443
    return $values;
1443
    return $values;
1444
}
1444
}
1445
1445
1446
sub _status {
1447
    my ($self) = @_;
1448
1449
    my @statuses;
1450
    if ( my $checkout = $self->checkout ) {
1451
        unless ( $checkout->onsite_checkout ) {
1452
            push @statuses, "checked_out";
1453
        } else {
1454
            push @statuses, "local_use";
1455
        }
1456
    } elsif ( my $transfer = $self->transfer ) {
1457
        if ( $transfer->datesent ) {
1458
            push @statuses, "in_transit";
1459
        } else {
1460
            push @statuses, "transit_pending";
1461
        }
1462
    }
1463
    if ( $self->itemlost ) {
1464
        push @statuses, 'lost';
1465
    }
1466
    if ( $self->withdrawn ) {
1467
        push @statuses, 'withdrawn';
1468
    }
1469
    if ( $self->damaged ) {
1470
        push @statuses, 'damaged';
1471
    }
1472
    if ( $self->notforloan || $self->item_type->notforloan  ) {
1473
        # TODO on a big Koha::Items loop we are going to join with item_type too often, use a cache
1474
        push @statuses, 'not_for_loan';
1475
    }
1476
    if ( $self->first_hold ) {
1477
        push @statuses, 'on_hold';
1478
    }
1479
    if ( C4::Context->preference('UseRecalls') && $self->recall ) {
1480
        push @statuses, 'recalled';
1481
    }
1482
1483
    unless (@statuses ){
1484
        push @statuses, 'available';
1485
    }
1486
1487
    if ( $self->restricted ) {
1488
        push @statuses, 'restricted';
1489
    }
1490
1491
    # TODO in_bundle?
1492
1493
    return join ',', @statuses;
1494
}
1495
1446
=head3 additional_attributes
1496
=head3 additional_attributes
1447
1497
1448
    my $attributes = $item->additional_attributes;
1498
    my $attributes = $item->additional_attributes;
(-)a/api/v1/swagger/definitions/item.yaml (+5 lines)
Lines 322-325 properties: Link Here
322
      - object
322
      - object
323
      - "null"
323
      - "null"
324
    description: A return claims object if one exists that's unresolved
324
    description: A return claims object if one exists that's unresolved
325
  _status:
326
    type:
327
      - string
328
      - "null"
329
    description: The status of the item
325
additionalProperties: false
330
additionalProperties: false
(-)a/api/v1/swagger/paths/biblios.yaml (+1 lines)
Lines 455-460 Link Here
455
          type: string
455
          type: string
456
          enum:
456
          enum:
457
            - +strings
457
            - +strings
458
            - _status
458
            - home_library
459
            - home_library
459
            - holding_library
460
            - holding_library
460
            - biblio.title
461
            - biblio.title
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-66 / +67 lines)
Lines 232-238 Link Here
232
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
232
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
233
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
233
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
234
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
234
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
235
    let embed = ["+strings,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
235
    let embed = ["+strings,_status,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
236
    [% IF Koha.Preference('LocalCoverImages') %]
236
    [% IF Koha.Preference('LocalCoverImages') %]
237
        embed.push('cover_image_ids');
237
        embed.push('cover_image_ids');
238
    [% END %]
238
    [% END %]
Lines 467-548 Link Here
467
                }
467
                }
468
            },
468
            },
469
            {
469
            {
470
                data: "me.lost_status",
470
                data: "me._status",
471
                className: "status",
471
                className: "status",
472
                searchable: false, // FIXME We are losing the ability to search on the status
472
                searchable: false, // FIXME We are losing the ability to search on the status
473
                orderable: false,
473
                orderable: false,
474
                render: function (data, type, row, meta) {
474
                render: function (data, type, row, meta) {
475
                    let nodes = "";
475
                    let nodes = "";
476
                    if ( row.checkout ) {
476
                    row._status.split(",").forEach( status => {
477
                        [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
477
                        if ( status == 'checked_out' || status == 'local_use') {
478
                        row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
478
                            nodes += '<span>';
479
479
480
                        nodes += '<span>';
480
                            [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
481
                        if ( row.checkout.onsite_checkout ) {
481
                            row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
482
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
482
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
483
                            nodes += _("Currently in local use by %s").format(patron_to_html);
483
484
                        } else {
484
                            if ( status == 'local_use' ) {
485
                            nodes += '<span class="datedue">';
485
                                nodes += _("Currently in local use by %s").format(patron_to_html);
486
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
486
                            } else {
487
                            nodes += _("Checked out to %s").format(patron_to_html);
487
                                nodes += '<span class="datedue">';
488
                                nodes += _("Checked out to %s").format(patron_to_html);
489
                            }
490
                            nodes += ': ';
491
                            nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
492
                            nodes += "</span>"
493
488
                        }
494
                        }
489
                        nodes += ': ';
495
                        if ( status == 'in_transit' ) {
490
                        nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
491
                        nodes += "</span>"
492
                    } else if ( row.transfer ) {
493
                        if ( row.transfer.datesent ) {
494
                            nodes += '<span class="intransit">%s</span>'.format(_("In transit from %s to %s since %s").format(escape_str(row.transfer._strings.from_library.str), escape_str(row.transfer._strings.to_library.str), $date(row.transfer.datesent)));
496
                            nodes += '<span class="intransit">%s</span>'.format(_("In transit from %s to %s since %s").format(escape_str(row.transfer._strings.from_library.str), escape_str(row.transfer._strings.to_library.str), $date(row.transfer.datesent)));
495
                        } else {
497
                        }
498
499
                        if ( status == 'transit_pending' ) {
496
                            nodes += '<span class="transitrequested">%s</span>'.format(_("Transit pending from %s to %s since %s").format(escape_str(row.transfer._strings.from_library.str), escape_str(row.transfer._strings.to_library.str), $date(row.transfer.daterequested)));
500
                            nodes += '<span class="transitrequested">%s</span>'.format(_("Transit pending from %s to %s since %s").format(escape_str(row.transfer._strings.from_library.str), escape_str(row.transfer._strings.to_library.str), $date(row.transfer.daterequested)));
497
                        }
501
                        }
498
                    }
499
502
500
                    if ( row.lost_status ) {
503
                        if ( status == 'lost' ) {
501
                        let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
504
                            let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
502
                        nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib));
505
                            nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib));
503
                        [% IF Koha.Preference('ClaimReturnedLostValue') %]
506
504
                            const hasReturnClaims = row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
507
                            const hasReturnClaims = row.return_claims && row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
505
                            if(hasReturnClaims) {
508
                            if(hasReturnClaims) {
506
                                nodes += '<span class="claimed_returned">' + _("(Claimed returned)") + '</span>';
509
                                nodes += '<span class="claimed_returned">' + _("(Claimed returned)") + '</span>';
507
                            }
510
                            }
508
                        [% END %]
511
                        }
509
                    }
510
512
511
                    if ( row.withdrawn ) {
513
                        if ( status == 'withdrawn' ) {
512
                        let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
514
                            let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
513
                        nodes += '<span class="wdn">%s</span>'.format(escape_str(withdrawn_lib));
515
                            nodes += '<span class="wdn">%s</span>'.format(escape_str(withdrawn_lib));
514
                    }
516
                        }
515
517
516
                    if ( row.damaged_status ) {
518
                        if ( status == 'damaged' ) {
517
                        let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
519
                            let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
518
                        nodes += '<span class="dmg">%s</span>'.format(escape_str(damaged_lib));
520
                            nodes += '<span class="dmg">%s</span>'.format(escape_str(damaged_lib));
519
                    }
521
                        }
520
522
521
                    if ( row.not_for_loan_status || item_types_notforloan.get(row.item_type_id) ) {
523
                        if ( status == 'not_for_loan' ) {
522
                        let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
524
                            let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
523
                        nodes += '<span class="notforloan">%s'.format(_("Not for loan")) + ( not_for_loan_lib ? '<span class="reason"> (%s)</span>'.format(escape_str(not_for_loan_lib)) : '' ) + '</span>';
525
                            nodes += '<span class="notforloan">%s'.format(_("Not for loan")) + ( not_for_loan_lib ? '<span class="reason"> (%s)</span>'.format(escape_str(not_for_loan_lib)) : '' ) + '</span>';
524
                    }
526
                        }
525
527
526
                    if ( row.first_hold ) {
528
                        if ( status == 'on_hold') {
527
                        if ( row.first_hold.waiting_date ) {
529
                            if ( row.first_hold.waiting_date ) {
528
                            if ( row.first_hold.desk ) {
530
                                if ( row.first_hold.desk ) {
529
                                nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s, %s since %s.").format(row.first_hold._strings.pickup_library_id.str, row.first_hold.desk.desk_name, $date(row.first_hold.waiting_date)));
531
                                    nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s, %s since %s.".format(row.first_hold._strings.pickup_library_id.str, row.first_hold.desk.desk_name, $date(row.first_hold.waiting_date))));
532
                                } else {
533
                                    nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s since %s.".format(row.first_hold._strings.pickup_library_id.str, $date(row.first_hold.waiting_date))));
534
                                }
535
                                [% IF Koha.Preference('canreservefromotherbranches') %]
536
                                    if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
537
                                        [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
538
                                        row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
539
540
                                        let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
541
                                        nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
542
                                    }
543
                                [% END %]
530
                            } else {
544
                            } else {
531
                                nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s since %s.").format(row.first_hold._strings.pickup_library_id.str, $date(row.first_hold.waiting_date)));
545
                                nodes += ' <span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
532
                            }
546
                            }
533
                            [% IF Koha.Preference('canreservefromotherbranches') %]
534
                                if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
535
                                    [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
536
                                    row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
537
538
                                    let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
539
                                    nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
540
                                }
541
                            [% END %]
542
                        } else {
543
                            nodes += ' <span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
544
                        }
547
                        }
545
                    }
546
548
547
                    [% IF Koha.Preference('UseRecalls') %]
549
                    [% IF Koha.Preference('UseRecalls') %]
548
                        if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
550
                        if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
Lines 557-574 Link Here
557
                            }
559
                            }
558
                        }
560
                        }
559
                    [% END %]
561
                    [% END %]
562
                        if ( status == 'available' ) {
563
                            nodes += ' <span>%s</span>'.format(_("Available"))
564
                        }
560
565
561
                    if ( ! ( row.not_for_loan_status || item_types_notforloan.get(row.item_type_id) || row.checked_out_date || row.lost_status || row.withdrawn || row.damaged_status || row.transfer || row.first_hold || ( row.recall && ( row.item_id === row.recall.item_id ) ) )) {
566
                        if ( status == 'restricted') {
562
                        nodes += ' <span>%s</span>'.format(_("Available"))
567
                            nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
563
                    }
568
                        }
564
565
                    if ( row.restricted_status ) {
566
                        nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
567
                    }
568
569
569
                    if ( row.in_bundle ) {
570
                        if ( status == 'restricted') {
570
                        nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
571
                            nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
571
                    }
572
                        }
573
                    });
572
                    return nodes;
574
                    return nodes;
573
                }
575
                }
574
            },
576
            },
575
- 

Return to bug 37334