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 / +54 lines)
Lines 21-54 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;
40
use C4::Serials;    #uses getsubscriptionfrom biblionumber
37
use C4::Tags qw(get_tags);
41
use C4::Tags qw(get_tags);
42
use C4::XISBN qw(get_xisbns);
38
use C4::XSLT;
43
use C4::XSLT;
39
use C4::Images;
44
40
use Koha::DateUtils;
41
use C4::HTML5Media;
42
use C4::CourseReserves qw(GetItemCourseReservesInfo);
43
use C4::Acquisition qw(GetOrdersByBiblionumber);
44
use Koha::AuthorisedValues;
45
use Koha::AuthorisedValues;
46
use Koha::Biblio::Volume::Items;
45
use Koha::Biblios;
47
use Koha::Biblios;
48
use Koha::DateUtils qw(format_sqldatetime);
46
use Koha::Illrequests;
49
use Koha::Illrequests;
47
use Koha::Items;
48
use Koha::ItemTypes;
50
use Koha::ItemTypes;
51
use Koha::Items;
52
use Koha::Items;
49
use Koha::Patrons;
53
use Koha::Patrons;
50
use Koha::Virtualshelves;
51
use Koha::Plugins;
54
use Koha::Plugins;
55
use Koha::Virtualshelves;
52
56
53
my $query = CGI->new();
57
my $query = CGI->new();
54
58
Lines 115-120 if ( not defined $record ) { Link Here
115
eval { $biblio->metadata->record };
119
eval { $biblio->metadata->record };
116
$template->param( decoding_error => $@ );
120
$template->param( decoding_error => $@ );
117
121
122
my $op = $query->param('op') || q{};
123
if ( $op eq 'set_volume' ) {
124
    my $volume_id   = $query->param('volume_id');
125
    my @itemnumbers = $query->multi_param('itemnumber');
126
127
    foreach my $itemnumber (@itemnumbers) {
128
        my $volume_item =
129
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
130
131
        if ($volume_item) {
132
            $volume_item->volume_id($volume_id);
133
        }
134
        else {
135
            $volume_item = Koha::Biblio::Volume::Item->new(
136
                {
137
                    itemnumber => $itemnumber,
138
                    volume_id  => $volume_id,
139
                }
140
            );
141
        }
142
143
        $volume_item->store();
144
    }
145
}
146
elsif ( $op eq 'unset_volume' ) {
147
    my $volume_id   = $query->param('volume_id');
148
    my @itemnumbers = $query->multi_param('itemnumber');
149
150
    foreach my $itemnumber (@itemnumbers) {
151
        my $volume_item =
152
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
153
        $volume_item->delete() if $volume_item;
154
    }
155
}
156
118
if($query->cookie("holdfor")){ 
157
if($query->cookie("holdfor")){ 
119
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
158
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
120
    $template->param(
159
    $template->param(
Lines 328-333 foreach my $item (@items) { Link Here
328
367
329
    # checking for holds
368
    # checking for holds
330
    my $item_object = Koha::Items->find( $item->{itemnumber} );
369
    my $item_object = Koha::Items->find( $item->{itemnumber} );
370
    $item->{object} = $item_object;
331
    my $holds = $item_object->current_holds;
371
    my $holds = $item_object->current_holds;
332
    if ( my $first_hold = $holds->next ) {
372
    if ( my $first_hold = $holds->next ) {
333
        $item->{first_hold} = $first_hold;
373
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 267-272 Link Here
267
              [% IF CAN_user_tools_items_batchmod %]
267
              [% IF CAN_user_tools_items_batchmod %]
268
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
268
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
269
              [% END %]
269
              [% END %]
270
              [% IF biblio.volumes.count %]
271
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
272
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
273
              [% END %]
270
            </span>
274
            </span>
271
        [% END %]
275
        [% END %]
272
    </div>
276
    </div>
Lines 278-283 Link Here
278
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
282
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
279
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
283
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
280
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
284
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
285
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
281
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
286
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
282
                [% IF volinfo %]
287
                [% IF volinfo %]
283
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
288
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
Lines 340-345 Note that permanent location is a code, and location may be an authval. Link Here
340
                        </span>
345
                        </span>
341
                    </td>
346
                    </td>
342
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
347
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
348
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
343
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
349
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
344
                    [% IF ( volinfo ) %]
350
                    [% IF ( volinfo ) %]
345
                        <td class="enumchron">
351
                        <td class="enumchron">
Lines 1029-1035 Note that permanent location is a code, and location may be an authval. Link Here
1029
    </div>
1035
    </div>
1030
</div>
1036
</div>
1031
1037
1032
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1038
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1033
    <div class="modal-dialog">
1039
    <div class="modal-dialog">
1034
        <div class="modal-content">
1040
        <div class="modal-content">
1035
            <div class="modal-header">
1041
            <div class="modal-header">
Lines 1047-1052 Note that permanent location is a code, and location may be an authval. Link Here
1047
    </div>
1053
    </div>
1048
</div>
1054
</div>
1049
1055
1056
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1057
    <div class="modal-dialog">
1058
        <div class="modal-content">
1059
            <div class="modal-header">
1060
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1061
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1062
            </div>
1063
            <form id="modal-volume-set-form" class="validated">
1064
                <div class="modal-body">
1065
                    <fieldset>
1066
                        <p>
1067
                            <label for="volume" class="required">Volume: </label>
1068
                            <select name="volume" id="volume-add-form-select">
1069
                                [% FOREACH v IN biblio.volumes %]
1070
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1071
                                [% END %]
1072
                            </select>
1073
                            <span class="required">Required</span>
1074
                        </p>
1075
                    </fieldset>
1076
                </div>
1077
                <div class="modal-footer">
1078
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1079
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1080
                </div>
1081
            </form>
1082
        </div>
1083
    </div>
1084
</div>
1085
1086
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1087
    <div class="modal-dialog">
1088
        <div class="modal-content">
1089
            <div class="modal-header">
1090
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1091
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1092
            </div>
1093
            <div class="modal-body">
1094
                Are you sure you want to remove these item(s) from their volume(s)?
1095
            </div>
1096
            <div class="modal-footer">
1097
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1098
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1099
            </div>
1100
        </div>
1101
    </div>
1102
</div>
1103
1050
[% MACRO jsinclude BLOCK %]
1104
[% MACRO jsinclude BLOCK %]
1051
    [% INCLUDE 'catalog-strings.inc' %]
1105
    [% INCLUDE 'catalog-strings.inc' %]
1052
    [% Asset.js("js/catalog.js") | $raw %]
1106
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1545-1550 Note that permanent location is a code, and location may be an authval. Link Here
1545
                    }
1599
                    }
1546
                });
1600
                });
1547
            });
1601
            });
1602
1603
            // Add item(s) to a volume
1604
            $('.itemselection_action_volume_set').on('click', function(){
1605
                $('#modal-volume-set').modal('show');
1606
            });
1607
1608
            $("#modal-volume-set-form").validate({
1609
                submitHandler: function(form) {
1610
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1611
1612
                    const volume_id = $('#volume-add-form-select').val();
1613
1614
                    let itemnumbers = new Array();
1615
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1616
                        const itemnumber = $(this).val();
1617
                        itemnumbers.push( itemnumber );
1618
                    });
1619
                    if (itemnumbers.length > 0) {
1620
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1621
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1622
                        url += '&biblionumber=[% biblionumber | uri %]';
1623
                        url += `&volume_id=${volume_id}`;
1624
1625
                        window.location.replace(url);
1626
                    }
1627
1628
                    $('#modal-volume-set').modal('hide');
1629
                }
1630
            });
1631
1632
            // Remove item(s) from a volume
1633
            $('.itemselection_action_volume_unset').on('click', function(){
1634
                $('#modal-volume-unset').modal('show');
1635
            });
1636
1637
            $("#modal-volume-unset-submit").on('click', function(){
1638
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1639
1640
                let itemnumbers = new Array();
1641
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1642
                    const itemnumber = $(this).val();
1643
                    itemnumbers.push( itemnumber );
1644
                });
1645
                if (itemnumbers.length > 0) {
1646
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1647
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1648
                    url += '&biblionumber=[% biblionumber | uri %]';
1649
1650
                    window.location.replace(url);
1651
                }
1652
1653
                $('#modal-volume-unset').modal('hide');
1654
            });
1548
        [% END %]
1655
        [% END %]
1549
    </script>
1656
    </script>
1550
[% END %]
1657
[% END %]
1551
- 

Return to bug 24857