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

(-)a/Koha/Biblio.pm (-1 / +2 lines)
Lines 37-49 use Koha::ArticleRequest::Status; Link Here
37
use Koha::ArticleRequests;
37
use Koha::ArticleRequests;
38
use Koha::Biblio::Metadatas;
38
use Koha::Biblio::Metadatas;
39
use Koha::Biblio::Volumes;
39
use Koha::Biblio::Volumes;
40
use Koha::Biblio::Volumes;
40
use Koha::Biblioitems;
41
use Koha::Biblioitems;
41
use Koha::CirculationRules;
42
use Koha::CirculationRules;
42
use Koha::Item::Transfer::Limits;
43
use Koha::Item::Transfer::Limits;
43
use Koha::Items;
44
use Koha::Items;
44
use Koha::Libraries;
45
use Koha::Libraries;
45
use Koha::Suggestions;
46
use Koha::Subscriptions;
46
use Koha::Subscriptions;
47
use Koha::Suggestions;
47
48
48
=head1 NAME
49
=head1 NAME
49
50
(-)a/catalogue/detail.pl (-13 / +51 lines)
Lines 21-55 use Modern::Perl; Link Here
21
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
use HTML::Entities;
22
use HTML::Entities;
23
use Try::Tiny;
23
use Try::Tiny;
24
25
use C4::Acquisition qw(GetOrdersByBiblionumber);
24
use C4::Auth;
26
use C4::Auth;
27
use C4::Biblio;
28
use C4::Circulation;
25
use C4::Context;
29
use C4::Context;
30
use C4::CourseReserves qw(GetItemCourseReservesInfo);
31
use C4::External::Amazon;
32
use C4::HTML5Media;
33
use C4::Images;
34
use C4::Items;
26
use C4::Koha;
35
use C4::Koha;
27
use C4::Serials;    #uses getsubscriptionfrom biblionumber
28
use C4::Output;
36
use C4::Output;
29
use C4::Biblio;
30
use C4::Items;
31
use C4::Circulation;
32
use C4::Reserves;
37
use C4::Reserves;
33
use C4::Serials;
34
use C4::XISBN qw(get_xisbns);
35
use C4::External::Amazon;
36
use C4::Search;        # enabled_staff_search_views
38
use C4::Search;        # enabled_staff_search_views
39
use C4::Serials;    #uses getsubscriptionfrom biblionumber
37
use C4::Tags qw(get_tags);
40
use C4::Tags qw(get_tags);
41
use C4::XISBN qw(get_xisbns);
38
use C4::XSLT;
42
use C4::XSLT;
39
use Koha::DateUtils;
40
use C4::HTML5Media;
41
use C4::CourseReserves qw(GetItemCourseReservesInfo);
42
use C4::Acquisition qw(GetOrdersByBiblionumber);
43
use Koha::AuthorisedValues;
43
use Koha::AuthorisedValues;
44
use Koha::Biblio::Volume::Items;
44
use Koha::Biblios;
45
use Koha::Biblios;
45
use Koha::CoverImages;
46
use Koha::CoverImages;
47
use Koha::DateUtils;
46
use Koha::Illrequests;
48
use Koha::Illrequests;
47
use Koha::Items;
48
use Koha::ItemTypes;
49
use Koha::ItemTypes;
50
use Koha::Items;
49
use Koha::Patrons;
51
use Koha::Patrons;
50
use Koha::Virtualshelves;
51
use Koha::Plugins;
52
use Koha::Plugins;
52
use Koha::SearchEngine::Search;
53
use Koha::SearchEngine::Search;
54
use Koha::Virtualshelves;
53
55
54
my $query = CGI->new();
56
my $query = CGI->new();
55
57
Lines 115-120 if ( not defined $record ) { Link Here
115
eval { $biblio->metadata->record };
117
eval { $biblio->metadata->record };
116
$template->param( decoding_error => $@ );
118
$template->param( decoding_error => $@ );
117
119
120
my $op = $query->param('op') || q{};
121
if ( $op eq 'set_volume' ) {
122
    my $volume_id   = $query->param('volume_id');
123
    my @itemnumbers = $query->multi_param('itemnumber');
124
125
    foreach my $itemnumber (@itemnumbers) {
126
        my $volume_item =
127
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
128
129
        if ($volume_item) {
130
            $volume_item->volume_id($volume_id);
131
        }
132
        else {
133
            $volume_item = Koha::Biblio::Volume::Item->new(
134
                {
135
                    itemnumber => $itemnumber,
136
                    volume_id  => $volume_id,
137
                }
138
            );
139
        }
140
141
        $volume_item->store();
142
    }
143
}
144
elsif ( $op eq 'unset_volume' ) {
145
    my $volume_id   = $query->param('volume_id');
146
    my @itemnumbers = $query->multi_param('itemnumber');
147
148
    foreach my $itemnumber (@itemnumbers) {
149
        my $volume_item =
150
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
151
        $volume_item->delete() if $volume_item;
152
    }
153
}
154
118
if($query->cookie("holdfor")){ 
155
if($query->cookie("holdfor")){ 
119
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
156
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
120
    $template->param(
157
    $template->param(
Lines 345-350 foreach my $item (@items) { Link Here
345
382
346
    # checking for holds
383
    # checking for holds
347
    my $item_object = Koha::Items->find( $item->{itemnumber} );
384
    my $item_object = Koha::Items->find( $item->{itemnumber} );
385
    $item->{object} = $item_object;
348
    my $holds = $item_object->current_holds;
386
    my $holds = $item_object->current_holds;
349
    if ( my $first_hold = $holds->next ) {
387
    if ( my $first_hold = $holds->next ) {
350
        $item->{first_hold} = $first_hold;
388
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 278-283 Link Here
278
              [% IF CAN_user_tools_items_batchmod %]
278
              [% IF CAN_user_tools_items_batchmod %]
279
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
279
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
280
              [% END %]
280
              [% END %]
281
              [% IF biblio.volumes.count %]
282
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
283
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
284
              [% END %]
281
            </span>
285
            </span>
282
        [% END %]
286
        [% END %]
283
    </div>
287
    </div>
Lines 292-297 Link Here
292
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
296
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
293
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
297
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
294
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
298
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
299
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
295
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
300
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
296
                [% IF volinfo %]
301
                [% IF volinfo %]
297
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
302
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
Lines 370-375 Note that permanent location is a code, and location may be an authval. Link Here
370
                        </span>
375
                        </span>
371
                    </td>
376
                    </td>
372
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
377
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
378
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
373
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
379
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
374
                    [% IF ( volinfo ) %]
380
                    [% IF ( volinfo ) %]
375
                        <td class="enumchron">
381
                        <td class="enumchron">
Lines 1071-1077 Note that permanent location is a code, and location may be an authval. Link Here
1071
    </div>
1077
    </div>
1072
</div>
1078
</div>
1073
1079
1074
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1080
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1075
    <div class="modal-dialog">
1081
    <div class="modal-dialog">
1076
        <div class="modal-content">
1082
        <div class="modal-content">
1077
            <div class="modal-header">
1083
            <div class="modal-header">
Lines 1089-1094 Note that permanent location is a code, and location may be an authval. Link Here
1089
    </div>
1095
    </div>
1090
</div>
1096
</div>
1091
1097
1098
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1099
    <div class="modal-dialog">
1100
        <div class="modal-content">
1101
            <div class="modal-header">
1102
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1103
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1104
            </div>
1105
            <form id="modal-volume-set-form" class="validated">
1106
                <div class="modal-body">
1107
                    <fieldset>
1108
                        <p>
1109
                            <label for="volume" class="required">Volume: </label>
1110
                            <select name="volume" id="volume-add-form-select">
1111
                                [% FOREACH v IN biblio.volumes %]
1112
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1113
                                [% END %]
1114
                            </select>
1115
                            <span class="required">Required</span>
1116
                        </p>
1117
                    </fieldset>
1118
                </div>
1119
                <div class="modal-footer">
1120
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1121
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1122
                </div>
1123
            </form>
1124
        </div>
1125
    </div>
1126
</div>
1127
1128
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1129
    <div class="modal-dialog">
1130
        <div class="modal-content">
1131
            <div class="modal-header">
1132
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1133
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1134
            </div>
1135
            <div class="modal-body">
1136
                Are you sure you want to remove these item(s) from their volume(s)?
1137
            </div>
1138
            <div class="modal-footer">
1139
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1140
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1141
            </div>
1142
        </div>
1143
    </div>
1144
</div>
1145
1092
[% MACRO jsinclude BLOCK %]
1146
[% MACRO jsinclude BLOCK %]
1093
    [% INCLUDE 'catalog-strings.inc' %]
1147
    [% INCLUDE 'catalog-strings.inc' %]
1094
    [% Asset.js("js/catalog.js") | $raw %]
1148
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1594-1599 Note that permanent location is a code, and location may be an authval. Link Here
1594
                    }
1648
                    }
1595
                });
1649
                });
1596
            });
