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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt (-181 / +35 lines)
Lines 6-11 Link Here
6
[% INCLUDE 'datatables.inc' %]
6
[% INCLUDE 'datatables.inc' %]
7
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
9
<script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/tags-review.js"></script>
10
<script type="text/javascript">
11
    var MSG_AJAX_APPROVE_FAILED = _("AJAX failed to approve tag: %s");
12
    var MSG_AJAX_REJECTION_FAILED = _("AJAX failed to reject tag: %s");
13
    var MSG_AJAX_TAG_PERMITTED = _("%s is permitted!");
14
    var MSG_AJAX_TAG_PROHIBITED = _("%s is prohibited!");
15
    var MSG_AJAX_TAG_UNCLASSIFIED = _("%s is neither permitted nor prohibited!");
16
    var MSG_AJAX_ERROR = _("AJAX error (%s alert)");
17
    var LABEL_SELECT_ALL = _("Select all");
18
    var LABEL_CLEAR_ALL = _("Clear all");
19
    var LABEL_SELECT_ALL_PENDING = _("Select all pending");
20
    var LABEL_APPROVE = _("Approve");
21
    var LABEL_APPROVED = _("Approved");
22
    var LABEL_REJECT = _("Reject");
23
    var LABEL_REJECTED = _("Rejected");
24
    var LABEL_TESTING = _("Testing...");
