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

(-)a/C4/ShelfBrowser.pm (-62 / +69 lines)
Lines 63-72 to take into account. Link Here
63
63
64
  $nearby = GetNearbyItems($itemnumber, [$num_each_side]);
64
  $nearby = GetNearbyItems($itemnumber, [$num_each_side]);
65
65
66
  @next = @{ $nearby->{next} };
66
  @items = @{ $nearby->{items} };
67
  @prev = @{ $nearby->{prev} };
68
67
69
  foreach (@next) {
68
  foreach (@items) {
70
      # These won't format well like this, but here are the fields
69
      # These won't format well like this, but here are the fields
71
  	  print $_->{title};
70
  	  print $_->{title};
72
  	  print $_->{biblionumber};
71
  	  print $_->{biblionumber};
Lines 78-87 to take into account. Link Here
78
77
79
  # This is the information required to scroll the browser to the next left
78
  # This is the information required to scroll the browser to the next left
80
  # or right set. Can be derived from next/prev, but it's here for convenience.
79
  # or right set. Can be derived from next/prev, but it's here for convenience.
81
  print $nearby->{prev_itemnumber};
80
  print $nearby->{prev_item}{itemnumber};
82
  print $nearby->{next_itemnumber};
81
  print $nearby->{next_item}{itemnumber};
83
  print $nearby->{prev_biblionumber};
82
  print $nearby->{prev_item}{biblionumber};
84
  print $nearby->{next_biblionumber};
83
  print $nearby->{next_item}{biblionumber};
85
84
86
  # These will be undef if the values are not used to calculate the 
85
  # These will be undef if the values are not used to calculate the 
87
  # nearby items.
86
  # nearby items.
Lines 92-99 to take into account. Link Here
92
  print $nearby->{starting_ccode}->{code};
91
  print $nearby->{starting_ccode}->{code};
93
  print $nearby->{starting_ccode}->{description};
92
  print $nearby->{starting_ccode}->{description};
94
93
95
  print $nearby->{starting_itemnumber};
96
  
97
This finds the items that are nearby to the supplied item, and supplies
94
This finds the items that are nearby to the supplied item, and supplies
98
those previous and next, along with the other useful information for displaying
95
those previous and next, along with the other useful information for displaying
99
the shelf browser.
96
the shelf browser.
Lines 113-123 This will throw an exception if something went wrong. Link Here
113
=cut
110
=cut
114
111
115
sub GetNearbyItems {
112
sub GetNearbyItems {
116
	my ($itemnumber, $num_each_side) = @_;
113
    my ( $itemnumber, $num_each_side, $gap) = @_;
117
	$num_each_side ||= 3;
114
    $num_each_side ||= 3;
115
    $gap ||= 7; # Should be > $num_each_side
116
    die "BAD CALL in C4::ShelfBrowser::GetNearbyItems, gap should be > num_each_side"
117
        if $gap <= $num_each_side;
118
118
119
    my $dbh         = C4::Context->dbh;
119
    my $dbh         = C4::Context->dbh;
120
    my $marcflavour = C4::Context->preference("marcflavour");
121
    my $branches = GetBranches();
120
    my $branches = GetBranches();
122
121
123
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
122
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
Lines 145-156 sub GetNearbyItems { Link Here
145
144
146
    # Build the query for previous and next items
145
    # Build the query for previous and next items
147
    my $prev_query ='
146
    my $prev_query ='
148
        SELECT *
147
        SELECT itemnumber, biblionumber, cn_sort, itemcallnumber
149
        FROM items
148
        FROM items
150
        WHERE
149
        WHERE
151
            ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) ';
150
            ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) ';
152
    my $next_query ='
151
    my $next_query ='
153
        SELECT *
152
        SELECT itemnumber, biblionumber, cn_sort, itemcallnumber
154
        FROM items
153
        FROM items
155
        WHERE
154
        WHERE
156
            ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) ';
155
            ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) ';
Lines 170-229 sub GetNearbyItems { Link Here
170
    	push @params, $start_ccode->{code};
169
    	push @params, $start_ccode->{code};
171
    }
170
    }
172
171
173
    my $sth_prev_items = $dbh->prepare($prev_query . $query_cond . ' ORDER BY cn_sort DESC, itemnumber LIMIT ?');
172
    my @prev_items = @{
174
    my $sth_next_items = $dbh->prepare($next_query . $query_cond . ' ORDER BY cn_sort, itemnumber LIMIT ?');
173
        $dbh->selectall_arrayref(
175
    push @params, $num_each_side;
174
            $prev_query . $query_cond . ' ORDER BY cn_sort DESC, itemnumber LIMIT ?',
176
    $sth_prev_items->execute(@params);
175
            { Slice => {} },
177
    $sth_next_items->execute(@params);
176
            ( @params, $gap )
178
    
177
        )
179
    # Now we have the query run, suck out the data like marrow
178
    };
180
    my @prev_items = reverse GetShelfInfo($sth_prev_items, $marcflavour);
179
    my @next_items = @{
181
    my @next_items = GetShelfInfo($sth_next_items, $marcflavour);
180
        $dbh->selectall_arrayref(
182
181
            $next_query . $query_cond . ' ORDER BY cn_sort, itemnumber LIMIT ?',
183
    my (
182
            { Slice => {} },
184
        $next_itemnumber, $next_biblionumber,
183
            ( @params, $gap + 1 )
185
        $prev_itemnumber, $prev_biblionumber
184
        )
186
    );
185
    };
