View | Details | Raw Unified | Return to bug 19653
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt (-25 / +31 lines)
Lines 1-28 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]<title>Koha &rsaquo; Tools &rsaquo; CSV export profiles</title>[% INCLUDE 'doc-head-close.inc' %]
1
[% SET footerjs = 1 %]
2
<script type="text/javascript">
2
[% INCLUDE 'doc-head-open.inc' %]
3
//<![CDATA[
3
<title>Koha &rsaquo; Tools &rsaquo; CSV export profiles</title>
4
function reloadPage(p) {
4
[% INCLUDE 'doc-head-close.inc' %]
5
    var id = p.value;
6
    if (id != 0) { document.location = "/cgi-bin/koha/tools/csv-profiles.pl?op=add_form&amp;export_format_id=" + id; }
7
}
8
     $(document).ready(function() {
9
        $("#type").change(function(){
10
            if ( $(this).find("option:selected").val() == "marc" ) {
11
                $("li.marc_specific").show();
12
                $("#marc_content").attr("required", "required");
13
                $("li.sql_specific").hide();
14
                $("#sql_content").removeAttr("required");
15
            } else {
16
                $("li.marc_specific").hide();
17
                $("#marc_content").removeAttr("required");
18
                $("li.sql_specific").show();
19
                $("#sql_content").attr("required", "required");
20
            }
21
        });
22
        $("#type").change();
23
     });
24
//]]>
25
</script>
26
</head>
5
</head>
27
6
28
<body id="tools_csv-profiles" class="tools">
7
<body id="tools_csv-profiles" class="tools">
Lines 304-307 function reloadPage(p) { Link Here
304
[% INCLUDE 'tools-menu.inc' %]
283
[% INCLUDE 'tools-menu.inc' %]
305
</div>
284
</div>
306
</div>
285
</div>
286
287
[% MACRO jsinclude BLOCK %]
288
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
289
    <script type="text/javascript">
290
        function reloadPage(p) {
291
            var id = p.value;
292
            if (id != 0) { document.location = "/cgi-bin/koha/tools/csv-profiles.pl?op=add_form&amp;export_format_id=" + id; }
293
        }
294
        $(document).ready(function() {
295
            $("#type").change(function(){
296
                if ( $(this).find("option:selected").val() == "marc" ) {
297
                    $("li.marc_specific").show();
298
                    $("#marc_content").attr("required", "required");
299
                    $("li.sql_specific").hide();
300
                    $("#sql_content").removeAttr("required");
301
                } else {
302
                    $("li.marc_specific").hide();
303
                    $("#marc_content").removeAttr("required");
304
                    $("li.sql_specific").show();
305
                    $("#sql_content").attr("required", "required");
306
                }
307
            });
308
            $("#type").change();
309
        });
310
    </script>
311
[% END %]
312
307
[% INCLUDE 'intranet-bottom.inc' %]
313
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-199 / +203 lines)
Lines 1-207 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Tools &rsaquo; [% Branches.GetName( branch ) %] calendar</title>
4
<title>Koha &rsaquo; Tools &rsaquo; [% Branches.GetName( branch ) %] calendar</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7
[% INCLUDE 'datatables.inc' %]
8
<script type="text/javascript">
9
//<![CDATA[
10
    var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
11
12
    /* Creates all the structures to deal with all different kinds of holidays */
13
    var week_days = new Array();
14
    var holidays = new Array();
15
    var holidates = new Array();
16
    var exception_holidays = new Array();
17
    var day_month_holidays = new Array();
18
    var hola= "[% code %]";
