3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
29 use C4::Auth qw( get_template_and_user );
30 use C4::Output qw( output_html_with_http_headers );
31 use Koha::RecordProcessor;
32 use Koha::CsvProfiles;
33 use Koha::AuthorisedValues;
39 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
41 template_name => "opac-basket.tt",
44 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
48 my $bib_list = $query->param('bib_list');
49 my $verbose = $query->param('verbose');
51 if ($verbose) { $template->param( verbose => 1 ); }
53 my @bibs = split( /\//, $bib_list );
57 my $marcflavour = C4::Context->preference('marcflavour');
58 if (C4::Context->preference('TagsEnabled')) {
59 $template->param(TagsEnabled => 1);
60 foreach (qw(TagsShowOnList TagsInputOnList)) {
61 C4::Context->preference($_) and $template->param($_ => 1);
65 my $logged_in_user = Koha::Patrons->find($borrowernumber);
67 my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
68 my $rules = C4::Context->yaml_preference('OpacHiddenItems');
70 foreach my $biblionumber ( @bibs ) {
71 $template->param( biblionumber => $biblionumber );
73 my $biblio = Koha::Biblios->find( $biblionumber ) or next;
74 my $dat = $biblio->unblessed;
76 # No filtering on the item records needed for the record itself
77 # since the only reason item information is grabbed is because of branchcodes.
78 my $record = $biblio->metadata->record;
79 my $framework = &GetFrameworkCode( $biblionumber );
80 $record_processor->options({
82 frameworkcode => $framework
84 $record_processor->process($record);
86 my $marcnotesarray = $biblio->get_marc_notes({ opac => 1 });
87 my $marcauthorsarray = $biblio->get_marc_contributors;
88 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
89 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
90 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
92 # If every item is hidden, then the biblio should be hidden too.
94 if $biblio->hidden_in_opac({ rules => $rules });
97 if($dat->{'author'} || @$marcauthorsarray) {
101 # COinS format FIXME: for books Only
102 my $fmt = substr $record->leader(), 6,2;
104 $fmts->{'am'} = 'book';
105 $dat->{ocoins_format} = $fmts->{$fmt};
107 if ( $num % 2 == 1 ) {
112 $dat->{biblionumber} = $biblionumber;
113 $dat->{ITEM_RESULTS} = $biblio->items->filter_by_visible_in_opac({ patron => $logged_in_user });
114 $dat->{MARCNOTES} = $marcnotesarray;
115 $dat->{MARCSUBJCTS} = $marcsubjctsarray;
116 $dat->{MARCAUTHORS} = $marcauthorsarray;
117 $dat->{MARCSERIES} = $marcseriesarray;
118 $dat->{MARCURLS} = $marcurlsarray;
119 $dat->{HASAUTHORS} = $hasauthors;
120 my ( $host, $relatedparts, $hostinfo ) = $biblio->get_marc_host;
121 $dat->{HOSTITEMENTRIES} = $host;
122 $dat->{RELATEDPARTS} = $relatedparts;
123 $dat->{HOSTINFO} = $hostinfo;
125 push( @results, $dat );
128 my $resultsarray = \@results;
130 # my $itemsarray=\@items;
133 csv_profiles => Koha::CsvProfiles->search(
134 { type => 'marc', used_for => 'export_records', staff_only => 0 } ),
135 bib_list => $bib_list,
136 BIBLIO_RESULTS => $resultsarray,
139 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };