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

(-)a/cataloguing/additem.pl (+15 lines)
Lines 32-37 use C4::Context; Link Here
32
use C4::Members;
32
use C4::Members;
33
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
33
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
34
use C4::Search qw( enabled_staff_search_views );
34
use C4::Search qw( enabled_staff_search_views );
35
use C4::Acquisition qw( GetOrderFromItemnumber );
35
use Koha::Biblios;
36
use Koha::Biblios;
36
use Koha::Item::Templates;
37
use Koha::Item::Templates;
37
use Koha::ItemTypes;
38
use Koha::ItemTypes;
Lines 42-47 use Koha::Patrons; Link Here
42
use Koha::SearchEngine::Indexer;
43
use Koha::SearchEngine::Indexer;
43
use Koha::UI::Form::Builder::Item;
44
use Koha::UI::Form::Builder::Item;
44
use Koha::Result::Boolean;
45
use Koha::Result::Boolean;
46
use Koha::Serial::Items;
47
use Koha::Subscriptions;
45
48
46
use Encode          qw( encode_utf8 );
49
use Encode          qw( encode_utf8 );
47
use List::MoreUtils qw( any uniq );
50
use List::MoreUtils qw( any uniq );
Lines 680-688 if ($op) { Link Here
680
# now, build existiing item list
683
# now, build existiing item list
681
684
682
my @items;
685
my @items;
686
my %warning_messages;
683
for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) {
687
for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) {
684
    my $i = $item->columns_to_str;
688
    my $i = $item->columns_to_str;
685
    $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch );
689
    $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch );
690
    my $i_order    = GetOrderFromItemnumber( $i->{itemnumber} );
691
    my $i_serialid = Koha::Serial::Items->find( { itemnumber => $i->{itemnumber} }, { prefetch => 'serialid' } );
692
    if ($i_order) {
693
        $warning_messages{ $i->{itemnumber} } =
694
            sprintf( 'There is an order (ordernumber %s) on this item', $i_order->{ordernumber} );
695
    }
696
    if ($i_serialid) {
697
        $warning_messages{ $i->{itemnumber} } = 'A subscription is linked to this item';
698
    }
699
    $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch );
686
    push @items, $i;
700
    push @items, $i;
687
}
701
}
688
702
Lines 807-812 $template->param( Link Here
807
    barcode          => $current_item->{barcode},
821
    barcode          => $current_item->{barcode},
808
    op               => $nextop,
822
    op               => $nextop,
809
    popup            => scalar $input->param('popup') ? 1 : 0,
823
    popup            => scalar $input->param('popup') ? 1 : 0,
824
    warning_messages => \%warning_messages,
810
    C4::Search::enabled_staff_search_views,
825
    C4::Search::enabled_staff_search_views,
811
);
826
);
812
$template->{'VARS'}->{'searchid'} = $searchid;
827
$template->{'VARS'}->{'searchid'} = $searchid;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (+19 lines)
Lines 262-267 Link Here
262
                [% END %]
262
                [% END %]
263
                <th class="anti-the">Title</th>
263
                <th class="anti-the">Title</th>
264
                <th class="holds_count" title="Item holds / Total holds">Holds</th>
264
                <th class="holds_count" title="Item holds / Total holds">Holds</th>
265
                <th class="linked_order" title="Linked order">Linked order</th>
266
                <th class="linked_subscription" title="Linked subscription">Linked subscription</th>
265
                [% FOREACH item_header IN headers %]
267
                [% FOREACH item_header IN headers %]
266
                    [% IF item_header.column_name %]
268
                    [% IF item_header.column_name %]
267
                        <th data-colname="[% item_header.column_name | html %]">
269
                        <th data-colname="[% item_header.column_name | html %]">
Lines 276-281 Link Here
276
        <tbody>
278
        <tbody>
277
            [% FOREACH item IN items %]
279
            [% FOREACH item IN items %]
