Bug 15407: (follow-up) Koha::Patron::Categories - replace C4::Category->al
[koha.git] / opac / opac-basket.pl
blob29337ea43ff467cc89168e0fc2ade5eb69453063
1 #!/usr/bin/perl
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>.
18 use Modern::Perl;
20 use CGI qw ( -utf8 );
21 use C4::Koha;
22 use C4::Biblio;
23 use C4::Branch;
24 use C4::Items;
25 use C4::Circulation;
26 use C4::Auth;
27 use C4::Output;
28 use Koha::RecordProcessor;
30 my $query = new CGI;
32 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
34 template_name => "opac-basket.tt",
35 query => $query,
36 type => "opac",
37 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
41 my $bib_list = $query->param('bib_list');
42 my $print_basket = $query->param('print');
43 my $verbose = $query->param('verbose');
45 if ($verbose) { $template->param( verbose => 1 ); }
46 if ($print_basket) { $template->param( print_basket => 1 ); }
48 my @bibs = split( /\//, $bib_list );
49 my @results;
51 my $num = 1;
52 my $marcflavour = C4::Context->preference('marcflavour');
53 if (C4::Context->preference('TagsEnabled')) {
54 $template->param(TagsEnabled => 1);
55 foreach (qw(TagsShowOnList TagsInputOnList)) {
56 C4::Context->preference($_) and $template->param($_ => 1);
60 my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
61 foreach my $biblionumber ( @bibs ) {
62 $template->param( biblionumber => $biblionumber );
64 my $dat = &GetBiblioData($biblionumber);
65 next unless $dat;
67 my $record = &GetMarcBiblio( $biblionumber );
68 my $framework = &GetFrameworkCode( $biblionumber );
69 $record_processor->options({
70 interface => 'opac',
71 frameworkcode => $framework
72 });
73 $record_processor->process($record);
74 next unless $record;
75 my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
76 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
77 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
78 my $marcseriesarray = GetMarcSeries ($record,$marcflavour);
79 my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
80 my @items = &GetItemsInfo( $biblionumber );
81 my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
83 my $hasauthors = 0;
84 if($dat->{'author'} || @$marcauthorsarray) {
85 $hasauthors = 1;
87 my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
88 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
90 # COinS format FIXME: for books Only
91 my $coins_format;
92 my $fmt = substr $record->leader(), 6,2;
93 my $fmts;
94 $fmts->{'am'} = 'book';
95 $dat->{ocoins_format} = $fmts->{$fmt};
97 if ( $num % 2 == 1 ) {
98 $dat->{'even'} = 1;
101 my $branches = GetBranches();
102 for my $itm (@items) {
103 if ($itm->{'location'}){
104 $itm->{'location_opac'} = $shelflocations->{$itm->{'location'} };
106 my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
107 if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
108 $itm->{transfertwhen} = $transfertwhen;
109 $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
110 $itm->{transfertto} = $branches->{$transfertto}{branchname};
113 $num++;
114 $dat->{biblionumber} = $biblionumber;
115 $dat->{ITEM_RESULTS} = \@items;
116 $dat->{MARCNOTES} = $marcnotesarray;
117 $dat->{MARCSUBJCTS} = $marcsubjctsarray;
118 $dat->{MARCAUTHORS} = $marcauthorsarray;
119 $dat->{MARCSERIES} = $marcseriesarray;
120 $dat->{MARCURLS} = $marcurlsarray;
121 $dat->{HASAUTHORS} = $hasauthors;
122 $dat->{subtitle} = $subtitle;
124 if ( C4::Context->preference("BiblioDefaultView") eq "normal" ) {
125 $dat->{dest} = "opac-detail.pl";
127 elsif ( C4::Context->preference("BiblioDefaultView") eq "marc" ) {
128 $dat->{dest} = "opac-MARCdetail.pl";
130 else {
131 $dat->{dest} = "opac-ISBDdetail.pl";
133 push( @results, $dat );
136 my $resultsarray = \@results;
138 # my $itemsarray=\@items;
140 $template->param(
141 bib_list => $bib_list,
142 BIBLIO_RESULTS => $resultsarray,
145 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };