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 (-69 / +69 lines)
Lines 247-253 Link Here
247
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
247
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
248
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
248
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
249
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
249
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
250
        let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
250
        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"];
251
        [% IF Koha.Preference('LocalCoverImages') %]
251
        [% IF Koha.Preference('LocalCoverImages') %]
252
            embed.push('cover_image_ids');
252
            embed.push('cover_image_ids');
253
        [% END %]
253
        [% END %]
Lines 497-578 Link Here
497
                    }
497
                    }
498
                },
498
                },
499
                {
499
                {
500
                    data: "me.lost_status",
500
                    data: "me._status",
501
                    className: "status",
501
                    className: "status",
502
                    searchable: false, // FIXME We are losing the ability to search on the status
502
                    searchable: false, // FIXME We are losing the ability to search on the status
503
                    orderable: false,
503
                    orderable: false,
504
                    render: function (data, type, row, meta) {
504
                    render: function (data, type, row, meta) {
505
                        let nodes = "";
505
                        let nodes = "";
506
                        if ( row.checkout ) {
506
                        row._status.split(",").forEach( status => {
507
                            [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
507
                            if ( status == 'checked_out' || status == 'local_use') {
508
                            row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
508
                                nodes += '<span>';
509
509
510
                            nodes += '<span>';
510
                                [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
511
                            if ( row.checkout.onsite_checkout ) {
511
                                row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) };
512
                                let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
512
                                let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
513
                                nodes += _("Currently in local use by %s").format(patron_to_html);
513
514
                            } else {
514
                                if ( status == 'local_use' ) {
515
                                nodes += '<span class="holding_status datedue">';
515
                                    nodes += _("Currently in local use by %s").format(patron_to_html);
516
                                let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
516
                                } else {
517
                                nodes += _("Checked out to %s").format(patron_to_html);
517
                                    nodes += '<span class="datedue">';
518
                                    nodes += _("Checked out to %s").format(patron_to_html);
519
                                }
520
                                nodes += ': ';
521
                                nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
522
                                nodes += "</span>"
523
518
                            }
524
                            }
519
                            nodes += ': ';
525
                            if ( status == 'in_transit' ) {
520
                            nodes += _("due %s").format($date(row.checkout.due_date, { as_due_date: true }));
526
                                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)));
521
                            nodes += "</span>"
522
                        } else if ( row.transfer ) {
523
                            if ( row.transfer.datesent ) {
524
                                nodes += '<span class="holding_status 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)));
525
                            } else {
526
                                nodes += '<span class="holding_status 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)));
527
                            }
527
                            }
528
                        }
529
528
530
                        if ( row.lost_status ) {
529
                            if ( status == 'transit_pending' ) {
531
                            let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
530
                                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)));
532
                            nodes += '<span class="holding_status lost">%s</span>'.format(escape_str(lost_lib));
531
                            }
533
                            [% IF Koha.Preference('ClaimReturnedLostValue') %]
532
534
                                const hasReturnClaims = row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
533
                            if ( status == 'lost' ) {
534
                                let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
535
                                nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib));
536
537
                                const hasReturnClaims = row.return_claims && row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false
535
                                if(hasReturnClaims) {
538
                                if(hasReturnClaims) {
536
                                    nodes += '<span class="holding_status claimed_returned">' + _("(Claimed returned)") + '</span>';
539
                                    nodes += '<span class="holding_status claimed_returned">' + _("(Claimed returned)") + '</span>';
537
                                }
540
                                }
538
                            [% END %]
541
                            }
539
                        }
540
542
541
                        if ( row.withdrawn ) {
543
                            if ( status == 'withdrawn' ) {
542
                            let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
544
                                let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
543
                            nodes += '<span class="holding_status wdn">%s</span>'.format(escape_str(withdrawn_lib));
545
                                nodes += '<span class="wdn">%s</span>'.format(escape_str(withdrawn_lib));
544
                        }
546
                            }
545
547
546
                        if ( row.damaged_status ) {
548
                            if ( status == 'damaged' ) {
547
                            let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
549
                                let damaged_lib = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
548
                            nodes += '<span class="holding_status dmg">%s</span>'.format(escape_str(damaged_lib));
550
                                nodes += '<span class="dmg">%s</span>'.format(escape_str(damaged_lib));
549
                        }
551
                            }
550
552
551
                        if ( row.not_for_loan_status || item_types_notforloan.get(row.item_type_id) ) {
553
                            if ( status == 'not_for_loan' ) {
552
                            let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
554
                                let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
553
                            nodes += '<span class="holding_status notforloan">%s'.format(_("Not for loan")) + ( not_for_loan_lib ? '<span class="reason"> (%s)</span>'.format(escape_str(not_for_loan_lib)) : '' ) + '</span>';
555
                                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>';
554
                        }
556
                            }
555
557
556
                        if ( row.first_hold ) {
558
                            if ( status == 'on_hold') {
557
                            if ( row.first_hold.waiting_date ) {
559
                                if ( row.first_hold.waiting_date ) {
558
                                if ( row.first_hold.desk ) {
560
                                    if ( row.first_hold.desk ) {
559
                                    nodes += '<span class="holding_status 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)));
561
                                        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))));
562
                                    } else {
563
                                        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))));
564
                                    }
565
                                    [% IF Koha.Preference('canreservefromotherbranches') %]
566
                                        if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
567
                                            [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
568
                                            row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
569
570
                                            let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
571
                                            nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
572
                                        }
573
                                    [% END %]
560
                                } else {
574
                                } else {
561
                                    nodes += '<span class="holding_status waitingat">%s</span>'.format(_("Waiting at %s since %s.").format(row.first_hold._strings.pickup_library_id.str, $date(row.first_hold.waiting_date)));
575
                                    nodes += ' <span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
562
                                }
576
                                }
563
                                [% IF Koha.Preference('canreservefromotherbranches') %]
564
                                    if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
565
                                        [%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
566
                                        row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
567
568
                                        let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
569
                                        nodes += ' <span class="holding_status heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
570
                                    }
571
                                [% END %]
572
                            } else {
573
                                nodes += ' <span class="holding_status holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
574
                            }
577
                            }
575
                        }
576
578
577
                        [% IF Koha.Preference('UseRecalls') %]
579
                        [% IF Koha.Preference('UseRecalls') %]
578
                            if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
580
                            if ( row.recall && ( row.item_id === row.recall.item_id ) ) {
Lines 587-604 Link Here
587
                                }
589
                                }
588
                            }
590
                            }
589
                        [% END %]
591
                        [% END %]
592
                            if ( status == 'available' ) {
593
                                nodes += ' <span>%s</span>'.format(_("Available"))
594
                            }
590
595
591
                        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 ) ) )) {
596
                            if ( status == 'restricted') {
592
                            nodes += ' <span class="holding_status available">%s</span>'.format(_("Available"))
597
                                nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
593
                        }
598
                            }
594
599
                            if ( status == 'in_bundle') {
595
                        if ( row.restricted_status ) {
600
                                nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
596
                            nodes += '<span class="holding_status restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString())));
601
                            }
597
                        }
602
                        });
598
599
                        if ( row.in_bundle ) {
600
                            nodes += '<span class="holding_status bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
601
                        }
602
                        return nodes;
603
                        return nodes;
603
                    }
604
                    }
604
                },
605
                },
605
- 

Return to bug 37334