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

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

Return to bug 37334