Bugzilla – Attachment 34924 Details for
Bug 13040
Improve exporter to allow multiple branch selections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13040 - multiple branch selections in exporter
Bug-13040---multiple-branch-selections-in-exporter.patch (text/plain), 9.62 KB, created by
Robin Sheat
on 2015-01-05 04:25:43 UTC
(
hide
)
Description:
Bug 13040 - multiple branch selections in exporter
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2015-01-05 04:25:43 UTC
Size:
9.62 KB
patch
obsolete
>From 97e96e1011e509b0811da40ac720df9ea8069a83 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Wed, 8 Oct 2014 19:12:13 +1300 >Subject: [PATCH] Bug 13040 - multiple branch selections in exporter > >This allows the exporter (Tools -> Export) to have any combination of >branches selected, rather than it being all or only one. > >Test Plan: >* Apply the patch >* Go to the exporter, see that instead of a dropdown you now have an > elegently laid out grid of branches you can select from >* Select some branches, run the export >* Note that only records with items in the selected branches are > returned. >* Repeat this with the item related options (as that code was refactored > slightly) and make sure everything is sane. > >Sponsored-By: South Taranaki District Libraries >--- > .../intranet-tmpl/prog/en/css/staff-global.css | 11 ++++++++ > .../prog/en/includes/branch-selector.inc | 21 +++++++++++++++ > .../prog/en/modules/help/tools/export.tt | 6 ++--- > .../intranet-tmpl/prog/en/modules/tools/export.tt | 13 +++------ > tools/export.pl | 31 +++++++++++----------- > 5 files changed, 53 insertions(+), 29 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 9d5b7ea..237fe6c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2758,3 +2758,14 @@ span.onsite_checkout { > border-radius: 4px; > border : 1px solid #FFF2CE; > } >+ >+.branchgriditem { >+ display: table-cell; >+ float: left; >+} >+.branchgridrow { >+ display: table-row; >+} >+.branchselector { >+ display: table; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc >new file mode 100644 >index 0000000..a5ce611 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc >@@ -0,0 +1,21 @@ >+[%# First check to see if we have anything selected, otherwise we select all %] >+[% selectall = 1 %] >+[% FOREACH branch IN branches; >+ IF branch.selected; >+ selectall = 0; >+ END; >+END %] >+<div class="branchselector"> >+ <div class="branchgridrow"> >+ [% FOREACH branch IN branches %] >+ <div class="branchgriditem"> >+ <input id="branch_[% branch.value %]" type="checkbox" name="branch" value="[% branch.value %]"[% IF branch.selected || (selectall == 1) %] checked="checked" [% END %]/> >+ <label for="branch_[% branch.value %]">[% branch.branchname %]</label> >+ </div> >+ [% IF loop.count() % 4 == 0 && !loop.last() %] >+ </div> >+ <div class="branchgridrow"> >+ [% END %] >+ [% END %] >+ </div> >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/export.tt >index 0584a3d..31a64c2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/export.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/export.tt >@@ -15,7 +15,7 @@ > <ul> > <li>Limit to a bib number range</li> > <li>Limit to a specific item type</li> >- <li>Limit to a specific library</li> >+ <li>Limit to a specific set of libraries</li> > <li>Limit to a call number range</li> > <li>Limit to an acquisition date range</li> > </ul> >@@ -23,7 +23,7 @@ > <li>Next choose what to skip when exporting > <ul> > <li>By default items will be exported, if you would like to only export bibliographic data, check the 'Don't export items' box</li> >- <li>To limit your export only to items from the library you're logged in as (if you leave the 'Library' field set to 'All') or to the library you selected above check the 'Remove non-local items' box</li> >+ <li>To limit your export only to items from the library you're logged in as, check the 'Remove non-local items' box</li> > <li>You can also choose what fields you don't want to export. This can be handy if you're sharing your data, you can remove all local fields before sending your data to another library</li> > </ul> > </li> >@@ -61,4 +61,4 @@ > > <p><strong>See the full documentation for Exporting MARC Records in the <a href="http://manual.koha-community.org/[% helpVersion %]/en/exportbibs.html">manual</a> (online).</strong></p> > >-[% INCLUDE 'help-bottom.inc' %] >\ No newline at end of file >+[% INCLUDE 'help-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >index 2e85732..36a25be 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >@@ -65,16 +65,9 @@ $(document).ready(function() { > </li> > > <li> >- <label for="branch">Library: </label> >- <select id="branch" name="branch"> >- <option value="">-- All --</option> >- [% FOREACH branchloo IN branchloop %] >- [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option> >- [% ELSE %] >- <option value="[% branchloo.value %]">[% branchloo.branchname %]</option> >- [% END %] >- [% END %] >- </select> >+ <label>Library: </label> >+ [% INCLUDE 'branch-selector.inc' >+ branches = branchloop %] > </li> > <li> > <label for="startcn">From item call number: </label> >diff --git a/tools/export.pl b/tools/export.pl >index bae6941..5cfe5db 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -134,13 +134,17 @@ my $limit_ind_branch = > && !C4::Context->IsSuperLibrarian() > && C4::Context->userenv->{branch} ) ? 1 : 0; > >-my $branch = $query->param("branch") || ''; >+my @branch = $query->param("branch"); > if ( C4::Context->preference("IndependentBranches") > && C4::Context->userenv > && !C4::Context->IsSuperLibrarian() ) > { >- $branch = C4::Context->userenv->{'branch'}; >+ @branch = ( C4::Context->userenv->{'branch'} ); > } >+# if stripping nonlocal items, use loggedinuser's branch >+my $localbranch = C4::Context->userenv->{'branch'}; >+ >+my %branchmap = map { $_ => 1 } @branch; # for quick lookups > > my $backupdir = C4::Context->config('backupdir'); > >@@ -246,7 +250,7 @@ if ( $op eq "export" ) { > itemstable => $itemstable, > StartingBiblionumber => $StartingBiblionumber, > EndingBiblionumber => $EndingBiblionumber, >- branch => $branch, >+ branch => \@branch, > start_callnumber => $start_callnumber, > end_callnumber => $end_callnumber, > start_accession => $start_accession, >@@ -323,7 +327,6 @@ if ( $op eq "export" ) { > # Someone is trying to mess us up > exit; > } >- > unless (@biblionumbers) { > my $sth = $dbh->prepare($sql_query); > $sth->execute(@sql_params); >@@ -364,14 +367,10 @@ if ( $op eq "export" ) { > my ( $homebranchfield, $homebranchsubfield ) = > GetMarcFromKohaField( 'items.homebranch', '' ); > for my $itemfield ( $record->field($homebranchfield) ) { >- >-# if stripping nonlocal items, use loggedinuser's branch if they didn't select one >- $branch = C4::Context->userenv->{'branch'} >- unless $branch; > $record->delete_field($itemfield) > if ( $dont_export_items >- || $itemfield->subfield($homebranchsubfield) ne >- $branch ); >+ || $localbranch ne $itemfield->subfield( >+ $homebranchsubfield) ); > } > } > } >@@ -472,7 +471,7 @@ else { > push @branchloop, > { > value => $thisbranch, >- selected => $thisbranch eq $branch, >+ selected => %branchmap ? $branchmap{$thisbranch} : 1, > branchname => $branches->{$thisbranch}->{'branchname'}, > }; > } >@@ -547,14 +546,14 @@ sub construct_query { > my $itemstable = $params->{itemstable}; > my $StartingBiblionumber = $params->{StartingBiblionumber}; > my $EndingBiblionumber = $params->{EndingBiblionumber}; >- my $branch = $params->{branch}; >+ my @branch = @{ $params->{branch} }; > my $start_callnumber = $params->{start_callnumber}; > my $end_callnumber = $params->{end_callnumber}; > my $start_accession = $params->{start_accession}; > my $end_accession = $params->{end_accession}; > my $itemtype = $params->{itemtype}; > my $items_filter = >- $branch >+ @branch > || $start_callnumber > || $end_callnumber > || $start_accession >@@ -576,9 +575,9 @@ sub construct_query { > push @sql_params, $EndingBiblionumber; > } > >- if ($branch) { >- $sql_query .= " AND homebranch = ? "; >- push @sql_params, $branch; >+ if (@branch) { >+ $sql_query .= " AND homebranch IN (".join(',',map({'?'} @branch)).")"; >+ push @sql_params, @branch; > } > > if ($start_callnumber) { >-- >2.1.0
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 13040
:
32052
|
34923
|
34924
|
35278
|
35505
|
35506
|
35508
|
35510