19
    [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
20
    week_days["[% WEEK_DAYS_LOO.KEY %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
21
    [% END %]
22
    [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
23
    holidates.push("[% HOLIDAYS_LOO.KEY %]");
24
    holidays["[% HOLIDAYS_LOO.KEY %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
25
    [% END %]
26
    [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
27
    exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
28
    [% END %]
29
    [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
30
    day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
31
    [% END %]
32
33
    function holidayOperation(formObject, opType) {
34
        var op = document.getElementsByName('operation');
35
        op[0].value = opType;
36
        formObject.submit();
37
    }
38
39
    // This function shows the "Show Holiday" panel //
40
    function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, holidayType) {
41
        $("#newHoliday").slideUp("fast");
42
        $("#showHoliday").slideDown("fast");
43
        $('#showDaynameOutput').html(dayName);
44
        $('#showDayname').val(dayName);
45
        $('#showBranchNameOutput').html($("#branch :selected").text());
46
        $('#showBranchName').val($("#branch").val());
47
        $('#showDayOutput').html(day);
48
        $('#showDay').val(day);
49
        $('#showMonthOutput').html(month);
50
        $('#showMonth').val(month);
51
        $('#showYearOutput').html(year);
52
        $('#showYear').val(year);
53
        $('#showDescription').val(description);
54
        $('#showWeekday:first').val(weekDay);
55
        $('#showTitle').val(title);
56
        $('#showHolidayType').val(holidayType);
57
58
        if (holidayType == 'exception') {
59
            $("#showOperationDelLabel").html(_("Delete this exception."));
60
            $("#holtype").attr("class","key exception").html(_("Holiday exception"));
61
        } else if(holidayType == 'weekday') {
62
            $("#showOperationDelLabel").html(_("Delete this holiday."));
63
            $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
64
        } else if(holidayType == 'daymonth') {
65
            $("#showOperationDelLabel").html(_("Delete this holiday."));
66
            $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
67
        } else {
68
            $("#showOperationDelLabel").html(_("Delete this holiday."));
69
            $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
70
        }
71
        
72
        if (exceptionPosibility == 1) {
73
            $("#exceptionPosibility").parent().show();
74
        } else {
75
            $("#exceptionPosibility").parent().hide();
76
        }
77
    }
78
79
    // This function shows the "Add Holiday" panel //
80
    function newHoliday (dayName, day, month, year, weekDay) {
81
        $("#showHoliday").slideUp("fast");
82
        $("#newHoliday").slideDown("fast");
83
        $("#newDaynameOutput").html(dayName);
84
        $("#newDayname").val(dayName);
85
        $("#newBranchNameOutput").html($('#branch :selected').text());
86
        $("#newBranchName").val($('#branch').val());
87
        $("#newDayOutput").html(day);
88
        $("#newDay").val(day);
89
        $("#newMonthOutput").html(month);
90
        $("#newMonth").val(month);
91
        $("#newYearOutput").html(year);
92
        $("#newYear").val(year);
93
        $("#newWeekday:first").val(weekDay);
94
    }
95
96
    function hidePanel(aPanelName) {
97
        $("#"+aPanelName).slideUp("fast");
98
    }
99
100
    function changeBranch () {
101
        var branch = $("#branch option:selected").val();
102
        location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate %]";
103
    }
104
105
    function Help() {
106
        newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
107
    }
108
109
    /* This function gives css clases to each kind of day */
110
    function dateStatusHandler(date) {
111
        date = new Date(date);
112
        var day = date.getDate();
113
        var month = date.getMonth() + 1;
114
        var year = date.getFullYear();
115
        var weekDay = date.getDay();
116
        var dayMonth = month + '/' + day;
117
        var dateString = year + '/' + month + '/' + day;
118
        if (exception_holidays[dateString] != null) {
119
            return [true, "exception", _("Exception: %s").format(exception_holidays[dateString].title)];
120
        } else if ( week_days[weekDay] != null ){
121
            return [true, "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)];
122
        } else if ( day_month_holidays[dayMonth] != null ) {
123
            return [true, "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)];
124
        } else if (holidays[dateString] != null) {
125
            return [true, "holiday", _("Single holiday: %s").format(holidays[dateString].title)];
126
        } else {
127
            return [true, "normalday", _("Normal day")];
128
        }
129
    }
130
131
    /* This function is in charge of showing the correct panel considering the kind of holiday */
132
    function dateChanged(calendar) {
133
        calendar = new Date(calendar);
134
        var day = calendar.getDate();
135
        var month = calendar.getMonth() + 1;
136
        var year = calendar.getFullYear();
137
        var weekDay = calendar.getDay();
138
        var dayName = weekdays[weekDay];
139
        var dayMonth = month + '/' + day;
140
        var dateString = year + '/' + month + '/' + day;
141
            if (holidays[dateString] != null) {
142
                showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,     holidays[dateString].description, 'ymd');
143
            } else if (exception_holidays[dateString] != null) {
144
                showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
145
            } else if (week_days[weekDay] != null) {
146
                showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,     week_days[weekDay].description, 'weekday');
147
            } else if (day_month_holidays[dayMonth] != null) {
148
                showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
149
            } else {
150
                newHoliday(dayName, day, month, year, weekDay);
151
            }
152
    };
153
154
    $(document).ready(function() {
155
156
        $(".hint").hide();
157
        $("#branch").change(function(){
158
            changeBranch();
159
        });
160
        $("#holidayweeklyrepeatable>tbody>tr").each(function(){
161
            var first_td = $(this).find('td').first();
162
            first_td.html(weekdays[first_td.html()]);
163
        });
164
        $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
165
            "sDom": 't',
166
            "bPaginate": false
167
        }));
168
        $("#holidayexceptions,#holidaysyearlyrepeatable,#holidaysunique").dataTable($.extend(true, {}, dataTablesDefaults, {
169
            "sDom": 't',
170
            "aoColumns": [
171
                { "sType": "title-string" },null,null
172
            ],
173
            "bPaginate": false
174
        }));
175
        $("a.helptext").click(function(){
176
            $(this).parent().find(".hint").toggle(); return false;
177
        });
178
        $("#dateofrange").datepicker();
179
        $("#datecancelrange").datepicker();
180
        $("#dateofrange").each(function () { this.value = "" });
181
        $("#datecancelrange").each(function () { this.value = "" });
182
        $("#jcalendar-container").datepicker({
183
          beforeShowDay: function(thedate) {
184
            var day = thedate.getDate();
185
            var month = thedate.getMonth() + 1;
186
            var year = thedate.getFullYear();
187
            var dateString = year + '/' + month + '/' + day;
188
            return dateStatusHandler(dateString);
189
            },
190
        onSelect: function(dateText, inst) {
191
            dateChanged($(this).datepicker("getDate"));
192
        },
193
        defaultDate: new Date("[% keydate %]")
194
        });
195
        $(".hidePanel").on("click",function(){
196
            if( $(this).hasClass("showHoliday") ){
197
                hidePanel("showHoliday");
198
            } else {
199
                hidePanel("newHoliday");
200
            }
201
        })
202
    });
203
//]]>
204
</script>
205
<style type="text/css"> .key { padding : 3px; white-space:nowrap; line-height:230%; }
7
<style type="text/css"> .key { padding : 3px; white-space:nowrap; line-height:230%; }
206
.ui-datepicker { font-size : 150%; }
8
.ui-datepicker { font-size : 150%; }
207
.ui-datepicker th, .ui-datepicker .ui-datepicker-title select { font-size : 80%; }
9
.ui-datepicker th, .ui-datepicker .ui-datepicker-title select { font-size : 80%; }
Lines 534-537 td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl Link Here
534
[% INCLUDE 'tools-menu.inc' %]
336
[% INCLUDE 'tools-menu.inc' %]
535
</div>
337
</div>
536
</div>
338
</div>
339
340
[% MACRO jsinclude BLOCK %]
341
    [% INCLUDE 'calendar.inc' %]
342
    [% INCLUDE 'datatables.inc' %]
343
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
344
    <script type="text/javascript">
345
        var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
346
347
        /* Creates all the structures to deal with all different kinds of holidays */
348
        var week_days = new Array();
349
        var holidays = new Array();
350
        var holidates = new Array();
351
        var exception_holidays = new Array();
352
        var day_month_holidays = new Array();
353
        var hola= "[% code %]";
354
        [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
355
        week_days["[% WEEK_DAYS_LOO.KEY %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
356
        [% END %]
357
        [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
358
        holidates.push("[% HOLIDAYS_LOO.KEY %]");
359
        holidays["[% HOLIDAYS_LOO.KEY %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
360
        [% END %]
361
        [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
362
        exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
363
        [% END %]
364
        [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
365
        day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE | replace('"','\"') |html %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') |html %]"};
366
        [% END %]
367
368
        function holidayOperation(formObject, opType) {
369
            var op = document.getElementsByName('operation');
370
            op[0].value = opType;
371
            formObject.submit();
372
        }
373
374
        // This function shows the "Show Holiday" panel //
375
        function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, holidayType) {
376
            $("#newHoliday").slideUp("fast");
377
            $("#showHoliday").slideDown("fast");
378
            $('#showDaynameOutput').html(dayName);
379
            $('#showDayname').val(dayName);
380
            $('#showBranchNameOutput').html($("#branch :selected").text());
381
            $('#showBranchName').val($("#branch").val());
382
            $('#showDayOutput').html(day);
383
            $('#showDay').val(day);
384
            $('#showMonthOutput').html(month);
385
            $('#showMonth').val(month);
386
            $('#showYearOutput').html(year);
387
            $('#showYear').val(year);
388
            $('#showDescription').val(description);
389
            $('#showWeekday:first').val(weekDay);
390
            $('#showTitle').val(title);
391
            $('#showHolidayType').val(holidayType);
392
393
            if (holidayType == 'exception') {
394
                $("#showOperationDelLabel").html(_("Delete this exception."));
395
                $("#holtype").attr("class","key exception").html(_("Holiday exception"));
396
            } else if(holidayType == 'weekday') {
397
                $("#showOperationDelLabel").html(_("Delete this holiday."));
398
                $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
399
            } else if(holidayType == 'daymonth') {
400
                $("#showOperationDelLabel").html(_("Delete this holiday."));
401
                $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
402
            } else {
403
                $("#showOperationDelLabel").html(_("Delete this holiday."));
404
                $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
405
            }
406
407
            if (exceptionPosibility == 1) {
408
                $("#exceptionPosibility").parent().show();
409
            } else {
410
                $("#exceptionPosibility").parent().hide();
411
            }
412
        }
413
414
        // This function shows the "Add Holiday" panel //
415
        function newHoliday (dayName, day, month, year, weekDay) {
416
            $("#showHoliday").slideUp("fast");
417
            $("#newHoliday").slideDown("fast");
418
            $("#newDaynameOutput").html(dayName);
419
            $("#newDayname").val(dayName);
420
            $("#newBranchNameOutput").html($('#branch :selected').text());
421
            $("#newBranchName").val($('#branch').val());
422
            $("#newDayOutput").html(day);
423
            $("#newDay").val(day);
424
            $("#newMonthOutput").html(month);
425
            $("#newMonth").val(month);
426
            $("#newYearOutput").html(year);
427
            $("#newYear").val(year);
428
            $("#newWeekday:first").val(weekDay);
429
        }
430
431
        function hidePanel(aPanelName) {
432
            $("#"+aPanelName).slideUp("fast");
433
        }
434
435
        function changeBranch () {
436
            var branch = $("#branch option:selected").val();
437
            location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate %]";
438
        }
439
440
        function Help() {
441
            newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
442
        }
443
444
        /* This function gives css clases to each kind of day */
445
        function dateStatusHandler(date) {
446
            date = new Date(date);
447
            var day = date.getDate();
448
            var month = date.getMonth() + 1;
449
            var year = date.getFullYear();
450
            var weekDay = date.getDay();
451
            var dayMonth = month + '/' + day;
452
            var dateString = year + '/' + month + '/' + day;
453
            if (exception_holidays[dateString] != null) {
454
                return [true, "exception", _("Exception: %s").format(exception_holidays[dateString].title)];
455
            } else if ( week_days[weekDay] != null ){
456
                return [true, "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)];
457
            } else if ( day_month_holidays[dayMonth] != null ) {
458
                return [true, "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)];
459
            } else if (holidays[dateString] != null) {
460
                return [true, "holiday", _("Single holiday: %s").format(holidays[dateString].title)];
461
            } else {
462
                return [true, "normalday", _("Normal day")];
463
            }
464
        }
465
466
        /* This function is in charge of showing the correct panel considering the kind of holiday */
467
        function dateChanged(calendar) {
468
            calendar = new Date(calendar);
469
            var day = calendar.getDate();
470
            var month = calendar.getMonth() + 1;
471
            var year = calendar.getFullYear();
472
            var weekDay = calendar.getDay();
473
            var dayName = weekdays[weekDay];
474
            var dayMonth = month + '/' + day;
475
            var dateString = year + '/' + month + '/' + day;
476
                if (holidays[dateString] != null) {
477
                    showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,     holidays[dateString].description, 'ymd');
478
                } else if (exception_holidays[dateString] != null) {
479
                    showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
480
                } else if (week_days[weekDay] != null) {
481
                    showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,     week_days[weekDay].description, 'weekday');
482
                } else if (day_month_holidays[dayMonth] != null) {
483
                    showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
484
                } else {
485
                    newHoliday(dayName, day, month, year, weekDay);
486
                }
487
        };
488
489
        $(document).ready(function() {
490
491
            $(".hint").hide();
492
            $("#branch").change(function(){
493
                changeBranch();
494
            });
495
            $("#holidayweeklyrepeatable>tbody>tr").each(function(){
496
                var first_td = $(this).find('td').first();
497
                first_td.html(weekdays[first_td.html()]);
498
            });
499
            $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
500
                "sDom": 't',
501
                "bPaginate": false
502
            }));
503
            $("#holidayexceptions,#holidaysyearlyrepeatable,#holidaysunique").dataTable($.extend(true, {}, dataTablesDefaults, {
504
                "sDom": 't',
505
                "aoColumns": [
506
                    { "sType": "title-string" },null,null
507
                ],
508
                "bPaginate": false
509
            }));
510
            $("a.helptext").click(function(){
511
                $(this).parent().find(".hint").toggle(); return false;
512
            });
513
            $("#dateofrange").datepicker();
514
            $("#datecancelrange").datepicker();
515
            $("#dateofrange").each(function () { this.value = "" });
516
            $("#datecancelrange").each(function () { this.value = "" });
517
            $("#jcalendar-container").datepicker({
518
              beforeShowDay: function(thedate) {
519
                var day = thedate.getDate();
520
                var month = thedate.getMonth() + 1;
521
                var year = thedate.getFullYear();
522
                var dateString = year + '/' + month + '/' + day;
523
                return dateStatusHandler(dateString);
524
                },
525
            onSelect: function(dateText, inst) {
526
                dateChanged($(this).datepicker("getDate"));
527
            },
528
            defaultDate: new Date("[% keydate %]")
529
            });
530
            $(".hidePanel").on("click",function(){
531
                if( $(this).hasClass("showHoliday") ){
532
                    hidePanel("showHoliday");
533
                } else {
534
                    hidePanel("newHoliday");
535
                }
536
            })
537
        });
538
    </script>
539
[% END %]
540
537
[% INCLUDE 'intranet-bottom.inc' %]
541
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt (-64 / +70 lines)
Lines 1-76 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; News</title>
5
<title>Koha &rsaquo; Tools &rsaquo; News</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
7
[% IF ( opac_news_count ) %]
7
[% IF ( opac_news_count ) %]
8
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
8
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
9
    [% INCLUDE 'datatables.inc' %]
10
    <script type="text/javascript">//<![CDATA[
11
    $(document).ready(function() {
12
        $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
13
            "aoColumnDefs": [
14
                { "aTargets": [ 0,-1,-2 ], "bSortable": false },
15
                { "aTargets": [ 0, -1 ], "bSearchable": false },
16
                { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
17
            ],
18
            "sPaginationType": "full_numbers"
19
        }));
20
        $(".delete_news").on("click", function(){
21
            return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
22
        });
23
24
        function Checkbox(){
25
            var form = document.getElementById('del_form');
26
            var inputs = form.getElementsByTagName('input');
27
            var checked = false;
28
            for (var i=0; i<inputs.length; i++) {
29
                if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
30
                    checked = inputs[i].checked;
31
                    if (checked) return true;
32
                }
33
            }
34
        }
35
36
        $("#del_form").on("submit",function(){
37
            if ( Checkbox() ) {
38
                return confirmDelete( _("Are you sure you want to delete the selected news?") );
39
            } else {
40
                alert(_("Please select a news item to delete."));
41
                return false;
42
            }
43
        });
44
    });
