Bugzilla – Attachment 156353 Details for
Bug 17015
New Koha Calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17015: Miscellaneous corrections
Bug-17015-Miscellaneous-corrections.patch (text/plain), 56.15 KB, created by
Emily-Rose Francoeur
on 2023-09-28 19:35:44 UTC
(
hide
)
Description:
Bug 17015: Miscellaneous corrections
Filename:
MIME Type:
Creator:
Emily-Rose Francoeur
Created:
2023-09-28 19:35:44 UTC
Size:
56.15 KB
patch
obsolete
>From 57dd9eb154c9b628b5fe9093d00f4456d65ce7cf Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >Date: Thu, 18 May 2023 16:22:20 -0400 >Subject: [PATCH] Bug 17015: Miscellaneous corrections > >--- > Koha/DiscreteCalendar.pm | 69 +- > .../intranet-tmpl/prog/css/src/calendar.scss | 13 + > .../en/modules/tools/discrete_calendar.tt | 646 +++++++++--------- > tools/discrete_calendar.pl | 32 +- > 4 files changed, 399 insertions(+), 361 deletions(-) > >diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm >index 6b5ef2c0f5..80161d991b 100644 >--- a/Koha/DiscreteCalendar.pm >+++ b/Koha/DiscreteCalendar.pm >@@ -1049,22 +1049,25 @@ Returns a string representing the next day the library is open, starting from C< > =cut > > sub next_open_day { >- my ( $self, $date ) = @_; >+ my ( $self, $date, $dayweek ) = @_; > my $branchcode = $self->{branchcode}; > my $schema = Koha::Database->new->schema; > my $dtf = $schema->storage->datetime_parser; > my $formatted_date = $dtf->format_datetime($date); > >+ my $options = { >+ order_by => { -asc => 'date' }, >+ rows => 1, >+ }; >+ $options->{where} = \['DAYOFWEEK(date) = DAYOFWEEK(?)', $formatted_date] if $dayweek; >+ > my $rs = $schema->resultset('DiscreteCalendar')->search( > { > branchcode => $branchcode, > is_opened => 1, >+ date => { '>' => \['DATE(?)', $formatted_date] }, > }, >- { >- where => \['date > date(?)', $formatted_date], >- order_by => { -asc => 'date' }, >- rows => 1 >- } >+ $options > ); > > my $next = $rs->next(); >@@ -1084,22 +1087,25 @@ Returns a string representing the closest previous day the library was open, sta > =cut > > sub prev_open_day { >- my ( $self, $date ) = @_; >+ my ( $self, $date, $dayweek ) = @_; > my $branchcode = $self->{branchcode}; > my $schema = Koha::Database->new->schema; > my $dtf = $schema->storage->datetime_parser; > my $formatted_date = $dtf->format_datetime($date); > >+ my $options = { >+ order_by => { -desc => 'date' }, >+ rows => 1, >+ }; >+ $options->{where} = \['DAYOFWEEK(date) = DAYOFWEEK(?)', $formatted_date] if $dayweek; >+ > my $rs = $schema->resultset('DiscreteCalendar')->search( > { > branchcode => $branchcode, > is_opened => 1, >+ date => { '<' => \['DATE(?)', $formatted_date] }, > }, >- { >- where => \['date < date(?)', $formatted_date], >- order_by => { -desc => 'date' }, >- rows => 1 >- } >+ $options > ); > > my $prev = $rs->next(); >@@ -1165,11 +1171,12 @@ sub hours_between { > my $hours_between = $schema->resultset('DiscreteCalendar')->search( > { > branchcode => $branchcode, >- is_opened => 0 >+ is_opened => 0, >+ date => { >+ '>=' => $start_date, >+ '<' => $end_date, >+ }, > }, >- { >- where => {date => {-between => [$start_date, $end_date]}}, >- } > ); > > if ($skipped_days = $hours_between->count()) { >@@ -1351,18 +1358,36 @@ sub addDays { > > } else { # Days or Datedue > # use straight days, then use calendar to push >- # the date to the next open day if Datedue >+ # the date to the next open day as appropriate >+ # if Datedue or Dayweek > $base_date->add_duration($days_duration); > >- if ( $self->{days_mode} eq 'Datedue' ) { >- # Datedue, then use the calendar to push >+ if ( $self->{days_mode} eq 'Datedue' || >+ $self->{days_mode} eq 'Dayweek') { >+ # Datedue or Dayweek, then use the calendar to push > # the date to the next open day if holiday >- if (!$self->is_opened($base_date) ) { >+ if ( $self->is_holiday($base_date) ) { >+ my $days = $days_duration->in_units('days'); >+ >+ my $dayweek = 0; >+ if ( >+ $self->{days_mode} eq 'Dayweek' && >+ $days % 7 == 0 # Is it a period based on weeks >+ ) { >+ my $dow = $base_date->day_of_week; >+ # Representation fix >+ # DateTime object dow (1-7) where Monday is 1 >+ # in Koha::DiscreteCalendar 1 = Sunday, not 7. >+ $dow = ( $dow == 7 ) ? 1 : $dow + 1; >+ >+ my @weekly_holidays = $self->get_week_days_holidays(); >+ $dayweek = !(@weekly_holidays && grep $_->{weekday} == $dow, @weekly_holidays); >+ } > > if ( $days_duration->is_negative() ) { >- $base_date = $self->prev_open_day($base_date); >+ $base_date = $self->prev_open_day($base_date, $dayweek); > } else { >- $base_date = $self->next_open_day($base_date); >+ $base_date = $self->next_open_day($base_date, $dayweek); > } > } > } >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/calendar.scss b/koha-tmpl/intranet-tmpl/prog/css/src/calendar.scss >index aaaa0adb6d..988b2ddc94 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/calendar.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/calendar.scss >@@ -177,3 +177,16 @@ fieldset.brief li.radio { > .dayContainer { > gap: 3px; > } >+ >+.calendar { >+ display: flex; >+ align-items: start; >+ gap: 10px; >+ flex-wrap: wrap; >+} >+ >+#newHoliday { >+ flex-grow: 1; >+ margin-top: 2px; >+ border-radius: 0; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >index 3b89bd13ff..56aff70001 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt >@@ -9,24 +9,20 @@ > </head> > > <body id="tools_holidays" class="tools"> >-[% INCLUDE 'header.inc' %] >-[% INCLUDE 'cat-search.inc' %] >- >-<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >- <ol> >- <li> >- <a href="/cgi-bin/koha/mainpage.pl">Home</a> >- </li> >- <li> >+[% WRAPPER 'header.inc' %] >+ [% INCLUDE 'cat-search.inc' %] >+[% END %] >+ >+[% WRAPPER 'sub-header.inc' %] >+ [% WRAPPER breadcrumbs %] >+ [% WRAPPER breadcrumb_item %] > <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> >- </li> >- <li> >- <a href="#" aria-current="page"> >- [% Branches.GetName( branch ) | html %] calendar >- </a> >- </li> >- </ol> >-</nav> >+ [% END %] >+ [% WRAPPER breadcrumb_item bc_active= 1 %] >+ <span>[% Branches.GetName( branch ) | html %] calendar</span> >+ [% END %] >+ [% END #/ WRAPPER breadcrumbs %] >+[% END #/ WRAPPER sub-header.inc %] > > <div id="main" class="main container-fluid"> > <div class="row"> >@@ -59,310 +55,320 @@ > <h1>[% Branches.GetName( branch ) | html %] calendar</h1> > > <div class="row"> >- <div class="col-sm-8"> >- <label for="branch">Define the holidays for:</label> >- <form id="copyCalendar-form" method="post"> >- <select id="branch" name="branch"> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] >- </select> >- Copy calendar to >- <select id='newBranch' name ='newBranch'> >- <option value=""></option> >- [% FOREACH l IN Branches.all() %] >- [% UNLESS branch == l.branchcode %] >- <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option> >+ <div class="col-sm-6"> >+ <div class="page-section"> >+ <label for="branch">Define the holidays for:</label> >+ <form id="copyCalendar-form" method="post"> >+ <select id="branch" name="branch"> >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] >+ </select> >+ Copy calendar to >+ <select id='newBranch' name ='newBranch'> >+ <option value=""></option> >+ [% FOREACH l IN Branches.all() %] >+ [% UNLESS branch == l.branchcode %] >+ <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option> >+ [% END %] > [% END %] >- [% END %] >- </select> >- <input type="hidden" name="action" value="copyBranch" /> >- <input type="submit" value="Clone"> >- </form> >- >- <h3>Calendar information</h3> >- >- <span id="calendar-anchor"></span> >- >- <!-- ***************************** Panel to deal with new holidays ********************** --> >- <div class="panel newHoliday" id="newHoliday"> >- <form id="newHoliday-form" method="post"> >- <fieldset class="brief"> >- <h3>Edit date details</h3> >- <span id="holtype"></span> >- <ol> >- <li> >- <strong>Library:</strong> >- <span id="newBranchNameOutput"></span> >- <input type="hidden" id="branch" name="branch" value="[% branch %]" /> >- </li> >- <li> >- <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> >- [% ELSIF ( dateformat == "dmydot" ) %]<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 %] >- >- <input type="hidden" id="newDayname" name="showDayname" /> >- <input type="hidden" id="Day" name="Day" /> >- <input type="hidden" id="Month" name="Month" /> >- <input type="hidden" id="Year" name="Year" /> >- </li> >- <li class="dateinsert"> >- <strong>To date:</strong> >- <input type="text" id="to_date_flatpickr" size="20" /> >- </li> >- <li> >- <label for="title">Title: </label> >- <input type="text" name="Title" id="title" size="35" /> >- </li> >- <li> >- <label for="description">Description: </label> >- <textarea id="description" name="description" rows="2" cols="40"></textarea> >- </li> >- <li id="holidayType"> >- <label for="holidayType">Date type</label> >- <select name ='holidayType'> >- <option value="empty"></option> >- <option value="none">Working day</option> >- <option value="E">Unique holiday</option> >- <option value="W">Weekly holiday</option> >- <option value="R">Repeatable holiday</option> >- <option value="F">Floating holiday</option> >- <option value="N" disabled>Need validation</option> >- </select> >- <a href="#" class="helptext">[?]</a> >- <div class="hint"> >- <ol> >- <li><strong>Working day:</strong> the library is open on that day.</li> >- <li><strong>Unique holiday:</strong> make a single holiday. For example, selecting August 1, 2012 will make it a holiday, but will not affect August 1 in other years.</li> >- <li><strong>Weekly holiday:</strong> make this weekday a holiday, every week. For example, if your library is closed on Saturdays, use this option to make every Saturday a holiday.</li> >- <li><strong>Repeatable holiday:</strong> 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 1 will make August 1 a holiday every year.</li> >- <li><strong>Floating holiday:</strong> this will take this day and month as a reference to make it a floating holiday. Through this option, you can add a holiday that repeats every year but not necessarily on the exact same day. On subsequent years the date will need validation.</li> >- <li><strong>Need validation:</strong> this holiday has been added automatically, but needs to be validated.</li> >- </ol> >- </div> >- </li> >- <li id="days_of_week"> >- <label for="day_of_week">Week day</label> >- <select name ='day_of_week'> >- <option value="everyday">Everyday</option> >- <option value="1">Sundays</option> >- <option value="2">Mondays</option> >- <option value="3">Tuesdays</option> >- <option value="4">Wednesdays</option> >- <option value="5">Thursdays</option> >- <option value="6">Fridays</option> >- <option value="7">Saturdays</option> >- </select> >- </li> >- <li class="radio" id="deleteType"> >- <input type="checkbox" name="deleteType" id="deleteType_checkbox" value="1" ><label for="deleteType_checkbox"> Delete this type</label> >- <a href="#" class="helptext">[?]</a> >- <div class="hint">Remove all repeated or weekly holidays of the selected date or week day <br> if working day is selected.</div> >- </li> >- <li> >- <label for="openHour">Open hours: </label><input type="text" name="openHour" id='openHour' /> >- </li> >- <li> >- <label for="closeHour">Close hours: </label><input type="text" name="closeHour" id='closeHour' /> >- </li> >- <li class="radio"> >- <input type="radio" name="action" id="EditRadioButton" value="edit" checked/> >- <label for="EditRadioButton">Edit selected dates</label> >- </li> >- <li class="radio"> >- <input type="radio" name="action" id="CopyRadioButton" value="copyDates" /> >- <label for="CopyRadioButton">Copy to different dates</label> >- </li> >- <li class="CopyDatePanel"> >- <label>From:</label> >- <input type="text" id="copyto_from_flatpickr" size="20"/> >- <label>To:</label> >- <input type="text" id="copyto_to_flatpickr" size="20"/> >- </li> >- <li class="checkbox"> >- <input type="checkbox" name="all_branches" id="all_branches" /> >- <label for="all_branches">Copy to all libraries</label>. >- <a href="#" class="helptext">[?]</a> >- <div class="hint">If checked, this holiday will be copied to all libraries.</div> >- </li> >- </ol> >- >- <!-- These yyyy-mm-dd --> >- <input type="hidden" name="from_date" id='from_date'> >- <input type="hidden" name="to_date" id='to_date'> >- <input type="hidden" name="copyto_from" id='copyto_from'> >- <input type="hidden" name="copyto_to" id='copyto_to'> >- <input type="hidden" name="daysnumber" id='daysnumber'> >- <input type="hidden" name="local_today" id='local_today'> >- >- <fieldset class="action"> >- <input type="submit" name="submit" value="Save" /> >- <a href="#" class="cancel hidePanel newHoliday">Cancel</a> >- </fieldset> >- </fieldset> >+ </select> >+ <input type="hidden" name="action" value="copyBranch" /> >+ <input type="submit" value="Clone"> > </form> >- </div> >- </div> >- >- <div class="col-sm-4"> >- <div class="help"> >- <h4>Hints</h4> >- <ul> >- <li>Search in the calendar the day you want to set as holiday.</li> >- <li>Click the date to add or edit a holiday.</li> >- <li>Enter a title and description for the holiday.</li> >- <li>Specify how the holiday should repeat.</li> >- <li>Click Save to finish.</li> >- <li>PS: >- <ul> >- <li>Past dates cannot be changed</li> >- <li>Weekly holidays change open/close hours for all the days affected unless inputs are empty</li> >- </ul> >- </li> >- </ul> >- <h4>Key</h4> >- <p> >- <span class="key normalday">Working day</span> >- <span class="key holiday">Unique holiday</span> >- <span class="key repeatableweekly">Holiday repeating weekly</span> >- <span class="key repeatableyearly">Holiday repeating yearly</span> >- <span class="key float">Floating holiday</span> >- <span class="key exception">Need validation</span> >- </p> >- </div> >- >- <div id="holiday-list"> >- [% IF ( NEED_VALIDATION_HOLIDAYS ) %] >- <h3>Need validation holidays</h3> >- <table id="holidaysvalidation" class="dataTable no-footer"> >- <thead> >- <tr> >- <th class="validation">Date</th> >- <th class="validation">Title</th> >- <th class="validation">Description</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH need_validation_holiday IN NEED_VALIDATION_HOLIDAYS %] >- <tr> >- <td><a href="#main" onclick="go_to_date('[% need_validation_holiday.date | html %]')"><span title="[% need_validation_holiday.DATE_SORT | html %]">[% need_validation_holiday.outputdate | html %]</span></a></td> >- <td>[% need_validation_holiday.note | html %]</td> >- <td>[% need_validation_holiday.description.replace('\\\r\\\n', '<br />') | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% END %] >- >- [% IF ( WEEKLY_HOLIDAYS ) %] >- <h3>Weekly - Repeatable holidays</h3> >- <table id="holidayweeklyrepeatable" class="dataTable no-footer"> >- <thead> >- <tr> >- <th class="repeatableweekly">Day of week</th> >- <th class="repeatableweekly">Title</th> >- <th class="repeatableweekly">Description</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH WEEK_DAYS_LOO IN WEEKLY_HOLIDAYS %] >- <tr> >- <td>[% WEEK_DAYS_LOO.weekday | html %]</td> >- <td>[% WEEK_DAYS_LOO.note | html %]</td> >- <td>[% WEEK_DAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% END %] >- >- [% IF ( REPEATABLE_HOLIDAYS ) %] >- <h3>Yearly - Repeatable holidays</h3> >- <table id="holidaysyearlyrepeatable" class="dataTable no-footer"> >- <thead> >- <tr> >- [% IF ( dateformat == "metric" ) %] >- <th class="repeatableyearly">Day/month</th> >- [% ELSE %] >- <th class="repeatableyearly">Month/day</th> >+ >+ <h3>Calendar information</h3> >+ >+ <div class="calendar"> >+ <span id="calendar-anchor"></span> >+ >+ <!-- ***************************** Panel to deal with new holidays ********************** --> >+ <div class="panel newHoliday" id="newHoliday"> >+ <form id="newHoliday-form" method="post"> >+ <fieldset class="brief"> >+ <h3>Edit date details</h3> >+ <span id="holtype"></span> >+ <ol> >+ <li> >+ <strong>Library:</strong> >+ <span id="newBranchNameOutput"></span> >+ <input type="hidden" id="branch" name="branch" value="[% branch %]" /> >+ </li> >+ <li> >+ <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> >+ [% ELSIF ( dateformat == "dmydot" ) %] >+ <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 %] >+ >+ <input type="hidden" id="newDayname" name="showDayname" /> >+ <input type="hidden" id="Day" name="Day" /> >+ <input type="hidden" id="Month" name="Month" /> >+ <input type="hidden" id="Year" name="Year" /> >+ </li> >+ <li class="dateinsert"> >+ <strong>To date:</strong> >+ <input type="text" id="to_date_flatpickr" size="20" /> >+ </li> >+ <li> >+ <label for="title">Title: </label> >+ <input type="text" name="Title" id="title" size="35" /> >+ </li> >+ <li> >+ <label for="description">Description: </label> >+ <textarea id="description" name="description" rows="2" cols="40"></textarea> >+ </li> >+ <li id="holidayType"> >+ <label for="holidayType">Date type</label> >+ <select name ='holidayType'> >+ <option value="empty"></option> >+ <option value="none">Working day</option> >+ <option value="E">Unique holiday</option> >+ <option value="W">Weekly holiday</option> >+ <option value="R">Repeatable holiday</option> >+ <option value="F">Floating holiday</option> >+ <option value="N" disabled>Need validation</option> >+ </select> >+ <a href="#" class="helptext">[?]</a> >+ <div class="hint"> >+ <ol> >+ <li><strong>Working day:</strong> the library is open on that day.</li> >+ <li><strong>Unique holiday:</strong> make a single holiday. For example, selecting August 1, 2012 will make it a holiday, but will not affect August 1 in other years.</li> >+ <li><strong>Weekly holiday:</strong> make this weekday a holiday, every week. For example, if your library is closed on Saturdays, use this option to make every Saturday a holiday.</li> >+ <li><strong>Repeatable holiday:</strong> 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 1 will make August 1 a holiday every year.</li> >+ <li><strong>Floating holiday:</strong> this will take this day and month as a reference to make it a floating holiday. Through this option, you can add a holiday that repeats every year but not necessarily on the exact same day. On subsequent years the date will need validation.</li> >+ <li><strong>Need validation:</strong> this holiday has been added automatically, but needs to be validated.</li> >+ </ol> >+ </div> >+ </li> >+ <li id="days_of_week"> >+ <label for="day_of_week">Week day</label> >+ <select name ='day_of_week'> >+ <option value="everyday">Everyday</option> >+ <option value="1">Sundays</option> >+ <option value="2">Mondays</option> >+ <option value="3">Tuesdays</option> >+ <option value="4">Wednesdays</option> >+ <option value="5">Thursdays</option> >+ <option value="6">Fridays</option> >+ <option value="7">Saturdays</option> >+ </select> >+ </li> >+ <li class="radio" id="deleteType"> >+ <input type="checkbox" name="deleteType" id="deleteType_checkbox" value="1" ><label for="deleteType_checkbox"> Delete this type</label> >+ <a href="#" class="helptext">[?]</a> >+ <div class="hint">Remove all repeated or weekly holidays of the selected date or week day <br> if working day is selected.</div> >+ </li> >+ <li> >+ <label for="openHour">Open hours: </label><input type="text" name="openHour" id='openHour' /> >+ </li> >+ <li> >+ <label for="closeHour">Close hours: </label><input type="text" name="closeHour" id='closeHour' /> >+ </li> >+ <li class="radio"> >+ <input type="radio" name="action" id="EditRadioButton" value="edit" checked/> >+ <label for="EditRadioButton">Edit selected dates</label> >+ </li> >+ <li class="radio"> >+ <input type="radio" name="action" id="CopyRadioButton" value="copyDates" /> >+ <label for="CopyRadioButton">Copy to different dates</label> >+ </li> >+ <li class="CopyDatePanel"> >+ <label>From:</label> >+ <input type="text" id="copyto_from_flatpickr" size="20"/> >+ <label>To:</label> >+ <input type="text" id="copyto_to_flatpickr" size="20"/> >+ </li> >+ <li class="checkbox"> >+ <input type="checkbox" name="all_branches" id="all_branches" /> >+ <label for="all_branches">Copy to all libraries</label>. >+ <a href="#" class="helptext">[?]</a> >+ <div class="hint">If checked, this holiday will be copied to all libraries.</div> >+ </li> >+ </ol> >+ >+ <!-- These yyyy-mm-dd --> >+ <input type="hidden" name="from_date" id='from_date'> >+ <input type="hidden" name="to_date" id='to_date'> >+ <input type="hidden" name="copyto_from" id='copyto_from'> >+ <input type="hidden" name="copyto_to" id='copyto_to'> >+ <input type="hidden" name="daysnumber" id='daysnumber'> >+ <input type="hidden" name="local_today" id='local_today'> >+ >+ <fieldset class="action"> >+ <input type="submit" name="submit" value="Save" /> >+ <a href="#" class="cancel hidePanel newHoliday">Cancel</a> >+ </fieldset> >+ </fieldset> >+ </form> >+ </div> >+ </div> >+ </div> <!-- /.page-section --> >+ </div> <!-- /.col-sm-6 --> >+ >+ <div class="col-sm-6"> >+ <div class="page-section"> >+ <div class="help"> >+ <h4>Hints</h4> >+ <ul> >+ <li>Search in the calendar the day you want to set as holiday.</li> >+ <li>Click the date to add or edit a holiday.</li> >+ <li>Enter a title and description for the holiday.</li> >+ <li>Specify how the holiday should repeat.</li> >+ <li>Click Save to finish.</li> >+ <li>PS: >+ <ul> >+ <li>Past dates cannot be changed</li> >+ <li>Weekly holidays change open/close hours for all the days affected unless inputs are empty</li> >+ </ul> >+ </li> >+ </ul> >+ <h4>Key</h4> >+ <p> >+ <span class="key normalday">Working day</span> >+ <span class="key holiday">Unique holiday</span> >+ <span class="key repeatableweekly">Holiday repeating weekly</span> >+ <span class="key repeatableyearly">Holiday repeating yearly</span> >+ <span class="key float">Floating holiday</span> >+ <span class="key exception">Need validation</span> >+ </p> >+ </div> <!-- /#help --> >+ >+ <div id="holiday-list"> >+ [% IF ( NEED_VALIDATION_HOLIDAYS ) %] >+ <h3>Need validation holidays</h3> >+ <table id="holidaysvalidation" class="dataTable no-footer"> >+ <thead> >+ <tr> >+ <th class="validation">Date</th> >+ <th class="validation">Title</th> >+ <th class="validation">Description</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH need_validation_holiday IN NEED_VALIDATION_HOLIDAYS %] >+ <tr> >+ <td><a href="#main" onclick="go_to_date('[% need_validation_holiday.date | html %]')"><span title="[% need_validation_holiday.DATE_SORT | html %]">[% need_validation_holiday.outputdate | html %]</span></a></td> >+ <td>[% need_validation_holiday.note | html %]</td> >+ <td>[% need_validation_holiday.description.replace('\\\r\\\n', '<br />') | html %]</td> >+ </tr> > [% END %] >- <th class="repeatableyearly">Title</th> >- <th class="repeatableyearly">Description</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN REPEATABLE_HOLIDAYS %] >- <tr> >- [% IF ( dateformat == "metric" ) %] >- <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">[% DAY_MONTH_HOLIDAYS_LOO.day | html %]/[% DAY_MONTH_HOLIDAYS_LOO.month | html %]</span></td> >- [% ELSE %] >- <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">[% DAY_MONTH_HOLIDAYS_LOO.month | html %]/[% DAY_MONTH_HOLIDAYS_LOO.day | html %]</span></td> >+ </tbody> >+ </table> <!-- /#holidayexceptions --> >+ [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %] >+ >+ [% IF ( WEEKLY_HOLIDAYS ) %] >+ <h3>Weekly - Repeatable holidays</h3> >+ <table id="holidayweeklyrepeatable" class="dataTable no-footer"> >+ <thead> >+ <tr> >+ <th class="repeatableweekly">Day of week</th> >+ <th class="repeatableweekly">Title</th> >+ <th class="repeatableweekly">Description</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH WEEK_DAYS_LOO IN WEEKLY_HOLIDAYS %] >+ <tr> >+ <td>[% WEEK_DAYS_LOO.weekday | html %]</td> >+ <td>[% WEEK_DAYS_LOO.note | html %]</td> >+ <td>[% WEEK_DAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >+ </tr> > [% END %] >- <td>[% DAY_MONTH_HOLIDAYS_LOO.note | html %]</td> >- <td>[% DAY_MONTH_HOLIDAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% END %] >- >- [% IF ( UNIQUE_HOLIDAYS ) %] >- <h3>Unique holidays</h3> >- <label class="controls"> >- <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" /> >- Show past entries >- </label> >- <table id="holidaysunique" class="dataTable no-footer"> >- <thead> >- <tr> >- <th class="holiday">Date</th> >- <th class="holiday">Title</th> >- <th class="holiday">Description</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH HOLIDAYS_LOO IN UNIQUE_HOLIDAYS %] >- <tr data-date="[% HOLIDAYS_LOO.date | html %]"> >- <td><a href="#main" onclick="go_to_date('[% HOLIDAYS_LOO.date | html %]')"><span title="[% HOLIDAYS_LOO.DATE_SORT | html %]">[% HOLIDAYS_LOO.outputdate | html %]</span></a></td> >- <td>[% HOLIDAYS_LOO.note | html %]</td> >- <td>[% HOLIDAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% END %] >- >- [% IF ( FLOAT_HOLIDAYS ) %] >- <h3>Floating holidays</h3> >- <label class="controls"> >- <input type="checkbox" name="show_past" id="show_past_holidaysfloat" class="show_past" /> >- Show past entries >- </label> >- <table id="holidaysfloat" class="dataTable no-footer"> >- <thead> >- <tr> >- <th class="float">Date</th> >- <th class="float">Title</th> >- <th class="float">Description</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH float_holiday IN FLOAT_HOLIDAYS %] >- <tr data-date="[% float_holiday.date | html %]"> >- <td><a href="#main" onclick="go_to_date('[% float_holiday.date | html %]')"><span title="[% float_holiday.DATE_SORT | html %]">[% float_holiday.outputdate | html %]</span></a></td> >- <td>[% float_holiday.note | html %]</td> >- <td>[% float_holiday.description.replace('\\\r\\\n', '<br />') | html %]</td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% END %] >- </div> >- </div> >- </div> >- >+ </tbody> >+ </table> <!-- /#holidayweeklyrepeatable --> >+ [% END # / IF ( WEEKLY_HOLIDAYS ) %] >+ >+ [% IF ( REPEATABLE_HOLIDAYS ) %] >+ <h3>Yearly - Repeatable holidays</h3> >+ <table id="holidaysyearlyrepeatable" class="dataTable no-footer"> >+ <thead> >+ <tr> >+ [% IF ( dateformat == "metric" ) %] >+ <th class="repeatableyearly">Day/month</th> >+ [% ELSE %] >+ <th class="repeatableyearly">Month/day</th> >+ [% END %] >+ <th class="repeatableyearly">Title</th> >+ <th class="repeatableyearly">Description</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN REPEATABLE_HOLIDAYS %] >+ <tr> >+ [% IF ( dateformat == "metric" ) %] >+ <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">[% DAY_MONTH_HOLIDAYS_LOO.day | html %]/[% DAY_MONTH_HOLIDAYS_LOO.month | html %]</span></td> >+ [% ELSE %] >+ <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">[% DAY_MONTH_HOLIDAYS_LOO.month | html %]/[% DAY_MONTH_HOLIDAYS_LOO.day | html %]</span></td> >+ [% END %] >+ <td>[% DAY_MONTH_HOLIDAYS_LOO.note | html %]</td> >+ <td>[% DAY_MONTH_HOLIDAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> <!-- /#holidaysyearlyrepeatable --> >+ [% END # /IF ( REPEATABLE_HOLIDAYS ) %] >+ >+ [% IF ( UNIQUE_HOLIDAYS ) %] >+ <h3>Unique holidays</h3> >+ <label class="controls"> >+ <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" /> >+ Show past entries >+ </label> >+ <table id="holidaysunique" class="dataTable no-footer"> >+ <thead> >+ <tr> >+ <th class="holiday">Date</th> >+ <th class="holiday">Title</th> >+ <th class="holiday">Description</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH HOLIDAYS_LOO IN UNIQUE_HOLIDAYS %] >+ <tr data-date="[% HOLIDAYS_LOO.date | html %]"> >+ <td><a href="#main" onclick="go_to_date('[% HOLIDAYS_LOO.date | html %]')"><span title="[% HOLIDAYS_LOO.DATE_SORT | html %]">[% HOLIDAYS_LOO.outputdate | html %]</span></a></td> >+ <td>[% HOLIDAYS_LOO.note | html %]</td> >+ <td>[% HOLIDAYS_LOO.description.replace('\\\r\\\n', '<br />') | html %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> <!-- /#holidaysunique --> >+ [% END # /IF ( UNIQUE_HOLIDAYS ) %] >+ >+ [% IF ( FLOAT_HOLIDAYS ) %] >+ <h3>Floating holidays</h3> >+ <label class="controls"> >+ <input type="checkbox" name="show_past" id="show_past_holidaysfloat" class="show_past" /> >+ Show past entries >+ </label> >+ <table id="holidaysfloat" class="dataTable no-footer"> >+ <thead> >+ <tr> >+ <th class="float">Date</th> >+ <th class="float">Title</th> >+ <th class="float">Description</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH float_holiday IN FLOAT_HOLIDAYS %] >+ <tr data-date="[% float_holiday.date | html %]"> >+ <td><a href="#main" onclick="go_to_date('[% float_holiday.date | html %]')"><span title="[% float_holiday.DATE_SORT | html %]">[% float_holiday.outputdate | html %]</span></a></td> >+ <td>[% float_holiday.note | html %]</td> >+ <td>[% float_holiday.description.replace('\\\r\\\n', '<br />') | html %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> <!-- /#holidaysfloat --> >+ [% END # /IF ( FLOAT_HOLIDAYS ) %] >+ </div> <!-- /#holiday-list --> >+ </div> <!-- /.page-section --> >+ </div> <!-- /.col-sm-6 --> >+ </div> <!-- /.row --> > </main> > </div> <!-- /.col-sm-10.col-sm-push-2 --> > >@@ -460,6 +466,7 @@ > $(".CopyDatePanel").toggle(value); > } > $("#title").prop('disabled', value); >+ $("#description").prop('disabled', value); > $("#holidayType select").prop('disabled', value); > $("#openHour").prop('disabled', value); > $("#closeHour").prop('disabled', value); >@@ -681,7 +688,9 @@ > }); > > $("a.helptext").click(function () { >- $(this).parent().find(".hint").toggle(); >+ $(this).parent().find(".hint") >+ .css("max-width", ($(this).closest("#newHoliday").width() - 20)+"px") >+ .toggle(); > return false; > }); > >@@ -796,5 +805,4 @@ > </script> > [% END %] > >-<!-- the main div is closed in intranet-bottom.inc --> > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/tools/discrete_calendar.pl b/tools/discrete_calendar.pl >index 96dd7daa31..71c46a9e8d 100755 >--- a/tools/discrete_calendar.pl >+++ b/tools/discrete_calendar.pl >@@ -20,8 +20,8 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use C4::Auth qw ( get_template_and_user ); >-use C4::Output qw ( output_html_with_http_headers ); >+use C4::Auth qw( get_template_and_user ); >+use C4::Output qw( output_html_with_http_headers ); > > use Koha::DateUtils qw ( dt_from_string output_pref ); > use Koha::DiscreteCalendar; >@@ -35,7 +35,6 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( > type => "intranet", > query => $input, > flagsrequired => {tools => 'edit_calendar'}, >- debug => 1, > } > ); > >@@ -56,11 +55,13 @@ my $action = $input->param('action') || ''; > > # calendardate - date passed in url for human readability (syspref) > # if the url has an invalid date default to 'now.' >-my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate')); } || dt_from_string; >+# FIXME There is something to improve in the date handling here >+my $calendarinput_dt = eval { dt_from_string( scalar $input->param('calendardate') ); } || dt_from_string; > my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } ); > > if ($action eq 'copyBranch') { >- $calendar->copy_to_branch(scalar $input->param('newBranch')); >+ my $new_branch = scalar $input->param('newBranch'); >+ $calendar->copy_to_branch($new_branch) if $new_branch; > } elsif($action eq 'copyDates') { > my $from_startDate = $input->param('from_date') ||''; > my $from_endDate = $input->param('to_date') || ''; >@@ -139,33 +140,24 @@ if ( C4::Context->only_my_library ) { > > # Get all the holidays > >-#discrete_calendar weekly holidays > my @week_days = $calendar->get_week_days_holidays(); >- >-#discrete_calendar repeatable holidays > my @repeatable_holidays = $calendar->get_repeatable_holidays(); >+my @unique_holidays = $calendar->get_unique_holidays(0); >+my @float_holidays = $calendar->get_float_holidays(0); >+my @need_validation_holidays = $calendar->get_need_validation_holidays(); > >-#discrete_calendar unique holidays >-my @unique_holidays =$calendar->get_unique_holidays(0); >-#discrete_calendar floating holidays >-my @float_holidays =$calendar->get_float_holidays(0); >-#discrete_caledar need validation holidays >-my @need_validation_holidays =$calendar->get_need_validation_holidays(); >- >-#Calendar maximum date >+#Calendar minimum & maximum dates > my $minDate = $calendar->get_min_date(); >- >-#Calendar minimum date > my $maxDate = $calendar->get_max_date(); > > my @datesInfos = $calendar->get_dates_info(); > > $template->param( >+ WEEKLY_HOLIDAYS => \@week_days, >+ REPEATABLE_HOLIDAYS => \@repeatable_holidays, > UNIQUE_HOLIDAYS => \@unique_holidays, > FLOAT_HOLIDAYS => \@float_holidays, > NEED_VALIDATION_HOLIDAYS => \@need_validation_holidays, >- REPEATABLE_HOLIDAYS => \@repeatable_holidays, >- WEEKLY_HOLIDAYS => \@week_days, > calendardate => $calendardate, > keydate => $keydate, > branch => $branch, >-- >2.34.1
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 17015
:
53859
|
54318
|
54419
|
59166
|
59167
|
59168
|
59169
|
59170
|
59171
|
59267
|
59268
|
59269
|
59270
|
59271
|
59463
|
59516
|
59517
|
59518
|
59519
|
59520
|
59561
|
59562
|
59586
|
59587
|
59888
|
59889
|
60902
|
60903
|
60904
|
60905
|
60906
|
60986
|
61737
|
62375
|
62376
|
62380
|
63257
|
63282
|
63362
|
63363
|
63364
|
63365
|
63366
|
63367
|
64235
|
65073
|
65074
|
65075
|
65076
|
65077
|
67721
|
67722
|
67723
|
67724
|
67725
|
67879
|
67929
|
67930
|
67931
|
67932
|
67933
|
67934
|
68392
|
68393
|
68394
|
68395
|
68396
|
68397
|
71634
|
71635
|
71636
|
71637
|
71638
|
72890
|
73145
|
74859
|
74860
|
74861
|
74862
|
74863
|
74864
|
74865
|
74866
|
75444
|
75479
|
76594
|
77249
|
77250
|
77607
|
77608
|
77609
|
77610
|
77611
|
77612
|
77613
|
77770
|
77771
|
77772
|
77773
|
77774
|
79035
|
80523
|
80524
|
80525
|
80526
|
80527
|
80528
|
80529
|
80530
|
80531
|
80532
|
80533
|
80534
|
80535
|
83547
|
85394
|
85677
|
85678
|
85679
|
85680
|
85681
|
85682
|
85683
|
85684
|
85685
|
85686
|
85687
|
85688
|
85689
|
85690
|
85691
|
92595
|
92596
|
92597
|
92598
|
100079
|
110383
|
110384
|
110386
|
110387
|
110388
|
110389
|
113541
|
113905
|
115501
|
115502
|
115503
|
115504
|
115505
|
115506
|
115507
|
115508
|
115509
|
115510
|
115511
|
118554
|
118555
|
118556
|
118557
|
118558
|
118559
|
119095
|
119097
|
119099
|
119100
|
119101
|
119102
|
131619
|
131620
|
131621
|
131622
|
131623
|
131624
|
131625
|
131626
|
131634
|
131635
|
131636
|
131637
|
131638
|
131639
|
131640
|
131641
|
131667
|
132199
|
133596
|
133597
|
133598
|
133599
|
133600
|
133601
|
133602
|
133603
|
133604
|
133605
|
133678
|
137219
|
137220
|
137221
|
137222
|
137223
|
137224
|
137225
|
137226
|
137227
|
137228
|
137229
|
139378
|
139379
|
139380
|
139381
|
139382
|
139599
|
139600
|
139601
|
139602
|
139603
|
139851
|
140150
|
141176
|
144257
|
144258
|
144259
|
144260
|
144261
|
144262
|
144264
|
144268
|
144269
|
144270
|
144271
|
144272
|
144273
|
151438
|
151439
|
151440
|
151441
|
151442
|
151443
|
151444
|
151445
|
151446
|
151447
|
151448
|
151449
|
151450
|
156340
|
156341
|
156342
|
156343
|
156344
|
156345
|
156346
|
156347
|
156348
|
156349
|
156350
|
156351
|
156352
|
156353
|
156354
|
156355
|
157656
|
157657
|
157658
|
157659
|
157660
|
157661
|
157662
|
157663
|
157664
|
157665
|
157666
|
157667
|
157668
|
157669
|
157670
|
157671
|
157672
|
167805
|
167806
|
167807
|
167808
|
167809