25
</script>
9
<style type="text/css">
26
<style type="text/css">
10
.setlabel {width: 6em; font-family: courier; background-color:#E8E8E8;}
27
.setlabel {width: 6em; font-family: courier; background-color:#E8E8E8;}
11
.rejected { color: #CC0033; }
28
.rejected { color: #CC0033; }
Lines 13-181 Link Here
13
.pending { color: #CCC; font-style: italic; }
30
.pending { color: #CCC; font-style: italic; }
14
tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
31
tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
15
</style>
32
</style>
16
<script type="text/javascript">
17
//<![CDATA[
18
	// [% script_name %]
19
	$.ajaxSetup({
20
	  url: "/cgi-bin/koha/tags/review.pl",
21
	  type: "POST",
22
	  dataType: "script"
23
	});
24
	var ok_count  = 0;
25
	var nok_count = 0;
26
	var rej_count = 0;
27
	var alerted = 0;
28
	function pull_counts () {
29
		ok_count  = parseInt(document.getElementById("terms_summary_approved_count"  ).innerHTML);
30
		nok_count = parseInt(document.getElementById("terms_summary_unapproved_count").innerHTML);
31
		rej_count = parseInt(document.getElementById("terms_summary_rejected_count"  ).innerHTML);
32
	}
33
	function count_approve () {
34
		pull_counts();
35
		if (nok_count > 0) {
36
			$("#terms_summary_unapproved_count").html(nok_count -1);
37
			$("#terms_summary_approved_count"  ).html( ok_count +1);
38
		}
39
	}
40
	function count_reject () {
41
		pull_counts();
42
		if (nok_count > 0) {
43
			$("#terms_summary_unapproved_count").html(nok_count -1);
44
			$("#terms_summary_rejected_count"  ).html(rej_count +1);
45
		}
46
	}
47
	function warn_once (evt) {
48
		if (alerted <= 1 && ($(evt.target).is('.ok') || $(evt.target).is('.rej'))) {
49
			alerted += 1;
50
			window.alert("this is: " + this + "is '.ok': " + $(evt.target).is('.ok') + "  is '.rej': " + $(evt.target).is('.rej'));
51
		}
52
	}
53
	var success_approve = function(tag){
54
		// window.alert(_("AJAX approved tag: ") + tag);
55
	};
56
	var failure_approve = function(tag){
57
                window.alert(_("AJAX failed to approve tag: %s").format(tag));
58
	};
59
	var success_reject  = function(tag){
60
		// window.alert(_("AJAX rejected tag: ") + tag);
61
	};
62
	var failure_reject  = function(tag){
63
                window.alert(_("AJAX failed to reject tag: %s").format(tag));
64
	};
65
	var success_test    = function(tag){
66
                $('#verdict').html(_("%s is permitted!").format(tag));
67
	};
68
	var failure_test    = function(tag){
69
                $('#verdict').html(_("%s is prohibited!").format(tag));
70
	};
71
	var indeterminate_test = function(tag){
72
                $('#verdict').html(_("%s is neither permitted nor prohibited!").format(tag));
73
	};
74
75
	var success_test_call = function() {
76
        $('#test_button').prop('disabled', false);
77
        $('#test_button').html("<i class='fa fa-check-square-o' aria-hidden='true'></i>" +_(" Test"));
78
	};
79
	$(document).ready(function() {
80
		$('.ajax_buttons' ).css({visibility:"visible"});
81
            $("p.check").html("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\"><\/i>"+_(" Select all")+"<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\"><\/i>"+_(" Clear all")+"<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> "+_("Select all pending")+"<\/a><\/div>");
82
	    $("#CheckAll").click(function(){
83
	        $(".checkboxed").checkCheckboxes();
84
	        return false;
85
	    });
86
	    $("#CheckNone").click(function(){
87
	        $(".checkboxed").unCheckCheckboxes();
88
	        return false;
89
	    });
90
	    $("#CheckPending").click(function(){
91
	        $(".checkboxed").checkCheckboxes(".pending");
92
	        return false;
93
	    });
94
		$('body').click(function(event) {
95
			pull_counts();
96
			// window.alert(_("Click detected on ") + event.target + ": " + $(event.target).html);
97
			if ($(event.target).is('.ok')) {
98
				$.ajax({
99
                    data: {ok: $(event.target).attr("title")},
100
                        success: count_approve // success_approve
101
				});
102
                $(event.target).next(".rej").prop('disabled', false).css("color","#000");
103
                $(event.target).next(".rej").html("<i class='fa fa-remove'></i>" + _(" Reject"));
104
                $(event.target).prop('disabled', true).css("color","#666");
105
                $(event.target).html("<i class='fa fa-check'></i>" + _(" Approved"));
106
                var getelement = $(event.target).attr("title");
107
                var gettitle = "span[data-title|=" + getelement + "]";
108
                $(gettitle).text(_("Approved"));
109
                if ($(gettitle).attr("class") == "pending"){
110
                    $(gettitle).toggleClass("pending approved");
111
                } else {
112
                    $(gettitle).toggleClass("rejected approved");
113
                }
114
				return false;	// cancel submit
115
			}
116
			if ($(event.target).is('.rej')) {
117
				$.ajax({
118
                    data: {rej: $(event.target).attr("title")},
119
                        success: count_reject // success_reject
120
                    });
121
                $(event.target).prev(".ok").prop('disabled', false).css("color","#000");
122
                $(event.target).prev(".ok").html("<i class='fa fa-check'></i>" + _(" Approve"));
123
                $(event.target).prop('disabled', true).css("color","#666");
124
                $(event.target).html("<i class='fa fa-remove'></i>" + _(" Rejected"));
125
                var getelement = $(event.target).attr("title");
126
                var gettitle = "span[data-title|=" + getelement + "]";
127
                $(gettitle).text(_("Rejected"));
128
                if ($(gettitle).attr("class") == "pending"){
129
                    $(gettitle).toggleClass("pending rejected");
130
                } else {
131
                    $(gettitle).toggleClass("approved rejected");
132
                }
133
				return false;	// cancel submit
134
			}
135
                if ($(event.target).is('#test_button')) {
136
                    $(event.target).text(_("Testing...")).prop('disabled', true);
137
                        $.ajax({
138
                            data: {test: $('#test').attr("value")},
139
                            success: success_test_call // success_reject
140
                        });
141
				return false;	// cancel submit
142
			}
143
		});
144
		$("*").ajaxError(function(evt, request, settings){
145
                        if ((alerted +=1) <= 1){ window.alert(_("AJAX error (%s alert)").format(alerted)); }
146
		});
147
        $("#tagst").dataTable($.extend(true, {}, dataTablesDefaults, {
148
            "aoColumnDefs": [
149
                [% IF ( filter_approved_pending ) %]
150
                    { "aTargets": [ 0,1,-2 ], "bSortable": false, "bSearchable": false }
151
                [% ELSE %]
152
                    { "aTargets": [ 0,1,-3 ], "bSortable": false, "bSearchable": false }
153
                [% END %]
154
            ],
155
            "aoColumns": [
156
                null,null,null,null,null,null,[% UNLESS ( filter_approved_pending ) %]null,[% END %]{ "sType": "title-string" }
157
            ],
158
            "aaSorting": [[ 4, "desc" ]],
159
            "sPaginationType": "four_button"
160
        }));
161
        var reviewerField = $("#approver");
162
        reviewerField.autocomplete({
163
            source: "/cgi-bin/koha/circ/ysearch.pl",
164
            minLength: 3,
165
            select: function( event, ui ) {
166
                reviewerField.val( ui.item.borrowernumber );
167
                return false;
168
            }
169
        })
170
        .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
171
            return $( "<li></li>" )
172
            .data( "ui-autocomplete-item", item )
173
            .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
174
            .appendTo( ul );
175
        };
176
	});
177
//]]>
178
</script>
179
</head>
33
</head>
180
<body id="tags_review" class="tools">
34
<body id="tags_review" class="tools">
181
[% INCLUDE 'header.inc' %]
35
[% INCLUDE 'header.inc' %]
Lines 239-252 tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } Link Here
239
  <table id="tagst">
93
  <table id="tagst">
240
    <thead>
94
    <thead>
241
        <tr>
95
        <tr>
242
		<th>&nbsp;</th>
96
            <th class="NoSort">&nbsp;</th>
243
		<th>&nbsp;</th>
97
            <th class="NoSort">&nbsp;</th>
244
		<th>Status</th>
98
		<th>Status</th>
245
		<th>Term</th>
99
		<th>Term</th>
246
		<th>Weight</th>
100
		<th>Weight</th>
247
		<th>Actions</th>
101
            <th class="NoSort">Actions</th>
248
            [% UNLESS ( filter_approved_pending ) %]<th>Reviewer</th>[% END %]
102
            [% UNLESS ( filter_approved_pending ) %]<th>Reviewer</th>[% END %]
249
		<th>Date</th>
103
        <th class="title-string">Date</th>
250
	</tr>
104
	</tr>
251
    </thead>
105
    </thead>
252
    <tbody>
106
    <tbody>
Lines 254-283 tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } Link Here
254
        <tr>
108
        <tr>
255
            <td class="count">[% offset + loop.count %]
109
            <td class="count">[% offset + loop.count %]
256
            </td>
110
            </td>
257
                [% IF ( tagloo.approved == 0 ) %]<td><span><input type="checkbox" value="[% tagloo.term %]" name="tags" class="pending" /></span>
111
                [% IF ( tagloo.approved == 0 ) %]<td><span><input type="checkbox" value="[% tagloo.term|html %]" name="tags" class="pending" /></span>
258
                [% ELSE %]<td><span><input type="checkbox" value="[% tagloo.term %]" name="tags" /></span>[% END %]
112
                [% ELSE %]<td><span><input type="checkbox" value="[% tagloo.term|html %]" name="tags" /></span>[% END %]
259
            </td>
113
            </td>
260
            <td>
114
            <td>
261
                [% IF ( tagloo.approved == -1 ) %]
115
                [% IF ( tagloo.approved == -1 ) %]
262
                    <span class="rejected" data-title="[% tagloo.term %]">Rejected</span>
116
                    <span class="rejected status[% offset + loop.count %]">Rejected</span>
263
                [% ELSIF ( tagloo.approved == 1 ) %]
117
                [% ELSIF ( tagloo.approved == 1 ) %]
264
                    <span class="approved" data-title="[% tagloo.term %]">Approved</span>
118
                    <span class="approved status[% offset + loop.count %]">Approved</span>
265
                [% ELSE %]
119
                [% ELSE %]
266
                    <span class="pending" data-title="[% tagloo.term %]">Pending</span>
120
                    <span class="pending status[% offset + loop.count %]">Pending</span>
267
                [% END %]
121
                [% END %]
268
            </td>
122
            </td>
269
            <td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term|uri %]">[% tagloo.term %]</a>
123
            <td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term|uri %]">[% tagloo.term|html %]</a>
270
            </td>
124
            </td>
271
            <td>[% tagloo.weight_total %]
125
            <td>[% tagloo.weight_total %]
272
            </td>
126
            </td>
273
            [% IF ( tagloo.approved ) %]
127
            [% IF ( tagloo.approved ) %]
274
            <td class="actions"><span class="ajax_buttons" style="visibility:hidden">
128
            <td class="actions"><span class="ajax_buttons" style="visibility:hidden">
275
                    [% IF ( tagloo.approved == -1 ) %]
129
                [% IF ( tagloo.approved == -1 ) %]
276
                <button class="ok btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
130
                    <button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
277
                <button class="rej btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term %]" value="Rejected" name="reject"><i class="fa fa-remove"></i> Rejected</button>
131
                    <button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term|html %]" value="Rejected" name="reject"><i class="fa fa-remove"></i> Rejected</button>