45
    //]]>
46
    </script>
47
[% END %]
9
[% END %]
48
<script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
49
<script type="text/javascript">//<![CDATA[
50
tinyMCE.init({
51
    mode : "textareas",
52
    theme : "advanced",
53
    convert_urls : false,
54
    relative_urls : false,
55
    content_css : "[% interface %]/[% theme %]/css/tinymce.css",
56
    plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
57
    theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
58
    theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
59
    theme_advanced_buttons3 : "",
60
    theme_advanced_toolbar_location : "top",
61
    theme_advanced_toolbar_align : "left",
62
    theme_advanced_path_location : "bottom",
63
    theme_advanced_resizing : true,
64
    plugin_insertdate_dateFormat : "%Y-%m-%d",
65
    plugin_insertdate_timeFormat : "%H:%M:%S",
66
    apply_source_formatting : true,
67
    height : "300",
68
    width : "700"
69
//]]>
70
});
71
//]]>
72
</script>
73
</head>
10
</head>
11
74
<body id="tools_koha-news" class="tools">
12
<body id="tools_koha-news" class="tools">
75
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'header.inc' %]
76
[% INCLUDE 'cat-search.inc' %]
14
[% INCLUDE 'cat-search.inc' %]
Lines 278-281 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
278
    </div>
216
    </div>
279
[% END %]
217
[% END %]
280
</div>
218
</div>
219
220
[% MACRO jsinclude BLOCK %]
221
    [% INCLUDE 'calendar.inc' %]
222
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
223
    [% IF ( opac_news_count ) %]
224
        [% INCLUDE 'datatables.inc' %]
225
        <script type="text/javascript">
226
            $(document).ready(function() {
227
                $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
228
                    "aoColumnDefs": [
229
                        { "aTargets": [ 0,-1,-2 ], "bSortable": false },
230
                        { "aTargets": [ 0, -1 ], "bSearchable": false },
231
                        { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
232
                    ],
233
                    "sPaginationType": "full_numbers"
234
                }));
235
                $(".delete_news").on("click", function(){
236
                    return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
237
                });
238
239
                function Checkbox(){
240
                    var form = document.getElementById('del_form');
241
                    var inputs = form.getElementsByTagName('input');
242
                    var checked = false;
243
                    for (var i=0; i<inputs.length; i++) {
244
                        if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
245
                            checked = inputs[i].checked;
246
                            if (checked) return true;
247
                        }
248
                    }
249
                }
250
251
                $("#del_form").on("submit",function(){
252
                    if ( Checkbox() ) {
253
                        return confirmDelete( _("Are you sure you want to delete the selected news?") );
254
                    } else {
255
                        alert(_("Please select a news item to delete."));
256
                        return false;
257
                    }
258
                });
259
            });
260
        </script>
261
    [% END %]
262
    <script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
263
    <script type="text/javascript">
264
        tinyMCE.init({
265
            mode : "textareas",
266
            theme : "advanced",
267
            convert_urls : false,
268
            relative_urls : false,
269
            content_css : "[% interface %]/[% theme %]/css/tinymce.css",
270
            plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
271
            theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
272
            theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
273
            theme_advanced_buttons3 : "",
274
            theme_advanced_toolbar_location : "top",
275
            theme_advanced_toolbar_align : "left",
276
            theme_advanced_path_location : "bottom",
277
            theme_advanced_resizing : true,
278
            plugin_insertdate_dateFormat : "%Y-%m-%d",
279
            plugin_insertdate_timeFormat : "%H:%M:%S",
280
            apply_source_formatting : true,
281
            height : "300",
282
            width : "700"
283
        });
284
    </script>
285
[% END %]
286
281
[% INCLUDE 'intranet-bottom.inc' %]
287
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt (-301 / +301 lines)
Lines 1-311 Link Here
1
[% SET footerjs = 1 %]
1
    [% INCLUDE 'doc-head-open.inc' %]
2
    [% INCLUDE 'doc-head-open.inc' %]
2
    <title>Koha &rsaquo; Tools &rsaquo; Quote uploader</title>
3
    <title>Koha &rsaquo; Tools &rsaquo; Quote uploader</title>
3
    [% INCLUDE 'doc-head-close.inc' %]
4
    [% INCLUDE 'doc-head-close.inc' %]
4
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/uploader.css" />
5
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/uploader.css" />
5
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/quotes.css" />
6
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/quotes.css" />
6
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7
    [% INCLUDE 'datatables.inc' %]
8
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini.js"></script>
9
    <script type="text/javascript">
10
    //<![CDATA[
11
    var oTable; //DataTable object
12
    $(document).ready(function() {
13
14
        $("#cancel_upload").on("click",function(e){
15
            e.preventDefault();
16
            fnAbortRead();
17
        });
18
        $("#cancel_quotes").on("click",function(){
19
            return confirm( _("Are you sure you want to cancel this import?") );
20
        });
21
22
    // Credits:
23
    // FileReader() code copied and hacked from:
24
    // http://www.html5rocks.com/en/tutorials/file/dndfiles/
25
    // fnCSVToArray() gratefully borrowed from:
26
    // http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm
27
28
    var reader;
29
    var progress = document.querySelector('.percent');
30
    $("#server_response").hide();
31
32
    function yuiGetData() {
33
        fnGetData(document.getElementById('quotes_editor'));
34
    }
35
36
    function fnAbortRead() {
37
        reader.abort();
38
    }
39
40
    function fnErrorHandler(evt) {
41
        switch(evt.target.error.code) {
42
            case evt.target.error.NOT_FOUND_ERR:
43
                alert('File Not Found!');
44
                break;
45
            case evt.target.error.NOT_READABLE_ERR:
46
                alert('File is not readable');
47
                break;
48
            case evt.target.error.ABORT_ERR:
49
                break; // noop
50
            default:
51
                alert('An error occurred reading this file.');
52
        };
53
    }
54
55
    function fnUpdateProgress(evt) {
56
        // evt is an ProgressEvent.
57
        if (evt.lengthComputable) {
58
            var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
59
            // Increase the progress bar length.
60
            if (percentLoaded < 100) {
61
                progress.style.width = percentLoaded + '%';
62
                progress.textContent = percentLoaded + '%';
63
            }
64
        }
65
    }
66
67
    function fnCSVToArray( strData, strDelimiter ){
68
        // This will parse a delimited string into an array of
69
        // arrays. The default delimiter is the comma, but this
70
        // can be overriden in the second argument.
71
72
        // Check to see if the delimiter is defined. If not,
73
        // then default to comma.
74
        strDelimiter = (strDelimiter || ",");
75
76
        // Create a regular expression to parse the CSV values.
77
        var objPattern = new RegExp(
78
        (
79
            // Delimiters.
80
            "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +
81
            // Quoted fields.
82
            "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +
83
            // Standard fields.
84
            "([^\"\\" + strDelimiter + "\\r\\n]*))"
85
        ),
86
            "gi"
87
        );
88
89
        // Create an array to hold our data. Give the array
90
        // a default empty first row.
91
        var arrData = [[]];
92
93
        // Create an array to hold our individual pattern
94
        // matching groups.
95
        var arrMatches = null;
96
97
        // Keep looping over the regular expression matches
98
        // until we can no longer find a match.
99
        while (arrMatches = objPattern.exec( strData )){
100
101
            // Get the delimiter that was found.
102
            var strMatchedDelimiter = arrMatches[ 1 ];
103
104
            // Check to see if the given delimiter has a length
105
            // (is not the start of string) and if it matches
106
            // field delimiter. If it does not, then we know
107
            // that this delimiter is a row delimiter.
108
            if ( strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter) ){
109
                // Since we have reached a new row of data,
110
                // add an empty row to our data array.
111
                // Note: if there is not more data, we will have to remove this row later
112
                arrData.push( [] );
113
            }
114
115
            // Now that we have our delimiter out of the way,
116
            // let's check to see which kind of value we
117
            // captured (quoted or unquoted).
118
            if (arrMatches[ 2 ]){
119
                // We found a quoted value. When we capture
120
                // this value, unescape any double quotes.
121
                var strMatchedValue = arrMatches[ 2 ].replace(
122
                new RegExp( "\"\"", "g" ),
123
                    "\""
124
                );
125
            } else if (arrMatches[3]){
126
                // We found a non-quoted value.
127
                var strMatchedValue = arrMatches[ 3 ];
128
            } else {
129
                // There is no more valid data so remove the row we added earlier
130
                // Is there a better way? Perhaps a look-ahead regexp?
131
                arrData.splice(arrData.length-1, 1);
132
            }
133
134
            // Now that we have our value string, let's add
135
            // it to the data array.
136
            arrData[ arrData.length - 1 ].push( strMatchedValue );
137
        }
138
139
        // Return the parsed data.
140
        return( arrData );
141
    }
142
143
    function fnDataTable(aaData) {
144
        for(var i=0; i<aaData.length; i++) {
145
            aaData[i].unshift(i+1); // Add a column w/quote number
146
        }
147
148
149
        /* Transition from the quote file uploader to the quote file editor interface */
150
        $('#toolbar').css("visibility","visible");
151
        $('#toolbar').css("position","");
152
        $('#file_editor_inst').css("visibility", "visible");
153
        $('#file_editor_inst').css("position", "");
154
        $('#file_uploader_inst').css("visibility", "hidden");
155
        $('#save_quotes').css("visibility","visible");
156
        $('#file_uploader').css("visibility","hidden");
157
        $('#file_uploader').css("position","absolute");
158
        $('#file_uploader').css("top","-150px");
159
        $('#quotes_editor').css("visibility","visible");
160
        $("#save_quotes").on("click", yuiGetData);
161
        $("#delete_quote").on("click", fnClickDeleteRow);
162
163
164
165
        oTable = $('#quotes_editor').dataTable( {
166
            "bAutoWidth"        : false,
167
            "bPaginate"         : true,
168
            "bSort"             : false,
169
            "sPaginationType"   : "full_numbers",
170
            "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
171
            "aaData"            : aaData,
172
            "aoColumns"         : [
173
                {
174
                    "sTitle"  : "Number",
175
                    "sWidth"  : "2%",
176
                },
177
                {
178
                    "sTitle"  : "Source",
179
                    "sWidth"  : "15%",
180
                },
181
                {
182
                    "sTitle"  : "Quote",
183
                    "sWidth"  : "83%",
184
                },
185
            ],
186
           "fnPreDrawCallback": function(oSettings) {
187
                return true;
188
            },
189
            "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
190
                /* do foo on various cells in the current row */
191
                var quoteNum = $('td', nRow)[0].innerHTML;
192
                $(nRow).attr("id", quoteNum); /* set row ids to quote number */
193
                $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
194
                $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
195
                /* apply no_edit id to noEditFields */
196
                noEditFields = [0]; /* number */
197
                for (i=0; i<noEditFields.length; i++) {
198
                    $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
199
                }
200
                return nRow;
201
            },
202
           "fnDrawCallback": function(oSettings) {
203
                /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
204
                $('#quotes_editor tbody td[id!="no_edit"]').editable( function(value, settings) {
205
                        var cellPosition = oTable.fnGetPosition( this );
206
                        oTable.fnUpdate(value, cellPosition[0], cellPosition[1], false, false);
207
                        return(value);
208
                    },
209
                    {
210
                    "callback"      : function( sValue, y ) {
211
                                          oTable.fnDraw(false); /* no filter/sort or we lose our pagination */
212
                                      },
213
                    "height"        : "14px",
214
                });
215
           },
216
        });
217
        $('#footer').css("visibility","visible");
218
    }