278
                [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
280
                [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
281
                [% SET current_itemnumber = item.itemnumber %]
282
                [% SET linked_order = linked_orders_subscriptions.$current_itemnumber %]
283
                [% SET linked_subscription = linked_orders_subscriptions.$current_itemnumber.subscription %]
279
284
280
                <tr>
285
                <tr>
281
                    <td>[% item.index + 1 | html %]</td>
286
                    <td>[% item.index + 1 | html %]</td>
Lines 346-351 Link Here
346
                        [% END %]
351
                        [% END %]
347
                        </a>
352
                        </a>
348
                    </td>
353
                    </td>
354
                    <td class="linked_order">
355
                        [% IF linked_order.ordernumber %]
356
                            <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% linked_order.basket | uri %]" title="See basket details">[% linked_order.ordernumber | html %]<a>
357
                        [% ELSE %]
358
                            None
359
                        [% END %]
360
                    </td>
361
                    <td class="linked_subscription">
362
                        [% IF linked_subscription %]
363
                            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% linked_subscription | uri %]" title="Subscription id [% linked_subscription | html %]">Subscription details<a>
364
                        [% ELSE %]
365
                            None
366
                        [% END %]
367
                    </td>
349
                    [% FOREACH header IN headers %]
368
                    [% FOREACH header IN headers %]
350
                        [% SET attribute = header.attribute %]
369
                        [% SET attribute = header.attribute %]
351
                        [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %]
370
                        [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-2 / +8 lines)
Lines 115-121 Link Here
115
            <tbody>
115
            <tbody>
116
                    [% FOREACH item IN items %]
116
                    [% FOREACH item IN items %]
117
                        [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %]
117
                        [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %]
118
                        [% IF item.itemnumber == itemnumber%]
118
                        [% SET current_itemnumber = item.itemnumber %]
119
                        [% SET warn_message = warning_messages.$current_itemnumber %]
120
                        [% IF item.itemnumber == itemnumber %]
119
                            [% UNLESS can_be_edited %]
121
                            [% UNLESS can_be_edited %]
120
                            <tr id="row[% item.itemnumber | html %]" class="active">
122
                            <tr id="row[% item.itemnumber | html %]" class="active">
121
                            [% ELSE %]
123
                            [% ELSE %]
Lines 157-163 Link Here
157
                                            <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
159
                                            <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
158
                                            <input type="hidden" name="searchid" value="[% searchid | html %]" />
160
                                            <input type="hidden" name="searchid" value="[% searchid | html %]" />
159
                                        </form>
161
                                        </form>
160
                                        <a class="dropdown-item delete" data-item="[% item.itemnumber | html %]" href="#">Delete</a>
162
                                        <a class="dropdown-item delete" data-item="[% item.itemnumber | html %]" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% item.biblionumber | html %]&amp;itemnumber=[% item.itemnumber | html %]&amp;searchid=[% searchid | html %]" onclick="return confirm_deletion();">Delete
163
                                            [% IF warn_message %]
164
                                                <i class="fa fa-warning warn" Title="[% warn_message | html %]"></i>
165
                                            [% END %]
166
                                        </a>
161
                                    </li>
167
                                    </li>
162
                                [% END %]
168
                                [% END %]
163
                            [% END %]
169
                            [% END %]
