Bugzilla – Attachment 26082 Details for
Bug 11169
OPAC: Display acquisition details
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11169: Display acquition details at the OPAC
Bug-11169-Display-acquition-details-at-the-OPAC.patch (text/plain), 16.18 KB, created by
Jonathan Druart
on 2014-03-11 11:17:41 UTC
(
hide
)
Description:
Bug 11169: Display acquition details at the OPAC
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-03-11 11:17:41 UTC
Size:
16.18 KB
patch
obsolete
>From bfc1ffb2136d9ae68f5a0c39627efeabf7a19c2c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 17 Sep 2013 15:33:35 +0200 >Subject: [PATCH] Bug 11169: Display acquition details at the OPAC > >This patch adds a new tab 'Acquisition detail' on the OPAC detail page. >A syspref (OPACAcquisitionDetails) permits to turn on this feature. > >Test plan: >- switch on the OPACAcquisitionDetails pref. >- set the AcqCreateItems pref to 'receiving'. >- create some orders on 1 or more items. >- go to the opac detail page and verify the "acquitision details" tab > contains the right number of items which is in order. >- receive the items. >- verify the number of items has decreased. >- set the AcqCreateItems pref to 'ordering'. >- create some orders on 1 or more items. >- go to the opac detail page and verify the "acquitision details" tab > contains the list of items which is in order. >- receive the items. >- verify the received items don't appear anymore in the table. >--- > C4/Acquisition.pm | 5 + > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 14 +++ > .../prog/en/modules/admin/preferences/opac.pref | 8 +- > .../opac-tmpl/prog/en/includes/item-status.inc | 2 + > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 21 +++- > opac/opac-detail.pl | 129 ++++++++++++-------- > 7 files changed, 130 insertions(+), 50 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 8c4bfdc..3fb20f3 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1654,6 +1654,7 @@ sub SearchOrders { > my $basketgroupname = $params->{basketgroupname}; > my $owner = $params->{owner}; > my $pending = $params->{pending}; >+ my $biblionumber = $params->{biblionumber}; > > my $dbh = C4::Context->dbh; > my @args = (); >@@ -1701,6 +1702,10 @@ sub SearchOrders { > $query .= ' AND (aqorders.ordernumber=?)'; > push @args, $ordernumber; > } >+ if ( $biblionumber ) { >+ $query .= 'AND aqorders.biblionumber = ?'; >+ push @args, $biblionumber; >+ } > if( $search ) { > $query .= ' AND (biblio.title LIKE ? OR biblio.author LIKE ? OR biblioitems.isbn LIKE ?)'; > push @args, ("%$search%","%$search%","%$search%"); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 66c2017..fce22d0 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -203,6 +203,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OAI-PMH:ConfFile','',NULL,'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','File'), > ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), > ('OCLCAffiliateID','','','Use with FRBRizeEditions and XISBN. You can sign up for an AffiliateID here: http://www.worldcat.org/wcpa/do/AffiliateUserServices?method=initSelfRegister','free'), >+('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'), > ('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'), > ('OPACAllowHoldDateInFuture','0','','If set, along with the AllowHoldDateInFuture system preference, OPAC users can set the date of a hold to be in the future.','YesNo'), > ('OpacAllowPublicListCreation','1',NULL,'If set, allows opac users to create public lists','YesNo'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 0768a88..319f525 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8037,6 +8037,20 @@ if(CheckVersion($DBversion)) { > SetVersion($DBversion); > } > >+ >+ >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q| >+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACAcquisitionDetails','0', '','Show the acquisition details at the OPAC','YesNo') >+ |); >+ print "Upgrade to $DBversion done (MT12445 - Add OPACAcquisitionDetails syspref)\n"; >+ SetVersion($DBversion); >+} >+ >+ >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index d541440..166a2b8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -436,7 +436,13 @@ OPAC: > yes: Allow > no: Do not allow > - users to add a note when placing a hold. >- >+ - >+ - pref: OPACAcquisitionDetails >+ default: 0 >+ choices: >+ yes: Display >+ no: Don't display >+ - the acquisition details on OPAC detail pages. > Policy: > - > - pref: singleBranchMode >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc >index 21bde2c..b014caa 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc >@@ -46,6 +46,8 @@ not use an API to fetch items that populates item.datedue. > [% ELSE %] > Item damaged > [% END %] >+[% ELSIF item.on_order %] >+ On order > [% ELSE %] > Available [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index fce873c..8b6441f 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -985,6 +985,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <a href="#subscriptions">Subscriptions</a> > </li> > [% END %] >+[% IF Koha.Preference('OPACAcquisitionDetails') and acquisition_details.orders.size > 0 %] >+ <li id="tab_acquisitions"><a href="#acquisition_details">Acquisition details</a></li> >+[% END %] > [% IF ( Koha.Preference( 'reviewson' ) == 1 ) %] > <li id="tab_comments"><a href="#comments">Comments ( [% reviews.size || 0 %] )</a></li> > [% END %] >@@ -1238,6 +1241,22 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > </div> > [% END %] > >+ >+[% IF Koha.Preference('OPACAcquisitionDetails') and acquisition_details.orders.size > 0 %] >+ <div id="acquisition_details"> >+ <h2>Acquisition details</h2> >+ [% IF Koha.Preference('AcqCreateItem') == 'ordering' %] >+ The following items are on order. >+ [% INCLUDE items_table items=acquisition_details.items tab="acquisition_details" noshelfbrowser=1 %] >+ [% ELSE %] >+ [% acquisition_details.total_quantity %] items are on order. >+ [% END %] >+ </div> >+[% END %] >+ >+ >+ >+ > [% IF ( LibraryThingForLibrariesID ) %] > [% IF ( LibraryThingForLibrariesTabbedView ) %] > <!-- Library Thing for Libraries Content --> >@@ -1558,7 +1577,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <td class="call_no" property="sku"> > [% IF ( ITEM_RESULT.itemcallnumber ) %] > [% ITEM_RESULT.itemcallnumber %] >- [% IF ( OPACShelfBrowser ) %] >+ [% IF ( OPACShelfBrowser and not noshelfbrowser ) %] > [% IF ( ITEM_RESULT.itemnumber == starting_itemnumber ) %] > (<a class="close_shelf" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ITEM_RESULT.biblionumber %]&shelfbrowse_itemnumber=[% ITEM_RESULT.itemnumber %]#[% tab %]">Browse shelf</a>) > [% ELSE %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 46f76fb..17e6ce3 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -25,6 +25,7 @@ use warnings; > > use CGI; > use C4::Auth qw(:DEFAULT get_session); >+use C4::Acquisition qw( SearchOrders ); > use C4::Branch; > use C4::Koha; > use C4::Serials; #uses getsubscriptionfrom biblionumber >@@ -487,16 +488,16 @@ if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { > > my $dat = &GetBiblioData($biblionumber); > >-my $itemtypes = GetItemTypes(); >+our $itemtypes = GetItemTypes(); > # imageurl: > my $itemtype = $dat->{'itemtype'}; > if ( $itemtype ) { > $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); > $dat->{'description'} = $itemtypes->{$itemtype}->{'description'}; > } >-my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac'); >-my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac'); >-my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac'); >+our $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac'); >+our $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac'); >+our $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac'); > > #coping with subscriptions > my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); >@@ -532,7 +533,7 @@ $dat->{'count'} = scalar(@items); > > my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) ); > >-my (%item_reserves, %priority); >+our (%item_reserves, %priority); > my ($show_holds_count, $show_priority); > for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { > m/holds/o and $show_holds_count = 1; >@@ -562,6 +563,7 @@ if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) { > $template->param(SeparateHoldings => 1); > } > my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch'); >+ > my $viewallitems = $query->param('viewallitems'); > my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50; > if ( not $viewallitems and @items > $max_items_to_display ) { >@@ -571,50 +573,8 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > ); > } else { > for my $itm (@items) { >- $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; >- $itm->{priority} = $priority{ $itm->{itemnumber} }; >- $norequests = 0 >- if ( (not $itm->{'withdrawn'} ) >- && (not $itm->{'itemlost'} ) >- && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} ) >- && (not $itemtypes->{$itm->{'itype'}}->{notforloan} ) >- && ($itm->{'itemnumber'} ) ); >+ $itm = _get_items_infos( $itm ); > >- # get collection code description, too >- my $ccode = $itm->{'ccode'}; >- $itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} ); >- my $copynumber = $itm->{'copynumber'}; >- $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) ); >- if ( defined $itm->{'location'} ) { >- $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} }; >- } >- if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { >- $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); >- $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'}; >- } >- foreach (qw(ccode enumchron copynumber itemnotes uri)) { >- $itemfields{$_} = 1 if ($itm->{$_}); >- } >- >- # walk through the item-level authorised values and populate some images >- my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) ); >- # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) ); >- >- if ( $itm->{'itemlost'} ) { >- my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images; >- $itm->{'lostimageurl'} = $lostimageinfo->{ 'imageurl' }; >- $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' }; >- } >- my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber}); >- if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; } >- if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; } >- >- my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); >- if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { >- $itm->{transfertwhen} = $transfertwhen; >- $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname}; >- $itm->{transfertto} = $branches->{$transfertto}{branchname}; >- } > my $itembranch = $itm->{$separatebranch}; > if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) { > if ($itembranch and $itembranch eq $currentbranch) { >@@ -1068,4 +1028,77 @@ if ( C4::Context->preference('UseCourseReserves') ) { > } > } > >+if ( C4::Context->preference('OPACAcquisitionDetails') ) { >+ my $orders = C4::Acquisition::SearchOrders({ >+ biblionumber => $biblionumber, >+ pending => 1, >+ }); >+ >+ my @items; >+ my $total_quantity; >+ for my $order ( @$orders ) { >+ if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) { >+ for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) { >+ my $item = C4::Items::GetItem( $itemnumber ); >+ $item->{on_order} = 1; >+ push @items, _get_items_infos( $item ); >+ } >+ } >+ $total_quantity += $order->{quantity}; >+ } >+ $template->{VARS}->{acquisition_details} = { >+ orders => $orders, >+ items => \@items, >+ total_quantity => $total_quantity, >+ }; >+} >+ > output_html_with_http_headers $query, $cookie, $template->output; >+ >+sub _get_items_infos { >+ my ( $itm ) = @_; >+ $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; >+ $itm->{priority} = $priority{ $itm->{itemnumber} }; >+ $norequests = 0 >+ if ( (not $itm->{'withdrawn'} ) >+ && (not $itm->{'itemlost'} ) >+ && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} ) >+ && (not $itemtypes->{$itm->{'itype'}}->{notforloan} ) >+ && ($itm->{'itemnumber'} ) ); >+ >+ # get collection code description, too >+ my $ccode = $itm->{'ccode'}; >+ $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) ); >+ my $copynumber = $itm->{'copynumber'}; >+ $itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) ); >+ if ( defined $itm->{'location'} ) { >+ $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} }; >+ } >+ if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { >+ $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); >+ $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'}; >+ } >+ foreach (qw(ccode enumchron copynumber itemnotes uri)) { >+ $itemfields{$_} = 1 if ($itm->{$_}); >+ } >+ >+ # walk through the item-level authorised values and populate some images >+ my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) ); >+ >+ if ( $itm->{'itemlost'} ) { >+ my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images; >+ $itm->{'lostimageurl'} = $lostimageinfo->{ 'imageurl' }; >+ $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' }; >+ } >+ my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber}); >+ if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; } >+ if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; } >+ >+ my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); >+ if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { >+ $itm->{transfertwhen} = $transfertwhen; >+ $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname}; >+ $itm->{transfertto} = $branches->{$transfertto}{branchname}; >+ } >+ return $itm; >+} >-- >1.7.10.4
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 11169
:
22594
|
22595
|
25654
|
25657
|
26082
|
26083
|
26084
|
26330
|
26331
|
26332
|
26343
|
26344
|
26345
|
27018
|
27019
|
27020
|
28045
|
28419
|
28483
|
28511
|
28512
|
28522
|
28523
|
28524
|
33522