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

(-)a/cataloguing/additem.pl (-3 / +17 lines)
Lines 30-37 use C4::Biblio qw( GetFrameworkCode GetMarcFromKohaField GetMarcStructure I Link Here
30
use C4::Circulation qw( barcodedecode LostItem );
30
use C4::Circulation qw( barcodedecode LostItem );
31
use C4::Context;
31
use C4::Context;
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-687 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;
689
    my $i_order    = GetOrderFromItemnumber( $i->{itemnumber} );
690
    my $i_serialid = Koha::Serial::Items->find( { itemnumber => $i->{itemnumber} }, { prefetch => 'serialid' } );
691
    if ($i_order) {
692
        $warning_messages{ $i->{itemnumber} } =
693
            sprintf( 'There is an order (ordernumber %s) on this item', $i_order->{ordernumber} );
694
    }
695
    if ($i_serialid) {
696
        $warning_messages{ $i->{itemnumber} } = 'A subscription is linked to this item';
697
    }
685
    $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch );
698
    $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch );
686
    push @items, $i;
699
    push @items, $i;
687
}
700
}
Lines 807-812 $template->param( Link Here
807
    barcode          => $current_item->{barcode},
820
    barcode          => $current_item->{barcode},
808
    op               => $nextop,
821
    op               => $nextop,
809
    popup            => scalar $input->param('popup') ? 1 : 0,
822
    popup            => scalar $input->param('popup') ? 1 : 0,
823
    warning_messages => \%warning_messages,
810
    C4::Search::enabled_staff_search_views,
824
    C4::Search::enabled_staff_search_views,
811
);
825
);
812
$template->{'VARS'}->{'searchid'} = $searchid;
826
$template->{'VARS'}->{'searchid'} = $searchid;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-2 / +18 lines)
Lines 336-342 Link Here
336
            <tbody>
336
            <tbody>
337
                [% FOREACH item IN items %]
337
                [% FOREACH item IN items %]
