@@ -, +, @@ --- .../intranet-tmpl/prog/en/css/staff-global.css | 2 + .../prog/en/modules/tools/holidays.tt | 28 +++++++- tools/newHolidays.pl | 83 ++++++++++++++++---- 3 files changed, 96 insertions(+), 17 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ a/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; } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt @@ -209,7 +209,7 @@
  • - Date: + From Date: , [% IF ( dateformat_us ) %]//[% ELSIF ( dateformat_metric ) %]//[% ELSE %]//[% END %] @@ -220,6 +220,22 @@
  • +
  • + To Date : + [% IF ( dateformat_us ) %] + + + + [% ELSIF ( dateformat_metric ) %] + + + + [% ELSE %] + + + + [% END %] +
  • @@ -239,6 +255,16 @@ [?]
    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.
  • +
  • + . + [?] +
    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.
    +
  • +
  • + . + [?] +
    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.
    +
  • . --- a/tools/newHolidays.pl +++ a/tools/newHolidays.pl @@ -10,24 +10,28 @@ 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 = $input->param('newDay1'); +my $month1 = $input->param('newMonth1'); +my $year1 = $input->param('newYear1'); +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'); $title || ($title = ''); if ($description) { @@ -80,5 +84,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 + ); + } + } + } } --