Bugzilla – Attachment 67739 Details for
Bug 18606
Move rotating collections code to Koha::Object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18606: Get rid of GetCollectionItemBranches
Bug-18606-Get-rid-of-GetCollectionItemBranches.patch (text/plain), 4.30 KB, created by
Josef Moravec
on 2017-10-06 17:14:37 UTC
(
hide
)
Description:
Bug 18606: Get rid of GetCollectionItemBranches
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-10-06 17:14:37 UTC
Size:
4.30 KB
patch
obsolete
>From 98f64d8500609d0790233e73ddc55318944db2fd Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Wed, 17 May 2017 10:36:05 +0000 >Subject: [PATCH] Bug 18606: Get rid of GetCollectionItemBranches > >--- > C4/Circulation.pm | 2 +- > C4/RotatingCollections.pm | 31 ------------------------------- > Koha/Item.pm | 19 +++++++++++++++++++ > circ/returns.pl | 23 +++++++++++------------ > 4 files changed, 31 insertions(+), 44 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b915b34..6a1b67b 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -35,7 +35,7 @@ use C4::Message; > use C4::Debug; > use C4::Log; # logaction > use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units); >-use C4::RotatingCollections qw(GetCollectionItemBranches); >+use C4::RotatingCollections; > use Algorithm::CheckDigits; > > use Data::Dumper; >diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm >index dafc1dc..521a4e9 100644 >--- a/C4/RotatingCollections.pm >+++ b/C4/RotatingCollections.pm >@@ -51,8 +51,6 @@ BEGIN { > AddItemToCollection > RemoveItemFromCollection > TransferCollection >- >- GetCollectionItemBranches > ); > } > >@@ -204,35 +202,6 @@ sub TransferCollection { > > } > >-=head2 GetCollectionItemBranches >- >- my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); >- >-=cut >- >-sub GetCollectionItemBranches { >- my ($itemnumber) = @_; >- >- if ( !$itemnumber ) { >- return; >- } >- >- my $dbh = C4::Context->dbh; >- >- my ( $sth, @results ); >- $sth = $dbh->prepare( >-"SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking >- WHERE items.itemnumber = collections_tracking.itemnumber >- AND collections.colId = collections_tracking.colId >- AND items.itemnumber = ?" >- ); >- $sth->execute($itemnumber); >- >- my $row = $sth->fetchrow_hashref; >- >- return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); >-} >- > =head2 isItemInThisCollection > > $inCollection = isItemInThisCollection( $itemnumber, $colId ); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index bea05f8..3a15571 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -30,6 +30,7 @@ use Koha::IssuingRules; > use Koha::Item::Transfer; > use Koha::Patrons; > use Koha::Libraries; >+use Koha::RotatingCollections; > > use base qw(Koha::Object); > >@@ -235,6 +236,24 @@ sub current_holds { > return Koha::Holds->_new_from_dbic($hold_rs); > } > >+=head3 rotating_collection >+ >+=cut >+ >+sub rotating_collection { >+ my ( $self ) = @_; >+ my $collection = Koha::RotatingCollections->search( >+ { >+ 'collections_trackings.itemnumber' => $self->itemnumber >+ }, >+ { >+ join => [ 'collections_trackings' ] >+ } >+ ); >+ >+ return $collection->single; >+} >+ > =head3 type > > =cut >diff --git a/circ/returns.pl b/circ/returns.pl >index c42e750..e02bd64 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -48,7 +48,6 @@ use C4::Items; > use C4::Members; > use C4::Members::Messaging; > use C4::Koha; # FIXME : is it still useful ? >-use C4::RotatingCollections; > use Koha::AuthorisedValues; > use Koha::DateUtils; > use Koha::Calendar; >@@ -648,17 +647,17 @@ $template->param( > > $itemnumber = GetItemnumberFromBarcode( $barcode ); > if ( $itemnumber ) { >- my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); >- if ( $holdingBranch and $collectionBranch ) { >- $holdingBranch //= ''; >- $collectionBranch //= $returnbranch; >- if ( ! ( $holdingBranch eq $collectionBranch ) ) { >- $template->param( >- collectionItemNeedsTransferred => 1, >- collectionBranch => $collectionBranch, >- itemnumber => $itemnumber, >- ); >- } >+ my $item = Koha::Items->find( $itemnumber ); >+ my $holdingBranch = $item->holdingbranch; >+ my $collection = $item->rotating_collection; >+ my $collectionBranch; >+ $collectionBranch = $collection->colBranchcode if $collection; >+ if ( $holdingBranch and $collectionBranch and ( $holdingBranch ne $collectionBranch ) ) { >+ $template->param( >+ collectionItemNeedsTransferred => 1, >+ collectionBranch => $collectionBranch, >+ itemnumber => $itemnumber, >+ ); > } > } > >-- >2.1.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 18606
:
63508
|
63509
|
63510
|
63511
|
63512
|
63513
|
63514
|
63515
|
63516
|
63517
|
63518
|
63519
|
63520
|
63521
|
63522
|
63523
|
63524
|
63525
|
63526
|
63527
|
63528
|
66227
|
66228
|
66229
|
66230
|
66231
|
66232
|
66233
|
66234
|
66235
|
66236
|
66237
|
66238
|
66239
|
66240
|
66241
|
66286
|
66287
|
66288
|
66289
|
66290
|
66291
|
66292
|
66293
|
66294
|
66295
|
66296
|
66297
|
66298
|
66299
|
66300
|
67734
|
67735
|
67736
|
67737
|
67738
|
67739
|
67740
|
67741
|
67742
|
67743
|
67744
|
67745
|
67746
|
67747
|
67748
|
67749
|
68428
|
68429
|
68430
|
68431
|
68432
|
68433
|
68434
|
68435
|
68436
|
68437
|
68438
|
68439
|
68440
|
68441
|
68442
|
68443
|
69709
|
69710
|
69711
|
69712
|
69713
|
69714
|
69715
|
69716
|
69717
|
69718
|
69719
|
69720
|
69721
|
69722
|
69723
|
69759
|
72416
|
72417
|
72418
|
72419
|
72420
|
72421
|
72422
|
72423
|
72424
|
72425
|
72426
|
72427
|
72428
|
72429
|
72430
|
72431
|
72572
|
72573
|
72574
|
72575
|
72576
|
72577
|
72578
|
72579
|
72580
|
72581
|
72582
|
72583
|
72584
|
72585
|
72586
|
72587
|
72816
|
79141
|
79142
|
79143
|
79144
|
79145
|
79146
|
79147
|
79148
|
79149
|
79150
|
79151
|
79152
|
79153
|
79154
|
79155
|
79156
|
79157
|
79158
|
79161