Bugzilla – Attachment 6586 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]
Signed-off patch
0001-SIGNED-OFF-Bug-6663-Features-for-holidays.pl-with-da.patch (text/plain), 9.62 KB, created by
Owen Leonard
on 2011-12-05 20:41:59 UTC
(
hide
)
Description:
Signed-off patch
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2011-12-05 20:41:59 UTC
Size:
9.62 KB
patch
obsolete
>From 858e833a5fb3d6281c13330960990130417c147e 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] [SIGNED-OFF] Bug 6663: Features for holidays.pl with datepicker >Content-Type: text/plain; charset="utf-8" > >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> >--- > .../intranet-tmpl/prog/en/css/staff-global.css | 2 + > .../prog/en/modules/tools/holidays.tt | 27 +++++- > tools/holidays.pl | 1 + > tools/newHolidays.pl | 98 ++++++++++++++++--- > 4 files changed, 111 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..83fcc7f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt >+++ b/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>. >diff --git a/tools/holidays.pl b/tools/holidays.pl >index 90ef56a..b3912eb 100755 >--- a/tools/holidays.pl >+++ b/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 > ); > >diff --git a/tools/newHolidays.pl b/tools/newHolidays.pl >index 34469d8..c36d328 100755 >--- a/tools/newHolidays.pl >+++ b/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 >+ ); >+ } >+ } >+ } > } >-- >1.7.3 >
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