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

(-)a/Koha/Item.pm (+12 lines)
Lines 767-772 sub get_transfer { Link Here
767
    return  Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer;
767
    return  Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer;
768
}
768
}
769
769
770
sub transfer {
771
    return shift->get_transfer(@_);
772
}
773
770
=head3 get_transfers
774
=head3 get_transfers
771
775
772
  my $transfer = $item->get_transfers;
776
  my $transfer = $item->get_transfers;
Lines 1049-1054 sub current_holds { Link Here
1049
    return Koha::Holds->_new_from_dbic($hold_rs);
1053
    return Koha::Holds->_new_from_dbic($hold_rs);
1050
}
1054
}
1051
1055
1056
sub first_hold {
1057
    my ( $self ) = @_;
1058
    return $self->current_holds->next;
1059
}
1060
1052
=head3 stockrotationitem
1061
=head3 stockrotationitem
1053
1062
1054
  my $sritem = Koha::Item->stockrotationitem;
1063
  my $sritem = Koha::Item->stockrotationitem;
Lines 1744-1749 sub itemtype { Link Here
1744
1753
1745
    return Koha::ItemTypes->find( $self->effective_itemtype );
1754
    return Koha::ItemTypes->find( $self->effective_itemtype );
1746
}
1755
}
1756
sub item_type {
1757
    return shift->itemtype;
1758
}
1747
1759
1748
=head3 orders
1760
=head3 orders
1749
1761
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-2 / +2 lines)
Lines 69-76 sub GetCategories { Link Here
69
69
70
sub GetDescriptionsByKohaField {
70
sub GetDescriptionsByKohaField {
71
    my ( $self, $params ) = @_;
71
    my ( $self, $params ) = @_;
72
    return Koha::AuthorisedValues->get_descriptions_by_koha_field(
72
    return [ Koha::AuthorisedValues->get_descriptions_by_koha_field(
73
        { kohafield => $params->{kohafield} } );
73
        { kohafield => $params->{kohafield} } ) ];
74
}
74
}
75
75
76
sub GetDescriptionByKohaField {
76
sub GetDescriptionByKohaField {
(-)a/api/v1/swagger/definitions/item.yaml (+28 lines)
Lines 242-247 properties: Link Here
242
    type:
242
    type:
243
      - object
243
      - object
244
      - "null"
244
      - "null"
245
  checkout:
246
    type:
247
      - object
248
      - "null"
249
  transfer:
250
    type:
251
      - object
252
      - "null"
253
  first_hold:
254
    type:
255
      - object
256
      - "null"
257
  recall:
258
    type:
259
      - object
260
      - "null"
261
  item_type:
262
    type:
263
      - object
264
      - "null"
265
  in_bundle:
266
    type:
267
      - boolean
268
      - "null"
269
  bundle_host:
270
    type:
271
      - object
272
      - "null"
245
  _strings:
273
  _strings:
246
    type:
274
    type:
247
      - object
275
      - object
(-)a/api/v1/swagger/paths/biblios.yaml (+10 lines)
Lines 423-428 Link Here
423
          type: string
423
          type: string
424
          enum:
424
          enum:
425
            - +strings
425
            - +strings
426
            - checkout
427
            - checkout.patron
428
            - transfer
429
            - first_hold
430
            - first_hold.patron
431
            - recall
432
            - recall.patron
433
            - item_type
434
            - in_bundle
435
            - bundle_host
426
            - cover_image_ids
436
            - cover_image_ids
427
            - item_group_item.item_group.description
437
            - item_group_item.item_group.description
428
            - serialitem.serial
438
            - serialitem.serial
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-7 / +103 lines)
Lines 2485-2495 Link Here
2485
2485
2486
            });
2486
            });
2487
        [% END %]
2487
        [% END %]
2488
        const can_edit_items_from = [% To.json(can_edit_items_from) | $raw %];
2488
        const can_edit_items_from = [% To.json(can_edit_items_from || {}) | $raw %];
2489
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
2489
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
2490
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
2490
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
2491
        const av_lost = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.itemlost' })) | $raw %].map( av => [av.authorised_value, av.lib]));
2492
        const av_withdrawn = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.withdrawn' })) | $raw %].map( av => [av.authorised_value, av.lib]));
2493
        const av_damaged = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.damaged' })) | $raw %].map( av => [av.authorised_value, av.lib]));
2494
        const av_not_for_loan= new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.notforloan' })) | $raw %].map( av => [av.authorised_value, av.lib]));
2495
        const av_restricted = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.restricted' })) | $raw %].map( av => [av.authorised_value, av.lib]));
2491
        let table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
2496
        let table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
2492
        let embed = ["+strings"];
2497
        let embed = ["+strings,checkout,checkout.patron,transfer,first_hold,first_hold.patron,item_type"];
2493
        [% IF Koha.Preference('LocalCoverImages') %]
2498
        [% IF Koha.Preference('LocalCoverImages') %]
2494
            embed.push('cover_image_ids');
2499
            embed.push('cover_image_ids');
2495
        [% END %]
2500
        [% END %]
Lines 2499-2504 Link Here
2499
        [% IF biblio.serial %]
2504
        [% IF biblio.serial %]
2500
            embed.push('serialitem.serial');
2505
            embed.push('serialitem.serial');
2501
        [% END %]
2506
        [% END %]
2507
        [% IF Koha.Preference('UseRecalls') %]
2508
            embed.push('recall', 'recall.patron')
2509
        [% END %]
2510
        embed.push('in_bundle', 'bundle_host');
2502
        let table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %];
2511
        let table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %];
