Bugzilla – Attachment 135651 Details for
Bug 27272
Move C4::Items::GetItemsInfo to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27272: moredetail
Bug-27272-moredetail.patch (text/plain), 12.77 KB, created by
Jonathan Druart
on 2022-06-03 06:49:57 UTC
(
hide
)
Description:
Bug 27272: moredetail
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-06-03 06:49:57 UTC
Size:
12.77 KB
patch
obsolete
>From c4f18217a3d43fb8bd821f84656dd2530c3f4748 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 27272: moredetail > >--- > catalogue/moredetail.pl | 129 +++++++++--------- > .../prog/en/modules/catalogue/moredetail.tt | 30 ++-- > 2 files changed, 89 insertions(+), 70 deletions(-) > >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index e05eef8fcda..ed45a4a7cb8 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 ); >@@ -104,33 +103,44 @@ 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( >+ {}, >+ { >+ # FIXME A different order is expected if at least one items.serial is true >+ order_by => [ >+ 'homebranch.branchname', >+ 'me.enumchron', >+ \"LDAP( me.copynumber, 8, '0' )", >+ -asc => 'me.dateacessioned' >+ ], >+ join => ['homebranch'] >+ } >+); >+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; >@@ -149,53 +159,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 >@@ -219,7 +235,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 }; > } > } > } >@@ -227,20 +243,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 }, {'!=' => ''}] }); >@@ -295,7 +302,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 6db25bb690d..59c02ae07af 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>Statuses [% 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 %] >+ [% ELSE %] >+ <span>Not for loan</span> >+ [% END %] >+ [% END %] > [% IF ( ITEM_DAT.itemlost ) %]Lost[% END %] > [% IF ( ITEM_DAT.damaged ) %]Damaged[% END %] > [% IF ( ITEM_DAT.withdrawn ) %]Withdrawn[% 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 ) %]Checked out to >- [% INCLUDE 'patron-title.inc' patron => ITEM_DAT.patron hide_patron_infos_if_needed=1 %] >- [% IF ( ITEM_DAT.lastreneweddate ) %] >- Last renewed [% ITEM_DAT.lastreneweddate | $KohaDates %], >+ [% SET checkout = ITEM_DAT.object.checkout %] >+ [% IF ( checkout ) %]Checked out to >+ [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %] >+ [% IF ( checkout.lastreneweddate ) %] >+ Last renewed [% checkout.lastreneweddate | $KohaDates %], > [% END %] >- [% IF ( ITEM_DAT.datedue ) %] >- Due back on [% ITEM_DAT.datedue | $KohaDates %] >+ [% IF ( checkout.date_due ) %] >+ Due back on [% ITEM_DAT.date_due | $KohaDates %] > [% ELSE %] > Not checked out > [% END %] >-- >2.25.1
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 27272
:
128230
|
128231
|
135640
|
135641
|
135642
|
135643
|
135644
|
135645
|
135646
|
135647
|
135648
|
135649
|
135650
|
135651
|
135652
|
135653
|
135654
|
135655
|
135656
|
135657
|
135658
|
135659
|
137966
|
137967
|
137968
|
137969
|
137970
|
137971
|
137972
|
137973
|
137974
|
137975
|
137976
|
137977
|
137978
|
137979
|
137980
|
137981
|
137982
|
138109
|
138296
|
138297
|
138298
|
138303
|
138304
|
138305
|
138306
|
138307
|
138308
|
138437
|
138438
|
138439
|
138440
|
138441
|
138442
|
138553
|
138554
|
138555
|
138556
|
138557
|
138558
|
138559
|
138560
|
138561
|
138562
|
138563
|
138564
|
138565
|
138566
|
138567
|
138568
|
138569
|
138570
|
138571
|
138572
|
138573
|
138574
|
138575
|
138614
|
138615
|
138616
|
138617
|
138618
|
138619
|
138620
|
138621
|
138622
|
138623
|
138624
|
138625
|
138626
|
138627
|
138628
|
138629
|
138630
|
138631
|
138632
|
138633
|
138634
|
138635
|
138636
|
138714
|
138715
|
138716
|
138717
|
138718
|
138719
|
138720
|
138721
|
138722
|
138723
|
138724
|
138725
|
138726
|
138727
|
138728
|
138729
|
138730
|
138731
|
138732
|
138733
|
138734
|
138735
|
138736
|
138773
|
138774
|
138775
|
138776
|
138777
|
138778
|
138779
|
138780
|
138781
|
138782
|
138783
|
138784
|
138785
|
138786
|
138787
|
138788
|
138789
|
138790
|
138791
|
138792
|
138793
|
138794
|
138832
|
139928