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

(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl (-1 / +1 lines)
Lines 427-433 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
427
427
428
<!-- TMPL_IF NAME="OpenOPACShelfBrowser" -->
428
<!-- TMPL_IF NAME="OpenOPACShelfBrowser" -->
429
<div id="shelfbrowser">
429
<div id="shelfbrowser">
430
<h5 style="text-align: center;"><!-- TMPL_IF NAME="starting_homebranch" -->Browsing <!-- TMPL_VAR NAME="starting_homebranch" --> Shelves<!-- /TMPL_IF --><!-- TMPL_IF NAME="starting_location" -->, Shelving Location:</span><!-- TMPL_VAR NAME="starting_location" --> <!-- /TMPL_IF --> <a style="font-size: 75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Close Shelf Browser</a></h5>
430
<h5 style="text-align: center;"><!-- TMPL_IF NAME="starting_homebranch" -->Browsing <!-- TMPL_VAR NAME="starting_homebranch" --> Library<!-- /TMPL_IF --><!-- TMPL_IF NAME="starting_ccode" -->, Collection:</span><!-- TMPL_VAR NAME="starting_ccode" --> <!-- /TMPL_IF --><!-- TMPL_IF NAME="starting_location" -->, Shelving Location:</span><!-- TMPL_VAR NAME="starting_location" --> <!-- /TMPL_IF --> <a style="font-size: 75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Close Shelf Browser</a></h5>
431
431
432
        
432
        
433
        <table><tr>
433
        <table><tr>
(-)a/opac/opac-detail.pl (-5 / +27 lines)
Lines 449-456 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
449
    my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
449
    my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
450
    $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
450
    $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
451
    # find the right cn_sort value for this item
451
    # find the right cn_sort value for this item
452
    my ($starting_cn_sort, $starting_homebranch, $starting_location);
452
    my ($starting_cn_sort, $starting_homebranch, $starting_location, $starting_ccode);
453
    my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
453
    my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
454
    $sth_get_cn_sort->execute($starting_itemnumber);
454
    $sth_get_cn_sort->execute($starting_itemnumber);
455
    while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
455
    while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
456
        $starting_cn_sort = $result->{'cn_sort'};
456
        $starting_cn_sort = $result->{'cn_sort'};
Lines 458-463 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
458
        $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
458
        $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
459
        $starting_location->{code} = $result->{'location'};
459
        $starting_location->{code} = $result->{'location'};
460
        $starting_location->{description} = GetAuthorisedValueDesc('','',   $result->{'location'} ,'','','LOC', 'opac');
460
        $starting_location->{description} = GetAuthorisedValueDesc('','',   $result->{'location'} ,'','','LOC', 'opac');
461
        $starting_ccode->{code} = $result->{'ccode'};
462
        $starting_ccode->{description} = GetAuthorisedValueDesc('','',   $result->{'ccode'} ,'','','CCODE');
461
    
463
    
462
    }
464
    }
463
    
465
    
Lines 465-471 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
465
    # order by cn_sort, which should include everything we need for ordering purposes (though not
467
    # order by cn_sort, which should include everything we need for ordering purposes (though not
466
    # for limits, those need to be handled separately
468
    # for limits, those need to be handled separately
467
    my $sth_shelfbrowse_previous;
469
    my $sth_shelfbrowse_previous;
468
    if (defined $starting_location->{code}) {
470
    if (defined $starting_ccode->{code} && defined $starting_location->{code}) {
471
      $sth_shelfbrowse_previous = $dbh->prepare("
472
        SELECT *
473
        FROM items
474
        WHERE
475
            ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
476
            homebranch = ? AND location = ? AND ccode = ?
477
        ORDER BY cn_sort DESC, itemnumber LIMIT 3
478
        ");
479
      $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code}, $starting_ccode->{code});
480
    } elsif (defined $starting_location->{code}) {
469
      $sth_shelfbrowse_previous = $dbh->prepare("
481
      $sth_shelfbrowse_previous = $dbh->prepare("
470
        SELECT *
482
        SELECT *
471
        FROM items
483
        FROM items
Lines 502-508 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
502
    
514
    
503
    ## List of Next Items; this also intentionally catches the current item
515
    ## List of Next Items; this also intentionally catches the current item
504
    my $sth_shelfbrowse_next;
516
    my $sth_shelfbrowse_next;
505
    if (defined $starting_location->{code}) {
517
    if (defined $starting_ccode->{code} && defined $starting_location->{code}) {
518
      $sth_shelfbrowse_next = $dbh->prepare("
519
        SELECT *
520
        FROM items
521
        WHERE
522
            ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
523
            homebranch = ? AND location = ? AND ccode = ?
524
        ORDER BY cn_sort, itemnumber LIMIT 3
525
        ");
526
      $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code}, $starting_ccode->{code});
527
    } elsif (defined $starting_location->{code}) {
506
      $sth_shelfbrowse_next = $dbh->prepare("
528
      $sth_shelfbrowse_next = $dbh->prepare("
507
        SELECT *
529
        SELECT *
508
        FROM items
530
        FROM items
Lines 544-549 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
544
    $template->param(
566
    $template->param(
545
        starting_homebranch => $starting_homebranch->{description},
567
        starting_homebranch => $starting_homebranch->{description},
546
        starting_location => $starting_location->{description},
568
        starting_location => $starting_location->{description},
569
        starting_ccode => $starting_ccode->{description},
547
        starting_itemnumber => $starting_itemnumber,
570
        starting_itemnumber => $starting_itemnumber,
548
        shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
571
        shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
549
        shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
572
        shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
550
- 

Return to bug 4367