219
220
    function fnHandleFileSelect(evt) {
221
        // Reset progress indicator on new file selection.
222
        progress.style.width = '0%';
223
        progress.textContent = '0%';
224
225
        reader = new FileReader();
226
        reader.onerror = fnErrorHandler;
227
        reader.onprogress = fnUpdateProgress;
228
        reader.onabort = function(e) {
229
            alert('File read cancelled');
230
            parent.location='quotes-upload.pl';
231
        };
232
        reader.onloadstart = function(e) {
233
            $('#cancel_upload').show();
234
            $('#progress_bar').addClass("loading");
235
        };
236
        reader.onload = function(e) {
237
            // Ensure that the progress bar displays 100% at the end.
238
            progress.style.width = '100%';
239
            progress.textContent = '100%';
240
            $('#cancel_upload').hide();
241
            quotes = fnCSVToArray(e.target.result, ',');
242
            fnDataTable(quotes);
243
        }
244
245
        // perform various sanity checks on the target file prior to uploading...
246
        var fileType = evt.target.files[0].type || 'unknown';
247
        var fileSizeInK = Math.round(evt.target.files[0].size/1024);
248
249
        if (!fileType.match(/comma-separated-values|csv|excel|calc/i)) {
250
            alert(_("Uploads limited to csv. Incorrect filetype: %s").format(fileType));
251
            parent.location='quotes-upload.pl';
252
            return;
253
        }
254
        if (fileSizeInK > 512) {
255
            if (!confirm(_("%s %s KB Do you really want to upload this file?").format(evt.target.files[0].name, fileSizeInK))) {
256
                parent.location='quotes-upload.pl';
257
                return;
258
            }
259
        }
260
        // Read in the image file as a text string.
261
        reader.readAsText(evt.target.files[0]);
262
    }
263
264
    $('#file_upload').one('change', fnHandleFileSelect);
265
266
    });
267
268
    function fnGetData(element) {
269
        var jqXHR = $.ajax({
270
            url         : "/cgi-bin/koha/tools/quotes/quotes-upload_ajax.pl",
271
            type        : "POST",
272
            contentType : "application/x-www-form-urlencoded", // we must claim this mimetype or CGI will not decode the URL encoding
273
            dataType    : "json",
274
            data        : {
275
                            "quote"     : encodeURI ( JSON.stringify(oTable.fnGetData()) ),
276
                            "action"    : "add",
277
                          },
278
            success     : function(){
279
                            var response = JSON.parse(jqXHR.responseText);
280
                            if (response.success) {
281
                                alert(_("%s quotes saved.").format(response.records));
282
                                window.location.reload(true);   // is this the best route?
283
                            }
284
                            else {
285
                                alert(_("%s quotes saved, but an error has occurred. Please ask your administrator to check the server log for more details.").format(response.records));
286
                                window.location.reload(true);   // is this the best route?
287
                            }
288
                          },
289
        });
290
    }
291
292
    function fnClickDeleteRow() {
293
        var idsToDelete = oTable.$('.selected').map(function() {
294
              return this.id;
295
        }).get().join(', ');
296
        if (!idsToDelete) {
297
            alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
298
        }
299
        else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
300
            oTable.$('.selected').each(function(){
301
                oTable.fnDeleteRow(this);
302
            });
303
        }
304
    }
305
306
    //]]>
307
    </script>
308
</head>
8
</head>
9
309
<body id="tools_quotes" class="tools">
10
<body id="tools_quotes" class="tools">
310
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'header.inc' %]
311
[% INCLUDE 'cat-search.inc' %]
12
[% INCLUDE 'cat-search.inc' %]
Lines 370-373 Link Here
370
        [% INCLUDE 'tools-menu.inc' %]
71
        [% INCLUDE 'tools-menu.inc' %]
371
    </div>
72
    </div>
372
</div>
73
</div>
74
75
[% MACRO jsinclude BLOCK %]
76
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
77
    [% INCLUDE 'datatables.inc' %]
78
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini.js"></script>
79
    <script type="text/javascript">
80
        var oTable; //DataTable object
81
        $(document).ready(function() {
82
83
            $("#cancel_upload").on("click",function(e){
84
                e.preventDefault();
85
                fnAbortRead();
86
            });
87
            $("#cancel_quotes").on("click",function(){
88
                return confirm( _("Are you sure you want to cancel this import?") );
89
            });
90
91
        // Credits:
92
        // FileReader() code copied and hacked from:
93
        // http://www.html5rocks.com/en/tutorials/file/dndfiles/
94
        // fnCSVToArray() gratefully borrowed from:
95
        // http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm
96
97
        var reader;
98
        var progress = document.querySelector('.percent');
99
        $("#server_response").hide();
100
101
        function yuiGetData() {
102
            fnGetData(document.getElementById('quotes_editor'));
103
        }
104
105
        function fnAbortRead() {
106
            reader.abort();
107
        }
108
109
        function fnErrorHandler(evt) {
110
            switch(evt.target.error.code) {
111
                case evt.target.error.NOT_FOUND_ERR:
112
                    alert('File Not Found!');
113
                    break;
114
                case evt.target.error.NOT_READABLE_ERR:
115
                    alert('File is not readable');
116
                    break;
117
                case evt.target.error.ABORT_ERR:
118
                    break; // noop
119
                default:
120
                    alert('An error occurred reading this file.');
121
            };
122
        }
123
124
        function fnUpdateProgress(evt) {
125
            // evt is an ProgressEvent.
126
            if (evt.lengthComputable) {
127
                var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
128
                // Increase the progress bar length.
129
                if (percentLoaded < 100) {
130
                    progress.style.width = percentLoaded + '%';
131
                    progress.textContent = percentLoaded + '%';
132
                }
133
            }
134
        }
135
136
        function fnCSVToArray( strData, strDelimiter ){
137
            // This will parse a delimited string into an array of
138
            // arrays. The default delimiter is the comma, but this
139
            // can be overriden in the second argument.
140
141
            // Check to see if the delimiter is defined. If not,
142
            // then default to comma.
143
            strDelimiter = (strDelimiter || ",");
144
145
            // Create a regular expression to parse the CSV values.
146
            var objPattern = new RegExp(
147
            (
148
                // Delimiters.
149
                "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +
150
                // Quoted fields.
151
                "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +
152
                // Standard fields.
153
                "([^\"\\" + strDelimiter + "\\r\\n]*))"
154
            ),
155
                "gi"
156
            );
157
158
            // Create an array to hold our data. Give the array
159
            // a default empty first row.
160
            var arrData = [[]];
161
162
            // Create an array to hold our individual pattern
163
            // matching groups.
164
            var arrMatches = null;
165
166
            // Keep looping over the regular expression matches
167
            // until we can no longer find a match.
168
            while (arrMatches = objPattern.exec( strData )){
169
170
                // Get the delimiter that was found.
171
                var strMatchedDelimiter = arrMatches[ 1 ];
172
173
                // Check to see if the given delimiter has a length
174
                // (is not the start of string) and if it matches
175
                // field delimiter. If it does not, then we know
176
                // that this delimiter is a row delimiter.
177
                if ( strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter) ){
178
                    // Since we have reached a new row of data,
179
                    // add an empty row to our data array.
180
                    // Note: if there is not more data, we will have to remove this row later
181
                    arrData.push( [] );
182
                }
183
184
                // Now that we have our delimiter out of the way,
185
                // let's check to see which kind of value we
186
                // captured (quoted or unquoted).
187
                if (arrMatches[ 2 ]){
188
                    // We found a quoted value. When we capture
189
                    // this value, unescape any double quotes.
190
                    var strMatchedValue = arrMatches[ 2 ].replace(
191
                    new RegExp( "\"\"", "g" ),
192
                        "\""
193
                    );
194
                } else if (arrMatches[3]){
195
                    // We found a non-quoted value.
196
                    var strMatchedValue = arrMatches[ 3 ];
197
                } else {
198
                    // There is no more valid data so remove the row we added earlier
199
                    // Is there a better way? Perhaps a look-ahead regexp?
200
                    arrData.splice(arrData.length-1, 1);
201
                }
202
203
                // Now that we have our value string, let's add
204
                // it to the data array.
205
                arrData[ arrData.length - 1 ].push( strMatchedValue );
206
            }
207
208
            // Return the parsed data.
209
            return( arrData );
210
        }
211
212
        function fnDataTable(aaData) {
213
            for(var i=0; i<aaData.length; i++) {
214
                aaData[i].unshift(i+1); // Add a column w/quote number
215
            }
216
217
            /* Transition from the quote file uploader to the quote file editor interface */
218
            $('#toolbar').css("visibility","visible");
219
            $('#toolbar').css("position","");
220
            $('#file_editor_inst').css("visibility", "visible");
221
            $('#file_editor_inst').css("position", "");
222
            $('#file_uploader_inst').css("visibility", "hidden");
223
            $('#save_quotes').css("visibility","visible");
224
            $('#file_uploader').css("visibility","hidden");
225
            $('#file_uploader').css("position","absolute");
226
            $('#file_uploader').css("top","-150px");
227
            $('#quotes_editor').css("visibility","visible");
228
            $("#save_quotes").on("click", yuiGetData);
229
            $("#delete_quote").on("click", fnClickDeleteRow);
230
231
            oTable = $('#quotes_editor').dataTable( {
232
                "bAutoWidth"        : false,
233
                "bPaginate"         : true,
234
                "bSort"             : false,
235
                "sPaginationType"   : "full_numbers",
236
                "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
237
                "aaData"            : aaData,
238
                "aoColumns"         : [
239
                    {
240
                        "sTitle"  : "Number",
241
                        "sWidth"  : "2%",
242
                    },
243
                    {
244
                        "sTitle"  : "Source",
245
                        "sWidth"  : "15%",
246
                    },
247
                    {
248
                        "sTitle"  : "Quote",
249
                        "sWidth"  : "83%",
250
                    },
251
                ],
252
               "fnPreDrawCallback": function(oSettings) {
253
                    return true;
254
                },
255
                "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
256
                    /* do foo on various cells in the current row */
257
                    var quoteNum = $('td', nRow)[0].innerHTML;
258
                    $(nRow).attr("id", quoteNum); /* set row ids to quote number */
259
                    $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
260
                    $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
261
                    /* apply no_edit id to noEditFields */
262
                    noEditFields = [0]; /* number */
263
                    for (i=0; i<noEditFields.length; i++) {
264
                        $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
265
                    }
266
                    return nRow;
267
                },
268
               "fnDrawCallback": function(oSettings) {
269
                    /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
270
                    $('#quotes_editor tbody td[id!="no_edit"]').editable( function(value, settings) {
271
                            var cellPosition = oTable.fnGetPosition( this );
272
                            oTable.fnUpdate(value, cellPosition[0], cellPosition[1], false, false);
273
                            return(value);
274
                        },
275
                        {
276
                        "callback"      : function( sValue, y ) {
277
                                              oTable.fnDraw(false); /* no filter/sort or we lose our pagination */
278
                                          },
279
                        "height"        : "14px",
280
                    });
281
               },
282
            });
283
            $('#footer').css("visibility","visible");
284
        }