187
186
188
    $next_itemnumber = $next_items[-1]->{itemnumber} if @next_items;
187
    my $prev_item = $prev_items[-1];
189
    $next_biblionumber = $next_items[-1]->{biblionumber} if @next_items;
188
    my $next_item = $next_items[-1];
190
189
    @next_items = splice( @next_items, 0, $num_each_side + 1 );
191
    $prev_itemnumber = $prev_items[0]->{itemnumber} if @prev_items;
190
    @prev_items = reverse splice( @prev_items, 0, $num_each_side );
192
    $prev_biblionumber = $prev_items[0]->{biblionumber} if @prev_items;
191
    my @items = ( @prev_items, @next_items );
193
192
194
    my %result = (
193
    $next_item = undef
195
        next                => \@next_items,
194
        if not $next_item
196
        prev                => \@prev_items,
195
            or ( $next_item->{itemnumber} == $items[-1]->{itemnumber}
197
        next_itemnumber     => $next_itemnumber,
196
                and ( @prev_items or @next_items <= 1 )
198
        next_biblionumber   => $next_biblionumber,
197
            );
199
        prev_itemnumber     => $prev_itemnumber,
198
    $prev_item = undef
200
        prev_biblionumber   => $prev_biblionumber,   
199
        if not $prev_item
201
        starting_itemnumber => $itemnumber,
200
            or ( $prev_item->{itemnumber} == $items[0]->{itemnumber}
202
    );
201
                and ( @next_items or @prev_items <= 1 )
203
    $result{starting_homebranch} = $start_homebranch if $start_homebranch;
202
            );
204
    $result{starting_location}   = $start_location   if $start_location;
203
205
    $result{starting_ccode}         = $start_ccode      if $start_ccode;
204
    # populate the items
206
    return \%result;
205
    @items = GetShelfInfo( @items );
206
207
    return {
208
        items               => \@items,
209
        next_item           => $next_item,
210
        prev_item           => $prev_item,
211
        starting_homebranch => $start_homebranch,
212
        starting_location   => $start_location,
213
        starting_ccode      => $start_ccode,
214
    };
207
}
215
}
208
216
209
# This runs through a statement handle and pulls out all the items in it, fills
217
# populate an item list with its title and upc, oclc and isbn normalized.
210
# them up with additional info that shelves want, and returns those as a list.
211
# Not really intended to be exported.
218
# Not really intended to be exported.
212
sub GetShelfInfo {
219
sub GetShelfInfo {
213
    my ($sth, $marcflavour) = @_;
220
    my @items = @_;
214
221
    my $marcflavour = C4::Context->preference("marcflavour");
215
    my @items;
222
    my @valid_items;
216
    while (my $this_item = $sth->fetchrow_hashref()) {
223
    for my $item ( @items ) {
217
        my $this_biblio = GetBibData($this_item->{biblionumber});
224
        my $this_biblio = GetBibData($item->{biblionumber});
218
        next if (!defined($this_biblio));
225
        next unless defined $this_biblio;
219
        $this_item->{'title'} = $this_biblio->{'title'};
226
        $item->{'title'} = $this_biblio->{'title'};
220
        my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
227
        my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
221
        $this_item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
228
        $item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
222
        $this_item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
229
        $item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
223
        $this_item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
230
        $item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
224
        push @items, $this_item;
231
        push @valid_items, $item;
225
    }
232
    }
226
    return @items;
233
    return @valid_items;
227
}
234
}
228
235
229
# Fetches some basic biblio data needed by the shelf stuff
236
# Fetches some basic biblio data needed by the shelf stuff
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/shelfbrowser.inc (+125 lines)
Line 0 Link Here
1
[% BLOCK shelfbrowser %]
2
  [% IF OpenOPACShelfBrowser %]
3
    <div id="shelfbrowser">
4
        <h5 style="text-align: center;">
5
            [% IF ( starting_homebranch ) %]Browsing [% starting_homebranch %] Shelves[% END %]
6
            [% IF ( starting_location ) %], Shelving location: [% starting_location %][% END %]
7
            [% IF ( starting_ccode ) %], Collection code: [% starting_ccode %][% END %]
8
            <a style="font-size: 75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]" class="close_shelf" >Close shelf browser</a>
9
        </h5>
10
11
        <table>
12
            <tr>
13
                <td rowspan="2" style="width:20px;">
14
                  [% IF shelfbrowser_prev_item %]
15
                    <div id="browser_previous">
16
                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% shelfbrowser_prev_item.biblionumber %]&amp;shelfbrowse_itemnumber=[% shelfbrowser_prev_item.itemnumber %]#shelfbrowser">Previous</a>
17
                    </div>
18
                  [% END %]
19
                </td>
20
21
                [% FOREACH item IN shelfbrowser_items %]
22
                    <td>
23
                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% item.biblionumber %]&amp;shelfbrowse_itemnumber=[% item.itemnumber %]#shelfbrowser">
24
                            [% IF ( OPACLocalCoverImages ) %]
25
                                <div title="[% item.biblionumber |url %]" class="[% item.biblionumber %] thumbnail-shelfbrowser" id="local-thumbnail-shelf-[% item.biblionumber %]"></div>
