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

(-)a/C4/Items.pm (-3 / +22 lines)
Lines 1265-1274 sub GetItemsByBiblioitemnumber { Link Here
1265
1265
1266
=head2 GetItemsInfo
1266
=head2 GetItemsInfo
1267
1267
1268
  @results = GetItemsInfo($biblionumber);
1268
  @results = GetItemsInfo($biblionumber, $order_by);
1269
1269
1270
Returns information about items with the given biblionumber.
1270
Returns information about items with the given biblionumber.
1271
1271
1272
The list is ordered by home branch name and some complex criteria
1273
within it (see the code), unless $order_by is specified.
1274
Currently only "cn_sort" is supported.
1275
1272
C<GetItemsInfo> returns a list of references-to-hash. Each element
1276
C<GetItemsInfo> returns a list of references-to-hash. Each element
1273
contains a number of keys. Most of them are attributes from the
1277
contains a number of keys. Most of them are attributes from the
1274
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
1278
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
Lines 1306-1312 If this is set, it is set to C<One Order>. Link Here
1306
=cut
1310
=cut
1307
1311
1308
sub GetItemsInfo {
1312
sub GetItemsInfo {
1309
    my ( $biblionumber ) = @_;
1313
    my ( $biblionumber, $order_by ) = @_;
1314
1310
    my $dbh   = C4::Context->dbh;
1315
    my $dbh   = C4::Context->dbh;
1311
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1316
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1312
    require C4::Languages;
1317
    require C4::Languages;
Lines 1361-1367 sub GetItemsInfo { Link Here
1361
        AND localization.lang = ?
1366
        AND localization.lang = ?
1362
    |;
1367
    |;
1363
1368
1364
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1369
    $query .= " WHERE items.biblionumber = ? ORDER BY ";
1370
    my $order_by_cause = "home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1371
    if ($order_by) {
1372
        if ($order_by eq 'cn_sort') {
1373
            $order_by_cause = "cn_sort ASC";
1374
        }
1375
        else {
1376
            warn qq{Unsupported order by "$order_by"};
1377
        }
1378
    }
1379
    $query .= $order_by_cause;
1380
1365
    my $sth = $dbh->prepare($query);
1381
    my $sth = $dbh->prepare($query);
1366
    $sth->execute($language, $biblionumber);
1382
    $sth->execute($language, $biblionumber);
1367
    my $i = 0;
1383
    my $i = 0;
Lines 1394-1399 sub GetItemsInfo { Link Here
1394
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1410
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1395
        }
1411
        }
1396
1412
1413
        $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1414
        $data->{location_opac}     = GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1415
1397
        # Find the last 3 people who borrowed this item.
1416
        # Find the last 3 people who borrowed this item.
1398
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1417
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1399
                                    WHERE itemnumber = ?
1418
                                    WHERE itemnumber = ?
(-)a/C4/Search.pm (-14 / +5 lines)
Lines 2034-2040 sub searchResults { Link Here
2034
        my $items_count           = scalar(@fields);
2034
        my $items_count           = scalar(@fields);
2035
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2035
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2036
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2036
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2037
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
2038
2037
2039
        # loop through every item
2038
        # loop through every item
2040
        foreach my $field (@fields) {
2039
        foreach my $field (@fields) {
Lines 2056-2062 sub searchResults { Link Here
2056
                # hidden based on OpacHiddenItems syspref
2055
                # hidden based on OpacHiddenItems syspref
2057
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2056
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2058
                if (scalar @hi) {
2057
                if (scalar @hi) {
2059
                    push @hiddenitems, @hi;
2060
                    $hideatopac_count++;
2058
                    $hideatopac_count++;
2061
                    next;
2059
                    next;
2062
                }
2060
                }
Lines 2073-2079 sub searchResults { Link Here
2073
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2071
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2074
            }
2072
            }
2075
2073
2076
			my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2074
            my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2077
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2075
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2078
            my $userenv = C4::Context->userenv;
2076
            my $userenv = C4::Context->userenv;
2079
            if ( $item->{onloan}
2077
            if ( $item->{onloan}
Lines 2081-2092 sub searchResults { Link Here
2081
            {
2079
            {
2082
                $onloan_count++;
2080
                $onloan_count++;
2083
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2081
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2082
                $onloan_items->{$key} = { %$item };
2084
                $onloan_items->{$key}->{due_date} = output_pref( { dt => dt_from_string( $item->{onloan} ), dateonly => 1 } );
2083
                $onloan_items->{$key}->{due_date} = output_pref( { dt => dt_from_string( $item->{onloan} ), dateonly => 1 } );
2085
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2084
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2086
                $onloan_items->{$key}->{branchname}     = $item->{branchname};
2087
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2085
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2088
                $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
2089
                $onloan_items->{$key}->{description}    = $item->{description};
2090
                $onloan_items->{$key}->{imageurl} =
2086
                $onloan_items->{$key}->{imageurl} =
2091
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2087
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2092
2088
Lines 2172-2196 sub searchResults { Link Here
2172
                    $other_count++;
2168
                    $other_count++;
2173
2169
2174
                    my $key = $prefix . $item->{status};
2170
                    my $key = $prefix . $item->{status};
2175
                    foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) {
2171
                    $other_items->{$key} = { %$item };
2176
                        $other_items->{$key}->{$_} = $item->{$_};
2177
                    }
2178
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2172
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2179
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2173
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2180
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2174
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2181
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2175
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2182
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2176
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2183
					$other_items->{$key}->{description} = $item->{description};
2184
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2177
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2185
                }
2178
                }
2186
                # item is available
2179
                # item is available
2187
                else {
2180
                else {
2188
                    $can_place_holds = 1;
2181
                    $can_place_holds = 1;
2189
                    $available_count++;
2182
                    $available_count++;
2183
                    $available_items->{$prefix} = { %$item };
2190
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2184
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2191
					foreach (qw(branchname itemcallnumber description)) {
2192
                    	$available_items->{$prefix}->{$_} = $item->{$_};
2193
					}
2194
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2185
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2195
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2186
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2196
                }
2187
                }
Lines 2219-2225 sub searchResults { Link Here
2219
        # XSLT processing of some stuff
2210
        # XSLT processing of some stuff
2220
        # we fetched the sysprefs already before the loop through all retrieved record!
2211
        # we fetched the sysprefs already before the loop through all retrieved record!
2221
        if (!$scan && $xslfile) {
2212
        if (!$scan && $xslfile) {
2222
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang);
2213
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, [@available_items_loop, @onloan_items_loop, @other_items_loop], 1, $sysxml, $xslfile, $lang);
2223
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2214
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2224
        }
2215
        }
2225
2216
(-)a/C4/XSLT.pm (-10 / +12 lines)
Lines 187-194 sub get_xslt_sysprefs { Link Here
187
    return $sysxml;
187
    return $sysxml;
188
}
188
}
189
189
190
=head2 XSLTParse4Display( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps, $sysxml, $xslfilename, $lang )
191
192
  $items => an array of items rerords, as returned from eg. GetItemsInfo
193
194
Returns XSLT block
195
196
=cut
197
190
sub XSLTParse4Display {
198
sub XSLTParse4Display {
191
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_;
199
    my ( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps, $sysxml, $xslfilename, $lang ) = @_;
192
200
193
    $sysxml ||= C4::Context->preference($xslsyspref);
201
    $sysxml ||= C4::Context->preference($xslsyspref);
194
    $xslfilename ||= C4::Context->preference($xslsyspref);
202
    $xslfilename ||= C4::Context->preference($xslsyspref);
Lines 240-246 sub XSLTParse4Display { Link Here
240
248
241
    # grab the XML, run it through our stylesheet, push it out to the browser
249
    # grab the XML, run it through our stylesheet, push it out to the browser
242
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
250
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
243
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
251
    my $itemsxml  = $items ? buildKohaItemsNamespace($biblionumber, $items) : "";
244
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
252
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
245
253
246
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
254
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
Lines 266-278 Is only used in this module currently. Link Here
266
=cut
274
=cut
267
275
268
sub buildKohaItemsNamespace {
276
sub buildKohaItemsNamespace {
269
    my ($biblionumber, $hidden_items) = @_;
277
    my ($biblionumber, $items) = @_;
270
271
    my @items = C4::Items::GetItemsInfo($biblionumber);
272
    if ($hidden_items && @$hidden_items) {
273
        my %hi = map {$_ => 1} @$hidden_items;
274
        @items = grep { !$hi{$_->{itemnumber}} } @items;
275
    }
276
278
277
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
279
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
278
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
280
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
Lines 282-288 sub buildKohaItemsNamespace { Link Here
282
    my $location = "";
284
    my $location = "";
283
    my $ccode = "";
285
    my $ccode = "";
284
    my $xml = '';
286
    my $xml = '';
285
    for my $item (@items) {
287
    for my $item (@$items) {
286
        my $status;
288
        my $status;
287
289
288
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
290
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
(-)a/catalogue/detail.pl (-15 / +15 lines)
Lines 84-104 my $fw = GetFrameworkCode($biblionumber); Link Here
84
my $showallitems = $query->param('showallitems');
84
my $showallitems = $query->param('showallitems');
85
my $marcflavour  = C4::Context->preference("marcflavour");
85
my $marcflavour  = C4::Context->preference("marcflavour");
86
86
87
# XSLT processing of some stuff
88
my $xslfile = C4::Context->preference('XSLTDetailsDisplay');
89
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
90
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
91
92
if ( $xslfile ) {
93
    $template->param(
94
        XSLTDetailsDisplay => '1',
95
        XSLTBloc => XSLTParse4Display(
96
                        $biblionumber, $record, "XSLTDetailsDisplay",
97
                        1, undef, $sysxml, $xslfile, $lang
98
                    )
99
    );
100
}
101
102
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
87
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
103
$template->param( ocoins => GetCOinSBiblio($record) );
88
$template->param( ocoins => GetCOinSBiblio($record) );
104
89
Lines 146-151 if (@hostitems){ Link Here
146
	push (@items,@hostitems);
131
	push (@items,@hostitems);
147
}
132
}
148
133
134
# XSLT processing of some stuff
135
my $xslfile = C4::Context->preference('XSLTDetailsDisplay');
136
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
137
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
138
139
if ( $xslfile ) {
140
    $template->param(
141
        XSLTDetailsDisplay => '1',
142
        XSLTBloc => XSLTParse4Display(
143
                        $biblionumber, $record, "XSLTDetailsDisplay", \@all_items,
144
                        1, $sysxml, $xslfile, $lang
145
                    )
146
    );
147
}
148
149
my $dat = &GetBiblioData($biblionumber);
149
my $dat = &GetBiblioData($biblionumber);
150
150
151
#coping with subscriptions
151
#coping with subscriptions
(-)a/opac/opac-detail.pl (-15 / +14 lines)
Lines 139-158 SetUTF8Flag($record); Link Here
139
my $marcflavour      = C4::Context->preference("marcflavour");
139
my $marcflavour      = C4::Context->preference("marcflavour");
140
my $ean = GetNormalizedEAN( $record, $marcflavour );
140
my $ean = GetNormalizedEAN( $record, $marcflavour );
141
141
142
# XSLT processing of some stuff
143
my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
144
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
145
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
146
147
if ( $xslfile ) {
148
    $template->param(
149
        XSLTBloc => XSLTParse4Display(
150
                        $biblionumber, $record, "OPACXSLTDetailsDisplay",
151
                        1, undef, $sysxml, $xslfile, $lang
152
                    )
153
    );
154
}
155
156
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
142
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
157
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
143
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
158
144
Lines 488-493 if ($hideitems) { Link Here
488
    @items = @all_items;
474
    @items = @all_items;
489
}
475
}
490
476
477
# XSLT processing of some stuff
478
my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
479
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
480
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
481
482
if ( $xslfile ) {
483
    $template->param(
484
        XSLTBloc => XSLTParse4Display(
485
                        $biblionumber, $record, "OPACXSLTDetailsDisplay", \@items,
486
                        1, $sysxml, $xslfile, $lang
487
                    )
488
    );
489
}
490
491
my $branches = GetBranches();
491
my $branches = GetBranches();
492
my $branch = '';
492
my $branch = '';
493
if (C4::Context->userenv){
493
if (C4::Context->userenv){
494
- 

Return to bug 11213