From 3dda0fa639acd4ea30e0523c68bd2703941b317f Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 22 Jan 2008 15:47:18 -0600 Subject: [PATCH] Fix for bug 1784, Signed-off-by: Joshua Ferraro --- tools/holidays.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/holidays.pl b/tools/holidays.pl index cf42716067..7c79cf9fbe 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -26,8 +26,11 @@ use C4::Output; use C4::Calendar; my $input = new CGI; -#my $branch = $input->param('branch'); + my $branch=C4::Context->preference('defaultbranch') || $input->param('branch'); + + + my $dbh = C4::Context->dbh(); # Get the template to use my ($template, $loggedinuser, $cookie) @@ -62,8 +65,12 @@ my $branchesList = CGI::scrolling_list(-name => 'branch', $branches->finish; +if ( C4::Context->preference("IndependantBranches") ) { + $branch = C4::Context->userenv->{'branch'}; +} # Get all the holidays -# warn "BRANCH : $branch"; + warn "BRANCH : $branch"; + my $calendar = C4::Calendar->new(branchcode => $branch); my $week_days_holidays = $calendar->get_week_days_holidays(); my @week_days; @@ -107,7 +114,13 @@ foreach my $yearMonthDay (keys %$single_holidays) { } # Replace the template values with the real ones -$template->param(BRANCHES => $branchesList); +# If we have independent branches on we need to only let the user set holidays for their branch +if ( C4::Context->preference("IndependantBranches") ) { + $template->param(BRANCHES => C4::Context->userenv->{'branchname'}); +} +else { + $template->param(BRANCHES => $branchesList); +} $template->param(WEEK_DAYS_LOOP => \@week_days); $template->param(HOLIDAYS_LOOP => \@holidays); $template->param(EXCEPTION_HOLIDAYS_LOOP => \@exception_holidays); -- 2.39.5