26
                            [% END %]
27
                            [% IF ( OPACAmazonCoverImages ) %]
28
                                [% IF ( item.browser_normalized_isbn ) %]
29
                                    <img border="0" src="http://images.amazon.com/images/P/[% item.browser_normalized_isbn %].01._AA75_PU_PU-5_.jpg" alt="" />
30
                                [% ELSE %]
31
                                    <span class="no-image">No cover image available</span>
32
                                [% END %]
33
                            [% END %]
34
35
                            [% IF ( SyndeticsEnabled ) %]
36
                                [% IF ( SyndeticsCoverImages ) %]
37
                                    [% IF ( content_identifier_exists ) %]
38
                                        [% IF ( using_https ) %]
39
                                            <img border="0" src="https://secure.syndetics.com/index.aspx?isbn=[% item.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( item.browser_normalized_upc ) %]&amp;upc=[% item.browser_normalized_upc %][% END %][% IF ( item.browser_normalized_oclc ) %]&amp;oclc=[% item.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
40
                                        [% ELSE %]
41
                                            <img border="0" src="http://www.syndetics.com/index.aspx?isbn=[% item.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( item.browser_normalized_upc ) %]&amp;upc=[% item.browser_normalized_upc %][% END %][% IF ( item.browser_normalized_oclc ) %]&amp;oclc=[% item.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
42
                                        [% END %]
43
                                    [% ELSE %]
44
                                        <span class="no-image">No cover image available</span>
45
                                    [% END %]
46
                                [% END %]
47
                            [% END %]
48
49
                            [% IF ( GoogleJackets ) %]
50
                                [% IF ( item.browser_normalized_isbn ) %]
51
                                    <div style="block" title="[% item.biblionumber |url %]" class="[% item.browser_normalized_isbn %]" id="gbs-thumbnail-preview[% loop.count %]"></div>
52
                                [% ELSE %]
53
                                    <span class="no-image">No cover image available</span>
54
                                [% END %]
55
                            [% END %]
56
                            [% IF ( BakerTaylorEnabled ) %]
57
                                [% IF ( item.browser_normalized_isbn ) %]
58
                                    <img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL |html %][% item.browser_normalized_isbn %]" />
59
                                [% ELSE %]
60
                                    <span class="no-image">No cover image available</span>
61
                                [% END %]
62
                            [% END %]
63
                        </a>
64
                    </td>
65
                [% END %]
66
67
                <td rowspan="2" style="width:20px;">
68
                  [% IF shelfbrowser_next_item %]
69
                    <div id="browser_next">
70
                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% shelfbrowser_prev_item.biblionumber %]&amp;shelfbrowse_itemnumber=[% shelfbrowser_prev_item.itemnumber %]#shelfbrowser">Next</a>
71
                    </div>
72
                  [% END %]
73
                </td>
74
            </tr>
75
76
            <tr>
77
                [% FOREACH item IN shelfbrowser_items %]
78
                    <td class="top">
79
                        [% item.itemcallnumber %]
80
                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% item.biblionumber %]&amp;shelfbrowse_itemnumber=[% item.itemnumber %]#shelfbrowser">[% item.title |html %]</a>
81
                    </td>
82
                [% END %]
83
            </tr>
84
        </table>
85
    </div>
86
    <script type="text/javascript">
87
      $(document).ready(function(){
88
        $(".close_shelf").click(function(e){
89
            e.preventDefault();
90
            $("#shelfbrowser").hide();
91
        });
92
        [% IF shelfbrowser_prev_item.itemnumber %]
93
          $("#browser_previous a").click(function(e){
94
            e.preventDefault();
95
            $.ajax({
96
                    url: "/cgi-bin/koha/svc/shelfbrowser.pl",
97
                type: "POST",
98
                data: {
99
                    "shelfbrowse_itemnumber": [% shelfbrowser_prev_item.itemnumber %]
100
                },
101
                success: function(data){
102
                    $("#shelfbrowser").replaceWith(data);
103
                }
104
            });
105
          });
106
        [% END %]
107
        [% IF shelfbrowser_next_item.itemnumber %]
108
          $("#browser_next a").click(function(e){
109
            e.preventDefault();
110
            $.ajax({
111
                url: "/cgi-bin/koha/svc/shelfbrowser.pl",
112
                type: "POST",
113
                data: {
114
                    "shelfbrowse_itemnumber": [% shelfbrowser_next_item.itemnumber %]
115
                },
116
                success: function(data){
117
                    $("#shelfbrowser").replaceWith(data);
118
                }
119
            });
120
          });
121
        [% END %]
122
      });
123
    </script>
124
  [% END %]