(-)a/tools/batchMod.pl (-6 / +22 lines)
Lines 26-31 use C4::Auth qw( get_template_and_user haspermission ); Link Here
26
use C4::Output qw( output_html_with_http_headers );
26
use C4::Output qw( output_html_with_http_headers );
27
use C4::Circulation qw( barcodedecode );
27
use C4::Circulation qw( barcodedecode );
28
use C4::Context;
28
use C4::Context;
29
use C4::Acquisition qw( GetOrderFromItemnumber );
29
use MARC::File::XML;
30
use MARC::File::XML;
30
use List::MoreUtils qw( uniq );
31
use List::MoreUtils qw( uniq );
31
use Encode qw( encode_utf8 );
32
use Encode qw( encode_utf8 );
Lines 40-45 use Koha::BackgroundJob::BatchDeleteItem; Link Here
40
use Koha::BackgroundJob::BatchUpdateItem;
41
use Koha::BackgroundJob::BatchUpdateItem;
41
use Koha::UI::Form::Builder::Item;
42
use Koha::UI::Form::Builder::Item;
42
use Koha::UI::Table::Builder::Items;
43
use Koha::UI::Table::Builder::Items;
44
use Koha::Serial::Items;
45
use Koha::Serials;
43
46
44
my $input = CGI->new;
47
my $input = CGI->new;
45
my $dbh = C4::Context->dbh;
48
my $dbh = C4::Context->dbh;
Lines 85-90 my $nextop=""; Link Here
85
my $display_items;
88
my $display_items;
86
89
87
my @messages;
90
my @messages;
91
my %linked_orders_subscriptions;
88
92
89
if ( $op eq "cud-action" ) {
93
if ( $op eq "cud-action" ) {
90
94
Lines 94-101 if ( $op eq "cud-action" ) { Link Here
94
                record_ids     => \@itemnumbers,
98
                record_ids     => \@itemnumbers,
95
                delete_biblios => $del_records,
99
                delete_biblios => $del_records,
96
            };
100
            };
97
            my $job_id =
101
            my $job_id = Koha::BackgroundJob::BatchDeleteItem->new->enqueue($params);
98
              Koha::BackgroundJob::BatchDeleteItem->new->enqueue($params);
99
            $nextop = 'enqueued';
102
            $nextop = 'enqueued';
100
            $template->param( job_id => $job_id, );
103
            $template->param( job_id => $job_id, );
101
        }
104
        }
Lines 239-244 if ($op eq "cud-show" || $op eq "show"){ Link Here
239
        if (defined $biblionumber && !@itemnumbers){
242
        if (defined $biblionumber && !@itemnumbers){
240
            my $biblio = Koha::Biblios->find($biblionumber);
243
            my $biblio = Koha::Biblios->find($biblionumber);
241
            @itemnumbers = $biblio ? $biblio->items->get_column('itemnumber') : ();
244
            @itemnumbers = $biblio ? $biblio->items->get_column('itemnumber') : ();
245
            foreach my $itemnumber (@itemnumbers) {
246
                $linked_orders_subscriptions{$itemnumber} = [];
247
                my $order     = GetOrderFromItemnumber($itemnumber);
248
                my $serial_id = Koha::Serial::Items->search( { itemnumber => $itemnumber } )->get_column('serialid');
249
                if ($order) {
250
                    $linked_orders_subscriptions{$itemnumber} =
251
                        { ordernumber => $order->{ordernumber}, basket => $order->{basketno} };
252
                }
253
                if ($serial_id) {
254
                    my $subscription_id = Koha::Serials->search( { serialid => $serial_id } )->get_column('subscriptionid');
255
                    $linked_orders_subscriptions{$itemnumber} = { subscription => $subscription_id };
256
                }
257
            }
242
        }
258
        }
243
        if ( my $list = $input->param('barcodelist') ) {
259
        if ( my $list = $input->param('barcodelist') ) {
244
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
260
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
Lines 291-299 if ($op eq "cud-show" || $op eq "show"){ Link Here
291
307
292
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
308
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
293
    $template->param(
309
    $template->param(
294
        subfields           => $subfields,
310
        subfields                   => $subfields,
295
        notfoundbarcodes    => \@notfoundbarcodes,
311
        notfoundbarcodes            => \@notfoundbarcodes,
296
        notfounditemnumbers => \@notfounditemnumbers
312
        notfounditemnumbers         => \@notfounditemnumbers,
313
        linked_orders_subscriptions => \%linked_orders_subscriptions,
297
    );
314
    );
298
    $nextop="cud-action";
315
    $nextop="cud-action";
299
    $template->param( show => 1 );
316
    $template->param( show => 1 );
300
- 

Return to bug 13870