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

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

Return to bug 37334