Bug 7833 - unique holiday link broken
[koha_gimpoz] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / holidays.tt
index a8bf8b6..6e50425 100644 (file)
                        $("#holtype").attr("class","key exception").html(_("Holiday exception"));
                } else if(holidayType == 'weekday') {
                        $("#showOperationDelLabel").html(_('Delete this holiday.'));
-                       $("#holtype").attr("class","key repeatableday").html(_("Repeatable holiday"));
+                       $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
+               } else if(holidayType == 'daymonth') {
+                       $("#showOperationDelLabel").html(_('Delete this holiday.'));
+                       $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
                } else {
                        $("#showOperationDelLabel").html(_('Delete this holiday.'));
                        $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
                newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
        }
        $(document).ready(function() {
+
+[% IF ( dateformat_metric ) %]         $.tablesorter.addParser({ // http://tablesorter.com/docs/example-parsers.html
+                       id: 'shortDates',
+                       is: function(s){
+                               return false;
+                       },
+                       format: function(s){
+                               var datepattern = new RegExp("[0-9]\/[0-9]");
+                               if( datepattern.test(s)){ // sorting a date without a year: "01/12"
+                                       var dateparts = s.split("/").reverse().join("-"); // build an ISO date to be sorted as text
+                                       s = "2000-" + dateparts; // use 2000 as the default year
+                               }
+                               return s;
+                       },
+                       type: 'text'
+               });
+[% END %]
                $(".hint").hide();
                $("#branch").change(function(){
                        changeBranch();
                });
-               $("#holidayexceptions").tablesorter({
+               $("#holidayexceptions").tablesorter({[% IF ( dateformat_metric ) %]
+                 dateFormat: 'uk',[% END %]
                  sortList: [[0,0]], widgets: ['zebra']
                });
-               $("#holidayweeklyrepeatable").tablesorter({
+               $("#holidayweeklyrepeatable").tablesorter({[% IF ( dateformat_metric ) %]
+                 dateFormat: 'uk',[% END %]
                  sortList: [[0,0]], widgets: ['zebra']
                });
-               $("#holidaysyearlyrepeatable").tablesorter({
-                 sortList: [[0,0]], widgets: ['zebra']
+               $("#holidaysyearlyrepeatable").tablesorter({[% IF ( dateformat_metric ) %]
+                       headers : {
+                               0: {
+                                       sorter : 'shortDates'
+                               }
+                       },[% END %]
+                       sortList: [[0,0]], widgets: ['zebra']
                });
-               $("#holidaysunique").tablesorter({
+               $("#holidaysunique").tablesorter({[% IF ( dateformat_metric ) %]
+                 dateFormat: 'uk',[% END %]
                  sortList: [[0,0]], widgets: ['zebra']
                });
                $("a.helptext").click(function(){
                        $(this).parent().find(".hint").toggle(); return false;
                });
+               $("#dateofrange").each(function () { this.value = "" });
        });
 //]]>
 </script>
 .normalday { background-color :  #EDEDED; color :  Black; border : 1px solid #BCBCBC; }
 .exception { background-color :  #b3d4ff; color :  Black; border : 1px solid #BCBCBC; }
 .holiday {  background-color :  #ffaeae; color :  Black;  border : 1px solid #BCBCBC; }
-.repeatableday {  background-color :  #FFFF99; color :  Black;  border : 1px solid #BCBCBC; }
+.repeatableweekly {  background-color :  #FFFF99; color :  Black;  border : 1px solid #BCBCBC; }
+.repeatableyearly {  background-color :  #FFCC66; color :  Black;  border : 1px solid #BCBCBC; }
 .information { z-index : 1; background-color :  #DCD2F1; width : 300px; display : none; border : 1px solid #000000; color :  #000000; font-size :  8pt; font-weight :  bold; background-color :  #FFD700; cursor :  pointer; padding : 2px; }
 .panel { z-index : 1; display : none; border : 3px solid #CCC; padding : 3px; margin-top: .3em;  background-color: #FEFEFE; } fieldset.brief { border : 0; margin-top: 0; }
 #showHoliday { margin : .5em 0; } h1 select { width: 20em; } div.yui-b fieldset.brief ol { font-size:100%; } div.yui-b fieldset.brief li, div.yui-b fieldset.brief li.radio  { padding:0.2em 0; } .help { margin:.3em 0;border:1px solid #EEE;padding:.3em .7em; font-size : 90%; } #holidayweeklyrepeatable, #holidaysyearlyrepeatable, #holidaysunique, #holidayexceptions { font-size : 90%; margin-bottom : 1em;} .calendar td, .calendar th, .calendar .button, .calendar tbody .day { padding : .7em; font-size: 110%; } .calendar { width: auto; border : 0; }
 </style>
 </head>
-<body>
+<body id="tools_holidays" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
                                <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 %]
                                <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>
                                                        <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>.
        var day_month_holidays = new Array();
        var hola= "[% code %]";
        [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
-       week_days["[% WEEK_DAYS_LOO.KEY %]"] = {title:"[% WEEK_DAYS_LOO.TITLE %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION %]"};
+       week_days["[% WEEK_DAYS_LOO.KEY %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') %]"};
        [% END %]
        [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
-       holidays["[% HOLIDAYS_LOO.KEY %]"] = {title:"[% HOLIDAYS_LOO.TITLE %]", description:"[% HOLIDAYS_LOO.DESCRIPTION %]"};
+       holidays["[% HOLIDAYS_LOO.KEY %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') %]"};
        [% END %]
        [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
-       exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION %]"};
+       exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') %]"};
        [% END %]
        [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
-       day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION %]"};
+       day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE | replace('"','\"') %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') %]"};
        [% END %]
 
        /* This function gives css clases to each kind of day */
                var dateString = year + '/' + month + '/' + day;
                if (exception_holidays[dateString] != null) {
                        return 'exception';
-               } else if ((week_days[weekDay] != null) || (day_month_holidays[dayMonth] != null)) {
-                       return 'repeatableday';
+               } else if ( week_days[weekDay] != null ){
+                       return 'repeatableweekly';
+               } else if ( day_month_holidays[dayMonth] != null ) {
+                       return 'repeatableyearly';
                } else if (holidays[dateString] != null) {
                        return 'holiday';
                } else {
 
 
 </div>
+
+<div style="margin-top: 2em;">
+<form action="copy-holidays.pl" method="post">
+       <input type="hidden" name="from_branchcode" value="[% branch %]" />
+  <label for="branchcode">Copy holidays to:</label>
+  <select id="branchcode" name="branchcode">
+    <option value=""></option>
+    [% FOREACH branchloo IN branchloop %]
+    <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
+    [% END %]
+  </select>
+       <input type="submit" value="Copy" />
+</form>
+</div>
+
 </div>
 <div class="yui-u">
 <div class="help">
        <p>
                <span class="key normalday">Working day</span>
                <span class="key holiday">Unique holiday</span>
-               <span class="key repeatableday">Repeatable holiday</span>
+               <span class="key repeatableweekly">Holiday repeating weekly</span>
+               <span class="key repeatableyearly">Holiday repeating yearly</span>
                <span class="key exception">Holiday exception</span>
        </p>
 </div>
 <tbody>
   [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
   <tr>
-  <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% EXCEPTION_HOLIDAYS_LOO.branch %]&amp;calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE %]">[% EXCEPTION_HOLIDAYS_LOO.DATE %]</a></td>
+  <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch %]&amp;calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE %]">[% EXCEPTION_HOLIDAYS_LOO.DATE %]</a></td>
   <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE %]</td>
   <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION %]</td> 
   </tr>
 <table id="holidayweeklyrepeatable">
 <thead>
 <tr>
-  <th class="repeatableday">Day of Week</th>
-  <th class="repeatableday">Title</th>
-  <th class="repeatableday">Description</th>
+  <th class="repeatableweekly">Day of week</th>
+  <th class="repeatableweekly">Title</th>
+  <th class="repeatableweekly">Description</th>
 </tr>
 </thead>
 <tbody>
 <table id="holidaysyearlyrepeatable">
 <thead>
 <tr>
-  [% IF ( dateformat == 'metric' ) %]
-  <th class="repeatableday">Day/Month</th>
+  [% IF ( dateformat_metric ) %]
+  <th class="repeatableyearly">Day/Month</th>
   [% ELSE %]
-  <th class="repeatableday">Month/Day</th>
+  <th class="repeatableyearly">Month/Day</th>
   [% END %]
-  <th class="repeatableday">Title</th>
-  <th class="repeatableday">Description</th>
+  <th class="repeatableyearly">Title</th>
+  <th class="repeatableyearly">Description</th>
 </tr>
 </thead>
 <tbody>
 <tbody>
     [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
 <tr>
-  <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% HOLIDAYS_LOO.branch %]&amp;calendardate=[% HOLIDAYS_LOO.DATE %]">[% HOLIDAYS_LOO.DATE %]</a></td>
+  <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch %]&amp;calendardate=[% HOLIDAYS_LOO.DATE %]">[% HOLIDAYS_LOO.DATE %]</a></td>
   <td>[% HOLIDAYS_LOO.TITLE %]</td>
   <td>[% HOLIDAYS_LOO.DESCRIPTION %]</td>
 </tr>