278
                [% ELSE %]
132
                [% ELSE %]
279
                <button class="ok btn btn-default btn-xs"  disabled="disabled" type="submit" title="[% tagloo.term %]" value="Approved" name="approve"><i class="fa fa-check"></i> Approved</button>
133
                    <button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs"  disabled="disabled" type="submit" title="[% tagloo.term|html %]" value="Approved" name="approve"><i class="fa fa-check"></i> Approved</button>
280
                <button class="rej btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
134
                    <button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
281
                [% END %]
135
                [% END %]
282
                </span>
136
                </span>
283
            </td>
137
            </td>
Lines 285-292 tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } Link Here
285
            </td>
139
            </td>
286
            [% ELSE %]
140
            [% ELSE %]
287
            <td class="actions"><span class="ajax_buttons" style="visibility:hidden">
141
            <td class="actions"><span class="ajax_buttons" style="visibility:hidden">
288
            <button class="ok btn btn-default btn-xs"  type="submit" title="[% tagloo.term %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
142
                <button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs"  type="submit" title="[% tagloo.term|html %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
289
                <button class="rej btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
143
                <button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
290
                </span>
144
                </span>
291
            </td>
145
            </td>
292
            [% UNLESS ( filter_approved_pending ) %]<td>&nbsp;</td>[% END %]
146
            [% UNLESS ( filter_approved_pending ) %]<td>&nbsp;</td>[% END %]
Lines 329-335 tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } Link Here
329
   <div class="description">Enter a word or phrase to check against approved/rejected lists: </div>
