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 92-97 if ( not defined $record ) { Link Here
92
eval { $biblio->metadata->record };
94
eval { $biblio->metadata->record };
93
$template->param( decoding_error => $@ );
95
$template->param( decoding_error => $@ );
94
96
97
my $op = $query->param('op') || q{};
98
if ( $op eq 'set_volume' ) {
99
    my $volume_id   = $query->param('volume_id');
100
    my @itemnumbers = $query->multi_param('itemnumber');
101
102
    foreach my $itemnumber (@itemnumbers) {
103
        my $volume_item =
104
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
105
106
        if ($volume_item) {
107
            $volume_item->volume_id($volume_id);
108
        }
109
        else {
110
            $volume_item = Koha::Biblio::Volume::Item->new(
111
                {
112
                    itemnumber => $itemnumber,
113
                    volume_id  => $volume_id,
114
                }
115
            );
116
        }
117
118
        $volume_item->store();
119
    }
120
}
121
elsif ( $op eq 'unset_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
        $volume_item->delete() if $volume_item;
129
    }
130
}
131
95
if($query->cookie("holdfor")){
132
if($query->cookie("holdfor")){
96
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
133
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
97
    if ( $holdfor_patron ) {
134
    if ( $holdfor_patron ) {
Lines 324-329 foreach my $item (@items) { Link Here
324
361
325
    # checking for holds
362
    # checking for holds
326
    my $item_object = Koha::Items->find( $item->{itemnumber} );
363
    my $item_object = Koha::Items->find( $item->{itemnumber} );
364
    $item->{object} = $item_object;
327
    my $holds = $item_object->current_holds;
365
    my $holds = $item_object->current_holds;
328
    if ( my $first_hold = $holds->next ) {
366
    if ( my $first_hold = $holds->next ) {
329
        $item->{first_hold} = $first_hold;
367
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 314-319 Link Here
314
              [% IF CAN_user_tools_items_batchmod %]
314
              [% IF CAN_user_tools_items_batchmod %]
315
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
315
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
316
              [% END %]
316
              [% END %]
317
              [% IF biblio.volumes.count %]
318
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
319
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
320
              [% END %]
317
            </span>
321
            </span>
318
        [% END %]
322
        [% END %]
319
    </div>
323
    </div>
Lines 328-333 Link Here
328
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
332
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
329
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
333
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
330
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
334
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
335
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
331
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
336
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
332
                [% IF volinfo %]
337
                [% IF volinfo %]
333
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
338
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
Lines 402-407 Note that permanent location is a code, and location may be an authval. Link Here
402
                        </span>
407
                        </span>
403
                    </td>
408
                    </td>
404
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
409
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
410
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
405
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
411
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
406
                    [% IF ( volinfo ) %]
412
                    [% IF ( volinfo ) %]
407
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
413
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
Lines 1106-1112 Note that permanent location is a code, and location may be an authval. Link Here
1106
    </div>
1112
    </div>
1107
</div>
1113
</div>
1108
1114
1109
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1115
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1110
    <div class="modal-dialog">
1116
    <div class="modal-dialog">
1111
        <div class="modal-content">
1117
        <div class="modal-content">
1112
            <div class="modal-header">
1118
            <div class="modal-header">
Lines 1124-1129 Note that permanent location is a code, and location may be an authval. Link Here
1124
    </div>
1130
    </div>
1125
</div>
1131
</div>
1126
1132
1133
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1134
    <div class="modal-dialog">
1135
        <div class="modal-content">
1136
            <div class="modal-header">
1137
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1138
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1139
            </div>
1140
            <form id="modal-volume-set-form" class="validated">
1141
                <div class="modal-body">
1142
                    <fieldset>
1143
                        <p>
1144
                            <label for="volume" class="required">Volume: </label>
1145
                            <select name="volume" id="volume-add-form-select">
1146
                                [% FOREACH v IN biblio.volumes %]
1147
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1148
                                [% END %]
1149
                            </select>
1150
                            <span class="required">Required</span>
1151
                        </p>
1152
                    </fieldset>
1153
                </div>
1154
                <div class="modal-footer">
1155
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1156
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1157
                </div>
1158
            </form>
1159
        </div>
1160
    </div>
1161
</div>
1162
1163
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1164
    <div class="modal-dialog">
1165
        <div class="modal-content">
1166
            <div class="modal-header">
1167
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1168
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1169
            </div>
1170
            <div class="modal-body">
1171
                Are you sure you want to remove these item(s) from their volume(s)?
1172
            </div>
1173
            <div class="modal-footer">
1174
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1175
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1176
            </div>
1177
        </div>
1178
    </div>
1179
</div>
1180
1127
[% MACRO jsinclude BLOCK %]
1181
[% MACRO jsinclude BLOCK %]
1128
    [% INCLUDE 'catalog-strings.inc' %]
1182
    [% INCLUDE 'catalog-strings.inc' %]
1129
    [% Asset.js("js/catalog.js") | $raw %]
1183
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1658-1663 Note that permanent location is a code, and location may be an authval. Link Here
1658
                    }
1712
                    }
1659
                });
1713
                });
1660
            });
1714
            });
1715
1716
            // Add item(s) to a volume
1717
            $('.itemselection_action_volume_set').on('click', function(){
1718
                $('#modal-volume-set').modal('show');
1719
            });
1720
1721
            $("#modal-volume-set-form").validate({
1722
                submitHandler: function(form) {
1723
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1724
1725
                    const volume_id = $('#volume-add-form-select').val();
1726
1727
                    let itemnumbers = new Array();
1728
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1729
                        const itemnumber = $(this).val();
1730
                        itemnumbers.push( itemnumber );
1731
                    });
1732
                    if (itemnumbers.length > 0) {
1733
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1734
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1735
                        url += '&biblionumber=[% biblionumber | uri %]';
1736
                        url += `&volume_id=${volume_id}`;
1737
1738
                        window.location.replace(url);
1739
                    }
1740
1741
                    $('#modal-volume-set').modal('hide');
1742
                }
1743
            });
1744
1745
            // Remove item(s) from a volume
1746
            $('.itemselection_action_volume_unset').on('click', function(){
1747
                $('#modal-volume-unset').modal('show');
1748
            });
1749
1750
            $("#modal-volume-unset-submit").on('click', function(){
1751
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1752
1753
                let itemnumbers = new Array();
1754
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1755
                    const itemnumber = $(this).val();
1756
                    itemnumbers.push( itemnumber );
1757
                });
1758
                if (itemnumbers.length > 0) {
1759
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1760
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1761
                    url += '&biblionumber=[% biblionumber | uri %]';
1762
1763
                    window.location.replace(url);
1764
                }
1765
1766
                $('#modal-volume-unset').modal('hide');
1767
            });
1661
        [% END %]
1768
        [% END %]
1662
    </script>
1769
    </script>
1663
[% END %]
1770
[% END %]
1664
- 

Return to bug 24857