From 179716efc0e803aab1c566c9986b3b624a51aeb9 Mon Sep 17 00:00:00 2001
From: Maryse Simard <maryse.simard@inlibro.com>
Date: Fri, 20 Nov 2020 23:22:01 -0500
Subject: [PATCH] Bug 17015: Add filters and use bootstrap grid in
 tools/discrete_calendar.tt

---
 .../prog/css/discretecalendar.css             |   8 +-
 .../en/modules/tools/discrete_calendar.tt     | 107 +++++++++---------
 2 files changed, 59 insertions(+), 56 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/css/discretecalendar.css b/koha-tmpl/intranet-tmpl/prog/css/discretecalendar.css
index 3b7625e1dd..71f8277d8b 100644
--- a/koha-tmpl/intranet-tmpl/prog/css/discretecalendar.css
+++ b/koha-tmpl/intranet-tmpl/prog/css/discretecalendar.css
@@ -159,19 +159,19 @@ td.repeatableyearly a.ui-state-default {
 
 fieldset.brief {
     border:0;
-    margin-top:0;
+    margin:0;
 }
 
 h1 select {
     width:20em;
 }
 
-div.yui-b fieldset.brief ol {
+fieldset.brief ol {
     font-size:100%;
 }
 
-div.yui-b fieldset.brief li,
-div.yui-b fieldset.brief li.radio {
+fieldset.brief li,
+fieldset.brief li.radio {
     padding:.2em 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 22cdc943b2..960d34ffff 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
@@ -1,26 +1,28 @@
+[% USE raw %]
 [% USE Asset %]
 [% USE Branches %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Tools &rsaquo; [% Branches.GetName( branch ) %] calendar</title>
+<title>Koha &rsaquo; Tools &rsaquo; [% Branches.GetName( branch ) | html %] calendar</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% Asset.css("css/discretecalendar.css") %]
+[% Asset.css("css/discretecalendar.css") | $raw %]
 </head>
 
 <body id="tools_holidays" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% Branches.GetName( branch ) %] calendar</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% Branches.GetName( branch ) | html %] calendar</div>
 
-<div id="doc3" class="yui-t1">
+<div id="main" class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
 
-   <div id="bd">
-    <div id="yui-main">
-    <div class="yui-b">
-    <h2>[% Branches.GetName( branch ) %] calendar</h2>
-    <div class="yui-g">
-    <div class="yui-u first" style="width:60%">
+    <h2>[% Branches.GetName( branch ) | html %] calendar</h2>
+
+    <div class="row">
+    <div class="col-sm-8">
         <label for="branch">Define the holidays for:</label>
         <form method="post" onsubmit="return validateForm('CopyCalendar')">
             <select id="branch" name="branch">
@@ -31,7 +33,7 @@
                 <option value=""></option>
                 [% FOREACH l IN Branches.all() %]
                     [% UNLESS branch == l.branchcode %]
-                    <option value="[% l.branchcode %]">[% l.branchname %]</option>
+                    <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
                     [% END %]
                 [% END %]
             </select>
@@ -76,7 +78,7 @@
                         <input type="hidden" id="Year" name="Year" />
                     </li>
                     <li class="dateinsert">
-                        <b>To date: </b>
+                        <strong>To date: </strong>
                         <input type="text" id="from_copyToDatePicker" name="toDate" size="20" class="datepicker" />
                     </li>
                     <li>
@@ -153,7 +155,7 @@
 <!-- ************************************************************************************** -->
 
 </div>
-<div class="yui-u" style="width : 40%">
+<div class="col-sm-4">
     <div class="help">
         <h4>Hints</h4>
         <ul>
@@ -170,7 +172,7 @@
         </ul>
         <h4>Key</h4>
         <p>
-            <span class="key normalday">Working day </span>
+            <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>
@@ -192,8 +194,8 @@
         <tbody>
             [% FOREACH need_validation_holiday IN NEED_VALIDATION_HOLIDAYS %]
             <tr>
-                <td><a href="#doc3" onclick="go_to_date('[% need_validation_holiday.date %]')"><span title="[% need_validation_holiday.DATE_SORT %]">[% need_validation_holiday.outputdate %]</span></a></td>
-                <td>[% need_validation_holiday.note %]</td>
+                <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>
             </tr>
             [% END %]
         </tbody>
@@ -212,14 +214,13 @@
         <tbody>
             [% FOREACH WEEK_DAYS_LOO IN WEEKLY_HOLIDAYS %]
             <tr>
-                <td>[% WEEK_DAYS_LOO.weekday %]</td>
-            </td>
-            <td>[% WEEK_DAYS_LOO.note %]</td>
-        </tr>
-        [% END %]
-    </tbody>
-</table>
-[% END %]
+                <td>[% WEEK_DAYS_LOO.weekday | html %]</td>
+                <td>[% WEEK_DAYS_LOO.note | html %]</td>
+            </tr>
+            [% END %]
+        </tbody>
+    </table>
+    [% END %]
 
 [% IF ( REPEATABLE_HOLIDAYS ) %]
 <h3>Yearly - Repeatable holidays</h3>
@@ -238,11 +239,11 @@
         [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN REPEATABLE_HOLIDAYS %]
         <tr>
             [% IF ( dateformat == "metric" ) %]
-            <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT %]">[% DAY_MONTH_HOLIDAYS_LOO.day %]/[% DAY_MONTH_HOLIDAYS_LOO.month %]</span></td>
+            <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 %]">[% DAY_MONTH_HOLIDAYS_LOO.month %]/[% DAY_MONTH_HOLIDAYS_LOO.day %]</span></td>
+            <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 %]</td>
+            <td>[% DAY_MONTH_HOLIDAYS_LOO.note | html %]</td>
         </tr>
         [% END %]
     </tbody>
@@ -261,8 +262,8 @@
     <tbody>
         [% FOREACH HOLIDAYS_LOO IN UNIQUE_HOLIDAYS %]
         <tr>
-            <td><a href="#doc3" onclick="go_to_date('[% HOLIDAYS_LOO.date %]')"><span title="[% HOLIDAYS_LOO.DATE_SORT %]">[% HOLIDAYS_LOO.outputdate %]</span></a></td>
-            <td>[% HOLIDAYS_LOO.note %]</td>
+            <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>
         </tr>
         [% END %]
     </tbody>
@@ -281,8 +282,8 @@
     <tbody>
         [% FOREACH float_holiday IN FLOAT_HOLIDAYS %]
         <tr>
-            <td><a href="#doc3" onclick="go_to_date('[% float_holiday.date %]')"><span title="[% float_holiday.DATE_SORT %]">[% float_holiday.outputdate %]</span></a></td>
-            <td>[% float_holiday.note %]</td>
+            <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>
         </tr>
         [% END %]
     </tbody>
@@ -291,29 +292,32 @@
 </div>
 </div>
 </div>
-</div>
-</div>
 
-<div class="yui-b noprint">
-[% INCLUDE 'tools-menu.inc' %]
-</div>
-</div>
+            </main>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+                [% INCLUDE 'tools-menu.inc' %]
+            </aside>
+        </div> <!-- .col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
 [% MACRO jsinclude BLOCK %]
-[% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") %]
+[% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
 [% INCLUDE 'calendar.inc' %]
 [% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-    //<![CDATA[
+<script>
         var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
         // Array containing all the information about each date in the calendar.
         var datesInfos = new Array();
         [% FOREACH date IN datesInfos %]
-            datesInfos["[% date.date %]"] = {
-                title : "[% date.note %]",
-                outputdate : "[% date.outputdate %]",
-                holiday_type:"[% date.holiday_type %]",
-                open_hour: "[% date.open_hour %]",
-                close_hour: "[% date.close_hour %]"
+            datesInfos["[% date.date | html %]"] = {
+                title : "[% date.note | html %]",
+                outputdate : "[% date.outputdate | html %]",
+                holiday_type:"[% date.holiday_type | html %]",
+                open_hour: "[% date.open_hour | html %]",
+                close_hour: "[% date.close_hour | html %]"
             };
         [% END %]
 
@@ -396,7 +400,7 @@
 
         function changeBranch () {
             var branch = $("#branch option:selected").val();
-            location.href='/cgi-bin/koha/tools/discrete_calendar.pl?branch=' + branch + '&calendardate=' + "[% calendardate %]";
+            location.href='/cgi-bin/koha/tools/discrete_calendar.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
         }
 
         function Help() {
@@ -596,10 +600,10 @@
                 beforeShowDay: function(thedate) {
                     return dateStatusHandler(thedate);
                 },
-                defaultDate: new Date("[% keydate %]"),
-                minDate: new Date("[% minDate %]"),
-                maxDate: new Date("[% maxDate %]"),
-                dateFormat: "[% datepickerformat %]"
+                defaultDate: new Date("[% keydate | html %]"),
+                minDate: new Date("[% minDate | html %]"),
+                maxDate: new Date("[% maxDate | html %]"),
+                dateFormat: "[% datepickerformat | html %]"
             });
             //Main datepicker
             $("#jcalendar-container").datepicker({
@@ -676,7 +680,6 @@
                 }
             });
         });
-    //]]>
 </script>
 [% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
-- 
2.17.1