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 458-463 Link Here
458
          type: string
458
          type: string
459
          enum:
459
          enum:
460
            - +strings
460
            - +strings
461
            - _status
461
            - home_library
462
            - home_library
462
            - holding_library
463
            - holding_library
463
            - biblio.title
464
            - biblio.title
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-66 / +67 lines)
Lines 236-242 Link Here
236
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
236
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
237
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
237
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
238
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
238
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
239
    let embed = ["+strings,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
239
    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"];
240
    [% IF Koha.Preference('LocalCoverImages') %]
240
    [% IF Koha.Preference('LocalCoverImages') %]
241
        embed.push('cover_image_ids');
241
        embed.push('cover_image_ids');
242
    [% END %]
242
    [% END %]
Lines 474-555 Link Here
474
                }
474
                }
475
            },
475
            },
476
            {
476
            {
477
                data: "me.lost_status",
477
                data: "me._status",
478
                className: "status",
478
                className: "status",
479
                searchable: false, // FIXME We are losing the ability to search on the status
479
                searchable: false, // FIXME We are losing the ability to search on the status
480
                orderable: false,
480
                orderable: false,
481
                render: function (data, type, row, meta) {
481
                render: function (data, type, row, meta) {
482
                    let nodes = "";
482
                    let nodes = "";
483
                    if ( row.checkout ) {
483
                    row._status.split(",").forEach( status => {
484
                        [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
484
                        if ( status == 'checked_out' || status == 'local_use') {
485
                        row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
485
                            nodes += '<span>';
486
486
487
                        nodes += '<span>';
487
                            [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
488
                        if ( row.checkout.onsite_checkout ) {
488
                            row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
489
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
489
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
490
                            nodes += _("Currently in local use by %s").format(patron_to_html);
490
491
                        } else {
491
                            if ( status == 'local_use' ) {
492
                            nodes += '<span class="datedue">';
492
                                nodes += _("Currently in local use by %s").format(patron_to_html);
493
                            let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
493
                            } else {
494
                            nodes += _("Checked out to %s").format(patron_to_html);
494
                                nodes += '<span class="datedue">';
495
                                nodes += _("Checked out to %s").format(patron_to_html);
496
                            }
497
                            nodes += ': ';
498
                            nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
499
                            nodes += "</span>"
500
495
                        }
501
                        }
496
                        nodes += ': ';
502
                        if ( status == 'in_transit' ) {
497
                        nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
498
                        nodes += "</span>"
499
                    } else if ( row.transfer ) {
500
                        if ( row.transfer.datesent ) {
501
                            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)));
503
                            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)));
502
                        } else {
504
                        }
505
506
                        if ( status == 'transit_pending' ) {
503
                            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)));
507
                            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)));
504
                        }
508
                        }
505
                    }
506
509
507
                    if ( row.lost_status ) {
510
                        if ( status == 'lost' ) {
508
                        let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
511
                            let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
509
                        nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib));
512
                            nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib));
510
                        [% IF Koha.Preference('ClaimReturnedLostValue') %]
513
511
                            const hasReturnClaims = row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
514
                            const hasReturnClaims = row.return_claims && row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
512
                            if(hasReturnClaims) {
515
                            if(hasReturnClaims) {
513
                                nodes += '<span class="claimed_returned">' + _("(Claimed returned)") + '</span>';
516
                                nodes += '<span class="claimed_returned">' + _("(Claimed returned)") + '</span>';
514
                            }
517
                            }
515
                        [% END %]
518
                        }
516
                    }
517
519
518
                    if ( row.withdrawn ) {
520
                        if ( status == 'withdrawn' ) {
519
                        let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
521
                            let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
520
                        nodes += '<span class="wdn">%s</span>'.format(escape_str(withdrawn_lib));
522
                            nodes += '<span class="wdn">%s</span>'.format(escape_str(withdrawn_lib));
521
                    }
523
                        }
522
524
523
                    if ( row.damaged_status ) {
525
                        if ( status == 'damaged' ) {
524
                        let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
526
                            let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
525
                        nodes += '<span class="dmg">%s</span>'.format(escape_str(damaged_lib));
527
                            nodes += '<span class="dmg">%s</span>'.format(escape_str(damaged_lib));
526
                    }
528
                        }
527
529
528
                    if ( row.not_for_loan_status || item_types_notforloan.get(row.item_type_id) ) {
530
                        if ( status == 'not_for_loan' ) {
529
                        let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
531
                            let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
530
                        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>';
532
                            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>';
531
                    }
533
                        }
532
534
533
                    if ( row.first_hold ) {
535
                        if ( status == 'on_hold') {
534
                        if ( row.first_hold.waiting_date ) {
536
                            if ( row.first_hold.waiting_date ) {
535
                            if ( row.first_hold.desk ) {
537
                                if ( row.first_hold.desk ) {
536
                                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)));
538
                                    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))));
539
                                } else {
540
                                    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))));
541
                                }
542
                                [% IF Koha.Preference('canreservefromotherbranches') %]
543
                                    if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
544
                                        [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
545
                                        row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
546
547
                                        let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
548
                                        nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
549
                                    }
550
                                [% END %]
537
                            } else {
551
                            } else {
538
                                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)));
552
                                nodes += ' <span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
539
                            }
553
                            }
540
                            [% IF Koha.Preference('canreservefromotherbranches') %]
541
                                if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
542
                                    [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
543
                                    row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
544
545
                                    let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
546
                                    nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
547
                                }
548
                            [% END %]
549
                        } else {
550
                            nodes += ' <span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
551
                        }
554
                        }
552
                    }
553
555
554
                    [% IF Koha.Preference('UseRecalls') %]
556
                    [% IF Koha.Preference('UseRecalls') %]
555
                        if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
557
                        if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
Lines 564-581 Link Here
564
                            }
566
                            }
565
                        }
567
                        }
566
                    [% END %]
568
                    [% END %]
569
                        if ( status == 'available' ) {
570
                            nodes += ' <span>%s</span>'.format(_("Available"))
571
                        }
567
572
568
                    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 ) ) )) {
573
                        if ( status == 'restricted') {
569
                        nodes += ' <span>%s</span>'.format(_("Available"))
574
                            nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
570
                    }
575
                        }
571
572
                    if ( row.restricted_status ) {
573
                        nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
574
                    }
575
576
576
                    if ( row.in_bundle ) {
577
                        if ( status == 'restricted') {
577
                        nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
578
                            nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
578
                    }
579
                        }
580
                    });
579
                    return nodes;
581
                    return nodes;
580
                }
582
                }
581
            },
583
            },
582
- 

Return to bug 37334