2503
        var items_table = $("#table_items").kohaTable({
2512
        var items_table = $("#table_items").kohaTable({
2504
            ajax: { url: table_url },
2513
            ajax: { url: table_url },
Lines 2659-2670 Link Here
2659
                }
2668
                }
2660
            },
2669
            },
2661
            {
2670
            {
2662
                data: "",
2671
                data: "me.lost_status",
2663
                className: "status",
2672
                className: "status",
2664
                searchable: false, // FIXME
2673
                searchable: false, // FIXME We are losing the ability to search on the status
2665
                orderable: true,
2674
                orderable: false,
2666
                render: function (data, type, row, meta) {
2675
                render: function (data, type, row, meta) {
2667
                    return "status"; // FIXME Display status
2676
                    let nodes = "";
2677
                    if ( row.checkout ) {
2678
                        nodes += '<span>';
2679
                        if ( row.checkout.onsite_checkout ) {
2680
                            if ( can_edit_items_from[row.holding_library_id] ){
2681
                                let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %]
2682
                                nodes += _("Currently in local use by %s").format(patron_to_html);
2683
                            } else {
2684
                                nodes += _("Currently in local use");
2685
                            }
2686
                        } else {
2687
                            nodes += '<span class="datedue">';
2688
                            if ( can_edit_items_from[row.holding_library_id] ){
2689
                                let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %]
2690
                                nodes += _("Checked out to %s").format(patron_to_html);
2691
                            } else {
2692
                                nodes += _("Checked out");
2693
                            }
2694
                        }
2695
                        nodes += ': ';
2696
                        nodes += _("due %s").format($date(row.checkout.due_date)); [%# FIXME Missing due date formatting here, $date do not have as_due_date option %]
2697
                        nodes += "</span>"
2698
                    } else if ( row.transfer ) {
2699
                        if ( row.transfer.datesent ) {
2700
                            nodes += '<span class="intransit">%s</span>'.format(_("In transit from %s to %s since %s").format(row.transfer.frombranch, row.transfer.tobranch, $date(row.transfer.datesent))); [%# FIXME display library names, not codes, do we use _strings here? %]
2701
                        } else {
2702
                            nodes += '<span class="transitrequested">%s</span>'.format(_("Transit pending from %s to %s since %s").format(row.transfer.frombranch, row.transfer.tobranch, $date(row.transfer.daterequested))); [%# FIXME See above %]
2703
                        }
2704
                    }
2705
2706
                    if ( row.lost_status ) {
2707
                        let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing");
2708
                        nodes += '<span class="lost">%s</span>'.format(lost_lib);
2709
                    }
2710
2711
                    if ( row.withdrawn ) {
2712
                        let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
2713
                        nodes += '<span class="wdn">%s</span>'.format(withdrawn_lib);
2714
                    }
2715
2716
                    if ( row.damaged ) {
2717
                        let damaged_lib = av_damaged.get(row.damaged.toString()) || _("Damaged");
2718
                        nodes += '<span class="dmg">%s</span>'.format(damaged_lib);
2719
                    }
2720
2721
                    if ( row.not_for_loan_status || row.item_type.notforloan ) {
2722
                        let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString());
2723
                        nodes += '<span class="notforloan">%s'.format(_("Not for loan")) + ( not_for_loan_lib ? '<span class="reason"> (%s)</span>'.format(not_for_loan_lib) : '' ) + '</span>';
2724
                    }
2725
2726
                    if ( row.first_hold ) {
2727
                        if ( row.first_hold.waiting_date ) {
2728
                            [%# FIXME Display library names instead of codes %]
2729
                            [%# FIXME We lost the desk name, we need an additional embed %]
2730
                            nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s since %s.".format(row.first_hold.pickup_library_id, $date(row.first_hold.waiting_date))));
2731
                            [% IF Koha.Preference('canreservefromotherbranches') %]
2732
                                if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) {
2733
                                    let patron_to_html = $patron_to_html(row.first_hold.patron); [%# FIXME What about hide_patron_infos_if_needed?? %]
2734
                                    nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
2735
                                }
2736
                            [% END %]
2737
                        } else {
2738
                            nodes += '<span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority));
2739
                        }
2740
                    }
2741
2742
                    [% IF Koha.Preference('UseRecalls') %]
2743
                        if ( row.recall ) {
2744
                            if ( row.recall.waiting_date ) {
2745
                                nodes += '<span>%s</span>'.format(_("Waiting at %s since %s").format(row.recall.pickup_library_id, $date(row.recall.waiting_date))); # FIXME Display library names instead of codes
2746
                            } else {
2747
                                let patron_to_html = $patron_to_html(row.recall.patron);
2748
                                nodes += '<span>%s</span>'.format(_("recalled by %s on %s").format(patron_to_html, row.recall.created_date));
2749
                            }
2750
                        }
2751
                    [% END %]
2752
2753
                    if ( ! ( row.not_for_loan_status || row.item_type.notforloan || row.checked_out_date || row.lost_status || row.withdrawn || row.damaged || row.transfer || row.first_hold || row.recall ) ) {
2754
                        nodes += ' <span>%s</span>'.format(_("Available"))
2755
                    }
2756
2757
                    if ( row.restricted_status ) {
2758
                        nodes += '<span class="restricted">(%s)</span>'.format(av_restricted.get(row.restricted_status.toString()));
2759
                    }
2760
2761
                    if ( row.in_bundle ) {
2762
                        nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true })));
2763
                    }
2764
                    return nodes;
2668
                }
2765
                }
2669
            },
2766
            },
2670
            {
2767
            {
2671
- 

Return to bug 33568