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

(-)a/catalogue/detail.pl (-57 / +60 lines)
Lines 33-39 use C4::Koha qw( Link Here
33
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
33
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
34
use C4::Output qw( output_html_with_http_headers );
34
use C4::Output qw( output_html_with_http_headers );
35
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
35
use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
36
use C4::Items qw( GetAnalyticsCount GetHostItemsInfo GetItemsInfo );
36
use C4::Items qw( GetAnalyticsCount );
37
use C4::Circulation qw( GetTransfers );
37
use C4::Circulation qw( GetTransfers );
38
use C4::Reserves;
38
use C4::Reserves;
39
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
39
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
Lines 56-61 use Koha::Virtualshelves; Link Here
56
use Koha::Plugins;
56
use Koha::Plugins;
57
use Koha::SearchEngine::Search;
57
use Koha::SearchEngine::Search;
58
use Koha::SearchEngine::QueryBuilder;
58
use Koha::SearchEngine::QueryBuilder;
59
use Koha::Serial::Items;
59
60
60
my $query = CGI->new();
61
my $query = CGI->new();
61
62
Lines 151-170 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unble Link Here
151
152
152
my $dbh = C4::Context->dbh;
153
my $dbh = C4::Context->dbh;
153
154
154
my @all_items = GetItemsInfo( $biblionumber );
155
my $all_items = $biblio->items;
155
my @items;
156
my @items;
156
my $patron = Koha::Patrons->find( $borrowernumber );
157
my $patron = Koha::Patrons->find( $borrowernumber );
157
for my $itm (@all_items) {
158
while ( my $item = $all_items->next ) {
158
    push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems);
159
    push @items, $item
160
      unless $item->itemlost
161
      && $patron->category->hidelostitems
162
      && !$showallitems;
159
}
163
}
160
164
161
# flag indicating existence of at least one item linked via a host record
165
# flag indicating existence of at least one item linked via a host record
162
my $hostrecords;
166
my $hostrecords;
163
# adding items linked via host biblios
167
# adding items linked via host biblios
164
my @hostitems = GetHostItemsInfo($record);
168
my $hostitems = $biblio->host_items;
165
if (@hostitems){
169
if ( $hostitems->count ) {
166
    $hostrecords =1;
170
    $hostrecords = 1;
167
    push (@items,@hostitems);
171
    push @items, $hostitems->as_list;
168
}
172
}
169
173
170
my $dat = &GetBiblioData($biblionumber);
174
my $dat = &GetBiblioData($biblionumber);
Lines 271-279 if ( defined $dat->{'itemtype'} ) { Link Here
271
    $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
275
    $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
272
}
276
}
273
277
274
$dat->{'count'} = scalar @all_items + @hostitems;
278
$dat->{'count'} = $all_items->count + $hostitems->count;
275
$dat->{'showncount'} = scalar @items + @hostitems;
279
$dat->{'showncount'} = scalar @items + $hostitems->count;
276
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
280
$dat->{'hiddencount'} = $all_items->count + $hostitems->count - scalar @items;
277
281
278
my $shelflocations =
282
my $shelflocations =
279
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
283
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
Lines 316-374 if ($currentbranch and C4::Context->preference('SeparateHoldings')) { Link Here
316
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
320
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
317
my ( $itemloop_has_images, $otheritemloop_has_images );
321
my ( $itemloop_has_images, $otheritemloop_has_images );
318
foreach my $item (@items) {
322
foreach my $item (@items) {
319
    my $itembranchcode = $item->{$separatebranch};
323
    my $itembranchcode = $item->$separatebranch;
320
324
321
    $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
325
    my $item_info = $item->unblessed;
322
                                               : '';
323
324
    $item->{datedue} = format_sqldatetime($item->{datedue});
325
326
326
    #get shelf location and collection code description if they are authorised value.
327
    #get shelf location and collection code description if they are authorised value.
327
    # same thing for copy number
328
    # same thing for copy number
328
    my $shelfcode = $item->{'location'};
329
    my $shelfcode = $item->location;
329
    $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
330
    $item_info->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
330
    my $ccode = $item->{'ccode'};
331
    my $ccode = $item->ccode;
331
    $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
332
    $item_info->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
332
    my $copynumber = $item->{'copynumber'};
333
    my $copynumber = $item->{'copynumber'};
333
    $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) );
334
    $item_info->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) );
334
    foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri publisheddate)) { # Warning when removing GetItemsInfo - publisheddate (at least) is not part of the items table
335
    foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri )) {
335
        $itemfields{$_} = 1 if ( $item->{$_} );
336
        $itemfields{$_} = 1 if $item->$_;
337
    }
338
339
    # FIXME The following must be Koha::Item->serial
340
    my $serial_item = Koha::Serial::Items->find($item->itemnumber);
341
    if ( $serial_item ) {
342
        $item_info->{serial} = $serial_item->serialid; # FIXME Not returning a Koha::Object!
343
        $itemfields{publisheddate} = 1;
336
    }
344
    }
337
345
338
    # checking for holds
346
    # checking for holds
339
    my $item_object = Koha::Items->find( $item->{itemnumber} );
