From 82d205c711df0f83a049b2e9b9c9f4050d10324d Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 23 Oct 2017 20:47:37 +0200 Subject: [PATCH] Bug 19519: Add ability to bind rotating collectino with library during creation Test plan: 0) Apply the patch 1) Go to rotating collections tool 2) Try to create and edit collections, note there is new field "library", try to set and unset it 3) try to transfer a collection, the library saved by creating/editing collection should be preselected --- .../prog/en/modules/rotating_collections/editCollections.tt | 10 ++++++++++ .../en/modules/rotating_collections/rotatingCollections.tt | 2 +- .../prog/en/modules/rotating_collections/transferCollection.tt | 6 +++++- rotating_collections/editCollections.pl | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt index 7ce9ed1..08575b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt @@ -1,4 +1,5 @@ [% SET footerjs = 1 %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections › [%- IF ( action == "new" ) %] @@ -93,6 +94,15 @@ <input type="text" size="50" name="description" /> [% END %] </li> + <li> + <label for="branchcode">Library: </label> + <select id="branchocode" name="branchcode"> + <option value="">No library, will select during transfer</option> + [% IF ( collection.colBranchcode ) %] + [% PROCESS options_for_libraries libraries => Branches.all( selected => collection.colBranchcode, unfiltered => 1, ) %] + [% ELSE %] + [% PROCESS options_for_libraries libraries => Branches.all( selected => collection.colBranchcode, unfiltered => 1, ) %] + [% END %] </ol> </fieldset> <fieldset class="action"> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt index 111e92d..585f820 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt @@ -27,7 +27,7 @@ <tr> <th>Title</th> <th>Description</th> - <th>Current location</th> + <th>Library</th> <th> </th> </tr> </thead> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt index e235ea7..065a2df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt @@ -39,7 +39,11 @@ <li> <label for="toBranch">Choose your library:</label> <select id="toBranch" name="toBranch"> - [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %] + [% IF ( collection.colBranchcode ) %] + [% PROCESS options_for_libraries libraries => Branches.all( selected => collection.colBranchcode, unfiltered => 1 ) %] + [% ELSE %] + [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %] + [% END %] </select> </li> </ol> diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl index 1427a57..a56c7de 100755 --- a/rotating_collections/editCollections.pl +++ b/rotating_collections/editCollections.pl @@ -46,11 +46,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( if ( $action eq 'create' ) { my $title = $query->param('title'); my $description = $query->param('description'); + my $branchcode = $query->param('branchcode') || undef; $template->param( createdTitle => $title ); my $collection = Koha::RotatingCollection->new( { colTitle => $title, colDesc => $description, + colBranchcode => $branchcode, } ); @@ -85,6 +87,7 @@ if ( $action eq 'create' ) { my $colId = $query->param('colId'); my $title = $query->param('title'); my $description = $query->param('description'); + my $branchcode = $query->param('branchcode') || undef; $template->param( updatedTitle => $title ); @@ -92,6 +95,7 @@ if ( $action eq 'create' ) { my $collection = Koha::RotatingCollections->find($colId); $collection->colTitle($title); $collection->colDesc($description); + $collection->colBranchcode($branchcode); eval { $collection->store; }; -- 2.1.4