Bugzilla – Attachment 6537 Details for
Bug 6663
would be nice to put ranges of dates in the calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Allow to select a range between 2 dates for holiday
0001-Bug-6663-Features-for-holidays.pl.patch (text/plain), 8.97 KB, created by
Christophe Croullebois
on 2011-12-02 15:29:59 UTC
(
hide
)
Description:
Allow to select a range between 2 dates for holiday
Filename:
MIME Type:
Creator:
Christophe Croullebois
Created:
2011-12-02 15:29:59 UTC
Size:
8.97 KB
patch
obsolete
>From fc877b7c5581c27208a4c6bb217f6a1257b0a18f Mon Sep 17 00:00:00 2001 >From: Christophe Croullebois <christophe.croullebois@biblibre.com> >Date: Fri, 2 Dec 2011 16:03:19 +0100 >Subject: [PATCH 1/1] Bug 6663: Features for holidays.pl > >Allow to select a range between 2 dates and in one "submit" creates holidays only on these days. >I add also Holidays repeated yearly on a range. >--- > .../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(-) > >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 7b38062..493a757 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/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; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >index ac867fe..a958788 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >@@ -209,7 +209,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 +220,22 @@ > <input type="hidden" id="newMonth" name="newMonth" /> > <input type="hidden" id="newYear" name="newYear" /> > </li> >+ <li class="dateinsert"> >+ <b>To Date : </b> >+ [% IF ( dateformat_us ) %] >+ <label for="newMonth1">Month </label> <input type="text" size="2" id="newMonth1" name="newMonth1"/> >+ <label for="newDay1">Day </label> <input type="text" size="2" id="newDay1" name="newDay1" /> >+ <label for="newYear1">Year </label> <input type="text" size="4" id="newYear1" name="newYear1"/> >+ [% ELSIF ( dateformat_metric ) %] >+ <label for="newDay1">Day </label> <input type="text" size="2" id="newDay1" name="newDay1" /> >+ <label for="newMonth1">Month </label> <input type="text" size="2" id="newMonth1" name="newMonth1"/> >+ <label for="newYear1">Year </label> <input type="text" size="4" id="newYear1" name="newYear1"/> >+ [% ELSE %] >+ <label for="newYear1">Year </label> <input type="text" size="4" id="newYear1" name="newYear1"/> >+ <label for="newMonth1">Month </label> <input type="text" size="2" id="newMonth1" name="newMonth1"/> >+ <label for="newDay1">Day </label> <input type="text" size="2" id="newDay1" name="newDay1" /> >+ [% END %] >+ </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 +255,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>. >diff --git a/tools/newHolidays.pl b/tools/newHolidays.pl >index 34469d8..f050b85 100755 >--- a/tools/newHolidays.pl >+++ b/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 >+ ); >+ } >+ } >+ } > } >-- >1.7.0.4 >
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 6663
:
6537
|
6569
|
6586