View | Details | Raw Unified | Return to bug 24857
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-1 / +2 lines)
Lines 35-47 use Koha::ArticleRequest::Status; Link Here
35
use Koha::ArticleRequests;
35
use Koha::ArticleRequests;
36
use Koha::Biblio::Metadatas;
36
use Koha::Biblio::Metadatas;
37
use Koha::Biblio::Volumes;
37
use Koha::Biblio::Volumes;
38
use Koha::Biblio::Volumes;
38
use Koha::Biblioitems;
39
use Koha::Biblioitems;
39
use Koha::CirculationRules;
40
use Koha::CirculationRules;
40
use Koha::Item::Transfer::Limits;
41
use Koha::Item::Transfer::Limits;
41
use Koha::Items;
42
use Koha::Items;
42
use Koha::Libraries;
43
use Koha::Libraries;
43
use Koha::Suggestions;
44
use Koha::Subscriptions;
44
use Koha::Subscriptions;
45
use Koha::Suggestions;
45
46
46
=head1 NAME
47
=head1 NAME
47
48
(-)a/catalogue/detail.pl (-2 / +40 lines)
Lines 46-60 use Koha::DateUtils qw( format_sqldatetime ); Link Here
46
use C4::HTML5Media;
46
use C4::HTML5Media;
47
use C4::CourseReserves qw( GetItemCourseReservesInfo );
47
use C4::CourseReserves qw( GetItemCourseReservesInfo );
48
use Koha::AuthorisedValues;
48
use Koha::AuthorisedValues;
49
use Koha::Biblio::Volume::Items;
49
use Koha::Biblios;
50
use Koha::Biblios;
50
use Koha::CoverImages;
51
use Koha::CoverImages;
52
use Koha::DateUtils;
51
use Koha::Illrequests;
53
use Koha::Illrequests;
52
use Koha::Items;
53
use Koha::ItemTypes;
54
use Koha::ItemTypes;
55
use Koha::Items;
54
use Koha::Patrons;
56
use Koha::Patrons;
55
use Koha::Virtualshelves;
56
use Koha::Plugins;
57
use Koha::Plugins;
57
use Koha::SearchEngine::Search;
58
use Koha::SearchEngine::Search;
59
use Koha::Virtualshelves;
58
60
59
my $query = CGI->new();
61
my $query = CGI->new();
60
62
Lines 97-102 if ( not defined $record ) { Link Here
97
eval { $biblio->metadata->record };
99
eval { $biblio->metadata->record };
98
$template->param( decoding_error => $@ );
100
$template->param( decoding_error => $@ );
99
101
102
my $op = $query->param('op') || q{};
103
if ( $op eq 'set_volume' ) {
104
    my $volume_id   = $query->param('volume_id');
105
    my @itemnumbers = $query->multi_param('itemnumber');
106
107
    foreach my $itemnumber (@itemnumbers) {
108
        my $volume_item =
109
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
110
111
        if ($volume_item) {
112
            $volume_item->volume_id($volume_id);
113
        }
114
        else {
115
            $volume_item = Koha::Biblio::Volume::Item->new(
116
                {
117
                    itemnumber => $itemnumber,
118
                    volume_id  => $volume_id,
119
                }
120
            );
121
        }
122
123
        $volume_item->store();
124
    }
125
}
126
elsif ( $op eq 'unset_volume' ) {
127
    my $volume_id   = $query->param('volume_id');
128
    my @itemnumbers = $query->multi_param('itemnumber');
129
130
    foreach my $itemnumber (@itemnumbers) {
131
        my $volume_item =
132
          Koha::Biblio::Volume::Items->find( { itemnumber => $itemnumber } );
133
        $volume_item->delete() if $volume_item;
134
    }
135
}
136
100
if($query->cookie("holdfor")){
137
if($query->cookie("holdfor")){
101
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
138
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
102
    if ( $holdfor_patron ) {
139
    if ( $holdfor_patron ) {
Lines 329-334 foreach my $item (@items) { Link Here
329
366
330
    # checking for holds
367
    # checking for holds
331
    my $item_object = Koha::Items->find( $item->{itemnumber} );
368
    my $item_object = Koha::Items->find( $item->{itemnumber} );
369
    $item->{object} = $item_object;
332
    my $holds = $item_object->current_holds;
370
    my $holds = $item_object->current_holds;
333
    if ( my $first_hold = $holds->next ) {
371
    if ( my $first_hold = $holds->next ) {
334
        $item->{first_hold} = $first_hold;
372
        $item->{first_hold} = $first_hold;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +108 lines)
Lines 310-315 Link Here
310
              [% IF CAN_user_tools_items_batchmod %]
310
              [% IF CAN_user_tools_items_batchmod %]
311
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
311
                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
312
              [% END %]
312
              [% END %]
313
              [% IF biblio.volumes.count %]
314
                <a class="itemselection_action_volume_set" href="#"><i class="fa fa-book"></i> Add/move to volume</a>
315
                <a class="itemselection_action_volume_unset" href="#"><i class="fa fa-unlink"></i> Remove from volume</a>
316
              [% END %]
313
            </span>
317
            </span>
314
        [% END %]
318
        [% END %]
315
    </div>
319
    </div>
Lines 324-329 Link Here
324
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
328
                <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
325
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
329
                <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
326
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
330
                [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
331
                [% IF Koha.Preference('EnableVolumes') %]<th>Volume</th>[% END %]
327
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
332
                <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
328
                [% IF volinfo %]
333
                [% IF volinfo %]
329
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
334
                    <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
Lines 398-403 Note that permanent location is a code, and location may be an authval. Link Here
398
                        </span>
403
                        </span>
399
                    </td>
404
                    </td>
400
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
405
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
406
                    [% IF Koha.Preference('EnableVolumes') %]<td>[% item.object.volume.description | html %]</td>[% END %]
401
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
407
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
402
                    [% IF ( volinfo ) %]
408
                    [% IF ( volinfo ) %]
403
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
409
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
Lines 1102-1108 Note that permanent location is a code, and location may be an authval. Link Here
1102
    </div>
1108
    </div>
1103
</div>
1109
</div>
1104
1110
1105
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1111
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-delete-label">
1106
    <div class="modal-dialog">
1112
    <div class="modal-dialog">
1107
        <div class="modal-content">
1113
        <div class="modal-content">
1108
            <div class="modal-header">
1114
            <div class="modal-header">
Lines 1120-1125 Note that permanent location is a code, and location may be an authval. Link Here
1120
    </div>
1126
    </div>
1121
</div>
1127
</div>
1122
1128
1129
<div class="modal fade" id="modal-volume-set" tabindex="-1" role="dialog" aria-labelledby="modal-volume-set-label">
1130
    <div class="modal-dialog">
1131
        <div class="modal-content">
1132
            <div class="modal-header">
1133
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1134
                <h3 id="modal-volume-set-label"><i class='fa fa-book'></i> Set volume for items</h3>
1135
            </div>
1136
            <form id="modal-volume-set-form" class="validated">
1137
                <div class="modal-body">
1138
                    <fieldset>
1139
                        <p>
1140
                            <label for="volume" class="required">Volume: </label>
1141
                            <select name="volume" id="volume-add-form-select">
1142
                                [% FOREACH v IN biblio.volumes %]
1143
                                    <option value="[% v.id | html %]">[% v.description | html %]</option>
1144
                                [% END %]
1145
                            </select>
1146
                            <span class="required">Required</span>
1147
                        </p>
1148
                    </fieldset>
1149
                </div>
1150
                <div class="modal-footer">
1151
                    <button id="modal-volume-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set volume</button>
1152
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1153
                </div>
1154
            </form>
1155
        </div>
1156
    </div>
1157
</div>
1158
1159
<div class="modal fade" id="modal-volume-unset" tabindex="-1" role="dialog" aria-labelledby="modal-volume-unset-label">
1160
    <div class="modal-dialog">
1161
        <div class="modal-content">
1162
            <div class="modal-header">
1163
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1164
                <h3 id="modal-volume-unset-label"><i class='fa fa-unlink'></i> Remove item from volume</h3>
1165
            </div>
1166
            <div class="modal-body">
1167
                Are you sure you want to remove these item(s) from their volume(s)?
1168
            </div>
1169
            <div class="modal-footer">
1170
                <button id="modal-volume-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1171
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1172
            </div>
1173
        </div>
1174
    </div>
1175
</div>
1176
1123
[% MACRO jsinclude BLOCK %]
1177
[% MACRO jsinclude BLOCK %]
1124
    [% INCLUDE 'catalog-strings.inc' %]
1178
    [% INCLUDE 'catalog-strings.inc' %]
1125
    [% Asset.js("js/catalog.js") | $raw %]
1179
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1654-1659 Note that permanent location is a code, and location may be an authval. Link Here
1654
                    }
1708
                    }
1655
                });
1709
                });
1656
            });