347
    my $holds = $item->current_holds;
340
    my $holds = $item_object->current_holds;
341
    if ( my $first_hold = $holds->next ) {
348
    if ( my $first_hold = $holds->next ) {
342
        $item->{first_hold} = $first_hold;
349
        $item_info->{first_hold} = $first_hold;
343
    }
350
    }
344
351
345
    if ( my $checkout = $item_object->checkout ) {
352
    if ( my $checkout = $item->checkout ) {
346
        $item->{CheckedOutFor} = $checkout->patron;
353
        $item_info->{CheckedOutFor} = $checkout->patron;
347
    }
354
    }
348
355
349
    # Check the transit status
356
    # Check the transit status
350
    my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
357
    my $transfer = $item->get_transfer;
351
    if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
358
    if ( $transfer ) {
352
        $item->{transfertwhen} = $transfertwhen;
359
        $item_info->{transfertwhen} = $transfer->datesent;
353
        $item->{transfertfrom} = $transfertfrom;
360
        $item_info->{transfertfrom} = $transfer->frombranch;
354
        $item->{transfertto}   = $transfertto;
361
        $item_info->{transfertto}   = $transfer->tobranch;
355
        $item->{nocancel} = 1;
362
        $item_info->{nocancel} = 1;
356
    }
363
    }
357
364
358
    foreach my $f (qw( itemnotes )) {
365
    foreach my $f (qw( itemnotes )) {
359
        if ($item->{$f}) {
366
        if ($item_info->{$f}) {
360
            $item->{$f} =~ s|\n|<br />|g;
367
            $item_info->{$f} =~ s|\n|<br />|g;
361
            $itemfields{$f} = 1;
368
            $itemfields{$f} = 1;
362
        }
369
        }
363
    }
370
    }
364
371
365
    #item has a host number if its biblio number does not match the current bib
372
    #item has a host number if its biblio number does not match the current bib
366
373
367
    if ($item->{biblionumber} ne $biblionumber){
374
    if ($item->biblionumber ne $biblionumber){
368
        $item->{hostbiblionumber} = $item->{biblionumber};
375
        $item_info->{hostbiblionumber} = $item->biblionumber;
369
        $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
376
        $item_info->{hosttitle} = $item->biblio->title;
370
    }
377
    }
371
	
378
372
379
373
    if ( $analyze ) {
380
    if ( $analyze ) {
374
        # count if item is used in analytical bibliorecords
381
        # count if item is used in analytical bibliorecords
Lines 376-419 foreach my $item (@items) { Link Here
376
        my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
383
        my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
377
        if ($countanalytics > 0){
384
        if ($countanalytics > 0){
378
            $analytics_flag=1;
385
            $analytics_flag=1;
379
            $item->{countanalytics} = $countanalytics;
386
            $item_info->{countanalytics} = $countanalytics;
380
        }
387
        }
381
    }
388
    }
382
389
383
    if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){
390
    if (defined($item->materials) && $item->materials =~ /\S/){
384
        $materials_flag = 1;
391
        $materials_flag = 1;
385
        if (defined $materials_map{ $item->{materials} }) {
392
        if (defined $materials_map{ $item->materials }) {
386
            $item->{materials} = $materials_map{ $item->{materials} };
393
            $item_info->{materials} = $materials_map{ $item->materials };
387
        }
394
        }
388
    }
395
    }
389
396
390
    if ( C4::Context->preference('UseCourseReserves') ) {
397
    if ( C4::Context->preference('UseCourseReserves') ) {
391
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
398
        $item_info->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber );
392
    }
399
    }
393
400
394
    if ( C4::Context->preference('IndependentBranches') ) {
401
    if ( C4::Context->preference('IndependentBranches') ) {
395
        my $userenv = C4::Context->userenv();
402
        my $userenv = C4::Context->userenv();
396
        if ( not C4::Context->IsSuperLibrarian()
403
        if ( not C4::Context->IsSuperLibrarian()
397
            and $userenv->{branch} ne $item->{homebranch} ) {
404
            and $userenv->{branch} ne $item->homebranch ) {
398
            $item->{cannot_be_edited} = 1;
405
            $item_info->{cannot_be_edited} = 1;
399
        }
406
        }
400
    }
407
    }
401
408
402
    if ( C4::Context->preference("LocalCoverImages") == 1 ) {
403
        $item->{cover_images} = $item_object->cover_images;
404
    }
405
406
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
409
    if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
407
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
410
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
408
            push @itemloop, $item;
411
            push @itemloop, $item_info;
409
            $itemloop_has_images++ if $item_object->cover_images->count;
412
            $itemloop_has_images++ if $item->cover_images->count;
410
        } else {
413
        } else {
411
            push @otheritemloop, $item;
414
            push @otheritemloop, $item_info;
412
            $otheritemloop_has_images++ if $item_object->cover_images->count;
415
            $otheritemloop_has_images++ if $item->cover_images->count;
413
        }
416
        }
414
    } else {
417
    } else {
415
        push @itemloop, $item;
418
        push @itemloop, $item_info;
416
        $itemloop_has_images++ if $item_object->cover_images->count;
419
        $itemloop_has_images++ if $item->cover_images->count;
417
    }