285
286
        function fnHandleFileSelect(evt) {
287
            // Reset progress indicator on new file selection.
288
            progress.style.width = '0%';
289
            progress.textContent = '0%';
290
291
            reader = new FileReader();
292
            reader.onerror = fnErrorHandler;
293
            reader.onprogress = fnUpdateProgress;
294
            reader.onabort = function(e) {
295
                alert('File read cancelled');
296
                parent.location='quotes-upload.pl';
297
            };
298
            reader.onloadstart = function(e) {
299
                $('#cancel_upload').show();
300
                $('#progress_bar').addClass("loading");
301
            };
302
            reader.onload = function(e) {
303
                // Ensure that the progress bar displays 100% at the end.
304
                progress.style.width = '100%';
305
                progress.textContent = '100%';
306
                $('#cancel_upload').hide();
307
                quotes = fnCSVToArray(e.target.result, ',');
308
                fnDataTable(quotes);
309
            }
310
311
            // perform various sanity checks on the target file prior to uploading...
312
            var fileType = evt.target.files[0].type || 'unknown';
313
            var fileSizeInK = Math.round(evt.target.files[0].size/1024);
314
315
            if (!fileType.match(/comma-separated-values|csv|excel|calc/i)) {
316
                alert(_("Uploads limited to csv. Incorrect filetype: %s").format(fileType));
317
                parent.location='quotes-upload.pl';
318
                return;
319
            }
320
            if (fileSizeInK > 512) {
321
                if (!confirm(_("%s %s KB Do you really want to upload this file?").format(evt.target.files[0].name, fileSizeInK))) {
322
                    parent.location='quotes-upload.pl';
323
                    return;
324
                }
325
            }
326
            // Read in the image file as a text string.
327
            reader.readAsText(evt.target.files[0]);
328
        }
329
330
        $('#file_upload').one('change', fnHandleFileSelect);
331
332
        });
333
334
        function fnGetData(element) {
335
            var jqXHR = $.ajax({
336
                url         : "/cgi-bin/koha/tools/quotes/quotes-upload_ajax.pl",
337
                type        : "POST",
338
                contentType : "application/x-www-form-urlencoded", // we must claim this mimetype or CGI will not decode the URL encoding
339
                dataType    : "json",
340
                data        : {
341
                                "quote"     : encodeURI ( JSON.stringify(oTable.fnGetData()) ),
342
                                "action"    : "add",
343
                              },
344
                success     : function(){
345
                    var response = JSON.parse(jqXHR.responseText);
346
                    if (response.success) {
347
                        alert(_("%s quotes saved.").format(response.records));
348
                        window.location.reload(true);   // is this the best route?
349
                    } else {
350
                        alert(_("%s quotes saved, but an error has occurred. Please ask your administrator to check the server log for more details.").format(response.records));
351
                        window.location.reload(true);   // is this the best route?
352
                    }
353
                  },
354
            });
355
        }
356
357
        function fnClickDeleteRow() {
358
            var idsToDelete = oTable.$('.selected').map(function() {
359
                  return this.id;
360
            }).get().join(', ');
361
            if (!idsToDelete) {
362
                alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
363
            }
364
            else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
365
                oTable.$('.selected').each(function(){
366
                    oTable.fnDeleteRow(this);
367
                });
368
            }
369
        }
370
    </script>
371
[% END %]
372
373
[% INCLUDE 'intranet-bottom.inc' %]
373
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt (-177 / +175 lines)
Lines 1-99 Link Here
1
[% SET footerjs = 1 %]
1
    [% INCLUDE 'doc-head-open.inc' %]
2
    [% INCLUDE 'doc-head-open.inc' %]
2
    <title>Koha &rsaquo; Tools &rsaquo; Quote editor</title>
3
    <title>Koha &rsaquo; Tools &rsaquo; Quote editor</title>
3
    [% INCLUDE 'doc-head-close.inc' %]
4
    [% INCLUDE 'doc-head-close.inc' %]
4
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/quotes.css" />
5
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/quotes.css" />
5
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7
</head>
8
9
<body id="tools_quotes" class="tools">
10
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'cat-search.inc' %]
12
13
<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; Quote editor</div>
14
15
<div id="doc3" class="yui-t2">
16
    <div id="bd">
17
        <div id="yui-main">
18
            <div class="yui-b">
19
                [% INCLUDE 'quotes-toolbar.inc' %]
20
                <h2>Quote editor</h2>
21
                <div id="instructions">
22
                <fieldset id="quote_editor_help" class="rows">
23
                    <legend>Instructions</legend>
24
                    <div id="quote_editor_inst">
25
                        <ul>
26
                        <li>Click on the 'Add quote' button to add a single quote; Press the &lt;Enter&gt; key to save the quote.<br />
27
                            <b>Note: </b>Both the 'source' and 'text' fields must have content in order for the quote to be saved.</li>
28
                        <li>Click on any field to edit the contents; Press the &lt;Enter&gt; key to save edit.</li>
29
                        <li>Click on one or more quote numbers to select entire quotes for deletion; Click the 'Delete quote(s)' button to delete selected quotes.</li>
30
                        <li>Click the 'Import quotes' button in the toolbar to import a CSV file of quotes.</li>
31
                        </ul>
32
                    </div>
33
                </fieldset>
34
                </div>
35
                <table id="quotes_editor">
36
                <thead>
37
                    <tr>
38
                        <th><span style="cursor: help" id="id_help">ID</span></th>
39
                        <th>Source</th>
40
                        <th>Text</th>
41
                        <th>Last displayed</th>
42
                    </tr>
43
                </thead>
44
                <tbody>
45
                    <!-- tbody content is generated by DataTables -->
46
                    <tr>
47
                        <td></td>
48
                        <td></td>
49
                        <td>Loading data...</td>
50
                        <td></td>
51
                    </tr>
52
                </tbody>
53
                </table>
54
                <fieldset id="footer" class="action">
55
                </fieldset>
56
            </div>
57
        </div>
58
    <div class="yui-b noprint">
59
        [% INCLUDE 'tools-menu.inc' %]
60
    </div>
61
</div>
62
63
[% MACRO jsinclude BLOCK %]
64
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
6
    [% INCLUDE 'datatables.inc' %]
65
    [% INCLUDE 'datatables.inc' %]
7
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.fnReloadAjax.js"></script>
66
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.fnReloadAjax.js"></script>
8
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini.js"></script>
67
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini.js"></script>
9
    <script type="text/javascript">
68
    <script type="text/javascript">
10
    //<![CDATA[
69
        var oTable; /* oTable needs to be global */
11
70
        var sEmptyTable = _("No quotes available. Please use the 'Add quote' button to add a quote."); /* override the default message in datatables.inc */
12
    var oTable; /* oTable needs to be global */
