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 / +53 lines)
Lines 21-53 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;
46
use Koha::Items;
48
use Koha::DateUtils;
47
use Koha::ItemTypes;
49
use Koha::ItemTypes;
50
use Koha::Items;
48
use Koha::Patrons;
51
use Koha::Patrons;
49
use Koha::Virtualshelves;
50
use Koha::Plugins;
52
use Koha::Plugins;
53
use Koha::Virtualshelves;
51
54
52
my $query = CGI->new();
55
my $query = CGI->new();
53
56
Lines 114-119 if ( not defined $record ) { Link Here
114
eval { $biblio->metadata->record };
117
eval { $biblio->metadata->record };
115
$template->param( decoding_error => $@ );
118
$template->param( decoding_error => $@ );
116
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
117
if($query->cookie("holdfor")){ 
155
if($query->cookie("holdfor")){ 
118
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
156
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
119
    $template->param(
157
    $template->param(
Lines 333-338 foreach my $item (@items) { Link Here
333
371
334
    # checking for holds
372
    # checking for holds
335
    my $item_object = Koha::Items->find( $item->{itemnumber} );
373
    my $item_object = Koha::Items->find( $item->{itemnumber} );
374
    $item->{object} = $item_object;
336
    my $holds = $item_object->current_holds;
375
    my $holds = $item_object->current_holds;
337
    if ( my $first_hold = $holds->next ) {
376
    if ( my $first_hold = $holds->next ) {
338
        $item->{first_hold} = $first_hold;
377
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 221-226 Link Here
221
              [% IF CAN_user_tools_items_batchmod %]
221
              [% IF CAN_user_tools_items_batchmod %]
222
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
222
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
223
              [% END %]
223
              [% END %]
224
              [% IF biblio.volumes.count %]
225
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
226
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
227
              [% END %]
224
            </span>
228
            </span>
225
        [% END %]
229
        [% END %]
226
    </div>
230
    </div>
Lines 232-237 Link Here
232
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current location</th>
236
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current location</th>
233
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
237
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
234
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
238
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
239
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
235
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
240
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
236
                [% IF volinfo %]
241
                [% IF volinfo %]
237
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
242
                [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting%]
Lines 293-298 Note that permanent location is a code, and location may be an authval. Link Here
293
                        </span>
298
                        </span>
294
                    </td>
299
                    </td>
295
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
300
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
301
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
296
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
302
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
297
                    [% IF ( volinfo ) %]
303
                    [% IF ( volinfo ) %]
298
                        <td class="enumchron">
304
                        <td class="enumchron">
Lines 981-987 Note that permanent location is a code, and location may be an authval. Link Here
981
    </div>
987
    </div>
982
</div>
988
</div>
983
989
984
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
990
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
985
    <div class="modal-dialog">
991
    <div class="modal-dialog">
986
        <div class="modal-content">
992
        <div class="modal-content">
987
            <div class="modal-header">
993
            <div class="modal-header">
Lines 999-1004 Note that permanent location is a code, and location may be an authval. Link Here
999
    </div>
1005
    </div>
1000
</div>
1006
</div>
1001
1007
1008
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1009
    <div class="modal-dialog">
1010
        <div class="modal-content">
1011
            <div class="modal-header">
1012
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1013
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1014
            </div>
1015
            <form id="modal-volume-set-form" class="validated">
1016
                <div class="modal-body">
1017
                    <fieldset>
1018
                        <p>
1019
                            <label for="volume" class="required">Volume: </label>
1020
                            <select name="volume" id="volume-add-form-select">
1021
                                [% FOREACH v IN biblio.volumes %]
1022
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1023
                                [% END %]
1024
                            </select>
1025
                            <span class="required">Required</span>
1026
                        </p>
1027
                    </fieldset>
1028
                </div>
1029
                <div class="modal-footer">
1030
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1031
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1032
                </div>
1033
            </form>
1034
        </div>
1035
    </div>
1036
</div>
1037
1038
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1039
    <div class="modal-dialog">
1040
        <div class="modal-content">
1041
            <div class="modal-header">
1042
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1043
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1044
            </div>
1045
            <div class="modal-body">
1046
                Are you sure you want to remove these item(s) from their volume(s)?
1047
            </div>
1048
            <div class="modal-footer">
1049
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1050
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1051
            </div>
1052
        </div>
1053
    </div>
1054
</div>
1055
1002
[% MACRO jsinclude BLOCK %]
1056
[% MACRO jsinclude BLOCK %]
1003
    [% INCLUDE 'catalog-strings.inc' %]
1057
    [% INCLUDE 'catalog-strings.inc' %]
1004
    [% Asset.js("js/catalog.js") | $raw %]
1058
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1448-1453 Note that permanent location is a code, and location may be an authval. Link Here
1448
                    }
1502
                    }
1449
                });
1503
                });
1450
            });
1504
            });
1505
1506
            // Add item(s) to a volume
1507
            $('.itemselection_action_volume_set').on('click', function(){
1508
                $('#modal-volume-set').modal('show');
1509
            });
1510
1511
            $("#modal-volume-set-form").validate({
1512
                submitHandler: function(form) {
1513
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1514
1515
                    const volume_id = $('#volume-add-form-select').val();
1516
1517
                    let itemnumbers = new Array();
1518
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1519
                        const itemnumber = $(this).val();
1520
                        itemnumbers.push( itemnumber );
1521
                    });
1522
                    if (itemnumbers.length > 0) {
1523
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1524
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1525
                        url += '&biblionumber=[% biblionumber | uri %]';
1526
                        url += `&volume_id=${volume_id}`;
1527
1528
                        window.location.replace(url);
1529
                    }
1530
1531
                    $('#modal-volume-set').modal('hide');
1532
                }
1533
            });
1534
1535
            // Remove item(s) from a volume
1536
            $('.itemselection_action_volume_unset').on('click', function(){
1537
                $('#modal-volume-unset').modal('show');
1538
            });
1539
1540
            $("#modal-volume-unset-submit").on('click', function(){
1541
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1542
1543
                let itemnumbers = new Array();
1544
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1545
                    const itemnumber = $(this).val();
1546
                    itemnumbers.push( itemnumber );
1547
                });
1548
                if (itemnumbers.length > 0) {
1549
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1550
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1551
                    url += '&biblionumber=[% biblionumber | uri %]';
1552
1553
                    window.location.replace(url);
1554
                }
1555
1556
                $('#modal-volume-unset').modal('hide');
1557
            });
1451
        [% END %]
1558
        [% END %]
1452
    </script>
1559
    </script>
1453
[% END %]
1560
[% END %]
1454
- 

Return to bug 24857