125
[% END %][%# end of shelfbrowser block %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-134 / +1 lines)
Lines 1068-1073 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1068
    [% END %]
1068
    [% END %]
1069
[% END %]
1069
[% END %]
1070
1070
1071
[% PROCESS 'shelfbrowser.inc' %]
1071
[% INCLUDE shelfbrowser tab='holdings' %]
1072
[% INCLUDE shelfbrowser tab='holdings' %]
1072
<br clear="all" />
1073
<br clear="all" />
1073
</div>
1074
</div>
Lines 1588-1724 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1588
	    [% END %]</tbody>
1589
	    [% END %]</tbody>
1589
	</table>
1590
	</table>
1590
[% END %][%# end of items_table block %]
1591
[% END %][%# end of items_table block %]
1591
1592
[% BLOCK shelfbrowser %]
1593
    [% IF ( OpenOPACShelfBrowser and shelfbrowser_tab == tab) %]
1594
        <div id="shelfbrowser">
1595
            <h5 style="text-align: center;">
1596
                [% IF ( starting_homebranch ) %]Browsing [% starting_homebranch %] Shelves[% END %]
1597
                [% IF ( starting_location ) %], Shelving location: [% starting_location %][% END %]
1598
                [% IF ( starting_ccode ) %], Collection code: [% starting_ccode %][% END %]
1599
                <a style="font-size: 75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]">Close shelf browser</a>
1600
            </h5>
1601
1602
            <table>
1603
                <tr>
1604
                    <td rowspan="2" style="width:20px;">
1605
                        <div id="browser_previous">
1606
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% IF ( shelfbrowser_prev_biblionumber ) %][% shelfbrowser_prev_biblionumber %][% ELSE %][% biblionumber %][% END %]&amp;shelfbrowse_itemnumber=[% shelfbrowser_prev_itemnumber %]#shelfbrowser">Previous</a>
1607
                        </div>
1608
                    </td>
1609
                    [% FOREACH PREVIOUS_SHELF_BROWS IN PREVIOUS_SHELF_BROWSE %]
1610
                        <td>
1611
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% PREVIOUS_SHELF_BROWS.biblionumber %]&amp;shelfbrowse_itemnumber=[% PREVIOUS_SHELF_BROWS.itemnumber %]#shelfbrowser">
1612
                                [% IF ( OPACLocalCoverImages ) %]
1613
                                    <div title="[% PREVIOUS_SHELF_BROWS.biblionumber |url %]" class="[% PREVIOUS_SHELF_BROWS.biblionumber %] thumbnail-shelfbrowser" id="local-thumbnail-shelf-[% PREVIOUS_SHELF_BROWS.biblionumber %]"></div>
1614
                                [% END %]
1615
                                [% IF ( OPACAmazonCoverImages ) %]
1616
                                    [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %]
1617
                                        <img border="0" src="http://images.amazon.com/images/P/[% PREVIOUS_SHELF_BROWS.browser_normalized_isbn %].01._AA75_PU_PU-5_.jpg" alt="" />
1618
                                    [% ELSE %]
1619
                                        <span class="no-image">No cover image available</span>
1620
                                    [% END %]
1621
                                [% END %]
1622
                                [% IF ( SyndeticsEnabled ) %]
1623
                                    [% IF ( SyndeticsCoverImages ) %]
1624
                                        [% IF ( content_identifier_exists ) %]
1625
                                            [% IF ( using_https ) %]
1626
                                                <img border="0" src="https://secure.syndetics.com/index.aspx?isbn=[% PREVIOUS_SHELF_BROWS.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_upc ) %]&amp;upc=[% PREVIOUS_SHELF_BROWS.browser_normalized_upc %][% END %][% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_oclc ) %]&amp;oclc=[% PREVIOUS_SHELF_BROWS.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
1627
                                            [% ELSE %]
1628
                                                <img border="0" src="http://www.syndetics.com/index.aspx?isbn=[% PREVIOUS_SHELF_BROWS.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_upc ) %]&amp;upc=[% PREVIOUS_SHELF_BROWS.browser_normalized_upc %][% END %][% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_oclc ) %]&amp;oclc=[% PREVIOUS_SHELF_BROWS.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
1629
                                            [% END %]
1630
                                        [% ELSE %]
1631
                                            <span class="no-image">No cover image available</span>
1632
                                        [% END %]
1633
                                    [% END %]
1634
                                [% END %]
1635
                                [% IF ( GoogleJackets ) %]
1636
                                    [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %]
1637
                                        <div style="block" title="[% PREVIOUS_SHELF_BROWS.biblionumber |url %]" class="[% PREVIOUS_SHELF_BROWS.browser_normalized_isbn %]" id="gbs-thumbnail-preview[% loop.count %]"></div>
1638
                                    [% ELSE %]
1639
                                        <span class="no-image">No cover image available</span>
1640
                                    [% END %]
1641
                                [% END %]
1642
                                [% IF ( BakerTaylorEnabled ) %]
1643
                                    [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %]
1644
                                        <img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL |html %][% PREVIOUS_SHELF_BROWS.browser_normalized_isbn %]" />
1645
                                    [% ELSE %]
1646
                                        <span class="no-image">No cover image available</span>
1647
                                    [% END %]
1648
                                [% END %]
1649
                            </a>
1650
                        </td>
1651
                    [% END %]
1652
1653
                    [% FOREACH NEXT_SHELF_BROWS IN NEXT_SHELF_BROWSE %]
1654
                        <td>
1655
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% NEXT_SHELF_BROWS.biblionumber %]&amp;shelfbrowse_itemnumber=[% NEXT_SHELF_BROWS.itemnumber %]#shelfbrowser">
1656
                                [% IF ( OPACLocalCoverImages ) %]
1657
                                    <div title="[% NEXT_SHELF_BROWS.biblionumber |url %]" class="[% NEXT_SHELF_BROWS.biblionumber %] thumbnail-shelfbrowser" id="local-thumbnail-shelf-[% NEXT_SHELF_BROWS.biblionumber %]"></div>
