From a27028cd9648bee9091cf91194ce97ca3f6c4fc6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall <kyle@bywatersolutions.com> Date: Tue, 21 Apr 2015 11:02:49 -0400 Subject: [PATCH] Bug 11625 - Implement DefaultToLoggedInLibraryNoticesSlips Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> --- .../intranet-tmpl/prog/en/modules/tools/letter.tt | 2 +- tools/letter.pl | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 3106498..1c7e46f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -162,7 +162,7 @@ $(document).ready(function() { <p> Select a library : <select name="branchcode" id="branch" style="width:20em;"> - <option value="">All libraries</option> + <option value="*">All libraries</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 %] diff --git a/tools/letter.pl b/tools/letter.pl index e9f39d9..3914f5d 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -58,15 +58,7 @@ sub protected_letters { return { map { $_->[0] => 1 } @{$codes} }; } -our $input = new CGI; -my $searchfield = $input->param('searchfield'); -my $script_name = '/cgi-bin/koha/tools/letter.pl'; -our $branchcode = $input->param('branchcode'); -my $code = $input->param('code'); -my $module = $input->param('module') || ''; -my $content = $input->param('content'); -my $op = $input->param('op') || ''; -my $dbh = C4::Context->dbh; +our $input = new CGI; our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user( { @@ -79,6 +71,24 @@ our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user } ); +my $searchfield = $input->param('searchfield'); +my $script_name = '/cgi-bin/koha/tools/letter.pl'; +my $code = $input->param('code'); +my $module = $input->param('module'); +my $content = $input->param('content'); +my $op = $input->param('op') || ''; + +# Default to logged in branch for notice list only, if DefaultToLoggedInLibraryNoticesSlips is enabled +our $branchcode = + !C4::Context->preference('DefaultToLoggedInLibraryNoticesSlips') ? $input->param('branchcode') + : $input->param('branchcode') eq '*' ? undef + : $input->param('branchcode') ? $input->param('branchcode') + : $op ? $input->param('branchcode') + : GetBranchesCount() == 1 ? undef + : C4::Branch::mybranch(); + +my $dbh = C4::Context->dbh; + our $my_branch = C4::Context->preference("IndependentBranches") && !$staffflags->{'superlibrarian'} ? C4::Context->userenv()->{'branch'} : undef; -- 1.7.2.5