|
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 104-136
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
Link Here
|
| 104 |
# $dewey=~ s/\.$//; |
103 |
# $dewey=~ s/\.$//; |
| 105 |
# $data->{'dewey'}=$dewey; |
104 |
# $data->{'dewey'}=$dewey; |
| 106 |
|
105 |
|
| 107 |
my $fw = GetFrameworkCode($biblionumber); |
|
|
| 108 |
my @all_items= GetItemsInfo($biblionumber); |
| 109 |
my @items; |
| 110 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
| 111 |
for my $itm (@all_items) { |
| 112 |
push @items, $itm unless ( $itm->{itemlost} && |
| 113 |
$patron->category->hidelostitems && |
| 114 |
!$showallitems && |
| 115 |
($itemnumber != $itm->{itemnumber})); |
| 116 |
} |
| 117 |
|
| 118 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
106 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
| 119 |
my $record = $biblio ? $biblio->metadata->record : undef; |
107 |
my $record = $biblio ? $biblio->metadata->record : undef; |
| 120 |
|
108 |
|
| 121 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
109 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
| 122 |
unless $biblio && $record; |
110 |
unless $biblio && $record; |
| 123 |
|
111 |
|
|
|
112 |
my $fw = GetFrameworkCode($biblionumber); |
| 113 |
my $all_items = $biblio->items( |
| 114 |
{}, |
| 115 |
{ |
| 116 |
# FIXME A different order is expected if at least one items.serial is true |
| 117 |
order_by => [ |
| 118 |
'homebranch.branchname', |
| 119 |
'me.enumchron', |
| 120 |
\"LDAP( me.copynumber, 8, '0' )", |
| 121 |
-asc => 'me.dateacessioned' |
| 122 |
], |
| 123 |
join => ['homebranch'] |
| 124 |
} |
| 125 |
); |
| 126 |
my @items; |
| 127 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
| 128 |
while ( my $item = $all_items->next ) { |
| 129 |
push @items, $item |
| 130 |
unless $item->itemlost |
| 131 |
&& $patron->category->hidelostitems |
| 132 |
&& !$showallitems; |
| 133 |
} |
| 134 |
|
| 124 |
my $hostrecords; |
135 |
my $hostrecords; |
| 125 |
# adding items linked via host biblios |
136 |
my $hostitems = $biblio->host_items; |
| 126 |
my @hostitems = GetHostItemsInfo($record); |
137 |
if ( $hostitems->count ) { |
| 127 |
if (@hostitems){ |
138 |
$hostrecords = 1; |
| 128 |
$hostrecords =1; |
139 |
push @items, $hostitems->as_list; |
| 129 |
push (@items,@hostitems); |
|
|
| 130 |
} |
140 |
} |
| 131 |
|
141 |
|
| 132 |
my $totalcount=@all_items; |
142 |
my $totalcount = $all_items->count; |
| 133 |
my $showncount=@items; |
143 |
my $showncount = scalar @items; |
| 134 |
my $hiddencount = $totalcount - $showncount; |
144 |
my $hiddencount = $totalcount - $showncount; |
| 135 |
$data->{'count'}=$totalcount; |
145 |
$data->{'count'}=$totalcount; |
| 136 |
$data->{'showncount'}=$showncount; |
146 |
$data->{'showncount'}=$showncount; |
|
Lines 149-201
foreach ( keys %{$data} ) {
Link Here
|
| 149 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
159 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
| 150 |
} |
160 |
} |
| 151 |
|
161 |
|
| 152 |
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items); |
162 |
my @item_data; |
| 153 |
foreach my $item (@items){ |
163 |
foreach my $item (@items){ |
| 154 |
$item->{object} = Koha::Items->find( $item->{itemnumber} ); |
164 |
|
| 155 |
$item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; |
165 |
my $item_info = $item->unblessed; |
| 156 |
$item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} }; |
166 |
$item_info->{object} = $item; |
| 157 |
$item->{'replacementprice'} = $item->{'replacementprice'}; |
167 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
| 158 |
if ( defined $item->{'copynumber'} ) { |
168 |
$item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; |
| 159 |
$item->{'displaycopy'} = 1; |
169 |
if ( defined $item->copynumber ) { |
| 160 |
if ( defined $copynumbers->{ $item->{'copynumber'} } ) { |
170 |
$item_info->{'displaycopy'} = 1; |
| 161 |
$item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} } |
171 |
if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) { |
|
|
172 |
$item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} } |
| 162 |
} |
173 |
} |
| 163 |
else { |
174 |
else { |
| 164 |
$item->{'copyvol'} = $item->{'copynumber'}; |
175 |
$item_info->{'copyvol'} = $item_info->{'copynumber'}; |
| 165 |
} |
176 |
} |
| 166 |
} |
177 |
} |
| 167 |
|
178 |
|
| 168 |
# item has a host number if its biblio number does not match the current bib |
179 |
# item has a host number if its biblio number does not match the current bib |
| 169 |
if ($item->{biblionumber} ne $biblionumber){ |
180 |
if ($item->biblionumber ne $biblionumber){ |
| 170 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
181 |
$item_info->{hostbiblionumber} = $item->{biblionumber}; |
| 171 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
182 |
$item_info->{hosttitle} = $item->biblio->title; |
| 172 |
} |
183 |
} |
| 173 |
|
184 |
|
|
|
185 |
# FIXME The acquisition code below could be improved using methods from Koha:: objects |
| 174 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
186 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
| 175 |
$item->{'ordernumber'} = $order->{'ordernumber'}; |
187 |
$item_info->{'basketno'} = $order->{'basketno'}; |
| 176 |
$item->{'basketno'} = $order->{'basketno'}; |
188 |
$item_info->{'orderdate'} = $order->{'entrydate'}; |
| 177 |
$item->{'orderdate'} = $order->{'entrydate'}; |
189 |
if ($item_info->{'basketno'}){ |
| 178 |
if ($item->{'basketno'}){ |
190 |
my $basket = GetBasket($item_info->{'basketno'}); |
| 179 |
my $basket = GetBasket($item->{'basketno'}); |
|
|
| 180 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
191 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
| 181 |
$item->{'vendor'} = $bookseller->name; |
192 |
$item_info->{'vendor'} = $bookseller->name; |
| 182 |
} |
193 |
} |
| 183 |
$item->{'invoiceid'} = $order->{'invoiceid'}; |
194 |
$item_info->{'invoiceid'} = $order->{'invoiceid'}; |
| 184 |
if($item->{invoiceid}) { |
195 |
if($item_info->{invoiceid}) { |
| 185 |
my $invoice = GetInvoice($item->{invoiceid}); |
196 |
my $invoice = GetInvoice($item_info->{invoiceid}); |
| 186 |
$item->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
197 |
$item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
| 187 |
} |
198 |
} |
| 188 |
$item->{'datereceived'} = $order->{'datereceived'}; |
199 |
$item_info->{'datereceived'} = $order->{'datereceived'}; |
| 189 |
|
200 |
|
| 190 |
if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) { |
201 |
if ( $item->notforloan |
| 191 |
$item->{status_advisory} = 1; |
202 |
|| $item->itemtype->notforloan |
|
|
203 |
|| $item->itemlost |
| 204 |
|| $item->damaged |
| 205 |
|| $item->withdrawn ) |
| 206 |
{ |
| 207 |
$item_info->{status_advisory} = 1; |
| 192 |
} |
208 |
} |
| 193 |
|
209 |
|
| 194 |
# Add paidfor info |
210 |
# Add paidfor info |
| 195 |
if ( $item->{itemlost} ) { |
211 |
if ( $item->itemlost ) { |
| 196 |
my $accountlines = Koha::Account::Lines->search( |
212 |
my $accountlines = Koha::Account::Lines->search( |
| 197 |
{ |
213 |
{ |
| 198 |
itemnumber => $item->{itemnumber}, |
214 |
itemnumber => $item->itemnumber, |
| 199 |
debit_type_code => 'LOST', |
215 |
debit_type_code => 'LOST', |
| 200 |
status => [ undef, { '<>' => 'RETURNED' } ], |
216 |
status => [ undef, { '<>' => 'RETURNED' } ], |
| 201 |
amountoutstanding => 0 |
217 |
amountoutstanding => 0 |
|
Lines 219-225
foreach my $item (@items){
Link Here
|
| 219 |
if ($payment_offsets->count) { |
235 |
if ($payment_offsets->count) { |
| 220 |
my $patron = $accountline->patron; |
236 |
my $patron = $accountline->patron; |
| 221 |
my $payment_offset = $payment_offsets->next; |
237 |
my $payment_offset = $payment_offsets->next; |
| 222 |
$item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
238 |
$item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
| 223 |
} |
239 |
} |
| 224 |
} |
240 |
} |
| 225 |
} |
241 |
} |
|
Lines 227-246
foreach my $item (@items){
Link Here
|
| 227 |
if (C4::Context->preference("IndependentBranches")) { |
243 |
if (C4::Context->preference("IndependentBranches")) { |
| 228 |
#verifying rights |
244 |
#verifying rights |
| 229 |
my $userenv = C4::Context->userenv(); |
245 |
my $userenv = C4::Context->userenv(); |
| 230 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) { |
246 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) { |
| 231 |
$item->{'nomod'}=1; |
247 |
$item_info->{'nomod'}=1; |
| 232 |
} |
248 |
} |
| 233 |
} |
249 |
} |
| 234 |
if ($item->{'datedue'}) { |
250 |
push @item_data, $item_info; |
| 235 |
$item->{'issue'}= 1; |
|
|
| 236 |
} else { |
| 237 |
$item->{'issue'}= 0; |
| 238 |
} |
| 239 |
|
| 240 |
if ( $item->{'borrowernumber'} ) { |
| 241 |
my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} ); |
| 242 |
$item->{patron} = $curr_borrower; |
| 243 |
} |
| 244 |
} |
251 |
} |
| 245 |
|
252 |
|
| 246 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
253 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
|
Lines 295-301
$template->param(
Link Here
|
| 295 |
); |
302 |
); |
| 296 |
|
303 |
|
| 297 |
$template->param( |
304 |
$template->param( |
| 298 |
ITEM_DATA => \@items, |
305 |
ITEM_DATA => \@item_data, |
| 299 |
moredetailview => 1, |
306 |
moredetailview => 1, |
| 300 |
loggedinuser => $loggedinuser, |
307 |
loggedinuser => $loggedinuser, |
| 301 |
biblionumber => $biblionumber, |
308 |
biblionumber => $biblionumber, |