420
    }
418
}
421
}
419
422
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-13 / +14 lines)
Lines 367-379 Link Here
367
367
368
                    [% IF ( item_level_itypes ) %]
368
                    [% IF ( item_level_itypes ) %]
369
                        <td class="itype">
369
                        <td class="itype">
370
                            [% IF !noItemTypeImages && item.imageurl %]
370
                            [% SET itemtype = item.object.itemtype %]
371
                                <img src="[% item.imageurl | html %]" alt="[% item.translated_description | html %]" title="[% item.translated_description | html %]" />
371
                            [% IF !noItemTypeImages && itemtype.image_location %]
372
                                <img src="[% itemtype.image_location | html %]" alt="[% itemtype.translated_description | html %]" title="[% itemtype.translated_description | html %]" />
372
                            [% END %]
373
                            [% END %]
373
                            <span class="itypedesc">[% item.translated_description | html %]</span>
374
                            <span class="itypedesc">[% itemtype.translated_description | html %]</span>
374
                        </td>
375
                        </td>
375
                    [% END %]
376
                    [% END %]
376
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) | html %] [% END %]</td>
377
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %]</td>
377
                    <td class="homebranch">
378
                    <td class="homebranch">
378
                        <span class="homebranchdesc">[% Branches.GetName(item.homebranch) | html %]</span>
379
                        <span class="homebranchdesc">[% Branches.GetName(item.homebranch) | html %]</span>
379
                        <span class="shelvingloc">
380
                        <span class="shelvingloc">
Lines 395-419 Note that permanent location is a code, and location may be an authval. Link Here
395
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
396
                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
396
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
397
                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
397
                    [% IF ( volinfo ) %]
398
                    [% IF ( volinfo ) %]
399
                        [% SET serial = item.object.serial %]
398
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
400
                        [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
399
                            <td class="enumchron" data-order="[% item.publisheddate | html %]">
401
                            <td class="enumchron" data-order="[% serial.publisheddate | html %]">
400
                        [% ELSE %]
402
                        [% ELSE %]
401
                            <td class="enumchron">
403
                            <td class="enumchron">
402
                        [% END %]
404
                        [% END %]
403
                            [% IF ( itemdata_enumchron ) %]
405
                            [% IF ( itemdata_enumchron ) %]
404
                                [% IF item.enumchron && item.serialseq %]
406
                                [% IF item.enumchron && serial.serialseq %]
405
                                    <span class="enum">[% item.enumchron | html %]</span>
407
                                    <span class="enum">[% item.enumchron | html %]</span>
406
                                    [% IF ( item.serialseq && item.enumchron!=item.serialseq ) %]
408
                                    [% IF ( item.serialseq && item.enumchron != serial.serialseq ) %]
407
                                        <span class="sep"> -- </span>
409
                                        <span class="sep"> -- </span>
408
                                        <span class="serialseq">[% item.serialseq | html %]</span>
410
                                        <span class="serialseq">[% serial.serialseq | html %]</span>
409
                                    [% END %]
411
                                    [% END %]
410
                                [% ELSIF item.enumchron %]
412
                                [% ELSIF item.enumchron %]
411
                                    <span class="enum">[% item.enumchron | html %]</span>
413
                                    <span class="enum">[% item.enumchron | html %]</span>
412
                                [% ELSIF item.serialseq %]
414
                                [% ELSIF item.serialseq %]
413
                                    <span class="serialseq">[% item.serialseq | html %]</span>
415
                                    <span class="serialseq">[% serial.serialseq | html %]</span>
414
                                [% END %]
416
                                [% END %]
415
                                [% IF ( item.publisheddate ) %]
417
                                [% IF serial.publisheddate %]
416
                                    <span class="pubdate">([% item.publisheddate | $KohaDates %])</span>
418
                                    <span class="pubdate">([% serial.publisheddate | $KohaDates %])</span>
417
                                [% END %]
419
                                [% END %]
418
                            [% END %]
420
                            [% END %]
419
                            </span>
421
                            </span>
Lines 435-441 Note that permanent location is a code, and location may be an authval. Link Here
435
                                  [% END %]
437
                                  [% END %]
436
                                  [% INCLUDE 'patron-title.inc' patron=item.CheckedOutFor hide_patron_infos_if_needed=1 %]
438
                                  [% INCLUDE 'patron-title.inc' patron=item.CheckedOutFor hide_patron_infos_if_needed=1 %]
437
                                [% END %]
439
                                [% END %]
438
                                : due [% item.datedue | html %]
440
                                : due [% item.datedue | $KohaDates as_due_date => 1 %]
439
                            </span>
441
                            </span>
440
                        [% ELSIF ( item.transfertwhen ) %]
442
                        [% ELSIF ( item.transfertwhen ) %]
441
                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) | html %] to [% Branches.GetName( item.transfertto ) | html %] since [% item.transfertwhen | $KohaDates %]</span>
443
                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) | html %] to [% Branches.GetName( item.transfertto ) | html %] since [% item.transfertwhen | $KohaDates %]</span>
442
- 

Return to bug 27272