183
   <div class="description">Enter a word or phrase to check against approved/rejected lists: </div>
330
   <form method="post" action="/cgi-bin/koha/tags/review.pl">
184
   <form method="post" action="/cgi-bin/koha/tags/review.pl">
331
   <input type="text" size="14" name="test" id="test" />
185
   <input type="text" size="14" name="test" id="test" />
332
   <fieldset class="action"><button type="submit" value="Test" class="btn btn-default btn-sm" id="test_button" name="op-test"><i class="fa fa-check-square-o" aria-hidden="true"></i> Test</button></fieldset>
186
   <fieldset class="action"><button type="submit" value="Test" class="approval_btn btn btn-default btn-sm" id="test_button" name="op-test"><i class="fa fa-check-square-o" aria-hidden="true"></i> Test</button></fieldset>
333
   <div id="verdict">
187
   <div id="verdict">
334
	[% IF ( test_term ) %]
188
	[% IF ( test_term ) %]
335
	[% IF ( verdict_ok ) %]
189
	[% IF ( verdict_ok ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js (+162 lines)
Line 0 Link Here
1
$.ajaxSetup({
2
    url: "/cgi-bin/koha/tags/review.pl",
3
    type: "POST",
4
    dataType: "script"
5
});
6
7
var ok_count  = 0;
8
var nok_count = 0;
9
var rej_count = 0;
10
var alerted = 0;
11
12
function pull_counts () {
13
    ok_count  = parseInt(document.getElementById("terms_summary_approved_count"  ).innerHTML);
14
    nok_count = parseInt(document.getElementById("terms_summary_unapproved_count").innerHTML);
15
    rej_count = parseInt(document.getElementById("terms_summary_rejected_count"  ).innerHTML);
16
}
17
18
function count_approve () {
19
    pull_counts();
20
    if (nok_count > 0) {
21
        $("#terms_summary_unapproved_count").html(nok_count -1);
22
        $("#terms_summary_approved_count"  ).html( ok_count +1);
23
    }
24
}
25
26
function count_reject () {
27
    pull_counts();
28
    if (nok_count > 0) {
29
        $("#terms_summary_unapproved_count").html(nok_count -1);
30
        $("#terms_summary_rejected_count"  ).html(rej_count +1);
31
    }
32
}
33
34
var success_approve = function(tag){
35
    // window.alert(_("AJAX approved tag: ") + tag);
36
};
37
var failure_approve = function(tag){
38
    window.alert(MSG_AJAX_APPROVE_FAILED.format(decodeURIComponent( tag )));
39
};
40
var success_reject  = function(tag){
41
    // window.alert(_("AJAX rejected tag: ") + tag);
42
};
43
var failure_reject  = function(tag){
44
    window.alert(MSG_AJAX_REJECTION_FAILED.format(decodeURIComponent( tag )));
45
};
46
var success_test    = function(tag){
47
    $('#verdict').html(MSG_AJAX_TAG_PERMITTED.format( decodeURIComponent( tag ) ));
48
};
49
var failure_test    = function(tag){
50
    $('#verdict').html(MSG_AJAX_TAG_PROHIBITED.format( decodeURIComponent( tag ) ));
51
};
52
var indeterminate_test = function(tag){
53
    $('#verdict').html(MSG_AJAX_TAG_UNCLASSIFIED.format( decodeURIComponent( tag ) ));
54
};
55
56
var success_test_call = function() {
57
    $('#test_button').prop('disabled', false);
58
    $('#test_button').html("<i class='fa fa-check-square-o' aria-hidden='true'></i>" +_(" Test"));
59
};
60
61
$(document).ready(function() {
62
    $("#tagst").dataTable($.extend(true, {}, dataTablesDefaults, {
63
        "aoColumnDefs": [
64
            { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
65
            { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
66
            { "sType": "title-string", "aTargets" : [ "title-string" ] }
67
        ],
68
        "aaSorting": [[ 4, "desc" ]],
69
        "sPaginationType": "four_button"
70
    }));
71
    $('.ajax_buttons' ).css({visibility:"visible"});
72
    $("p.check").html("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\"><\/i> "+ LABEL_SELECT_ALL +"<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\"><\/i> "+ LABEL_CLEAR_ALL +"<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> "+ LABEL_SELECT_ALL_PENDING +"<\/a><\/div>");
73
    $("#CheckAll").click(function(){
74
        $(".checkboxed").checkCheckboxes();
75
        return false;
76
    });
77
    $("#CheckNone").click(function(){
78
        $(".checkboxed").unCheckCheckboxes();
79
        return false;
80
    });
81
    $("#CheckPending").click(function(){
82
        $(".checkboxed").checkCheckboxes(".pending");
83
        return false;
84
    });
85
    $(".approval_btn").on('click',function(event) {
86
        event.preventDefault();
87
        pull_counts();
88
        var getelement;
89
        var gettitle;
90
        // window.alert(_("Click detected on ") + event.target + ": " + $(event.target).html);
91
        if ($(event.target).is('.ok')) {
92
            $.ajax({
93
                data: {
94
                    ok: $(event.target).attr("title")
95
                },
96
                success: count_approve // success_approve
97
            });
98
            $(event.target).next(".rej").prop('disabled', false).css("color","#000");
99
            $(event.target).next(".rej").html("<i class='fa fa-remove'></i> " + _("Reject"));
100
            $(event.target).prop('disabled', true).css("color","#666");
101
            $(event.target).html("<i class='fa fa-check'></i> " + LABEL_APPROVED );
102
            getelement = $(event.target).data("num");
103
            gettitle = ".status" + getelement;
104
            $(gettitle).text( LABEL_APPROVED );
105
            if ($(gettitle).hasClass("pending") ){
106
                $(gettitle).toggleClass("pending approved");
107
            } else {
108
                $(gettitle).toggleClass("rejected approved");
109
            }
110
        }
111
        if ($(event.target).is('.rej')) {
112
            $.ajax({
113
                data: {
114
                    rej: $(event.target).attr("title")
115
                },
116
                success: count_reject // success_reject
117
            });
118
            $(event.target).prev(".ok").prop('disabled', false).css("color","#000");
119
            $(event.target).prev(".ok").html("<i class='fa fa-check'></i> " + LABEL_APPROVE );
120
            $(event.target).prop('disabled', true).css("color","#666");
121
            $(event.target).html("<i class='fa fa-remove'></i> " + LABEL_REJECTED );
122
            getelement = $(event.target).data("num");
123
            gettitle = ".status" + getelement;
124
            $(gettitle).text( LABEL_REJECTED );
125
            if ($(gettitle).hasClass("pending") ){
126
                $(gettitle).toggleClass("pending rejected");
127
            } else {
128
                $(gettitle).toggleClass("approved rejected");
129
            }
130
            return false;   // cancel submit
131
        }
132
        if ($(event.target).is('#test_button')) {
133
            $(event.target).text( LABEL_TESTING ).prop('disabled', true);
134
            $.ajax({
135
                data: {
136
                    test: $('#test').attr("value")
137
                },
138
                success: success_test_call // success_reject
139
            });
140
            return false;   // cancel submit
141
        }
142
    });
143
    $("*").ajaxError(function(evt, request, settings){
144
        if ((alerted +=1) <= 1){ window.alert(MSG_AJAX_ERROR.format(alerted)); }
145
    });
146
147
    var reviewerField = $("#approver");
148
    reviewerField.autocomplete({
149
        source: "/cgi-bin/koha/circ/ysearch.pl",
150
        minLength: 3,
151
        select: function( event, ui ) {
152
            reviewerField.val( ui.item.borrowernumber );
153
            return false;
154
        }
155
    })
156
    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
157
        return $( "<li></li>" )
158
        .data( "ui-autocomplete-item", item )
159
        .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
160
        .appendTo( ul );
161
    };
162
});
(-)a/tags/review.pl (-6 / +4 lines)
Lines 25-31 use Data::Dumper; Link Here
25
use POSIX;
25
use POSIX;
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use CGI::Cookie; # need to check cookies before having CGI parse the POST request
27
use CGI::Cookie; # need to check cookies before having CGI parse the POST request
28
28
use URI::Escape;
29
use C4::Auth qw(:DEFAULT check_cookie_auth);
29
use C4::Auth qw(:DEFAULT check_cookie_auth);
30
use C4::Context;
30
use C4::Context;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
Lines 63-76 if (is_ajax()) { Link Here
63
	my ($tag, $js_reply);
63
	my ($tag, $js_reply);
64
	if ($tag = $input->param('test')) {
64
	if ($tag = $input->param('test')) {
65
		my $check = is_approved($tag);
65
		my $check = is_approved($tag);
66
		$js_reply = ( $check >=  1 ? 'success' :
66
        $js_reply = ( $check >=  1 ? 'success' : $check <= -1 ? 'failure' : 'indeterminate' ) . "_test('".uri_escape($tag)."');\n";
67
					  $check <= -1 ? 'failure' : 'indeterminate' ) . "_test('$tag');\n";
68
	}
67
	}
69
	if ($tag = $input->param('ok')) {
68
	if ($tag = $input->param('ok')) {
70
		$js_reply = (   whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('$tag');\n";
69
        $js_reply = (   whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('".uri_escape($tag)."');\n";
71
	} 
70
	} 
72
	if ($tag = $input->param('rej')) {
71
	if ($tag = $input->param('rej')) {
73
		$js_reply = (   blacklist($operator,$tag) ? 'success' : 'failure')  . "_reject('$tag');\n";
72
        $js_reply = (   blacklist($operator,$tag) ? 'success' : 'failure')  . "_reject('".uri_escape($tag)."');\n";
74
	}
73
	}
75
	output_with_http_headers $input, undef, $js_reply, 'js';
74
	output_with_http_headers $input, undef, $js_reply, 'js';
76
	exit;
75
	exit;
77
- 

Return to bug 5471