71
        $(document).ready(function() {
13
    var sEmptyTable = _("No quotes available. Please use the 'Add quote' button to add a quote."); /* override the default message in datatables.inc */
72
            /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
14
    $(document).ready(function() {
73
            /* See the datatable docs if you don't understand this difference. */
15
        /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
74
            oTable = $("#quotes_editor").dataTable({
16
        /* See the datatable docs if you don't understand this difference. */
75
                "bAutoWidth"        : false,
17
        oTable = $("#quotes_editor").dataTable({
76
                "bProcessing"       : true,
18
                    "bAutoWidth"        : false,
77
                "bPaginate"         : true,
19
                    "bProcessing"       : true,
78
                "sPaginationType"   : "full_numbers",
20
                    "bPaginate"         : true,
79
                "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
21
                    "sPaginationType"   : "full_numbers",
80
                "sAjaxSource"       : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
22
                    "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
81
                "aoColumns"         : [
23
                    "sAjaxSource"       : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
82
                                        { "sWidth": "3%"  },
24
                    "aoColumns"         : [
83
                                        { "sWidth": "11%" },
25
                                            { "sWidth": "3%"  },
84
                                        { "sWidth": "75%" },
26
                                            { "sWidth": "11%" },
85
                                        { "sWidth": "11%" },
27
                                            { "sWidth": "75%" },
86
                                      ],
28
                                            { "sWidth": "11%" },
87
               "oLanguage"          : {
29
                                          ],
88
                                        "oPaginate": {
30
                   "oLanguage"          : {
89
                                                       "sFirst": MSG_DT_FIRST,
31
                                            "oPaginate": {
90
                                                       "sLast": MSG_DT_LAST,
32
                                                           "sFirst": MSG_DT_FIRST,
91
                                                       "sNext": MSG_DT_NEXT,
33
                                                           "sLast": MSG_DT_LAST,
92
                                                       "sPrevious": MSG_DT_PREVIOUS,
34
                                                           "sNext": MSG_DT_NEXT,
93
                                                     },
35
                                                           "sPrevious": MSG_DT_PREVIOUS,
94
                                        "sEmptyTable": MSG_DT_EMPTY_TABLE,
36
                                                         },
95
                                        "sInfo": MSG_DT_INFO,
37
                                            "sEmptyTable": MSG_DT_EMPTY_TABLE,
96
                                        "sInfoEmpty": MSG_DT_INFO_EMPTY,
38
                                            "sInfo": MSG_DT_INFO,
97
                                        "sInfoFiltered": MSG_DT_INFO_FILTERED,
39
                                            "sInfoEmpty": MSG_DT_INFO_EMPTY,
98
                                        "sLengthMenu": MSG_DT_LENGTH_MENU,
40
                                            "sInfoFiltered": MSG_DT_INFO_FILTERED,
99
                                        "sLoadingRecords": MSG_DT_LOADING_RECORDS,
41
                                            "sLengthMenu": MSG_DT_LENGTH_MENU,
100
                                        "sProcessing": MSG_DT_PROCESSING,
42
                                            "sLoadingRecords": MSG_DT_LOADING_RECORDS,
101
                                        "sSearch": MSG_DT_SEARCH,
43
                                            "sProcessing": MSG_DT_PROCESSING,
102
                                        "sZeroRecords": MSG_DT_ZERO_RECORDS,
44
                                            "sSearch": MSG_DT_SEARCH,
103
                                      },
45
                                            "sZeroRecords": MSG_DT_ZERO_RECORDS,
104
               "fnPreDrawCallback": function(oSettings) {
105
                    return true;
106
                },
107
                "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
108
                    /* do foo on the current row and its child nodes */
109
                    var noEditFields = [];
110
                    var quoteID = $('td', nRow)[0].innerHTML;
111
                    $(nRow).attr("id", quoteID); /* set row ids to quote id */
112
                    $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
113
                    $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
114
                    $('td', nRow).attr("id",quoteID); /* FIXME: this is a bit of a hack */
115
                    if (isNaN(quoteID)) {
116
                        noEditFields = [0,1,2,3]; /* all fields when adding a quote */
117
                    } else {
118
                        noEditFields = [0,3]; /* id, timestamp */
119
                    }
120
                    /* apply no_edit id to noEditFields */
121
                    for (i=0; i<noEditFields.length; i++) {
122
                        $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
123
                    }
124
                    return nRow;
125
                },
126
               "fnDrawCallback": function(oSettings) {
127
                    /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
128
                    $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
129
                        "submitdata"    : function ( value, settings ) {
130
                                              return {
131
                                                  "column"        : oTable.fnGetPosition( this )[2],
132
                                                  "action"        : "edit",
133
                                              };
46
                                          },
134
                                          },
47
                   "fnPreDrawCallback": function(oSettings) {
135
                        "height"        : "14px",
48
                        return true;
136
                        "placeholder"   : "Saving data...",
49
                    },
137
                    });
50
                    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
138
               },
51
                        /* do foo on the current row and its child nodes */
139
            });
52
                        var noEditFields = [];
140
            $("#add_quote").click(function(){
53
                        var quoteID = $('td', nRow)[0].innerHTML;
141
                fnClickAddRow();
54
                        $(nRow).attr("id", quoteID); /* set row ids to quote id */
142
                return false;
55
                        $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
143
            });
56
                        $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
144
            $("#delete_quote").click(function(){
57
                        $('td', nRow).attr("id",quoteID); /* FIXME: this is a bit of a hack */
145
                fnClickDeleteRow();
58
                        if (isNaN(quoteID)) {
146
                return false;
59
                            noEditFields = [0,1,2,3]; /* all fields when adding a quote */
147
            });
60
                        }
148
            $("#id_help").on("click",function(e){
61
                        else {
149
                e.stopPropagation();
62
                            noEditFields = [0,3]; /* id, timestamp */
150
                alert( _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.") );
63
                        }
151
            });
64
                        /* apply no_edit id to noEditFields */
65
                        for (i=0; i<noEditFields.length; i++) {
66
                            $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
67
                        }
68
                        return nRow;
69
                    },
70
                   "fnDrawCallback": function(oSettings) {
71
                        /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
72
                        $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
73
                            "submitdata"    : function ( value, settings ) {
74
                                                  return {
75
                                                      "column"        : oTable.fnGetPosition( this )[2],
76
                                                      "action"        : "edit",
77
                                                  };
78
                                              },
79
                            "height"        : "14px",
80
                            "placeholder"   : "Saving data...",
81
                        });
82
                   },
83
        });
84
        $("#add_quote").click(function(){
85
            fnClickAddRow();
86
            return false;
87
        });
88
        $("#delete_quote").click(function(){
89
            fnClickDeleteRow();
90
            return false;
91
        });
92
        $("#id_help").on("click",function(e){
93
            e.stopPropagation();
94
            alert( _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.") );
95
        });
152
        });
96
    });
97
153
98
        function fnClickAddQuote(e, node) {
154
        function fnClickAddQuote(e, node) {
99
            if (e.charCode) {
155
            if (e.charCode) {
Lines 110-142 Link Here
110
                        url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
166
                        url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
111
                        type: "POST",
167
                        type: "POST",
112
                        data: {
168
                        data: {
113
                                "source"    : quoteSource,
169
                            "source"    : quoteSource,
114
                                "text"      : quoteText,
170
                            "text"      : quoteText,
115
                                "action"    : "add",
171
                            "action"    : "add",
116
                        },
172
                        },
117
                        success: function(data){
173
                        success: function(data){
118
                                    var newQuote = data[0];
174
                            var newQuote = data[0];
119
                                    var aRow = oTable.fnUpdate(
175
                            var aRow = oTable.fnUpdate(
120
                                        newQuote,
176
                                newQuote,
121
                                        node,
177
                                node,
122
                                        undefined,
178
                                undefined,
123
                                        false,
179
                                false,
124
                                        false
180
                                false
125
                                    );
181
                            );
126
                                    oTable.fnPageChange( 'last' );
182
                            oTable.fnPageChange( 'last' );
127
                                    $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
183
                            $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
128
                            }
184
                        }
129
                    });
185
                    });
130
                }
186
                } else {
131
                else {
132
                    alert(_("Please supply both the text and source of the quote before saving."));
187
                    alert(_("Please supply both the text and source of the quote before saving."));
133
                }
188
                }
134
            }
189
            } else if (e.keyCode == 27) {
135
            else if (e.keyCode == 27) {
136
                if (confirm(_("Are you sure you want to cancel adding this quote?"))) {
190
                if (confirm(_("Are you sure you want to cancel adding this quote?"))) {
137
                    oTable.fnDeleteRow(node);
191
                    oTable.fnDeleteRow(node);
138
                }
192
                } else {
139
                else {
140
                    return;
193
                    return;
141
                }
194
                }
142
            }
195
            }
Lines 163-245 Link Here
163
            }).get().join(', ');
216
            }).get().join(', ');
164
            if (!idsToDelete) {
217
            if (!idsToDelete) {
165
                alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
218
                alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
166
            }
219
            } else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
167
            else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
168
                oTable.$('.selected').each(function(){
220
                oTable.$('.selected').each(function(){
169
                        var quoteID = $(this).attr('id');
221
                    var quoteID = $(this).attr('id');
170
                            $.ajax({
222
                    $.ajax({
171
                                url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
223
                        url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
172
                                type: "POST",
224
                        type: "POST",
173
                                data: {
225
                        data: {
174
                                        "id"        : quoteID,
226
                                "id"        : quoteID,
175
                                        "action"    : "delete",
227
                                "action"    : "delete",
176
                                },
228
                        },
177
                                /* Delete the row from the datatable */
229
                        /* Delete the row from the datatable */
178
                                success: function(){
230
                        success: function(){
179
                                    oTable.fnDeleteRow(this);
231
                            oTable.fnDeleteRow(this);
180
                                    oTable.fnReloadAjax(null, null, true);
232
                            oTable.fnReloadAjax(null, null, true);
181
                                }
233
                        }
182
                            });
183
                    });
234
                    });
184
            }
235
                });
