Bugzilla – Attachment 139926 Details for
Bug 31315
Remove GetItemsInfo from moredetail
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31315: Remove GetHostItemsInfo and GetItemsInfo from moredetail
Bug-31315-Remove-GetHostItemsInfo-and-GetItemsInfo.patch (text/plain), 13.08 KB, created by
Joonas Kylmälä
on 2022-08-28 15:30:45 UTC
(
hide
)
Description:
Bug 31315: Remove GetHostItemsInfo and GetItemsInfo from moredetail
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2022-08-28 15:30:45 UTC
Size:
13.08 KB
patch
obsolete
>From d5e307cff2d556e3157c9105e72c7c716caf9dd1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 3 Jun 2022 08:16:20 +0200 >Subject: [PATCH] Bug 31315: Remove GetHostItemsInfo and GetItemsInfo from > moredetail >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Bug 27272 is going to remove C4::Items::GetItemsInfo in favour of Koha::Items->search. > >Here we are going to deal with catalogue/moredetail > >Test plan: >List items on the modified view and confirm that all the info is >displayed correctly > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> >--- > catalogue/moredetail.pl | 118 +++++++++--------- > .../prog/en/modules/catalogue/moredetail.tt | 30 +++-- > 2 files changed, 78 insertions(+), 70 deletions(-) > >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index 834678ec3c..a4ed85e03a 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -24,7 +24,6 @@ use C4::Koha qw( GetAuthorisedValues ); > use CGI qw ( -utf8 ); > use HTML::Entities; > use C4::Biblio qw( GetBiblioData GetFrameworkCode ); >-use C4::Items qw( GetHostItemsInfo GetItemsInfo ); > use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); > use C4::Output qw( output_and_exit output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); >@@ -102,33 +101,33 @@ my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); > # $dewey=~ s/\.$//; > # $data->{'dewey'}=$dewey; > >-my $fw = GetFrameworkCode($biblionumber); >-my @all_items= GetItemsInfo($biblionumber); >-my @items; >-my $patron = Koha::Patrons->find( $loggedinuser ); >-for my $itm (@all_items) { >- push @items, $itm unless ( $itm->{itemlost} && >- $patron->category->hidelostitems && >- !$showallitems && >- ($itemnumber != $itm->{itemnumber})); >-} >- > my $biblio = Koha::Biblios->find( $biblionumber ); > my $record = $biblio ? $biblio->metadata->record : undef; > > output_and_exit( $query, $cookie, $template, 'unknown_biblio') > unless $biblio && $record; > >+my $fw = GetFrameworkCode($biblionumber); >+my $all_items = $biblio->items->search_ordered; >+ >+my @items; >+my $patron = Koha::Patrons->find( $loggedinuser ); >+while ( my $item = $all_items->next ) { >+ push @items, $item >+ unless $item->itemlost >+ && $patron->category->hidelostitems >+ && !$showallitems; >+} >+ > my $hostrecords; >-# adding items linked via host biblios >-my @hostitems = GetHostItemsInfo($record); >-if (@hostitems){ >- $hostrecords =1; >- push (@items,@hostitems); >+my $hostitems = $biblio->host_items; >+if ( $hostitems->count ) { >+ $hostrecords = 1; >+ push @items, $hostitems->as_list; > } > >-my $totalcount=@all_items; >-my $showncount=@items; >+my $totalcount = $all_items->count; >+my $showncount = scalar @items; > my $hiddencount = $totalcount - $showncount; > $data->{'count'}=$totalcount; > $data->{'showncount'}=$showncount; >@@ -147,53 +146,59 @@ foreach ( keys %{$data} ) { > $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); > } > >-($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items); >+my @item_data; > foreach my $item (@items){ >- $item->{object} = Koha::Items->find( $item->{itemnumber} ); >- $item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; >- $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} }; >- $item->{'replacementprice'} = $item->{'replacementprice'}; >- if ( defined $item->{'copynumber'} ) { >- $item->{'displaycopy'} = 1; >- if ( defined $copynumbers->{ $item->{'copynumber'} } ) { >- $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} } >+ >+ my $item_info = $item->unblessed; >+ $item_info->{object} = $item; >+ $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; >+ $item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; >+ if ( defined $item->copynumber ) { >+ $item_info->{'displaycopy'} = 1; >+ if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) { >+ $item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} } > } > else { >- $item->{'copyvol'} = $item->{'copynumber'}; >+ $item_info->{'copyvol'} = $item_info->{'copynumber'}; > } > } > > # item has a host number if its biblio number does not match the current bib >- if ($item->{biblionumber} ne $biblionumber){ >- $item->{hostbiblionumber} = $item->{biblionumber}; >- $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; >+ if ($item->biblionumber ne $biblionumber){ >+ $item_info->{hostbiblionumber} = $item->{biblionumber}; >+ $item_info->{hosttitle} = $item->biblio->title; > } > >+ # FIXME The acquisition code below could be improved using methods from Koha:: objects > my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); >- $item->{'ordernumber'} = $order->{'ordernumber'}; >- $item->{'basketno'} = $order->{'basketno'}; >- $item->{'orderdate'} = $order->{'entrydate'}; >- if ($item->{'basketno'}){ >- my $basket = GetBasket($item->{'basketno'}); >+ $item_info->{'basketno'} = $order->{'basketno'}; >+ $item_info->{'orderdate'} = $order->{'entrydate'}; >+ if ($item_info->{'basketno'}){ >+ my $basket = GetBasket($item_info->{'basketno'}); > my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); >- $item->{'vendor'} = $bookseller->name; >+ $item_info->{'vendor'} = $bookseller->name; > } >- $item->{'invoiceid'} = $order->{'invoiceid'}; >- if($item->{invoiceid}) { >- my $invoice = GetInvoice($item->{invoiceid}); >- $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice; >+ $item_info->{'invoiceid'} = $order->{'invoiceid'}; >+ if($item_info->{invoiceid}) { >+ my $invoice = GetInvoice($item_info->{invoiceid}); >+ $item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice; > } >- $item->{'datereceived'} = $order->{'datereceived'}; >+ $item_info->{'datereceived'} = $order->{'datereceived'}; > >- if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) { >- $item->{status_advisory} = 1; >+ if ( $item->notforloan >+ || $item->itemtype->notforloan >+ || $item->itemlost >+ || $item->damaged >+ || $item->withdrawn ) >+ { >+ $item_info->{status_advisory} = 1; > } > > # Add paidfor info >- if ( $item->{itemlost} ) { >+ if ( $item->itemlost ) { > my $accountlines = Koha::Account::Lines->search( > { >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > debit_type_code => 'LOST', > status => [ undef, { '<>' => 'RETURNED' } ], > amountoutstanding => 0 >@@ -217,7 +222,7 @@ foreach my $item (@items){ > if ($payment_offsets->count) { > my $patron = $accountline->patron; > my $payment_offset = $payment_offsets->next; >- $item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; >+ $item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; > } > } > } >@@ -225,20 +230,11 @@ foreach my $item (@items){ > if (C4::Context->preference("IndependentBranches")) { > #verifying rights > my $userenv = C4::Context->userenv(); >- unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) { >- $item->{'nomod'}=1; >+ unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) { >+ $item_info->{'nomod'}=1; > } > } >- if ($item->{'datedue'}) { >- $item->{'issue'}= 1; >- } else { >- $item->{'issue'}= 0; >- } >- >- if ( $item->{'borrowernumber'} ) { >- my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} ); >- $item->{patron} = $curr_borrower; >- } >+ push @item_data, $item_info; > } > > my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); >@@ -293,7 +289,7 @@ $template->param( > ); > > $template->param( >- ITEM_DATA => \@items, >+ ITEM_DATA => \@item_data, > moredetailview => 1, > loggedinuser => $loggedinuser, > biblionumber => $biblionumber, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index 3bb6dc5b51..5c8dacb0a4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -88,8 +88,13 @@ > [% END %] > > [% FOREACH ITEM_DAT IN ITEM_DATA %] >+ [% SET not_for_loan = 0 %] >+ [% IF ITEM_DAT.notforloan || ITEM_DAT.itemtype.notforloan %] >+ [% SET not_for_loan = 1 %] >+ [% SET not_for_loan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %] >+ [% END %] > <div class="listgroup"> >- <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %] [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %]</h3> >+ <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %] [% IF not_for_loan %][% not_for_loan_description | html %] [% END %]</h3> > > <h4>Item information [% UNLESS ( ITEM_DAT.nomod ) %] > [% IF ( CAN_user_editcatalogue_edit_items ) %] >@@ -102,14 +107,20 @@ > [% IF ( item_level_itypes ) %] > <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %] </li> > [% END %] >- [% IF ( ITEM_DAT.collection ) %]<li><span class="label">Collection:</span> [% ITEM_DAT.collection | html %]</li> [% END %] >+ [% IF ( ITEM_DAT.ccode) %]<li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li> [% END %] > <li><span class="label">Item callnumber:</span> [% ITEM_DAT.itemcallnumber | html %] </li> > [% IF ( ITEM_DAT.displaycopy ) %]<li><span class="label">Copy number:</span> [% ITEM_DAT.copyvol | html %] </li> [% END %] > [% IF ( ITEM_DAT.replacementprice ) %]<li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | $Price %] </li> [% END %] > [% IF ITEM_DAT.materials %]<li><span class="label">Materials specified:</span> [% ITEM_DAT.materials | html %] </li> [% END %] > </ol></div></div> > <div class="listgroup"><h4><span>Statuses</span> [% IF ( ITEM_DAT.status_advisory ) %]( >- [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %] >+ [% IF ( not_for_loan ) %] >+ [% IF not_for_loan_description %] >+ [% not_for_loan_description | html %] >+ [% ELSE %] >+ <span>Not for loan</span> >+ [% END %] >+ [% END %] > [% IF ( ITEM_DAT.itemlost ) %]<span>Lost</span>[% END %] > [% IF ( ITEM_DAT.damaged ) %]<span>Damaged</span>[% END %] > [% IF ( ITEM_DAT.withdrawn ) %]<span>Withdrawn</span>[% END %] >@@ -119,13 +130,14 @@ > <ol class="bibliodetails"> > <li><span class="label">Current library:</span> [% Branches.GetName( ITEM_DAT.holdingbranch ) | html %] </li> > <li><span class="label">Checkout status:</span> >- [% IF ( ITEM_DAT.issue ) %]<span>Checked out to >- [% INCLUDE 'patron-title.inc' patron => ITEM_DAT.patron hide_patron_infos_if_needed=1 %]</span> >- [% IF ( ITEM_DAT.lastreneweddate ) %] >- <span>Last renewed [% ITEM_DAT.lastreneweddate | $KohaDates %]</span>, >+ [% SET checkout = ITEM_DAT.object.checkout %] >+ [% IF ( checkout ) %]<span>Checked out to >+ [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]</span> >+ [% IF ( checkout.lastreneweddate ) %] >+ <span>Last renewed [% checkout.lastreneweddate | $KohaDates %]</span>, > [% END %] >- [% IF ( ITEM_DAT.datedue ) %] >- <span>Due back on [% ITEM_DAT.datedue | $KohaDates %]</span> >+ [% IF ( checkout.date_due ) %] >+ <span>Due back on [% ITEM_DAT.date_due | $KohaDates %]</span> > [% ELSE %] > <span>Not checked out</span> > [% END %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31315
:
138824
|
138897
| 139926 |
139927