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

(-)a/C4/Items.pm (-3 / +22 lines)
Lines 1258-1267 sub GetItemsByBiblioitemnumber { Link Here
1258
1258
1259
=head2 GetItemsInfo
1259
=head2 GetItemsInfo
1260
1260
1261
  @results = GetItemsInfo($biblionumber);
1261
  @results = GetItemsInfo($biblionumber, $order_by);
1262
1262
1263
Returns information about items with the given biblionumber.
1263
Returns information about items with the given biblionumber.
1264
1264
1265
The list is ordered by home branch name and some complex criteria
1266
within it (see the code), unless $order_by is specified.
1267
Currently only "cn_sort" is supported.
1268
1265
C<GetItemsInfo> returns a list of references-to-hash. Each element
1269
C<GetItemsInfo> returns a list of references-to-hash. Each element
1266
contains a number of keys. Most of them are attributes from the
1270
contains a number of keys. Most of them are attributes from the
1267
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
1271
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
Lines 1299-1305 If this is set, it is set to C<One Order>. Link Here
1299
=cut
1303
=cut
1300
1304
1301
sub GetItemsInfo {
1305
sub GetItemsInfo {
1302
    my ( $biblionumber ) = @_;
1306
    my ( $biblionumber, $order_by ) = @_;
1307
1303
    my $dbh   = C4::Context->dbh;
1308
    my $dbh   = C4::Context->dbh;
1304
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1309
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1305
    require C4::Languages;
1310
    require C4::Languages;
Lines 1354-1360 sub GetItemsInfo { Link Here
1354
        AND localization.lang = ?
1359
        AND localization.lang = ?
1355
    |;
1360
    |;
1356
1361
1357
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1362
    $query .= " WHERE items.biblionumber = ? ORDER BY ";
1363
    my $order_by_cause = "home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1364
    if ($order_by) {
1365
        if ($order_by eq 'cn_sort') {
1366
            $order_by_cause = "cn_sort ASC";
1367
        }
1368
        else {
1369
            warn qq{Unsupported order by "$order_by"};
1370
        }
1371
    }
1372
    $query .= $order_by_cause;
1373
1358
    my $sth = $dbh->prepare($query);
1374
    my $sth = $dbh->prepare($query);
1359
    $sth->execute($language, $biblionumber);
1375
    $sth->execute($language, $biblionumber);
1360
    my $i = 0;
1376
    my $i = 0;
Lines 1387-1392 sub GetItemsInfo { Link Here
1387
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1403
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1388
        }
1404
        }
1389
1405
1406
        $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1407
        $data->{location_opac}     = GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1408
1390
        # Find the last 3 people who borrowed this item.
1409
        # Find the last 3 people who borrowed this item.
1391
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1410
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1392
                                    WHERE itemnumber = ?
1411
                                    WHERE itemnumber = ?
(-)a/C4/Search.pm (-14 / +5 lines)
Lines 2007-2013 sub searchResults { Link Here
2007
        my $items_count           = scalar(@fields);
2007
        my $items_count           = scalar(@fields);
2008
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2008
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2009
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2009
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2010
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
2011
2010
2012
        # loop through every item
2011
        # loop through every item
2013
        foreach my $field (@fields) {
2012
        foreach my $field (@fields) {
Lines 2029-2035 sub searchResults { Link Here
2029
                # hidden based on OpacHiddenItems syspref
2028
                # hidden based on OpacHiddenItems syspref
2030
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2029
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2031
                if (scalar @hi) {
2030
                if (scalar @hi) {
2032
                    push @hiddenitems, @hi;
2033
                    $hideatopac_count++;
2031
                    $hideatopac_count++;
2034
                    next;
2032
                    next;
2035
                }
2033
                }
Lines 2046-2052 sub searchResults { Link Here
2046
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2044
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2047
            }
2045
            }
2048
2046
2049
			my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2047
            my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2050
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2048
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2051
            my $userenv = C4::Context->userenv;
2049
            my $userenv = C4::Context->userenv;
2052
            if ( $item->{onloan}
2050
            if ( $item->{onloan}
Lines 2054-2065 sub searchResults { Link Here
2054
            {
2052
            {
2055
                $onloan_count++;
2053
                $onloan_count++;
2056
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2054
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2055
                $onloan_items->{$key} = { %$item };
2057
                $onloan_items->{$key}->{due_date} = output_pref( { dt => dt_from_string( $item->{onloan} ), dateonly => 1 } );
2056
                $onloan_items->{$key}->{due_date} = output_pref( { dt => dt_from_string( $item->{onloan} ), dateonly => 1 } );
2058
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2057
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2059
                $onloan_items->{$key}->{branchname}     = $item->{branchname};
2060
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2058
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2061
                $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
2062
                $onloan_items->{$key}->{description}    = $item->{description};
2063
                $onloan_items->{$key}->{imageurl} =
2059
                $onloan_items->{$key}->{imageurl} =
2064
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2060
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2065
2061
Lines 2145-2169 sub searchResults { Link Here
2145
                    $other_count++;
2141
                    $other_count++;
2146
2142
2147
                    my $key = $prefix . $item->{status};
2143
                    my $key = $prefix . $item->{status};
2148
                    foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) {
2144
                    $other_items->{$key} = { %$item };
2149
                        $other_items->{$key}->{$_} = $item->{$_};
2150
                    }
2151
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2145
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2152
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2146
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2153
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2147
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2154
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2148
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2155
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2149
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2156
					$other_items->{$key}->{description} = $item->{description};
2157
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2150
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2158
                }
2151
                }
2159
                # item is available
2152
                # item is available
2160
                else {
2153
                else {
2161
                    $can_place_holds = 1;
2154
                    $can_place_holds = 1;
2162
                    $available_count++;
2155
                    $available_count++;
2156
                    $available_items->{$prefix} = { %$item };
2163
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2157
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2164
					foreach (qw(branchname itemcallnumber description)) {
2165
                    	$available_items->{$prefix}->{$_} = $item->{$_};
2166
					}
2167
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2158
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2168
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2159
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2169
                }
2160
                }
Lines 2192-2198 sub searchResults { Link Here
2192
        # XSLT processing of some stuff
2183
        # XSLT processing of some stuff
2193
        my $interface = $search_context eq 'opac' ? 'OPAC' : '';
2184
        my $interface = $search_context eq 'opac' ? 'OPAC' : '';
2194
        if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
2185
        if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
2195
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
2186
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", [@available_items_loop, @onloan_items_loop, @other_items_loop], 1);
2196
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2187
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2197
        }
2188
        }
2198
2189
(-)a/C4/XSLT.pm (-10 / +13 lines)
Lines 156-163 sub _get_best_default_xslt_filename { Link Here
156
    return $xslfilename;
156
    return $xslfilename;
157
}
157
}
158
158
159
=head2 XSLTParse4Display( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps )
160
161
  $items => an array of items rerords, as returned from eg. GetItemsInfo
162
163
Returns XSLT block
164
165
=cut
166
159
sub XSLTParse4Display {
167
sub XSLTParse4Display {
160
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
168
    my ( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps ) = @_;
169
161
    my $xslfilename = C4::Context->preference($xslsyspref);
170
    my $xslfilename = C4::Context->preference($xslsyspref);
162
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
171
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
163
        my $htdocs;
172
        my $htdocs;
Lines 195-201 sub XSLTParse4Display { Link Here
195
204
196
    # grab the XML, run it through our stylesheet, push it out to the browser
205
    # grab the XML, run it through our stylesheet, push it out to the browser
197
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
206
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
198
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
207
    my $itemsxml  = $items ? buildKohaItemsNamespace($biblionumber, $items) : "";
199
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
208
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
200
    my $sysxml = "<sysprefs>\n";
209
    my $sysxml = "<sysprefs>\n";
201
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
210
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
Lines 242-254 Is only used in this module currently. Link Here
242
=cut
251
=cut
243
252
244
sub buildKohaItemsNamespace {
253
sub buildKohaItemsNamespace {
245
    my ($biblionumber, $hidden_items) = @_;
254
    my ($biblionumber, $items) = @_;
246
247
    my @items = C4::Items::GetItemsInfo($biblionumber);
248
    if ($hidden_items && @$hidden_items) {
249
        my %hi = map {$_ => 1} @$hidden_items;
250
        @items = grep { !$hi{$_->{itemnumber}} } @items;
251
    }
252
255
253
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
256
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
254
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
257
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
Lines 258-264 sub buildKohaItemsNamespace { Link Here
258
    my $location = "";
261
    my $location = "";
259
    my $ccode = "";
262
    my $ccode = "";
260
    my $xml = '';
263
    my $xml = '';
261
    for my $item (@items) {
264
    for my $item (@$items) {
262
        my $status;
265
        my $status;
263
266
264
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
267
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
(-)a/catalogue/detail.pl (-6 / +6 lines)
Lines 83-94 my $fw = GetFrameworkCode($biblionumber); Link Here
83
my $showallitems = $query->param('showallitems');
83
my $showallitems = $query->param('showallitems');
84
my $marcflavour  = C4::Context->preference("marcflavour");
84
my $marcflavour  = C4::Context->preference("marcflavour");
85
85
86
# XSLT processing of some stuff
87
if (C4::Context->preference("XSLTDetailsDisplay") ) {
88
    $template->param('XSLTDetailsDisplay' =>'1',
89
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
90
}
91
92
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
86
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
93
$template->param( ocoins => GetCOinSBiblio($record) );
87
$template->param( ocoins => GetCOinSBiblio($record) );
94
88
Lines 136-141 if (@hostitems){ Link Here
136
	push (@items,@hostitems);
130
	push (@items,@hostitems);
137
}
131
}
138
132
133
# XSLT processing of some stuff
134
if (C4::Context->preference("XSLTDetailsDisplay") ) {
135
    $template->param('XSLTDetailsDisplay' =>'1',
136
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay", \@all_items) );
137
}
138
139
my $dat = &GetBiblioData($biblionumber);
139
my $dat = &GetBiblioData($biblionumber);
140
140
141
#coping with subscriptions
141
#coping with subscriptions
(-)a/opac/opac-detail.pl (-6 / +5 lines)
Lines 140-150 SetUTF8Flag($record); Link Here
140
my $marcflavour      = C4::Context->preference("marcflavour");
140
my $marcflavour      = C4::Context->preference("marcflavour");
141
my $ean = GetNormalizedEAN( $record, $marcflavour );
141
my $ean = GetNormalizedEAN( $record, $marcflavour );
142
142
143
# XSLT processing of some stuff
144
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
145
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
146
}
147
148
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
143
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
149
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
144
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
150
145
Lines 480-485 if ($hideitems) { Link Here
480
    @items = @all_items;
475
    @items = @all_items;
481
}
476
}
482
477
478
# XSLT processing of some stuff
479
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
480
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay", \@items) );
481
}
482
483
my $branches = GetBranches();
483
my $branches = GetBranches();
484
my $branch = '';
484
my $branch = '';
485
if (C4::Context->userenv){
485
if (C4::Context->userenv){
486
- 

Return to bug 11213