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 (-14 / +52 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-98 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
95
if($query->cookie("holdfor")){
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
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 ) {
98
        $template->param(
135
        $template->param(
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 304-309 Link Here
304
              [% IF CAN_user_tools_items_batchmod %]
304
              [% IF CAN_user_tools_items_batchmod %]
305
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
305
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
306
              [% END %]
306
              [% END %]
307
              [% IF biblio.volumes.count %]
308
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
309
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
310
              [% END %]
307
            </span>
311
            </span>
308
        [% END %]
312
        [% END %]
309
    </div>
313
    </div>
Lines 318-323 Link Here
318
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
322
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
319
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
323
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
320
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
324
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
325
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
321
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
326
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
322
                [% IF volinfo %]
327
                [% IF volinfo %]
323
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
328
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
Lines 392-397 Note that permanent location is a code, and location may be an authval. Link Here
392
                        </span>
397
                        </span>
393
                    </td>
398
                    </td>
394
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
399
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
400
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
395
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
401
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
396
                    [% IF ( volinfo ) %]
402
                    [% IF ( volinfo ) %]
397
                        <td class="enumchron" data-order="[% item.publisheddate | html %]">
403
                        <td class="enumchron" data-order="[% item.publisheddate | html %]">
Lines 1092-1098 Note that permanent location is a code, and location may be an authval. Link Here
1092
    </div>
1098
    </div>
1093
</div>
1099
</div>
1094
1100
1095
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1101
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1096
    <div class="modal-dialog">
1102
    <div class="modal-dialog">
1097
        <div class="modal-content">
1103
        <div class="modal-content">
1098
            <div class="modal-header">
1104
            <div class="modal-header">
Lines 1110-1115 Note that permanent location is a code, and location may be an authval. Link Here
1110
    </div>
1116
    </div>
1111
</div>
1117
</div>
1112
1118
1119
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1120
    <div class="modal-dialog">
1121
        <div class="modal-content">
1122
            <div class="modal-header">
1123
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1124
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1125
            </div>
1126
            <form id="modal-volume-set-form" class="validated">
1127
                <div class="modal-body">
1128
                    <fieldset>
1129
                        <p>
1130
                            <label for="volume" class="required">Volume: </label>
1131
                            <select name="volume" id="volume-add-form-select">
1132
                                [% FOREACH v IN biblio.volumes %]
1133
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1134
                                [% END %]
1135
                            </select>
1136
                            <span class="required">Required</span>
1137
                        </p>
1138
                    </fieldset>
1139
                </div>
1140
                <div class="modal-footer">
1141
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1142
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1143
                </div>
1144
            </form>
1145
        </div>
1146
    </div>
1147
</div>
1148
1149
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1150
    <div class="modal-dialog">
1151
        <div class="modal-content">
1152
            <div class="modal-header">
1153
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1154
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1155
            </div>
1156
            <div class="modal-body">
1157
                Are you sure you want to remove these item(s) from their volume(s)?
1158
            </div>
1159
            <div class="modal-footer">
1160
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1161
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1162
            </div>
1163
        </div>
1164
    </div>
1165
</div>
1166
1113
[% MACRO jsinclude BLOCK %]
1167
[% MACRO jsinclude BLOCK %]
1114
    [% INCLUDE 'catalog-strings.inc' %]
1168
    [% INCLUDE 'catalog-strings.inc' %]
1115
    [% Asset.js("js/catalog.js") | $raw %]
1169
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1622-1627 Note that permanent location is a code, and location may be an authval. Link Here
1622
                    }
1676
                    }
1623
                });
1677
                });
1624
            });
1678
            });
1679
1680
            // Add item(s) to a volume
1681
            $('.itemselection_action_volume_set').on('click', function(){
1682
                $('#modal-volume-set').modal('show');
1683
            });
1684
1685
            $("#modal-volume-set-form").validate({
1686
                submitHandler: function(form) {
1687
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1688
1689
                    const volume_id = $('#volume-add-form-select').val();
1690
1691
                    let itemnumbers = new Array();
1692
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1693
                        const itemnumber = $(this).val();
1694
                        itemnumbers.push( itemnumber );
1695
                    });
1696
                    if (itemnumbers.length > 0) {
1697
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1698
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1699
                        url += '&biblionumber=[% biblionumber | uri %]';
1700
                        url += `&volume_id=${volume_id}`;
1701
1702
                        window.location.replace(url);
1703
                    }
1704
1705
                    $('#modal-volume-set').modal('hide');
1706
                }
1707
            });
1708
1709
            // Remove item(s) from a volume
1710
            $('.itemselection_action_volume_unset').on('click', function(){
1711
                $('#modal-volume-unset').modal('show');
1712
            });
1713
1714
            $("#modal-volume-unset-submit").on('click', function(){
1715
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1716
1717
                let itemnumbers = new Array();
1718
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1719
                    const itemnumber = $(this).val();
1720
                    itemnumbers.push( itemnumber );
1721
                });
1722
                if (itemnumbers.length > 0) {
1723
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1724
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1725
                    url += '&biblionumber=[% biblionumber | uri %]';
1726
1727
                    window.location.replace(url);
1728
                }
1729
1730
                $('#modal-volume-unset').modal('hide');
1731
            });
1625
        [% END %]
1732
        [% END %]
1626
    </script>
1733
    </script>
1627
[% END %]
1734
[% END %]
1628
- 

Return to bug 24857