|
Lines 24-30
use C4::Koha qw( GetAuthorisedValues );
Link Here
|
| 24 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
| 25 |
use HTML::Entities; |
25 |
use HTML::Entities; |
| 26 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
26 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
| 27 |
use C4::Items qw( GetHostItemsInfo GetItemsInfo ); |
|
|
| 28 |
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); |
27 |
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); |
| 29 |
use C4::Output qw( output_and_exit output_html_with_http_headers ); |
28 |
use C4::Output qw( output_and_exit output_html_with_http_headers ); |
| 30 |
use C4::Auth qw( get_template_and_user ); |
29 |
use C4::Auth qw( get_template_and_user ); |
|
Lines 102-134
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
Link Here
|
| 102 |
# $dewey=~ s/\.$//; |
101 |
# $dewey=~ s/\.$//; |
| 103 |
# $data->{'dewey'}=$dewey; |
102 |
# $data->{'dewey'}=$dewey; |
| 104 |
|
103 |
|
| 105 |
my $fw = GetFrameworkCode($biblionumber); |
|
|
| 106 |
my @all_items= GetItemsInfo($biblionumber); |
| 107 |
my @items; |
| 108 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
| 109 |
for my $itm (@all_items) { |
| 110 |
push @items, $itm unless ( $itm->{itemlost} && |
| 111 |
$patron->category->hidelostitems && |
| 112 |
!$showallitems && |
| 113 |
($itemnumber != $itm->{itemnumber})); |
| 114 |
} |
| 115 |
|
| 116 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
104 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
| 117 |
my $record = $biblio ? $biblio->metadata->record : undef; |
105 |
my $record = $biblio ? $biblio->metadata->record : undef; |
| 118 |
|
106 |
|
| 119 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
107 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
| 120 |
unless $biblio && $record; |
108 |
unless $biblio && $record; |
| 121 |
|
109 |
|
|
|
110 |
my $fw = GetFrameworkCode($biblionumber); |
| 111 |
my $all_items = $biblio->items->search_ordered; |
| 112 |
|
| 113 |
my @items; |
| 114 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
| 115 |
while ( my $item = $all_items->next ) { |
| 116 |
push @items, $item |
| 117 |
unless $item->itemlost |
| 118 |
&& $patron->category->hidelostitems |
| 119 |
&& !$showallitems; |
| 120 |
} |
| 121 |
|
| 122 |
my $hostrecords; |
122 |
my $hostrecords; |
| 123 |
# adding items linked via host biblios |
123 |
my $hostitems = $biblio->host_items; |
| 124 |
my @hostitems = GetHostItemsInfo($record); |
124 |
if ( $hostitems->count ) { |
| 125 |
if (@hostitems){ |
125 |
$hostrecords = 1; |
| 126 |
$hostrecords =1; |
126 |
push @items, $hostitems->as_list; |
| 127 |
push (@items,@hostitems); |
|
|
| 128 |
} |
127 |
} |
| 129 |
|
128 |
|
| 130 |
my $totalcount=@all_items; |
129 |
my $totalcount = $all_items->count; |
| 131 |
my $showncount=@items; |
130 |
my $showncount = scalar @items; |
| 132 |
my $hiddencount = $totalcount - $showncount; |
131 |
my $hiddencount = $totalcount - $showncount; |
| 133 |
$data->{'count'}=$totalcount; |
132 |
$data->{'count'}=$totalcount; |
| 134 |
$data->{'showncount'}=$showncount; |
133 |
$data->{'showncount'}=$showncount; |
|
Lines 147-199
foreach ( keys %{$data} ) {
Link Here
|
| 147 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
146 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
| 148 |
} |
147 |
} |
| 149 |
|
148 |
|
| 150 |
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items); |
149 |
my @item_data; |
| 151 |
foreach my $item (@items){ |
150 |
foreach my $item (@items){ |
| 152 |
$item->{object} = Koha::Items->find( $item->{itemnumber} ); |
151 |
|
| 153 |
$item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; |
152 |
my $item_info = $item->unblessed; |
| 154 |
$item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} }; |
153 |
$item_info->{object} = $item; |
| 155 |
$item->{'replacementprice'} = $item->{'replacementprice'}; |
154 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
| 156 |
if ( defined $item->{'copynumber'} ) { |
155 |
$item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; |
| 157 |
$item->{'displaycopy'} = 1; |
156 |
if ( defined $item->copynumber ) { |
| 158 |
if ( defined $copynumbers->{ $item->{'copynumber'} } ) { |
157 |
$item_info->{'displaycopy'} = 1; |
| 159 |
$item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} } |
158 |
if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) { |
|
|
159 |
$item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} } |
| 160 |
} |
160 |
} |
| 161 |
else { |
161 |
else { |
| 162 |
$item->{'copyvol'} = $item->{'copynumber'}; |
162 |
$item_info->{'copyvol'} = $item_info->{'copynumber'}; |
| 163 |
} |
163 |
} |
| 164 |
} |
164 |
} |
| 165 |
|
165 |
|
| 166 |
# item has a host number if its biblio number does not match the current bib |
166 |
# item has a host number if its biblio number does not match the current bib |
| 167 |
if ($item->{biblionumber} ne $biblionumber){ |
167 |
if ($item->biblionumber ne $biblionumber){ |
| 168 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
168 |
$item_info->{hostbiblionumber} = $item->{biblionumber}; |
| 169 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
169 |
$item_info->{hosttitle} = $item->biblio->title; |
| 170 |
} |
170 |
} |
| 171 |
|
171 |
|
|
|
172 |
# FIXME The acquisition code below could be improved using methods from Koha:: objects |
| 172 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
173 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
| 173 |
$item->{'ordernumber'} = $order->{'ordernumber'}; |
174 |
$item_info->{'basketno'} = $order->{'basketno'}; |
| 174 |
$item->{'basketno'} = $order->{'basketno'}; |
175 |
$item_info->{'orderdate'} = $order->{'entrydate'}; |
| 175 |
$item->{'orderdate'} = $order->{'entrydate'}; |
176 |
if ($item_info->{'basketno'}){ |
| 176 |
if ($item->{'basketno'}){ |
177 |
my $basket = GetBasket($item_info->{'basketno'}); |
| 177 |
my $basket = GetBasket($item->{'basketno'}); |
|
|
| 178 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
178 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
| 179 |
$item->{'vendor'} = $bookseller->name; |
179 |
$item_info->{'vendor'} = $bookseller->name; |
| 180 |
} |
180 |
} |
| 181 |
$item->{'invoiceid'} = $order->{'invoiceid'}; |
181 |
$item_info->{'invoiceid'} = $order->{'invoiceid'}; |
| 182 |
if($item->{invoiceid}) { |
182 |
if($item_info->{invoiceid}) { |
| 183 |
my $invoice = GetInvoice($item->{invoiceid}); |
183 |
my $invoice = GetInvoice($item_info->{invoiceid}); |
| 184 |
$item->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
184 |
$item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
| 185 |
} |
185 |
} |
| 186 |
$item->{'datereceived'} = $order->{'datereceived'}; |
186 |
$item_info->{'datereceived'} = $order->{'datereceived'}; |
| 187 |
|
187 |
|
| 188 |
if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) { |
188 |
if ( $item->notforloan |
| 189 |
$item->{status_advisory} = 1; |
189 |
|| $item->itemtype->notforloan |
|
|
190 |
|| $item->itemlost |
| 191 |
|| $item->damaged |
| 192 |
|| $item->withdrawn ) |
| 193 |
{ |
| 194 |
$item_info->{status_advisory} = 1; |
| 190 |
} |
195 |
} |
| 191 |
|
196 |
|
| 192 |
# Add paidfor info |
197 |
# Add paidfor info |
| 193 |
if ( $item->{itemlost} ) { |
198 |
if ( $item->itemlost ) { |
| 194 |
my $accountlines = Koha::Account::Lines->search( |
199 |
my $accountlines = Koha::Account::Lines->search( |
| 195 |
{ |
200 |
{ |
| 196 |
itemnumber => $item->{itemnumber}, |
201 |
itemnumber => $item->itemnumber, |
| 197 |
debit_type_code => 'LOST', |
202 |
debit_type_code => 'LOST', |
| 198 |
status => [ undef, { '<>' => 'RETURNED' } ], |
203 |
status => [ undef, { '<>' => 'RETURNED' } ], |
| 199 |
amountoutstanding => 0 |
204 |
amountoutstanding => 0 |
|
Lines 217-223
foreach my $item (@items){
Link Here
|
| 217 |
if ($payment_offsets->count) { |
222 |
if ($payment_offsets->count) { |
| 218 |
my $patron = $accountline->patron; |
223 |
my $patron = $accountline->patron; |
| 219 |
my $payment_offset = $payment_offsets->next; |
224 |
my $payment_offset = $payment_offsets->next; |
| 220 |
$item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
225 |
$item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
| 221 |
} |
226 |
} |
| 222 |
} |
227 |
} |
| 223 |
} |
228 |
} |
|
Lines 225-244
foreach my $item (@items){
Link Here
|
| 225 |
if (C4::Context->preference("IndependentBranches")) { |
230 |
if (C4::Context->preference("IndependentBranches")) { |
| 226 |
#verifying rights |
231 |
#verifying rights |
| 227 |
my $userenv = C4::Context->userenv(); |
232 |
my $userenv = C4::Context->userenv(); |
| 228 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) { |
233 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) { |
| 229 |
$item->{'nomod'}=1; |
234 |
$item_info->{'nomod'}=1; |
| 230 |
} |
235 |
} |
| 231 |
} |
236 |
} |
| 232 |
if ($item->{'datedue'}) { |
237 |
push @item_data, $item_info; |
| 233 |
$item->{'issue'}= 1; |
|
|
| 234 |
} else { |
| 235 |
$item->{'issue'}= 0; |
| 236 |
} |
| 237 |
|
| 238 |
if ( $item->{'borrowernumber'} ) { |
| 239 |
my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} ); |
| 240 |
$item->{patron} = $curr_borrower; |
| 241 |
} |
| 242 |
} |
238 |
} |
| 243 |
|
239 |
|
| 244 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
240 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
|
Lines 293-299
$template->param(
Link Here
|
| 293 |
); |
289 |
); |
| 294 |
|
290 |
|
| 295 |
$template->param( |
291 |
$template->param( |
| 296 |
ITEM_DATA => \@items, |
292 |
ITEM_DATA => \@item_data, |
| 297 |
moredetailview => 1, |
293 |
moredetailview => 1, |
| 298 |
loggedinuser => $loggedinuser, |
294 |
loggedinuser => $loggedinuser, |
| 299 |
biblionumber => $biblionumber, |
295 |
biblionumber => $biblionumber, |