185
            else {
236
            } else {
186
                return;
237
                return;
187
            }
238
            }
188
        }
239
        }
189
    //]]>
190
    </script>
240
    </script>
191
</head>
241
[% END %]
192
<body id="tools_quotes" class="tools">
193
[% INCLUDE 'header.inc' %]
194
[% INCLUDE 'cat-search.inc' %]
195
196
<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; Quote editor</div>
197
242
198
<div id="doc3" class="yui-t2">
199
    <div id="bd">
200
        <div id="yui-main">
201
            <div class="yui-b">
202
                [% INCLUDE 'quotes-toolbar.inc' %]
203
                <h2>Quote editor</h2>
204
                <div id="instructions">
205
                <fieldset id="quote_editor_help" class="rows">
206
                    <legend>Instructions</legend>
207
                    <div id="quote_editor_inst">
208
                        <ul>
209
                        <li>Click on the 'Add quote' button to add a single quote; Press the &lt;Enter&gt; key to save the quote.<br />
210
                            <b>Note: </b>Both the 'source' and 'text' fields must have content in order for the quote to be saved.</li>
211
                        <li>Click on any field to edit the contents; Press the &lt;Enter&gt; key to save edit.</li>
212
                        <li>Click on one or more quote numbers to select entire quotes for deletion; Click the 'Delete quote(s)' button to delete selected quotes.</li>
213
                        <li>Click the 'Import quotes' button in the toolbar to import a CSV file of quotes.</li>
214
                        </ul>
215
                    </div>
216
                </fieldset>
217
                </div>
218
                <table id="quotes_editor">
219
                <thead>
220
                    <tr>
221
                        <th><span style="cursor: help" id="id_help">ID</span></th>
222
                        <th>Source</th>
223
                        <th>Text</th>
224
                        <th>Last displayed</th>
225
                    </tr>
226
                </thead>
227
                <tbody>
228
                    <!-- tbody content is generated by DataTables -->
229
                    <tr>
230
                        <td></td>
231
                        <td></td>
232
                        <td>Loading data...</td>
233
                        <td></td>
234
                    </tr>
235
                </tbody>
236
                </table>
237
                <fieldset id="footer" class="action">
238
                </fieldset>
239
            </div>
240
        </div>
241
    <div class="yui-b noprint">
242
        [% INCLUDE 'tools-menu.inc' %]
243
    </div>
244
</div>
245
[% INCLUDE 'intranet-bottom.inc' %]
243
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt (-8 / +13 lines)
Lines 1-15 Link Here
1
[% SET footerjs = 1 %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Task scheduler</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Task scheduler</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script type="text/JavaScript">
6
//<![CDATA[
7
    $(document).ready(function(){
8
        $("#startdate").datepicker({ minDate: "+0D" });
9
    });
10
//]]>
11
</script>
12
</head>
5
</head>
6
13
<body id="tools_scheduler" class="tools">
7
<body id="tools_scheduler" class="tools">
14
[% INCLUDE 'header.inc' %]
8
[% INCLUDE 'header.inc' %]
15
[% INCLUDE 'circ-search.inc' %]
9
[% INCLUDE 'circ-search.inc' %]
Lines 95-98 Link Here
95
[% INCLUDE 'guided-reports-view.inc' %]
89
[% INCLUDE 'guided-reports-view.inc' %]
96
</div>
90
</div>
97
</div>
91
</div>
92
93
[% MACRO jsinclude BLOCK %]
94
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
95
    [% INCLUDE 'calendar.inc' %]
96
    <script type="text/javascript">
97
        $(document).ready(function(){
98
            $("#startdate").datepicker({ minDate: "+0D" });
99
        });
100
    </script>
101
[% END %]
102
98
[% INCLUDE 'intranet-bottom.inc' %]
103
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt (-160 / +163 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% USE Koha %]
1
[% USE Koha %]
2
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% IF plugin %]
4
[% IF plugin %]
4
    <title>Upload plugin</title>
5
    <title>Upload plugin</title>
5
[% ELSE %]
6
[% ELSE %]
Lines 186-357 Link Here
186
   </table>
187
   </table>
187
[% END %]
188
[% END %]
188
189
189
[% INCLUDE 'datatables.inc' %]
190
<style type="text/css">
190
<style type="text/css">
191
    #fileuploadstatus,#fileuploadfailed { display : none; }
191
    #fileuploadstatus,#fileuploadfailed { display : none; }
192
    #fileuploadstatus { margin:.4em; }
192
    #fileuploadstatus { margin:.4em; }
193
    #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
193
    #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
194
</style>
194
</style>
195
195
196
<script type="text/javascript">
197
//<![CDATA[
198
    var errMESSAGES = [
199
        "Error 0: Not in use",
200
        _("This file already exists (in this category)."),
201
        _("File could not be created. Check permissions."),
202
        _("Your koha-conf.xml does not contain a valid upload_path."),
203
        _("No temporary directory found."),
204
        _("File could not be read."),
205
        _("File has been deleted."),
206
        _("File or upload record could not be deleted."),
207
    ];
208
//]]>
209
</script>
210
<script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
211
<script type="text/javascript">
212
//<![CDATA[
213
function StartUpload() {
214
    if( $('#fileToUpload').prop('files').length == 0 ) return;
215
    $('#fileToUpload').prop('disabled',true);
216
    $('#fileuploadbutton').hide();
217
    $("#fileuploadcancel").show();
218
    $("#fileuploadfailed").html('');
219
    $("#myalerts").hide('');
220
    $("#myalerts").html('');
221
    $("#fileuploadstatus").show();
222
    $("#uploadedfileid").val('');
223
    $("#searchfile").hide();
224
    $("#lastbreadcrumb").text( _("Add a new upload") );
225
196
226
    var cat, xtra='';
227
    if( $("#uploadcategory").val() )
228
        cat = encodeURIComponent( $("#uploadcategory").val() );
229
    if( cat ) xtra= 'category=' + cat + '&';
230
    [% IF plugin %]
231
        xtra = xtra + 'public=1&temp=0';
232
    [% ELSE %]
233
        if( !cat ) xtra = 'temp=1&';
234
        if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
235
    [% END %]
236
    xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
237
}
238
function CancelUpload() {
239
    if( xhr ) xhr.abort();
240
    $("#fileuploadstatus").hide();
241
    $('#fileToUpload').prop('disabled', false);
242
    $('#fileuploadbutton').show();
243
    $("#fileuploadcancel").hide();
244
    $("#fileuploadfailed").show();
245
    $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
246
}
247
function cbUpload( status, fileid, err ) {
248
    $('#fileToUpload').prop('disabled', false);
249
    if( status=='done' ) {
250
        var e = err? JSON.stringify(err): '';
251
        SubmitMe( 'search', fileid, e );
252
    } else {
253
        $('#fileuploadbutton').show();
254
        $("#fileuploadcancel").hide();
255
        $("#fileuploadstatus").hide();
256
        $("#fileuploadfailed").show();
257
        $("#fileuploadfailed").html( _("Upload status: ") +
258
            ( status=='failed'? _("Failed"):
259
            ( status=='denied'? _("Denied"): status ))
260
        );
261
        ShowAlerts( err );
262
    }
263
}
264
function ShowAlerts(err) {
265
    var str = '';
266
    for( var file in err ) {
267
        str= str + '<p>' + file + ': ' +
268
            errMESSAGES[ err[file].code ] + '</p>';
269
    }
270
    if( str ) {
271
        $('#myalerts').html(str);
272
        $('#myalerts').show();
273
    }
274
}
275
function CheckSearch() {
276
    if( $("#term").val()=="" ) {
277
        alert( _("Please enter a search term.") );
278
        return false;
279
    }
280
    return true;
281
}
282
function SubmitMe(op, id, msg ) {
283
    $("#submitter #op").val( op );
284
    $("#submitter #id").val( id );
285
    $("#submitter #msg").val( msg );
286
    $("#submitter").submit();
287
}
288
function DeleteEntry(id) {
289
    if( !confirm( _("Do you really want to delete this upload?") ))
290
        return false;
291
    ClearField();
292
    SubmitMe( 'delete', id );
293
}
294
function ClearField() {
295
    [% IF plugin %]
296
        $(window.opener.document).find('#[% index %]').val( '' );
297
    [% END %]
298
}
299
function Choose(hashval) {
300
    var res = '[% Koha.Preference('OPACBaseURL') %]';
301
    res = res.replace( /\/$/, '');
302
    res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
303
    [% IF index %]
304
        $(window.opener.document).find('#[% index %]').val( res );
305
    [% END %]
306
    window.close();
307
}
308
$(document).ready(function() {
309
    $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
310
        "aoColumnDefs": [
311
            { 'bSortable': false, 'aTargets': [ 'nosort' ] }
312
        ],
313
        "sPaginationType": "four_button"
314
    }));
315
    [% IF msg %]
316
        ShowAlerts( [% msg %] );
317
    [% END %]
318
    $("#fileuploadcancel").hide();
319
    $("#public_cb").click(function() {
320
        $("#public").click();
321
    });
322
    $("#fileuploadbutton").on("click",function(e){
323
        e.preventDefault();
324
        StartUpload();
325
    });
326
    $("#fileuploadcancel").on("click",function(e){
327
        e.preventDefault();
328
        CancelUpload();
329
    });
330
    $("#searchbutton").on("click",function(){
331
        return CheckSearch();
332
    });
333
    $(".choose_entry").on("click",function(e){
334
        e.preventDefault();
335
        var record_hashvalue = $(this).data("record-hashvalue");
336
        Choose( record_hashvalue );
337
    });
338
    $(".download_entry").on("click",function(e){
339
        e.preventDefault();
340
        var record_id = $(this).data("record-id");
341
        SubmitMe( 'download', record_id );
342
    });
343
    $(".delete_entry").on("click",function(e){
344
        e.preventDefault();
345
        var record_id = $(this).data("record-id");
346
        DeleteEntry( record_id );
347
    });