1650
            });
1651
1652
            // Add item(s) to a volume
1653
            $('.itemselection_action_volume_set').on('click', function(){
1654
                $('#modal-volume-set').modal('show');
1655
            });
1656
1657
            $("#modal-volume-set-form").validate({
1658
                submitHandler: function(form) {
1659
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1660
1661
                    const volume_id = $('#volume-add-form-select').val();
1662
1663
                    let itemnumbers = new Array();
1664
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1665
                        const itemnumber = $(this).val();
1666
                        itemnumbers.push( itemnumber );
1667
                    });
1668
                    if (itemnumbers.length > 0) {
1669
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1670
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1671
                        url += '&biblionumber=[% biblionumber | uri %]';
1672
                        url += `&volume_id=${volume_id}`;
1673
1674
                        window.location.replace(url);
1675
                    }
1676
1677
                    $('#modal-volume-set').modal('hide');
1678
                }
1679
            });
1680
1681
            // Remove item(s) from a volume
1682
            $('.itemselection_action_volume_unset').on('click', function(){
1683
                $('#modal-volume-unset').modal('show');
1684
            });
1685
1686
            $("#modal-volume-unset-submit").on('click', function(){
1687
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1688
1689
                let itemnumbers = new Array();
1690
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1691
                    const itemnumber = $(this).val();
1692
                    itemnumbers.push( itemnumber );
1693
                });
1694
                if (itemnumbers.length > 0) {
1695
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1696
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1697
                    url += '&biblionumber=[% biblionumber | uri %]';
1698
1699
                    window.location.replace(url);
1700
                }
1701
1702
                $('#modal-volume-unset').modal('hide');
1703
            });
1597
        [% END %]
1704
        [% END %]
1598
    </script>
1705
    </script>
1599
[% END %]
1706
[% END %]
1600
- 

Return to bug 24857