1658
                                [% END %]
1659
                                [% IF ( OPACAmazonCoverImages ) %]
1660
                                    [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %]
1661
                                        <img border="0" src="http://images.amazon.com/images/P/[% NEXT_SHELF_BROWS.browser_normalized_isbn %].01._AA75_PU_PU-5_.jpg" alt="" />
1662
                                    [% ELSE %]
1663
                                        <span class="no-image">No cover image available</span>
1664
                                    [% END %]
1665
                                [% END %]
1666
1667
                                [% IF ( SyndeticsEnabled ) %]
1668
                                    [% IF ( SyndeticsCoverImages ) %]
1669
                                        [% IF ( content_identifier_exists ) %]
1670
                                            [% IF ( using_https ) %]
1671
                                                <img border="0" src="https://secure.syndetics.com/index.aspx?isbn=[% NEXT_SHELF_BROWS.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( NEXT_SHELF_BROWS.browser_normalized_upc ) %]&amp;upc=[% NEXT_SHELF_BROWS.browser_normalized_upc %][% END %][% IF ( NEXT_SHELF_BROWS.browser_normalized_oclc ) %]&amp;oclc=[% NEXT_SHELF_BROWS.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
1672
                                            [% ELSE %]
1673
                                                <img border="0" src="http://www.syndetics.com/index.aspx?isbn=[% NEXT_SHELF_BROWS.browser_normalized_isbn %]/SC.GIF&amp;client=[% SyndeticsClientCode %][% IF ( NEXT_SHELF_BROWS.browser_normalized_upc ) %]&amp;upc=[% NEXT_SHELF_BROWS.browser_normalized_upc %][% END %][% IF ( NEXT_SHELF_BROWS.browser_normalized_oclc ) %]&amp;oclc=[% NEXT_SHELF_BROWS.browser_normalized_oclc %][% END %]&amp;type=xw10" alt="" />
1674
                                            [% END %]
1675
                                        [% ELSE %]
1676
                                            <span class="no-image">No cover image available</span>
1677
                                        [% END %]
1678
                                    [% END %]
1679
                                [% END %]
1680
1681
                                [% IF ( GoogleJackets ) %]
1682
                                    [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %]
1683
                                        <div style="block" title="[% NEXT_SHELF_BROWS.biblionumber |url %]" class="[% NEXT_SHELF_BROWS.browser_normalized_isbn %]" id="gbs-thumbnail-preview[% loop.count %]"></div>
1684
                                    [% ELSE %]
1685
                                        <span class="no-image">No cover image available</span>
1686
                                    [% END %]
1687
                                [% END %]
1688
                                [% IF ( BakerTaylorEnabled ) %]
1689
                                    [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %]
1690
                                        <img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL |html %][% NEXT_SHELF_BROWS.browser_normalized_isbn %]" />
1691
                                    [% ELSE %]
1692
                                        <span class="no-image">No cover image available</span>
1693
                                    [% END %]
1694
                                [% END %]
1695
                            </a>
1696
                        </td>
1697
                    [% END %]
1698
1699
                    <td rowspan="2">
1700
                        <div id="browser_next">
1701
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% IF ( shelfbrowser_next_biblionumber ) %][% shelfbrowser_next_biblionumber %][% ELSE %][% biblionumber %][% END %]&amp;shelfbrowse_itemnumber=[% shelfbrowser_next_itemnumber %]#shelfbrowser">Next</a>
1702
                        </div>
1703
                    </td>
1704
                </tr>
1705
1706
                <tr>
1707
                    [% FOREACH PREVIOUS_SHELF_BROWS IN PREVIOUS_SHELF_BROWSE %]
1708
                        <td class="top">
1709
                            [% PREVIOUS_SHELF_BROWS.itemcallnumber %]
1710
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% PREVIOUS_SHELF_BROWS.biblionumber %]&amp;shelfbrowse_itemnumber=[% PREVIOUS_SHELF_BROWS.itemnumber %]#shelfbrowser">[% PREVIOUS_SHELF_BROWS.title |html %]</a>
1711
                        </td>
1712
                    [% END %]
1713
1714
                    [% FOREACH NEXT_SHELF_BROWS IN NEXT_SHELF_BROWSE %]
1715
                        <td class="top" style="width:20px;">
1716
                            [% NEXT_SHELF_BROWS.itemcallnumber %]
1717
                            <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% NEXT_SHELF_BROWS.biblionumber %]&amp;shelfbrowse_itemnumber=[% NEXT_SHELF_BROWS.itemnumber %]#shelfbrowser">[% NEXT_SHELF_BROWS.title |html %]</a>
1718
                        </td>
1719
                    [% END %]
1720
                </tr>
1721
            </table>
1722
        </div>
1723
    [% END %]