1710
            });
1711
1712
            // Add item(s) to a volume
1713
            $('.itemselection_action_volume_set').on('click', function(){
1714
                $('#modal-volume-set').modal('show');
1715
            });
1716
1717
            $("#modal-volume-set-form").validate({
1718
                submitHandler: function(form) {
1719
                    $('#modal-volume-set-submit').attr('disabled', 'disabled');
1720
1721
                    const volume_id = $('#volume-add-form-select').val();
1722
1723
                    let itemnumbers = new Array();
1724
                    $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1725
                        const itemnumber = $(this).val();
1726
                        itemnumbers.push( itemnumber );
1727
                    });
1728
                    if (itemnumbers.length > 0) {
1729
                        let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_volume';
1730
                        url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1731
                        url += '&biblionumber=[% biblionumber | uri %]';
1732
                        url += `&volume_id=${volume_id}`;
1733
1734
                        window.location.replace(url);
1735
                    }
1736
1737
                    $('#modal-volume-set').modal('hide');
1738
                }
1739
            });
1740
1741
            // Remove item(s) from a volume
1742
            $('.itemselection_action_volume_unset').on('click', function(){
1743
                $('#modal-volume-unset').modal('show');
1744
            });
1745
1746
            $("#modal-volume-unset-submit").on('click', function(){
1747
                $('#modal-volume-unset-submit').attr('disabled', 'disabled');
1748
1749
                let itemnumbers = new Array();
1750
                $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
1751
                    const itemnumber = $(this).val();
1752
                    itemnumbers.push( itemnumber );
1753
                });
1754
                if (itemnumbers.length > 0) {
1755
                    let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_volume';
1756
                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1757
                    url += '&biblionumber=[% biblionumber | uri %]';
1758
1759
                    window.location.replace(url);
1760
                }
1761
1762
                $('#modal-volume-unset').modal('hide');
1763
            });
1657
        [% END %]
1764
        [% END %]
1658
    </script>
1765
    </script>
1659
[% END %]
1766
[% END %]
1660
- 

Return to bug 24857