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 (-1 / +19 lines)
Lines 324-329 Link Here
324
                    [% END %]
324
                    [% END %]
325
                    <th class="anti-the">Title</th>
325
                    <th class="anti-the">Title</th>
326
                    <th class="holds_count" title="Item holds / Total holds">Holds</th>
326
                    <th class="holds_count" title="Item holds / Total holds">Holds</th>
327
                    <th class="linked_order" title="Linked order">Linked order</th>
328
                    <th class="linked_subscription" title="Linked subscription">Linked subscription</th>
327
                    [% FOREACH item_header IN headers %]
329
                    [% FOREACH item_header IN headers %]
328
                        [% IF item_header.column_name %]
330
                        [% IF item_header.column_name %]
329
                            <th data-colname="[% item_header.column_name | html %]"> [% item_header.header_value | html %] </th>
331
                            <th data-colname="[% item_header.column_name | html %]"> [% item_header.header_value | html %] </th>
Lines 336-342 Link Here
336
            <tbody>
338
            <tbody>
337
                [% FOREACH item IN items %]
339
                [% FOREACH item IN items %]
338
                    [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
340
                    [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %]
339
341
                    [% SET current_itemnumber = item.itemnumber %]
342
                    [% SET linked_order = linked_orders_subscriptions.$current_itemnumber %]
343
                    [% SET linked_subscription = linked_orders_subscriptions.$current_itemnumber.subscription %]
340
                    <tr>
344
                    <tr>
341
                        <td>[% item.index + 1 | html %]</td>
345
                        <td>[% item.index + 1 | html %]</td>
342
                        [% IF checkboxes_edit %]
346
                        [% IF checkboxes_edit %]
Lines 410-415 Link Here
410
                                [% END %]
414
                                [% END %]
411
                            </a>
415
                            </a>
412
                        </td>
416
                        </td>
417
                        <td class="linked_order">
418
                            [% IF linked_order.ordernumber %]
419
                                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% linked_order.basket | uri %]" title="See basket details">[% linked_order.ordernumber | html %]</a>
420
                            [% ELSE %]
421
                                <span>None</span>
422
                            [% END %]
423
                        </td>
424
                        <td class="linked_subscription">
425
                            [% IF linked_subscription %]
426
                                <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% linked_subscription | uri %]" title="Subscription id [% linked_subscription | html %]">Subscription details</a>
427
                            [% ELSE %]
428
                                <span>None</span>
429
                            [% END %]
430
                        </td>
413
                        [% FOREACH header IN headers %]
431
                        [% FOREACH header IN headers %]
414
                            [% SET attribute = header.attribute %]
432
                            [% SET attribute = header.attribute %]
415
                            [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %]
433
                            [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %]
(-)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