1724
[% END %][%# end of shelfbrowser block %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/svc/shelfbrowser.tt (+2 lines)
Line 0 Link Here
1
[% PROCESS 'shelfbrowser.inc' %]
2
[% INCLUDE shelfbrowser %]
(-)a/opac/opac-detail.pl (-8 / +4 lines)
Lines 928-946 if (C4::Context->preference("OPACShelfBrowser")) { Link Here
928
    my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
928
    my $starting_itemnumber = $query->param('shelfbrowse_itemnumber');
929
    if (defined($starting_itemnumber)) {
929
    if (defined($starting_itemnumber)) {
930
        $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
930
        $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
931
        my $nearby = GetNearbyItems($starting_itemnumber,3);
931
        my $nearby = GetNearbyItems($starting_itemnumber);
932
932
933
        $template->param(
933
        $template->param(
934
            starting_homebranch => $nearby->{starting_homebranch}->{description},
934
            starting_homebranch => $nearby->{starting_homebranch}->{description},
935
            starting_location => $nearby->{starting_location}->{description},
935
            starting_location => $nearby->{starting_location}->{description},
936
            starting_ccode => $nearby->{starting_ccode}->{description},
936
            starting_ccode => $nearby->{starting_ccode}->{description},
937
            starting_itemnumber => $nearby->{starting_itemnumber},
937
            shelfbrowser_prev_item => $nearby->{prev_item},
938
            shelfbrowser_prev_itemnumber => $nearby->{prev_itemnumber},
938
            shelfbrowser_next_item => $nearby->{next_item},
939
            shelfbrowser_next_itemnumber => $nearby->{next_itemnumber},
939
            shelfbrowser_items => $nearby->{items},
940
            shelfbrowser_prev_biblionumber => $nearby->{prev_biblionumber},
941
            shelfbrowser_next_biblionumber => $nearby->{next_biblionumber},
942
            PREVIOUS_SHELF_BROWSE => $nearby->{prev},
943
            NEXT_SHELF_BROWSE => $nearby->{next},
944
        );
940
        );
945
941
946
        # in which tab shelf browser should open ?
942
        # in which tab shelf browser should open ?
(-)a/opac/svc/shelfbrowser.pl (+41 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use CGI;
5
6
use C4::Auth;
7
use C4::Context;
8
use C4::Output;
9
use C4::ShelfBrowser;
10
11
my $cgi = new CGI;
12
13
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
14
    {
15
        template_name   => "svc/shelfbrowser.tt",
16
        query           => $cgi,
17
        type            => "opac",
18
        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
19
        flagsrequired   => { borrow => 1 },
20
    }
21
);
22
23
# Shelf Browser Stuff
24
if (C4::Context->preference("OPACShelfBrowser")) {
25
    my $starting_itemnumber = $cgi->param('shelfbrowse_itemnumber');
26
    if (defined($starting_itemnumber)) {
27
        my $nearby = GetNearbyItems($starting_itemnumber);
28
29
        $template->param(
30
            starting_homebranch => $nearby->{starting_homebranch}->{description},
31
            starting_location => $nearby->{starting_location}->{description},
32
            starting_ccode => $nearby->{starting_ccode}->{description},
33
            shelfbrowser_prev_item => $nearby->{prev_item},
34
            shelfbrowser_next_item => $nearby->{next_item},
35
            shelfbrowser_items => $nearby->{items},
36
            OpenOPACShelfBrowser => 1,
37
        );
38
    }
39
}
40
41
print $template->output;
(-)a/t/db_dependent/ShelfBrowser.t (-1 / +212 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Test::More tests => 74;
5
use List::Util qw( shuffle );
6
use MARC::Field;
7
use MARC::Record;
8
9
use C4::Biblio;
10
use C4::Context;
11
use C4::Items;
12
13
use_ok('C4::ShelfBrowser');
14
15
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
19
$dbh->do(q|DELETE FROM reserves|);
20
$dbh->do(q|DELETE FROM issues|);
21
$dbh->do(q|DELETE FROM items|);
22
23
my $cn;
24
25
# 100.100 150.100 200.100 210.100 300.000 320.000 400.100 410.100 500.100 510.100 520.100 600.000 610.000 700.100 710.100 720.100 730.100 740.100 750.100
26
my @callnumbers = qw(
27
    100.100
28
    150.100
29
    200.100
30
    210.100
31
    300.000
32
    320.000
33
    400.100
34
    410.100
35
    500.100
36
    510.100
37
    520.100
38
    600.000
39
    610.000
40
    700.100
41
    710.100
42
    720.100
43
    730.100
44
    740.100
45
    750.100
46
);
47
48
my $record = MARC::Record->new();
49
$record->append_fields(
50
    MARC::Field->new('100', ' ', ' ', a => 'Donald E. Knuth.'),
51
    MARC::Field->new('245', ' ', ' ', a => 'The art of computer programming'),
52
);
53
my ( $biblionumber, undef, undef ) = C4::Biblio::AddBiblio($record, '');
54
55
for my $callnumber ( shuffle @callnumbers ) {
56
    my ( $biblionumber, undef, $itemnumber ) = C4::Items::AddItem({
57
        homebranch => 'CPL',
58
        holdingbranch => 'CPL',
59
        itemcallnumber => $callnumber,
60
    }, $biblionumber);
61
    $cn->{$callnumber} = {
62
        biblionumber => $biblionumber,
63
        itemnumber => $itemnumber,
64
        itemcallnumber => $callnumber,
65
    }
66
}
67
68
my $nearby;
69
70
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'500.100'}{itemnumber} );
71
# We have
72
# < 320.000 400.100 410.100 500.100 510.100 520.100 600.000 >
73
#      6       7       8      [9]       10      11      12
74
# Clicking on previous, we want a link to 150.100
75
is( $nearby->{prev_item}{itemcallnumber}, '150.100', "Simple case: previous link 1/2" );
76
is( $nearby->{prev_item}{itemnumber}, $cn->{'150.100'}{itemnumber}, "Simple case: previous link 2/2" );
77
# Clicking on next, we want a link to 730.100
78
is( $nearby->{next_item}{itemcallnumber}, '720.100', "Simple case: next link 1/2" );
79
is( $nearby->{next_item}{itemnumber}, $cn->{'720.100'}{itemnumber}, "Simple case: next link 2/2" );
80
81
is( $nearby->{items}[0]{itemcallnumber}, '320.000', "Simple case: item 1");
82
is( $nearby->{items}[1]{itemcallnumber}, '400.100', "Simple case: item 2");
83
is( $nearby->{items}[2]{itemcallnumber}, '410.100', "Simple case: item 3");
84
is( $nearby->{items}[3]{itemcallnumber}, '500.100', "Simple case: item 4");
85
is( $nearby->{items}[4]{itemcallnumber}, '510.100', "Simple case: item 5");
86
is( $nearby->{items}[5]{itemcallnumber}, '520.100', "Simple case: item 6");
87
is( $nearby->{items}[6]{itemcallnumber}, '600.000', "Simple case: item 7");
88
89
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'500.100'}{itemnumber}, 2, 3 );
90
# We have
91
# < 400.100 410.100 500.100 510.100 520.100 >
92
#      7       8      [9]       10      11
93
# Clicking on previous, we want a link to 320.000
94
is( $nearby->{prev_item}{itemcallnumber}, '320.000', "Test gap: previous link 1/2" );
95
is( $nearby->{prev_item}{itemnumber}, $cn->{'320.000'}{itemnumber}, "Test gap: previous link 2/2" );
96
# Clicking on next, we want a link to 600.000
97
is( $nearby->{next_item}{itemcallnumber}, '600.000', "Test gap: next link 1/2" );
98
is( $nearby->{next_item}{itemnumber}, $cn->{'600.000'}{itemnumber}, "Test gap: next link 2/2" );
99
100
is( scalar( @{$nearby->{items}} ), 5, "Test gap: got 5 items" );
101
is( $nearby->{items}[0]{itemcallnumber}, '400.100', "Test gap: item 1");
102
is( $nearby->{items}[1]{itemcallnumber}, '410.100', "Test gap: item 2");
103
is( $nearby->{items}[2]{itemcallnumber}, '500.100', "Test gap: item 3");
104
is( $nearby->{items}[3]{itemcallnumber}, '510.100', "Test gap: item 4");
105
is( $nearby->{items}[4]{itemcallnumber}, '520.100', "Test gap: item 5");
106
107
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'300.000'}{itemnumber} );
108
# We have
109
# < 150.100 200.100 210.100 300.000 320.000 400.100 410.100 >
110
#      2       3       4      [5]      6       7       8
111
# Clicking on previous, we want a link to 100.100
112
is( $nearby->{prev_item}{itemcallnumber}, '100.100', "Test start shelf: previous link 1/2" );
113
is( $nearby->{prev_item}{itemnumber}, $cn->{'100.100'}{itemnumber}, "Test start shelf: previous link 2/2" );
114
# Clicking on next, we want a link to 600.000
115
is( $nearby->{next_item}{itemcallnumber}, '600.000', "Test start shelf: next link 1/2" );
116
is( $nearby->{next_item}{itemnumber}, $cn->{'600.000'}{itemnumber}, "Test start shelf: next link 2/2" );
117
118
is( $nearby->{items}[0]{itemcallnumber}, '150.100', "Test start shelf: item 1");
119
is( $nearby->{items}[1]{itemcallnumber}, '200.100', "Test start shelf: item 2");
120
is( $nearby->{items}[2]{itemcallnumber}, '210.100', "Test start shelf: item 3");
121
is( $nearby->{items}[3]{itemcallnumber}, '300.000', "Test start shelf: item 4");
122
is( $nearby->{items}[4]{itemcallnumber}, '320.000', "Test start shelf: item 5");
123
is( $nearby->{items}[5]{itemcallnumber}, '400.100', "Test start shelf: item 6");
124
is( $nearby->{items}[6]{itemcallnumber}, '410.100', "Test start shelf: item 7");
125
126
127
128
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'100.100'}{itemnumber} );
129
# We have
130
# 100.100 150.100 200.100 210.100 >
131
#   [1]       2       3       4
132
# There is no previous link
133
is( $nearby->{prev_item}, undef, "Test first item on a shelf: no previous link" );
134
# Clicking on next, we want a link to 410.100
135
is( $nearby->{next_item}{itemcallnumber}, '410.100', "Test first item on a shelf: next link 1/2" );
136
is( $nearby->{next_item}{itemnumber}, $cn->{'410.100'}{itemnumber}, "Test first item on a shelf: next link 2/2" );
137
138
is( scalar( @{$nearby->{items}} ), 4, "Test first item on a shelf: There are 4 items displayed" );
139
is( $nearby->{items}[0]{itemcallnumber}, '100.100', "Test first item on a shelf: item 1");
140
is( $nearby->{items}[1]{itemcallnumber}, '150.100', "Test first item on a shelf: item 2");
141
is( $nearby->{items}[2]{itemcallnumber}, '200.100', "Test first item on a shelf: item 3");
142
is( $nearby->{items}[3]{itemcallnumber}, '210.100', "Test first item on a shelf: item 4");
143
144
145
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'150.100'}{itemnumber} );
146
# We have
147
# 100.100 150.100 200.100 210.100 300.000 >
148
#    1      [2]       3       4      5
149
# There is no previous link
150
is( $nearby->{prev_item}, undef, "Test second item on a shelf: no previous link" );
151
# Clicking on next, we want a link to 500.100
152
is( $nearby->{next_item}{itemcallnumber}, '500.100', "Test second item on a shelf: next link 1/2" );
153
is( $nearby->{next_item}{itemnumber}, $cn->{'500.100'}{itemnumber}, "Test second item on a shelf: next link 2/2" );
154
155
is( scalar( @{$nearby->{items}} ), 5, "Test second item on a shelf: got 5 items" );
156
is( $nearby->{items}[0]{itemcallnumber}, '100.100', "Test second item on a shelf: item 1");
157
is( $nearby->{items}[1]{itemcallnumber}, '150.100', "Test second item on a shelf: item 2");
158
is( $nearby->{items}[2]{itemcallnumber}, '200.100', "Test second item on a shelf: item 3");
159
is( $nearby->{items}[3]{itemcallnumber}, '210.100', "Test second item on a shelf: item 4");
160
is( $nearby->{items}[4]{itemcallnumber}, '300.000', "Test second item on a shelf: item 5");
161
162
163
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'710.100'}{itemnumber} );
164
# We have
165
# < 600.000 610.000 700.100 710.100 720.100 730.100 740.100 >
166
#      12      13      14     [15]     16      17      18
167
# Clicking on previous, we want a link to 410.100
168
is( $nearby->{prev_item}{itemcallnumber}, '410.100', "Test end shelf: previous link 1/2" );
169
is( $nearby->{prev_item}{itemnumber}, $cn->{'410.100'}{itemnumber}, "Test end shelf: previous link 2/2" );
170
# Clicking on next, we want a link to 730.100
171
is( $nearby->{next_item}{itemcallnumber}, '750.100', "Test end shelf: next link is a link to the last item 1/2" );
172
is( $nearby->{next_item}{itemnumber}, $cn->{'750.100'}{itemnumber}, "Test end shelf: next link is a link to the last item 2/2" );
173
174
is( $nearby->{items}[0]{itemcallnumber}, '600.000', "Test end shelf: item 1");
175
is( $nearby->{items}[1]{itemcallnumber}, '610.000', "Test end shelf: item 2");
176
is( $nearby->{items}[2]{itemcallnumber}, '700.100', "Test end shelf: item 3");
177
is( $nearby->{items}[3]{itemcallnumber}, '710.100', "Test end shelf: item 4");
178
is( $nearby->{items}[4]{itemcallnumber}, '720.100', "Test end shelf: item 5");
179
is( $nearby->{items}[5]{itemcallnumber}, '730.100', "Test end shelf: item 6");
180
is( $nearby->{items}[6]{itemcallnumber}, '740.100', "Test end shelf: item 7");
181
182
183
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'740.100'}{itemnumber} );
184
# We have
185
# < 710.100 720.100 730.100 740.100 750.100
186
#      15      16      17     [18]     19
187
# Clicking on previous, we want a link to
188
is( $nearby->{prev_item}{itemcallnumber}, '520.100', "Test end of the shelf: previous link 1/2" );
189
is( $nearby->{prev_item}{itemnumber}, $cn->{'520.100'}{itemnumber}, "Test end of the shelf: previous link 2/2" );
190
# No next link
191
is( $nearby->{next_item}, undef, "Test end of the shelf: no next link" );
192
193
is( scalar( @{$nearby->{items}} ), 5, "Test end of the shelf: got 5 items" );
194
is( $nearby->{items}[0]{itemcallnumber}, '710.100', "Test end of the shelf: item 1");
195
is( $nearby->{items}[1]{itemcallnumber}, '720.100', "Test end of the shelf: item 2");
196
is( $nearby->{items}[2]{itemcallnumber}, '730.100', "Test end of the shelf: item 3");
197
is( $nearby->{items}[3]{itemcallnumber}, '740.100', "Test end of the shelf: item 4");
198
is( $nearby->{items}[4]{itemcallnumber}, '750.100', "Test end of the shelf: item 5");
199
200
$nearby = C4::ShelfBrowser::GetNearbyItems( $cn->{'750.100'}{itemnumber} );
201
# We have
202
# < 720.100 730.100 740.100 750.100
203
#      16      17      18     [19]
204
# Clicking on previous, we want a link to
205
is( $nearby->{prev_item}{itemcallnumber}, '600.000', "Test last item of the shelf: previous link 1/2" );
206
is( $nearby->{prev_item}{itemnumber}, $cn->{'600.000'}{itemnumber}, "Test last item of the shelf: previous link 2/2" );
207
# No next link
208
is( $nearby->{next_item}, undef, "Test end of the shelf: no next link" );
209
210
is( scalar( @{$nearby->{items}} ), 4, "Test last item of the shelf: got 4 items" );
211
212
$dbh->rollback;

Return to bug 10856