From 410f4796c41df8710f174f54e3416c12fb12d208 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 9a1a942..a88f957 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,3 +1,4 @@ +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections › [%- IF ( action == "new" ) %] @@ -92,6 +93,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 70b99df..f48bc62 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 @@ -46,7 +46,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 4552721..d6012ee 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 @@ -38,7 +38,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