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 324-329 foreach my $item (@items) { Link Here
324
363
325
    # checking for holds
364
    # checking for holds
326
    my $item_object = Koha::Items->find( $item->{itemnumber} );
365
    my $item_object = Koha::Items->find( $item->{itemnumber} );
366
    $item->{object} = $item_object;
327
    my $holds = $item_object->current_holds;
367
    my $holds = $item_object->current_holds;
328
    if ( my $first_hold = $holds->next ) {
368
    if ( my $first_hold = $holds->next ) {
329
        $item->{first_hold} = $first_hold;
369
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 279-284 Link Here
279
              [% IF CAN_user_tools_items_batchmod %]
279
              [% IF CAN_user_tools_items_batchmod %]
280
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
280
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
281
              [% END %]
281
              [% END %]
282
              [% IF biblio.volumes.count %]
283
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
284
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
285
              [% END %]
282
            </span>
286
            </span>
283
        [% END %]
287
        [% END %]
284
    </div>
288
    </div>
Lines 290-295 Link Here
290
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
294
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
291
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
295
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
292
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
296
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
297
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
293
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
298
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
294
                [% IF volinfo %]
299
                [% IF volinfo %]
295
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
300
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
Lines 352-357 Note that permanent location is a code, and location may be an authval. Link Here
352
                        </span>
357
                        </span>
353
                    </td>
358
                    </td>
354
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
359
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
360
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
355
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
361
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
356
                    [% IF ( volinfo ) %]
362
                    [% IF ( volinfo ) %]
357
                        <td class="enumchron">
363
                        <td class="enumchron">
Lines 1041-1047 Note that permanent location is a code, and location may be an authval. Link Here
1041
    </div>
1047
    </div>
1042
</div>
1048
</div>
1043
1049
1044
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1050
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1045
    <div class="modal-dialog">
1051
    <div class="modal-dialog">
1046
        <div class="modal-content">
1052
        <div class="modal-content">
1047
            <div class="modal-header">
1053
            <div class="modal-header">
Lines 1059-1064 Note that permanent location is a code, and location may be an authval. Link Here
1059
    </div>
1065
    </div>
1060
</div>
1066
</div>
1061
1067
1068
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1069
    <div class="modal-dialog">
1070
        <div class="modal-content">
1071
            <div class="modal-header">
1072
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1073
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1074
            </div>
1075
            <form id="modal-volume-set-form" class="validated">
1076
                <div class="modal-body">
1077
                    <fieldset>
1078
                        <p>
1079
                            <label for="volume" class="required">Volume: </label>
1080
                            <select name="volume" id="volume-add-form-select">
1081
                                [% FOREACH v IN biblio.volumes %]
1082
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1083
                                [% END %]
1084
                            </select>
1085
                            <span class="required">Required</span>
1086
                        </p>
1087
                    </fieldset>
1088
                </div>
1089
                <div class="modal-footer">
1090
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1091
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1092
                </div>
1093
            </form>
1094
        </div>
1095
    </div>
1096
</div>
1097
1098
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-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-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1104
            </div>
1105
            <div class="modal-body">
1106
                Are you sure you want to remove these item(s) from their volume(s)?
1107
            </div>
1108
            <div class="modal-footer">
1109
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1110
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1111
            </div>
1112
        </div>
1113
    </div>
1114
</div>
1115
1062
[% MACRO jsinclude BLOCK %]
1116
[% MACRO jsinclude BLOCK %]
1063
    [% INCLUDE 'catalog-strings.inc' %]
1117
    [% INCLUDE 'catalog-strings.inc' %]
1064
    [% Asset.js("js/catalog.js") | $raw %]
1118
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1557-1562 Note that permanent location is a code, and location may be an authval. Link Here
1557
                    }
1611
                    }
1558
                });
1612
                });
1559
            });
1613
            });
1614
1615
            // Add item(s) to a volume
1616
            $('.itemselection_action_volume_set').on('click', function(){
1617
                $('#modal-volume-set').modal('show');
1618
            });
1619
1620
            $("#modal-volume-set-form").validate({
1621
                submitHandler: function(form) {
1622
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1623
1624
                    const volume_id = $('#volume-add-form-select').val();
1625
1626
                    let itemnumbers = new Array();
1627
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1628
                        const itemnumber = $(this).val();
1629
                        itemnumbers.push( itemnumber );
1630
                    });
1631
                    if (itemnumbers.length > 0) {
1632
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1633
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1634
                        url += '&biblionumber=[% biblionumber | uri %]';
1635
                        url += `&volume_id=${volume_id}`;
1636
1637
                        window.location.replace(url);
1638
                    }
1639
1640
                    $('#modal-volume-set').modal('hide');
1641
                }
1642
            });
1643
1644
            // Remove item(s) from a volume
1645
            $('.itemselection_action_volume_unset').on('click', function(){
1646
                $('#modal-volume-unset').modal('show');
1647
            });
1648
1649
            $("#modal-volume-unset-submit").on('click', function(){
1650
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1651
1652
                let itemnumbers = new Array();
1653
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1654
                    const itemnumber = $(this).val();
1655
                    itemnumbers.push( itemnumber );
1656
                });
1657
                if (itemnumbers.length > 0) {
1658
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1659
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1660
                    url += '&biblionumber=[% biblionumber | uri %]';
1661
1662
                    window.location.replace(url);
1663
                }
1664
1665
                $('#modal-volume-unset').modal('hide');
1666
            });
1560
        [% END %]
1667
        [% END %]
1561
    </script>
1668
    </script>
1562
[% END %]
1669
[% END %]
1563
- 

Return to bug 24857