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

(-)a/C4/Items.pm (-3 / +22 lines)
Lines 1148-1157 sub GetItemsByBiblioitemnumber { Link Here
1148
1148
1149
=head2 GetItemsInfo
1149
=head2 GetItemsInfo
1150
1150
1151
  @results = GetItemsInfo($biblionumber);
1151
  @results = GetItemsInfo($biblionumber, $order_by);
1152
1152
1153
Returns information about items with the given biblionumber.
1153
Returns information about items with the given biblionumber.
1154
1154
1155
The list is ordered by home branch name and some complex criteria
1156
within it (see the code), unless $order_by is specified.
1157
Currently only "cn_sort" is supported.
1158
1155
C<GetItemsInfo> returns a list of references-to-hash. Each element
1159
C<GetItemsInfo> returns a list of references-to-hash. Each element
1156
contains a number of keys. Most of them are attributes from the
1160
contains a number of keys. Most of them are attributes from the
1157
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
1161
C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
Lines 1189-1195 If this is set, it is set to C<One Order>. Link Here
1189
=cut
1193
=cut
1190
1194
1191
sub GetItemsInfo {
1195
sub GetItemsInfo {
1192
    my ( $biblionumber ) = @_;
1196
    my ( $biblionumber, $order_by ) = @_;
1197
1193
    my $dbh   = C4::Context->dbh;
1198
    my $dbh   = C4::Context->dbh;
1194
    require C4::Languages;
1199
    require C4::Languages;
1195
    my $language = C4::Languages::getlanguage();
1200
    my $language = C4::Languages::getlanguage();
Lines 1244-1250 sub GetItemsInfo { Link Here
1244
        AND localization.lang = ?
1249
        AND localization.lang = ?
1245
    |;
1250
    |;
1246
1251
1247
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1252
    $query .= " WHERE items.biblionumber = ? ORDER BY ";
1253
    my $order_by_cause = "home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1254
    if ($order_by) {
1255
        if ($order_by eq 'cn_sort') {
1256
            $order_by_cause = "cn_sort ASC";
1257
        }
1258
        else {
1259
            warn qq{Unsupported order by "$order_by"};
1260
        }
1261
    }
1262
    $query .= $order_by_cause;
1263
1248
    my $sth = $dbh->prepare($query);
1264
    my $sth = $dbh->prepare($query);
1249
    $sth->execute($language, $biblionumber);
1265
    $sth->execute($language, $biblionumber);
1250
    my $i = 0;
1266
    my $i = 0;
Lines 1275-1280 sub GetItemsInfo { Link Here
1275
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1291
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1276
        $data->{stack}          = $descriptions->{lib} // '';
1292
        $data->{stack}          = $descriptions->{lib} // '';
1277
1293
1294
        $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1295
        $data->{location_opac}     = GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1296
1278
        # Find the last 3 people who borrowed this item.
1297
        # Find the last 3 people who borrowed this item.
1279
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1298
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1280
                                    WHERE itemnumber = ?
1299
                                    WHERE itemnumber = ?
(-)a/C4/Search.pm (-14 / +5 lines)
Lines 2049-2055 sub searchResults { Link Here
2049
        my $items_count           = scalar(@fields);
2049
        my $items_count           = scalar(@fields);
2050
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2050
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2051
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2051
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2052
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
2053
2052
2054
        # loop through every item
2053
        # loop through every item
2055
        foreach my $field (@fields) {
2054
        foreach my $field (@fields) {
Lines 2071-2077 sub searchResults { Link Here
2071
                # hidden based on OpacHiddenItems syspref
2070
                # hidden based on OpacHiddenItems syspref
2072
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2071
                my @hi = C4::Items::GetHiddenItemnumbers($item);
2073
                if (scalar @hi) {
2072
                if (scalar @hi) {
2074
                    push @hiddenitems, @hi;
2075
                    $hideatopac_count++;
2073
                    $hideatopac_count++;
2076
                    next;
2074
                    next;
2077
                }
2075
                }
Lines 2088-2094 sub searchResults { Link Here
2088
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2086
                $item->{'branchname'} = $branches{$item->{$otherbranch}};
2089
            }
2087
            }
2090
2088
2091
			my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2089
            my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
2092
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2090
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
2093
            my $userenv = C4::Context->userenv;
2091
            my $userenv = C4::Context->userenv;
2094
            if ( $item->{onloan}
2092
            if ( $item->{onloan}
Lines 2098-2109 sub searchResults { Link Here
2098
            {
2096
            {
2099
                $onloan_count++;
2097
                $onloan_count++;
2100
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2098
                my $key = $prefix . $item->{onloan} . $item->{barcode};
2099
                $onloan_items->{$key} = { %$item };
2101
                $onloan_items->{$key}->{due_date} = $item->{onloan};
2100
                $onloan_items->{$key}->{due_date} = $item->{onloan};
2102
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2101
                $onloan_items->{$key}->{count}++ if $item->{$hbranch};
2103
                $onloan_items->{$key}->{branchname}     = $item->{branchname};
2104
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2102
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} };
2105
                $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
2106
                $onloan_items->{$key}->{description}    = $item->{description};
2107
                $onloan_items->{$key}->{imageurl} =
2103
                $onloan_items->{$key}->{imageurl} =
2108
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2104
                  getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2109
2105
Lines 2189-2213 sub searchResults { Link Here
2189
                    $other_count++;
2185
                    $other_count++;
2190
2186
2191
                    my $key = $prefix . $item->{status};
2187
                    my $key = $prefix . $item->{status};
2192
                    foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) {
2188
                    $other_items->{$key} = { %$item };
2193
                        $other_items->{$key}->{$_} = $item->{$_};
2194
                    }
2195
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2189
                    $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
2196
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2190
                    $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
2197
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2191
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
2198
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2192
					$other_items->{$key}->{count}++ if $item->{$hbranch};
2199
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2193
					$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
2200
					$other_items->{$key}->{description} = $item->{description};
2201
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2194
					$other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2202
                }
2195
                }
2203
                # item is available
2196
                # item is available
2204
                else {
2197
                else {
2205
                    $can_place_holds = 1;
2198
                    $can_place_holds = 1;
2206
                    $available_count++;
2199
                    $available_count++;
2200
                    $available_items->{$prefix} = { %$item };
2207
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2201
					$available_items->{$prefix}->{count}++ if $item->{$hbranch};
2208
					foreach (qw(branchname itemcallnumber description)) {
2209
                    	$available_items->{$prefix}->{$_} = $item->{$_};
2210
					}
2211
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2202
					$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
2212
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2203
					$available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
2213
                }
2204
                }
Lines 2236-2242 sub searchResults { Link Here
2236
        # XSLT processing of some stuff
2227
        # XSLT processing of some stuff
2237
        # we fetched the sysprefs already before the loop through all retrieved record!
2228
        # we fetched the sysprefs already before the loop through all retrieved record!
2238
        if (!$scan && $xslfile) {
2229
        if (!$scan && $xslfile) {
2239
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang);
2230
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, [@available_items_loop, @onloan_items_loop, @other_items_loop], 1, $sysxml, $xslfile, $lang);
2240
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2231
        # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
2241
        }
2232
        }
2242
2233
(-)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 =
279
    my $shelflocations =
278
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
280
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
Lines 285-291 sub buildKohaItemsNamespace { Link Here
285
    my $location = "";
287
    my $location = "";
286
    my $ccode = "";
288
    my $ccode = "";
287
    my $xml = '';
289
    my $xml = '';
288
    for my $item (@items) {
290
    for my $item (@$items) {
289
        my $status;
291
        my $status;
290
292
291
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
293
        my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
(-)a/catalogue/detail.pl (-15 / +15 lines)
Lines 88-108 my $fw = GetFrameworkCode($biblionumber); Link Here
88
my $showallitems = $query->param('showallitems');
88
my $showallitems = $query->param('showallitems');
89
my $marcflavour  = C4::Context->preference("marcflavour");
89
my $marcflavour  = C4::Context->preference("marcflavour");
90
90
91
# XSLT processing of some stuff
92
my $xslfile = C4::Context->preference('XSLTDetailsDisplay');
93
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
94
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
95
96
if ( $xslfile ) {
97
    $template->param(
98
        XSLTDetailsDisplay => '1',
99
        XSLTBloc => XSLTParse4Display(
100
                        $biblionumber, $record, "XSLTDetailsDisplay",
101
                        1, undef, $sysxml, $xslfile, $lang
102
                    )
103
    );
104
}
105
106
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
91
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
107
$template->param( ocoins => GetCOinSBiblio($record) );
92
$template->param( ocoins => GetCOinSBiblio($record) );
108
93
Lines 150-155 if (@hostitems){ Link Here
150
	push (@items,@hostitems);
135
	push (@items,@hostitems);
151
}
136
}
152
137
138
# XSLT processing of some stuff
139
my $xslfile = C4::Context->preference('XSLTDetailsDisplay');
140
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
141
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
142
143
if ( $xslfile ) {
144
    $template->param(
145
        XSLTDetailsDisplay => '1',
146
        XSLTBloc => XSLTParse4Display(
147
                        $biblionumber, $record, "XSLTDetailsDisplay", \@all_items,
148
                        1, $sysxml, $xslfile, $lang
149
                    )
150
    );
151
}
152
153
my $dat = &GetBiblioData($biblionumber);
153
my $dat = &GetBiblioData($biblionumber);
154
154
155
#coping with subscriptions
155
#coping with subscriptions
(-)a/opac/opac-detail.pl (-15 / +14 lines)
Lines 150-169 SetUTF8Flag($record); Link Here
150
my $marcflavour      = C4::Context->preference("marcflavour");
150
my $marcflavour      = C4::Context->preference("marcflavour");
151
my $ean = GetNormalizedEAN( $record, $marcflavour );
151
my $ean = GetNormalizedEAN( $record, $marcflavour );
152
152
153
# XSLT processing of some stuff
154
my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
155
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
156
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
157
158
if ( $xslfile ) {
159
    $template->param(
160
        XSLTBloc => XSLTParse4Display(
161
                        $biblionumber, $record, "OPACXSLTDetailsDisplay",
162
                        1, undef, $sysxml, $xslfile, $lang
163
                    )
164
    );
165
}
166
167
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
153
my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults");
168
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
154
$template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults;
169
155
Lines 498-503 if ($hideitems) { Link Here
498
    @items = @all_items;
484
    @items = @all_items;
499
}
485
}
500
486
487
# XSLT processing of some stuff
488
my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay');
489
my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
490
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
491
492
if ( $xslfile ) {
493
    $template->param(
494
        XSLTBloc => XSLTParse4Display(
495
                        $biblionumber, $record, "OPACXSLTDetailsDisplay", \@items,
496
                        1, $sysxml, $xslfile, $lang
497
                    )
498
    );
499
}
500
501
my $branch = '';
501
my $branch = '';
502
if (C4::Context->userenv){
502
if (C4::Context->userenv){
503
    $branch = C4::Context->userenv->{branch};
503
    $branch = C4::Context->userenv->{branch};
504
- 

Return to bug 11213