Lines 61-110
use Koha::Biblios;
Link Here
|
61 |
use Koha::Patrons; |
61 |
use Koha::Patrons; |
62 |
use Koha::RecordProcessor; |
62 |
use Koha::RecordProcessor; |
63 |
|
63 |
|
64 |
my $query = new CGI; |
64 |
my $query = CGI->new(); |
65 |
|
|
|
66 |
my $dbh = C4::Context->dbh; |
67 |
|
65 |
|
68 |
my $biblionumber = $query->param('biblionumber'); |
66 |
my $biblionumber = $query->param('biblionumber'); |
69 |
if ( ! $biblionumber ) { |
67 |
if ( ! $biblionumber ) { |
70 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
68 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
71 |
exit; |
69 |
exit; |
72 |
} |
70 |
} |
|
|
71 |
$biblionumber = int($biblionumber); |
72 |
|
73 |
# open template |
74 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
75 |
{ |
76 |
template_name => "opac-MARCdetail.tt", |
77 |
query => $query, |
78 |
type => "opac", |
79 |
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), |
80 |
debug => 1, |
81 |
} |
82 |
); |
83 |
|
84 |
my $borcat = q{}; |
85 |
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { |
86 |
# we need to fetch the borrower info here, so we can pass the category |
87 |
my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); |
88 |
$borcat = $borrower ? $borrower->categorycode : $borcat; |
89 |
} |
73 |
|
90 |
|
74 |
my $record = GetMarcBiblio({ |
91 |
my $record = GetMarcBiblio({ |
75 |
biblionumber => $biblionumber, |
92 |
biblionumber => $biblionumber, |
76 |
embed_items => 1 }); |
93 |
embed_items => 1, |
|
|
94 |
opac => 1, |
95 |
borcat => $borcat }); |
77 |
if ( ! $record ) { |
96 |
if ( ! $record ) { |
78 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
97 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
79 |
exit; |
98 |
exit; |
80 |
} |
99 |
} |
81 |
|
100 |
|
82 |
my @all_items = GetItemsInfo($biblionumber); |
101 |
my @all_items = GetItemsInfo($biblionumber); |
83 |
my @items2hide; |
|
|
84 |
if (scalar @all_items >= 1) { |
85 |
my $borrowernumber; |
86 |
my $borcat; |
87 |
if (C4::Context->userenv) { |
88 |
$borrowernumber = C4::Context->userenv->{'number'}; |
89 |
} |
90 |
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { |
91 |
|
92 |
# we need to fetch the borrower info here, so we can pass the category |
93 |
my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } ); |
94 |
$borcat = $borrower ? $borrower->categorycode : q{}; |
95 |
} |
96 |
push @items2hide, GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat }); |
97 |
|
98 |
if (scalar @items2hide == scalar @all_items ) { |
99 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
100 |
exit; |
101 |
} |
102 |
} |
103 |
|
104 |
my $framework = &GetFrameworkCode( $biblionumber ); |
102 |
my $framework = &GetFrameworkCode( $biblionumber ); |
105 |
my $tagslib = &GetMarcStructure( 0, $framework ); |
|
|
106 |
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); |
103 |
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); |
107 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
104 |
my @nonhiddenitems = $record->field($tag_itemnumber); |
|
|
105 |
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) { |
106 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
107 |
exit; |
108 |
} |
108 |
|
109 |
|
109 |
my $record_processor = Koha::RecordProcessor->new({ |
110 |
my $record_processor = Koha::RecordProcessor->new({ |
110 |
filters => 'ViewPolicy', |
111 |
filters => 'ViewPolicy', |
Lines 115-137
my $record_processor = Koha::RecordProcessor->new({
Link Here
|
115 |
}); |
116 |
}); |
116 |
$record_processor->process($record); |
117 |
$record_processor->process($record); |
117 |
|
118 |
|
118 |
# open template |
|
|
119 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
120 |
{ |
121 |
template_name => "opac-MARCdetail.tt", |
122 |
query => $query, |
123 |
type => "opac", |
124 |
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), |
125 |
debug => 1, |
126 |
} |
127 |
); |
128 |
|
129 |
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); |
130 |
$template->param( |
131 |
bibliotitle => $biblio->title, |
132 |
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. |
133 |
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; |
134 |
|
135 |
# get biblionumbers stored in the cart |
119 |
# get biblionumbers stored in the cart |
136 |
if(my $cart_list = $query->cookie("bib_list")){ |
120 |
if(my $cart_list = $query->cookie("bib_list")){ |
137 |
my @cart_list = split(/\//, $cart_list); |
121 |
my @cart_list = split(/\//, $cart_list); |
Lines 140-145
if(my $cart_list = $query->cookie("bib_list")){
Link Here
|
140 |
} |
124 |
} |
141 |
} |
125 |
} |
142 |
|
126 |
|
|
|
127 |
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); |
128 |
|
129 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
130 |
my $tagslib = &GetMarcStructure( 0, $framework ); |
131 |
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); |
132 |
$template->param( |
133 |
bibliotitle => $biblio->title, |
134 |
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. |
135 |
$tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; |
136 |
|
143 |
my $allow_onshelf_holds; |
137 |
my $allow_onshelf_holds; |
144 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
138 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
145 |
for my $itm (@all_items) { |
139 |
for my $itm (@all_items) { |
Lines 148-154
for my $itm (@all_items) {
Link Here
|
148 |
} |
142 |
} |
149 |
|
143 |
|
150 |
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds ); |
144 |
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds ); |
151 |
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); |
|
|
152 |
|
145 |
|
153 |
# adding the $RequestOnOpac param |
146 |
# adding the $RequestOnOpac param |
154 |
my $RequestOnOpac; |
147 |
my $RequestOnOpac; |
Lines 278-283
for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) {
Link Here
|
278 |
# loop through each tag |
271 |
# loop through each tag |
279 |
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary |
272 |
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary |
280 |
# then construct template. |
273 |
# then construct template. |
|
|
274 |
# $record has already had all the item fields filtered above. |
281 |
my @fields = $record->fields(); |
275 |
my @fields = $record->fields(); |
282 |
my %witness |
276 |
my %witness |
283 |
; #---- stores the list of subfields used at least once, with the "meaning" of the code |
277 |
; #---- stores the list of subfields used at least once, with the "meaning" of the code |
Lines 285-293
my @item_subfield_codes;
Link Here
|
285 |
my @item_loop; |
279 |
my @item_loop; |
286 |
foreach my $field (@fields) { |
280 |
foreach my $field (@fields) { |
287 |
next if ( $field->tag() < 10 ); |
281 |
next if ( $field->tag() < 10 ); |
288 |
next if ( ( $field->tag() eq $tag_itemnumber ) && |
|
|
289 |
( any { $field->subfield($subtag_itemnumber) eq $_ } |
290 |
@items2hide) ); |
291 |
my @subf = $field->subfields; |
282 |
my @subf = $field->subfields; |
292 |
my $item; |
283 |
my $item; |
293 |
|
284 |
|
294 |
- |
|
|