Bugzilla – Attachment 67738 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 GetItemsInCollection
Bug-18606-Get-rid-of-GetItemsInCollection.patch (text/plain), 10.67 KB, created by
Josef Moravec
on 2017-10-06 17:14:33 UTC
(
hide
)
Description:
Bug 18606: Get rid of GetItemsInCollection
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-10-06 17:14:33 UTC
Size:
10.67 KB
patch
obsolete
>From af0a0e49dbe2d127c1da3a6ceacd509e4ee90f54 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Mon, 15 May 2017 11:42:43 +0000 >Subject: [PATCH] Bug 18606: Get rid of GetItemsInCollection > >--- > C4/RotatingCollections.pm | 51 ---------------------- > Koha/RotatingCollection.pm | 19 ++++++++ > .../en/includes/rotating-collections-toolbar.inc | 8 ++-- > .../en/modules/rotating_collections/addItems.tt | 24 +++++----- > rotating_collections/addItems.pl | 10 +---- > 5 files changed, 36 insertions(+), 76 deletions(-) > >diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm >index 66a64c4..dafc1dc 100644 >--- a/C4/RotatingCollections.pm >+++ b/C4/RotatingCollections.pm >@@ -48,8 +48,6 @@ BEGIN { > require Exporter; > @ISA = qw( Exporter ); > @EXPORT = qw( >- GetItemsInCollection >- > AddItemToCollection > RemoveItemFromCollection > TransferCollection >@@ -58,55 +56,6 @@ BEGIN { > ); > } > >-=head2 GetItemsInCollection >- >- ( $results, $success, $errorcode, $errormessage ) = GetItemsInCollection( $colId ); >- >- Returns information about the items in the given collection >- >- Input: >- $colId: The id of the collection >- >- Output: >- $results: Reference to an array of associated arrays >- $success: 1 if all database operations were successful, 0 otherwise >- $errorCode: Code for reason of failure, good for translating errors in templates >- $errorMessage: English description of error >- >-=cut >- >-sub GetItemsInCollection { >- my ($colId) = @_; >- >- ## Parameter check >- if ( !$colId ) { >- return ( 0, 0, 1, "NO_ID" ); >- } >- >- my $dbh = C4::Context->dbh; >- >- my $sth = $dbh->prepare( >- "SELECT >- biblio.title, >- biblio.biblionumber, >- items.itemcallnumber, >- items.barcode >- FROM collections, collections_tracking, items, biblio >- WHERE collections.colId = collections_tracking.colId >- AND collections_tracking.itemnumber = items.itemnumber >- AND items.biblionumber = biblio.biblionumber >- AND collections.colId = ? ORDER BY biblio.title" >- ); >- $sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() ); >- >- my @results; >- while ( my $row = $sth->fetchrow_hashref ) { >- push( @results, $row ); >- } >- >- return \@results; >-} >- > =head2 AddItemToCollection > > ( $success, $errorcode, $errormessage ) = AddItemToCollection( $colId, $itemnumber ); >diff --git a/Koha/RotatingCollection.pm b/Koha/RotatingCollection.pm >index c8857b2..ba90192 100644 >--- a/Koha/RotatingCollection.pm >+++ b/Koha/RotatingCollection.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use Carp; > > use Koha::Database; >+use Koha::Items; > > use base qw(Koha::Object); > >@@ -35,6 +36,24 @@ Koha::RotatingCollection - Koha Rotating collection Object class > > =cut > >+=head3 items >+ >+=cut >+ >+sub items { >+ my ( $self ) = @_; >+ my $items = Koha::Items->search( >+ { >+ 'collections_trackings.colId' => $self->colId >+ }, >+ { >+ join => [ 'collections_trackings' ] >+ } >+ ); >+ >+ return $items; >+} >+ > =head3 type > > =cut >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc >index 9dd3e7a..938ec9b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc >@@ -17,15 +17,15 @@ > <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=new"><i class="fa fa-plus"></i> New collection</a> > </div> > >- [% IF ( colId ) %] >+ [% IF ( collection.colId ) %] > <div class="btn-group"> >- <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% colId %]"><i class="fa fa-exchange"></i> Transfer</a> >+ <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% collection.colId %]"><i class="fa fa-exchange"></i> Transfer</a> > </div> > <div class="btn-group"> >- <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&colId=[% colId %]"><i class="fa fa-pencil"></i> Edit</a> >+ <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&colId=[% collection.colId %]"><i class="fa fa-pencil"></i> Edit</a> > </div> > <div class="btn-group"> >- <a class="btn btn-default btn-sm confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&colId=[% colId %]"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-sm confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&colId=[% collection.colId %]"><i class="fa fa-trash"></i> Delete</a> > </div> > [% END %] > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt >index 43d4a8b..1cfc944 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt >@@ -1,5 +1,5 @@ > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Tools › Rotating collections › Collection [% colTitle %] ’ Add or remove items</title> >+<title>Koha › Tools › Rotating collections › Collection [% collection.colTitle %] ’ Add or remove items</title> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript"> > //<![CDATA[ >@@ -13,21 +13,21 @@ > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] > >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a> › <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId %]">Collection <i>[% colTitle %]</i></a> › Add or remove items</div> >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a> › <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId %]">Collection <i>[% collection.colTitle %]</i></a> › Add or remove items</div> > > <div id="doc3" class="yui-t2"> > <div id="bd"> > <div id="yui-main"> > <div class="yui-b"> > >- [% IF ( ! colId ) %] >+ [% IF ( ! collection ) %] > <div class="dialog message"> > <p>Invalid collection id</p> > <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p> > </div> > [% ELSE %] > [% INCLUDE 'rotating-collections-toolbar.inc' %] >- <h1>Collection <i>[% colTitle %]</i></h1> >+ <h1>Collection <i>[% collection.colTitle %]</i></h1> > > [% IF ( previousActionAdd ) %] > [% IF ( addSuccess ) %] >@@ -85,7 +85,7 @@ > </li> > </ol> > <p> >- <input type="hidden" id="colId" name="colId" value="[% colId %]" /> >+ <input type="hidden" id="colId" name="colId" value="[% collection.colId %]" /> > <input type="hidden" name="action" value="addItem" /> > <input type="submit" value="Submit" /> > </p> >@@ -95,8 +95,8 @@ > </div> > > <div> >- <h2>Items in <i>[% colTitle %]</i></h2> >- [% IF ( collectionItemsLoop ) %] >+ <h2>Items in <i>[% collection.colTitle %]</i></h2> >+ [% IF ( collection.items ) %] > <table> > <tr> > <th>Title</th> >@@ -104,12 +104,12 @@ > <th>Barcode</th> > <th> </th> > </tr> >- [% FOREACH collectionItemsLoo IN collectionItemsLoop %] >+ [% FOREACH item IN collection.items %] > <tr> >- <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = collectionItemsLoo.biblionumber %][% collectionItemsLoo.title |html %]</a></td> >- <td>[% collectionItemsLoo.itemcallnumber %]</td> >- <td>[% collectionItemsLoo.barcode %]</td> >- <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId %]&barcode=[% collectionItemsLoo.barcode %]&removeItem=1&action=addItem">Remove</a></td> >+ <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = item.biblionumber %][% item.biblio.title |html %]</a></td> >+ <td>[% item.itemcallnumber %]</td> >+ <td>[% item.barcode %]</td> >+ <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId %]&barcode=[% item.barcode %]&removeItem=1&action=addItem">Remove</a></td> > </tr> > [% END %] > </table> >diff --git a/rotating_collections/addItems.pl b/rotating_collections/addItems.pl >index 1a3f358..8ef4645 100755 >--- a/rotating_collections/addItems.pl >+++ b/rotating_collections/addItems.pl >@@ -92,16 +92,8 @@ if ( $query->param('action') eq 'addItem' ) { > my $colId = $query->param('colId'); > my $collection = Koha::RotatingCollections->find($colId); > >-my $collectionItems = GetItemsInCollection($colId); >-if ($collectionItems) { >- $template->param( collectionItemsLoop => $collectionItems ); >-} >- > $template->param( >- colId => $collection->colId, >- colTitle => $collection->colTitle, >- colDescription => $collection->colDesc, >- colBranchcode => $collection->colBranchcode, >+ collection => $collection, > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >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