Browse Source

Bug 6663: Features for holidays.pl with datepicker

Allow to select a range between 2 dates and in one "submit" creates holidays only on these days.
I have added also Holidays repeated yearly on a range.
On suggestions I have added a datepicker for "To Date".

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
3.8.x
Christophe Croullebois 13 years ago
committed by Paul Poulain
parent
commit
806fac60f4
  1. 2
      koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
  2. 27
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt
  3. 1
      tools/holidays.pl
  4. 98
      tools/newHolidays.pl

2
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css

@ -554,6 +554,8 @@ div.yui-b fieldset.brief li.radio {
padding : .7em 0;
}
div.yui-b fieldset.brief li.radio label,
div.yui-b fieldset.brief li.dateinsert label,
div.yui-b fieldset.brief li.dateinsert span.label,
div.yui-b fieldset.brief li.radio span.label {
display : inline;
}

27
koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt

@ -103,6 +103,7 @@
$("a.helptext").click(function(){
$(this).parent().find(".hint").toggle(); return false;
});
$("#dateofrange").each(function () { this.value = "" });
});
//]]>
</script>
@ -209,7 +210,7 @@
<input type="hidden" id="newBranchName" name="newBranchName" />
</li>
<li>
<strong>Date:</strong>
<strong>From Date:</strong>
<span id="newDaynameOutput"></span>,
[% IF ( dateformat_us ) %]<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>[% ELSIF ( dateformat_metric ) %]<span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>[% ELSE %]<span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>[% END %]
@ -220,6 +221,20 @@
<input type="hidden" id="newMonth" name="newMonth" />
<input type="hidden" id="newYear" name="newYear" />
</li>
<li class="dateinsert">
<b>To Date : </b>
<input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange %]" />
<img src="[% themelang %]/lib/calendar/cal.gif" id="dateofrange_button" alt="Show Calendar" />
<script language="JavaScript" type="text/javascript">
Calendar.setup(
{
inputField : "dateofrange",
ifFormat : "[% DHTMLcalendar_dateformat %]",
button : "dateofrange_button"
}
);
</script>
</li>
<li><label for="title">Title: </label><input type="text" name="newTitle" id="title" size="35" /></li>
<li><label for="newDescription">Description:</label>
<textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
@ -239,6 +254,16 @@
<a href="#" class="helptext">[?]</a>
<div class="hint">This will take this day and month as a reference to make it a holiday. Through this option, you can repeat this rule for every year. For example, selecting August 1st will make August 1st a holiday every year.</div>
</li>
<li class="radio"><input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
<label for="newOperationField">Holidays on a range</label>.
<a href="#" class="helptext">[?]</a>
<div class="hint">Make a single holiday on a range. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st holiday, but will not affect August 1st-10st in other years.</div>
</li>
<li class="radio"><input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
<label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
<a href="#" class="helptext">[?]</a>
<div class="hint">Make a single holiday on a range repeated yearly. For example, selecting August 1st, 2012 and August 10st, 2012 will make all days between 1st and 10st holiday, and will affect August 1st-10st in other years.</div>
</li>
<li class="radio">
<input type="checkbox" name="allBranches" id="allBranches" />
<label for="allBranches">Copy to all libraries</label>.

1
tools/holidays.pl

@ -147,6 +147,7 @@ $template->param(WEEK_DAYS_LOOP => \@week_days,
keydate => $keydate,
branchcodes => $branchcodes,
branch => $branch,
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
branchname => $branchname
);

98
tools/newHolidays.pl

@ -10,25 +10,44 @@ use C4::Output;
use C4::Calendar;
use DateTime;
my $input = new CGI;
my $dbh = C4::Context->dbh();
my $input = new CGI;
my $dbh = C4::Context->dbh();
my $branchcode = $input->param('newBranchName');
my $originalbranchcode = $branchcode;
my $weekday = $input->param('newWeekday');
my $day = $input->param('newDay');
my $month = $input->param('newMonth');
my $year = $input->param('newYear');
my $title = $input->param('newTitle');
my $description = $input->param('newDescription');
my $newoperation = $input->param('newOperation');
my $allbranches = $input->param('allBranches');
my $branchcode = $input->param('newBranchName');
my $originalbranchcode = $branchcode;
my $weekday = $input->param('newWeekday');
my $day = $input->param('newDay');
my $month = $input->param('newMonth');
my $year = $input->param('newYear');
my $day1;
my $month1;
my $year1;
my $dateofrange = $input->param('dateofrange');
my $title = $input->param('newTitle');
my $description = $input->param('newDescription');
my $newoperation = $input->param('newOperation');
my $allbranches = $input->param('allBranches');
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
my $isodate = C4::Dates->new($calendardate, 'iso');
$calendardate = $isodate->output('syspref');
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
my $isodate = C4::Dates->new($calendardate, 'iso');
$calendardate = $isodate->output('syspref');
my @dateend = split(/[\/-]/, $dateofrange);
if (C4::Context->preference("dateformat") eq "metric") {
$day1 = $dateend[0];
$month1 = $dateend[1];
$year1 = $dateend[2];
}elsif (C4::Context->preference("dateformat") eq "us") {
$month1 = $dateend[0];
$day1 = $dateend[1];
$year1 = $dateend[2];
} else {
$year1 = $dateend[0];
$month1 = $dateend[1];
$day1 = $dateend[2];
}
$title || ($title = '');
if ($description) {
$description =~ s/\r/\\r/g;
@ -80,5 +99,52 @@ sub add_holiday {
description => $description);
}
}
} elsif ( $newoperation eq 'holidayrange' ) {
#Make an array with holiday's days
my $first_dt = DateTime->new(year => $year, month => $month, day => $day);
my $end_dt = DateTime->new(year => $year1, month => $month1, day => $day1);
my @holiday_list = ();
for (my $dt = $first_dt->clone();
$dt <= $end_dt;
$dt->add(days => 1) )
{
push @holiday_list, $dt->clone();
}
foreach my $date (@holiday_list){
unless ( $calendar->isHoliday( $date->{local_c}->{day}, $date->{local_c}->{month}, $date->{local_c}->{year} ) ) {
$calendar->insert_single_holiday(
day => $date->{local_c}->{day},
month => $date->{local_c}->{month},
year => $date->{local_c}->{year},
title => $title,
description => $description
);
}
}
} elsif ( $newoperation eq 'holidayrangerepeat' ) {
#Make an array with holiday's days
my $first_dt = DateTime->new(year => $year, month => $month, day => $day);
my $end_dt = DateTime->new(year => $year1, month => $month1, day => $day1);
my @holiday_list = ();
for (my $dt = $first_dt->clone();
$dt <= $end_dt;
$dt->add(days => 1) )
{
push @holiday_list, $dt->clone();
}
foreach my $date (@holiday_list){
unless ( $calendar->isHoliday( $date->{local_c}->{day}, $date->{local_c}->{month}, $date->{local_c}->{year} ) ) {
$calendar->insert_day_month_holiday(
day => $date->{local_c}->{day},
month => $date->{local_c}->{month},
title => $title,
description => $description
);
}
}
}
}

Loading…
Cancel
Save