348
    $("#new_search").on("click",function(e){
349
        e.preventDefault();
350
        SubmitMe('new');
351
    });
352
});
353
//]]>
354
</script>
355
</head>
197
</head>
356
198
357
[% IF ( plugin ) %]
199
[% IF ( plugin ) %]
Lines 402-405 $(document).ready(function() { Link Here
402
[% END %]
244
[% END %]
403
245
404
</div>
246
</div>
247
248
[% MACRO jsinclude BLOCK %]
249
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
250
    [% INCLUDE 'datatables.inc' %]
251
    <script type="text/javascript">
252
        var errMESSAGES = [
253
            "Error 0: Not in use",
254
            _("This file already exists (in this category)."),
255
            _("File could not be created. Check permissions."),
256
            _("Your koha-conf.xml does not contain a valid upload_path."),
257
            _("No temporary directory found."),
258
            _("File could not be read."),
259
            _("File has been deleted."),
260
            _("File or upload record could not be deleted."),
261
        ];
262
    </script>
263
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
264
    <script type="text/javascript">
265
        function StartUpload() {
266
            if( $('#fileToUpload').prop('files').length == 0 ) return;
267
            $('#fileToUpload').prop('disabled',true);
268
            $('#fileuploadbutton').hide();
269
            $("#fileuploadcancel").show();
270
            $("#fileuploadfailed").html('');
271
            $("#myalerts").hide('');
272
            $("#myalerts").html('');
273
            $("#fileuploadstatus").show();
274
            $("#uploadedfileid").val('');
275
            $("#searchfile").hide();
276
            $("#lastbreadcrumb").text( _("Add a new upload") );
277
278
            var cat, xtra='';
279
            if( $("#uploadcategory").val() )
280
                cat = encodeURIComponent( $("#uploadcategory").val() );
281
            if( cat ) xtra= 'category=' + cat + '&';
282
            [% IF plugin %]
283
                xtra = xtra + 'public=1&temp=0';
284
            [% ELSE %]
285
                if( !cat ) xtra = 'temp=1&';
286
                if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
287
            [% END %]
288
            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
289
        }
290
        function CancelUpload() {
291
            if( xhr ) xhr.abort();
292
            $("#fileuploadstatus").hide();
293
            $('#fileToUpload').prop('disabled', false);
294
            $('#fileuploadbutton').show();
295
            $("#fileuploadcancel").hide();
296
            $("#fileuploadfailed").show();
297
            $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
298
        }
299
        function cbUpload( status, fileid, err ) {
300
            $('#fileToUpload').prop('disabled', false);
301
            if( status=='done' ) {
302
                var e = err? JSON.stringify(err): '';
303
                SubmitMe( 'search', fileid, e );
304
            } else {
305
                $('#fileuploadbutton').show();
306
                $("#fileuploadcancel").hide();
307
                $("#fileuploadstatus").hide();
308
                $("#fileuploadfailed").show();
309
                $("#fileuploadfailed").html( _("Upload status: ") +
310
                    ( status=='failed'? _("Failed"):
311
                    ( status=='denied'? _("Denied"): status ))
312
                );
313
                ShowAlerts( err );
314
            }
315
        }
316
        function ShowAlerts(err) {
317
            var str = '';
318
            for( var file in err ) {
319
                str= str + '<p>' + file + ': ' +
320
                    errMESSAGES[ err[file].code ] + '</p>';
321
            }
322
            if( str ) {
323
                $('#myalerts').html(str);
324
                $('#myalerts').show();
325
            }
326
        }
327
        function CheckSearch() {
328
            if( $("#term").val()=="" ) {
329
                alert( _("Please enter a search term.") );
330
                return false;
331
            }
332
            return true;
333
        }
334
        function SubmitMe(op, id, msg ) {
335
            $("#submitter #op").val( op );
336
            $("#submitter #id").val( id );
337
            $("#submitter #msg").val( msg );
338
            $("#submitter").submit();
339
        }
340
        function DeleteEntry(id) {
341
            if( !confirm( _("Do you really want to delete this upload?") ))
342
                return false;
343
            ClearField();
344
            SubmitMe( 'delete', id );
345
        }
346
        function ClearField() {
347
            [% IF plugin %]
348
                $(window.opener.document).find('#[% index %]').val( '' );
349
            [% END %]
350
        }
351
        function Choose(hashval) {
352
            var res = '[% Koha.Preference('OPACBaseURL') %]';
353
            res = res.replace( /\/$/, '');
354
            res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
355
            [% IF index %]
356
                $(window.opener.document).find('#[% index %]').val( res );
357
            [% END %]
358
            window.close();
359
        }
360
        $(document).ready(function() {
361
            $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
362
                "aoColumnDefs": [
363
                    { 'bSortable': false, 'aTargets': [ 'nosort' ] }
364
                ],
365
                "sPaginationType": "four_button"
366
            }));
367
            [% IF msg %]
368
                ShowAlerts( [% msg %] );
369
            [% END %]
370
            $("#fileuploadcancel").hide();
371
            $("#public_cb").click(function() {
372
                $("#public").click();
373
            });
374
            $("#fileuploadbutton").on("click",function(e){
375
                e.preventDefault();
376
                StartUpload();
377
            });
378
            $("#fileuploadcancel").on("click",function(e){
379
                e.preventDefault();
380
                CancelUpload();
381
            });
382
            $("#searchbutton").on("click",function(){
383
                return CheckSearch();
384
            });
385
            $(".choose_entry").on("click",function(e){
386
                e.preventDefault();
387
                var record_hashvalue = $(this).data("record-hashvalue");
388
                Choose( record_hashvalue );
389
            });
390
            $(".download_entry").on("click",function(e){
391
                e.preventDefault();
392
                var record_id = $(this).data("record-id");
393
                SubmitMe( 'download', record_id );
394
            });
395
            $(".delete_entry").on("click",function(e){
396
                e.preventDefault();
397
                var record_id = $(this).data("record-id");
398
                DeleteEntry( record_id );
399
            });
400
            $("#new_search").on("click",function(e){
401
                e.preventDefault();
402
                SubmitMe('new');
403
            });
404
        });
405
    </script>
406
[% END %]
407
405
[% INCLUDE 'intranet-bottom.inc' %]
408
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt (-7 / +13 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE AuthorisedValues %]
2
[% USE AuthorisedValues %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>
6
<title>
6
	Koha &rsaquo; Tools &rsaquo;
7
	Koha &rsaquo; Tools &rsaquo;
Lines 11-18 Link Here
11
	[% END %]
12
	[% END %]
12
</title>
13
</title>
13
[% INCLUDE 'doc-head-close.inc' %]
14
[% INCLUDE 'doc-head-close.inc' %]
14
[% INCLUDE 'calendar.inc' %]
15
</head>
15
</head>
16
16
<body id="tools_viewlog" class="tools">
17
<body id="tools_viewlog" class="tools">
17
[% INCLUDE 'header.inc' %]
18
[% INCLUDE 'header.inc' %]
18
[% INCLUDE 'cat-search.inc' %]
19
[% INCLUDE 'cat-search.inc' %]
Lines 56-67 Link Here
56
[% END %]
57
[% END %]
57
58
58
[% BLOCK translate_log_interface %]
59
[% BLOCK translate_log_interface %]
59
[%    SWITCH interface %]
60
[%    SWITCH log_interface %]
60
[%        CASE 'INTRANET'    %]Intranet
61
[%        CASE 'INTRANET'    %]Intranet
61
[%        CASE 'OPAC'        %]OPAC
62
[%        CASE 'OPAC'        %]OPAC
62
[%        CASE 'SIP'         %]SIP
63
[%        CASE 'SIP'         %]SIP
63
[%        CASE 'COMMANDLINE' %]Command-line
64
[%        CASE 'COMMANDLINE' %]Command-line
64
[%        CASE %][% interface %]
65
[%        CASE %][% log_interface %]
65
[%    END %]
66
[%    END %]
66
[% END %]
67
[% END %]
67
68
Lines 145-153 Link Here
145
146
146
                                    [% FOREACH interf IN [ 'INTRANET' 'OPAC' 'SIP' 'COMMANDLINE' ] %]
147
                                    [% FOREACH interf IN [ 'INTRANET' 'OPAC' 'SIP' 'COMMANDLINE' ] %]
147
                                        [% IF interfaces.grep(interf).size %]
148
                                        [% IF interfaces.grep(interf).size %]
148
                                            <option value="[% interf %]" selected="selected">[% PROCESS translate_log_interface interface=interf %]</option>
149
                                            <option value="[% interf %]" selected="selected">[% PROCESS translate_log_interface log_interface=interf %]</option>
149
                                        [% ELSE %]
150
                                        [% ELSE %]
150
                                            <option value="[% interf %]">[% PROCESS translate_log_interface interface=interf %]</option>
151
                                            <option value="[% interf %]">[% PROCESS translate_log_interface log_interface=interf %]</option>
151
                                        [% END %]
152
                                        [% END %]
152
                                    [% END %]
153
                                    [% END %]
153
                                </select>
154
                                </select>
Lines 244-250 Link Here
244
                                            [% loopro.info |html %]
245
                                            [% loopro.info |html %]
245
                                        [% END %]
246
                                        [% END %]
246
                                    </td>
247
                                    </td>
247
                                    <td>[% PROCESS translate_log_interface interface=loopro.interface %]</td>
248
                                    <td>[% PROCESS translate_log_interface log_interface=loopro.interface %]</td>
248
                                </tr>
249
                                </tr>
249
                            [% END %]
250
                            [% END %]
250
                            </tbody>
251
                            </tbody>
Lines 276-279 Link Here
276
			[% END %]
277
			[% END %]
277
		</div>
278
		</div>
278
	</div>
279
	</div>
280
281
[% MACRO jsinclude BLOCK %]
282
    [% INCLUDE 'calendar.inc' %]
283
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
284
[% END %]
285
279
[% INCLUDE 'intranet-bottom.inc' %]
286
[% INCLUDE 'intranet-bottom.inc' %]
280
- 

Return to bug 19653