338
                    [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
338
                    [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
339
339
                    [% SET current_itemnumber = item.itemnumber %]
340
                    [% SET linked_order = linked_orders_subscriptions.$current_itemnumber %]
341
                    [% SET linked_subscription = linked_orders_subscriptions.$current_itemnumber.subscription %]
340
                    <tr>
342
                    <tr>
341
                        <td>[% item.index + 1 | html %]</td>
343
                        <td>[% item.index + 1 | html %]</td>
342
                        [% IF checkboxes_edit %]
344
                        [% IF checkboxes_edit %]
Lines 347-352 Link Here
347
                            [% ELSE %]
349
                            [% ELSE %]
348
                                <td>
350
                                <td>
349
                                    <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" id="row[% item.itemnumber | html %]" checked="checked" data-is-onloan="[% item.is_checked_out | html %]" />
351
                                    <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" id="row[% item.itemnumber | html %]" checked="checked" data-is-onloan="[% item.is_checked_out | html %]" />
352
                                    [% IF linked_order.ordernumber %]
353
                                        <i class="fa fa-warning warn" Title="There is an order (ordernumber [% linked_order.ordernumber | html %]) on this item"></i>
354
                                    [% END %]
355
                                    [% IF linked_subscription %]
356
                                        <i class="fa fa-warning warn" Title="There is a subscription linked (subscription id [% linked_subscription | html %])"></i>
357
                                    [% END %]
350
                                </td>
358
                                </td>
351
                            [% END %]
359
                            [% END %]
352
                        [% ELSIF checkboxes_delete %]
360
                        [% ELSIF checkboxes_delete %]
Lines 356-362 Link Here
356
                                </td>
364
                                </td>
357
                            [% ELSE %]
365
                            [% ELSE %]
358
                                [% IF item.safe_to_delete %]
366
                                [% IF item.safe_to_delete %]
359
                                    <td><input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" id="row[% item.itemnumber | html %]" checked="checked" /></td>
367
                                    <td>
368
                                        <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" id="row[% item.itemnumber | html %]" checked="checked" />
369
                                        [% IF linked_order.ordernumber %]
370
                                            <i class="fa fa-warning warn" Title="There is an order (ordernumber [% linked_order.ordernumber | html %]) on this item"></i>
371
                                        [% END %]
372
                                        [% IF linked_subscription %]
373
                                            <i class="fa fa-warning warn" Title="There is a subscription linked (subscription id [% linked_subscription | html %])"></i>
374
                                        [% END %]
375
                                    </td>
360
                                [% ELSE %]
376
                                [% ELSE %]
361
                                    [% SET messages = item.safe_to_delete.messages %]
377
                                    [% SET messages = item.safe_to_delete.messages %]
362
                                    [% FOR m IN messages %]
378
                                    [% FOR m IN messages %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +12 lines)
Lines 117-122 Link Here
117
                        [% FOREACH item IN items %]
117
                        [% FOREACH item IN items %]
118
                            [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %]
118
                            [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %]
119
                            [% SET tr_class = '' %]
119
                            [% SET tr_class = '' %]
120
                            [% SET current_itemnumber = item.itemnumber %]
121
                            [% SET warn_message = warning_messages.$current_itemnumber %]
120
                            [% IF item.itemnumber == itemnumber %]
122
                            [% IF item.itemnumber == itemnumber %]
121
                                [% UNLESS can_be_edited %]
123
                                [% UNLESS can_be_edited %]
122
                                    [% SET tr_class='active' %]
124
                                    [% SET tr_class='active' %]
Lines 184-190 Link Here
184
                                                                <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
186
                                                                <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
185
                                                                <input type="hidden" name="searchid" value="[% searchid | html %]" />
187
                                                                <input type="hidden" name="searchid" value="[% searchid | html %]" />
186
                                                            </form>
188
                                                            </form>
187
                                                            <a class="dropdown-item delete" data-item="[% item.itemnumber | html %]" href="#">Delete</a>
189
                                                            <a
190
                                                                class="dropdown-item delete"
191
                                                                data-item="[% item.itemnumber | html %]"
192
                                                                href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% item.biblionumber | html %]&amp;itemnumber=[% item.itemnumber | html %]&amp;searchid=[% searchid | html %]"
193
                                                                onclick="return confirm_deletion();"
194
                                                                >Delete
195
                                                                [% IF warn_message %]
196
                                                                    <i class="fa fa-warning warn" Title="[% warn_message | html %]"></i>
197
                                                                [% END %]
198
                                                            </a>
188
                                                        </li>
199
                                                        </li>
189
                                                    [% END %]
200
                                                    [% END %]
190
                                                [% END %]
201
                                                [% END %]
(-)a/tools/batchMod.pl (-4 / +22 lines)
Lines 25-30 use C4::Auth qw( get_template_and_user haspermission ); Link Here
25
use C4::Output      qw( output_html_with_http_headers );
25
use C4::Output      qw( output_html_with_http_headers );
26
use C4::Circulation qw( barcodedecode );
26
use C4::Circulation qw( barcodedecode );
27
use C4::Context;
27
use C4::Context;
28
use C4::Acquisition qw( GetOrderFromItemnumber );
28
use MARC::File::XML;
29
use MARC::File::XML;
29
use List::MoreUtils qw( uniq );
30
use List::MoreUtils qw( uniq );
30
use Encode          qw( encode_utf8 );
31
use Encode          qw( encode_utf8 );
Lines 39-44 use Koha::BackgroundJob::BatchDeleteItem; Link Here
39
use Koha::BackgroundJob::BatchUpdateItem;
40
use Koha::BackgroundJob::BatchUpdateItem;
40
use Koha::UI::Form::Builder::Item;
41
use Koha::UI::Form::Builder::Item;
41
use Koha::UI::Table::Builder::Items;
42
use Koha::UI::Table::Builder::Items;
43
use Koha::Serial::Items;
44
use Koha::Serials;
42
45
43
my $input                             = CGI->new;
46
my $input                             = CGI->new;
44
my $dbh                               = C4::Context->dbh;
47
my $dbh                               = C4::Context->dbh;
Lines 87-92 my $nextop = ""; Link Here
87
my $display_items;
90
my $display_items;
88
91
89
my @messages;
92
my @messages;
93
my %linked_orders_subscriptions;
90
94
91
if ( $op eq "cud-action" ) {
95
if ( $op eq "cud-action" ) {
92
96
Lines 232-237 if ( $op eq "cud-show" || $op eq "show" ) { Link Here
232
        if ( defined $biblionumber && !@itemnumbers ) {
236
        if ( defined $biblionumber && !@itemnumbers ) {
233
            my $biblio = Koha::Biblios->find($biblionumber);
237
            my $biblio = Koha::Biblios->find($biblionumber);
234
            @itemnumbers = $biblio ? $biblio->items->get_column('itemnumber') : ();
238
            @itemnumbers = $biblio ? $biblio->items->get_column('itemnumber') : ();
239
            foreach my $itemnumber (@itemnumbers) {
240
                $linked_orders_subscriptions{$itemnumber} = [];
241
                my $order     = GetOrderFromItemnumber($itemnumber);
242
                my $serial_id = Koha::Serial::Items->search( { itemnumber => $itemnumber } )->get_column('serialid');
243
                if ($order) {
244
                    $linked_orders_subscriptions{$itemnumber} =
245
                        { ordernumber => $order->{ordernumber}, basket => $order->{basketno} };
246
                }
247
                if ($serial_id) {
248
                    my $subscription_id =
249
                        Koha::Serials->search( { serialid => $serial_id } )->get_column('subscriptionid');
250
                    $linked_orders_subscriptions{$itemnumber} = { subscription => $subscription_id };
251
                }
252
            }
235
        }
253
        }
236
        if ( my $list = $input->param('barcodelist') ) {
254
        if ( my $list = $input->param('barcodelist') ) {
237
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
255
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
Lines 295-303 if ( $op eq "cud-show" || $op eq "show" ) { Link Here
295
313
296
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
314
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
297
    $template->param(
315
    $template->param(
298
        subfields           => $subfields,
316
        subfields                   => $subfields,
299
        notfoundbarcodes    => \@notfoundbarcodes,
317
        notfoundbarcodes            => \@notfoundbarcodes,
300
        notfounditemnumbers => \@notfounditemnumbers
318
        notfounditemnumbers         => \@notfounditemnumbers,
319
        linked_orders_subscriptions => \%linked_orders_subscriptions,
301
    );
320
    );
302
    $nextop = "cud-action";
321
    $nextop = "cud-action";
303
    $template->param( show => 1 );
322
    $template->param( show => 1 );
304
- 

Return to bug 13870