Bugfix is_approved() to handle the 3-state nature of approval.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tags / review.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Tags &rsaquo; <!-- TMPL_IF NAME="do_it" -->Review &rsaquo; <!-- TMPL_ELSE -->Review Tags<!-- /TMPL_IF --></title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
5 <style type="text/css">
6 .setlabel {width: 6em; font-family: courier; background-color:#E8E8E8;}
7 .red      {color:darkred;   background-color: pink;}
8 .green    {color:darkgreen; background-color: #D1EFD5; text-align: center;}
9 .pending  {background-color: lightyellow;}
10 </style>
11 <script type="text/javascript">
12 //<![CDATA[
13         // <!-- TMPL_VAR NAME="script_name" -->
14         $.ajaxSetup({
15           url: "/cgi-bin/koha/tags/review.pl",
16           type: "POST",
17           dataType: "script"
18         });
19         var ok_count  = 0;
20         var nok_count = 0;
21         var rej_count = 0;
22         var alerted = 0;
23         function pull_counts () {
24                 ok_count  = parseInt(document.getElementById("terms_summary_approved_count"  ).innerHTML);
25                 nok_count = parseInt(document.getElementById("terms_summary_unapproved_count").innerHTML);
26                 rej_count = parseInt(document.getElementById("terms_summary_rejected_count"  ).innerHTML);
27         }
28         function count_approve () {
29                 pull_counts();
30                 if (nok_count > 0) {
31                         $("#terms_summary_unapproved_count").html(nok_count -1);
32                         $("#terms_summary_approved_count"  ).html( ok_count +1);
33                 }
34         }
35         function count_reject () {
36                 pull_counts();
37                 if (nok_count > 0) {
38                         $("#terms_summary_unapproved_count").html(nok_count -1);
39                         $("#terms_summary_rejected_count"  ).html(rej_count +1);
40                 }
41         }
42         function warn_once (evt) {
43                 if (alerted <= 1 && ($(evt.target).is('.ok') || $(evt.target).is('.rej'))) {
44                         alerted += 1;
45                         window.alert("this is: " + this + "is '.ok': " + $(evt.target).is('.ok') + "  is '.rej': " + $(evt.target).is('.rej'));
46                 }
47         }
48         var success_approve = function(tag){
49                 // window.alert('AJAX approved tag: ' + tag);
50         };
51         var failure_approve = function(tag){
52                 window.alert('AJAX failed to approve tag: ' + tag);
53         };
54         var success_reject  = function(tag){
55                 // window.alert('AJAX rejected tag: ' + tag);
56         };
57         var failure_reject  = function(tag){
58                 window.alert('AJAX failed to reject tag: ' + tag);
59         };
60         var success_test    = function(tag){
61                 $('#verdict').html(tag + ' is permitted!');
62         };
63         var failure_test    = function(tag){
64                 $('#verdict').html(tag + ' is prohibited!');
65         };
66         var indeterminate_test = function(tag){
67                 $('#verdict').html(tag + ' is neither permitted nor prohibited!');
68         };
69
70         var success_test_call = function() {
71                 $('#test_button').removeAttr("disabled");
72                 $('#test_button').attr("value","test");
73         };
74         function readCookie(name) { // from http://www.quirksmode.org/js/cookies.html
75                 var nameEQ = name + "=";
76                 var ca = document.cookie.split(';');
77                         for(var i=0;i < ca.length;i++) {
78                                 var c = ca[i];
79                                 while (c.charAt(0)==' '){ c = c.substring(1,c.length); }
80                                 if (c.indexOf(nameEQ) == 0){ return c.substring(nameEQ.length,c.length); }
81                         }
82                 return null;
83         }
84         function check_all() {
85                 $(':checkbox').each(function(){this.checked="checked"});
86         }
87         function uncheck_all() {
88                 $(':checkbox').each(function(){this.checked=""});
89         }
90         $(document).ready(function() {
91                 $('.ajax_buttons' ).css({visibility:"visible"});
92                 $('body').click(function(event) {
93                         pull_counts();
94                         // window.alert("Click detected on " + event.target + ": " + $(event.target).html);
95                         if ($(event.target).is('.ok')) {
96                                 $.ajax({
97                                         "data": {ok: $(event.target).attr("title"), CGISESSID: readCookie('CGISESSID')},
98                                         "success": count_approve // success_approve
99                                 });
100                                 $(event.target).next(".rej").removeAttr("disabled");
101                                 $(event.target).attr(   "value","approved");
102                                 $(event.target).attr("disabled","disabled");
103                                 return false;   // cancel submit
104                         }
105                         if ($(event.target).is('.rej')) {
106                                 $.ajax({
107                                         "data": {rej: $(event.target).attr("title"), CGISESSID: readCookie('CGISESSID')},
108                                         "success": count_reject // success_reject
109                                 });
110                                 $(event.target).prev(".ok").removeAttr("disabled");
111                                 $(event.target).attr(   "value","rejected");
112                                 $(event.target).attr("disabled","disabled");
113                                 return false;   // cancel submit
114                         }
115                         if ($(event.target).is('#test_button')) {
116                                 $(event.target).attr(   "value","testing...");
117                                 $(event.target).attr("disabled","disabled");
118                                 $.ajax({
119                                         "data": {test: $('#test').attr("value")},
120                                         "success": success_test_call // success_reject
121                                 });
122                                 return false;   // cancel submit
123                         }
124                 });
125                 $("*").ajaxError(function(evt, request, settings){
126                         if ((alerted +=1) <= 1){ window.alert("AJAX error (" + alerted + " alert)"); }
127                 });
128         });
129 //]]>
130 </script>
131 </head>
132 <body>
133 <!-- TMPL_INCLUDE NAME="header.inc" -->
134 <!-- TMPL_INCLUDE NAME="cat-search.inc" -->
135
136 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tags/review.pl">Tags</a> &rsaquo; Review Tags</div>
137
138 <div id="doc3" class="yui-t2">
139  <div id="bd">
140   <div id="yui-main">
141    <div class="yui-b">
142
143 <form method="post" action="/cgi-bin/koha/tags/review.pl">
144 <fieldset>
145   <legend>Filters</legend>
146         <input type="submit" value="Apply Filter(s)" />
147   <br />
148   <br />
149   <table>
150     <tr>
151                 <th>Term</th>
152                 <th>Status</th>
153                 <th>Reviewer</th>
154                 <th>Date</th>
155         </tr>
156         <tr>
157             <td><input type="text" name="tag" value="<!-- TMPL_VAR NAME="filter_tag" -->" />
158             </td>
159             <td><select name="approved">
160                         <option <!-- TMPL_IF NAME="filter_approved_all"     -->selected="selected" <!-- /TMPL_IF -->value="all">all</option>
161                         <option <!-- TMPL_IF NAME="filter_approved_ok"      -->selected="selected" <!-- /TMPL_IF -->value="1">approved</option>
162                         <option <!-- TMPL_IF NAME="filter_approved_pending" -->selected="selected" <!-- /TMPL_IF -->value="0">pending</option>
163                         <option <!-- TMPL_IF NAME="filter_approved_rej"     -->selected="selected" <!-- /TMPL_IF -->value="-1">rejected</option>
164                         </select>
165             </td>
166             <td><input type="text" name="approver" value="<!-- TMPL_VAR NAME="filter_approver" -->" />
167             </td>
168             <td>
169                         <label for="from" class="setlabel">from </label>
170                         <input type="text" size="10" id="from" name="from" value="<!-- TMPL_VAR NAME="filter_date_approved_from" -->" />
171                         <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" border="0" alt="Show Calendar" style="cursor: pointer;" id="openCalendarFrom" />
172                         <br />
173                         <label for="to" class="setlabel">&nbsp;&nbsp;to </label>
174                         <input type="text" size="10" id="to"   name="to"   value="<!-- TMPL_VAR NAME="filter_date_approved_to" -->" />
175                         <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" border="0" alt="Show Calendar" style="cursor: pointer;" id="openCalendarTo" />
176             </td>
177         </tr>
178   </table>
179 </fieldset>
180 </form>
181 <script type="text/javascript">
182 //<![CDATA[
183 // function submit_check (from_id,to_id) {
184 //      var dateFrom = Date_from_syspref(document.getElementById(from_id).value);
185 //      var dateTo   = Date_from_syspref(document.getElementById(  to_id).value);
186 //      var today = new Date();
187 //      if (dateFrom < dateTo) { 
188 //              alert("The starting date cannot be after the ending date.");
189 //              document.getElementById(to_id).select();
190 //              return false;
191 //      }
192 //      if (dateFrom > today) { 
193 //              alert("The starting date cannot be in the future.");
194 //              document.getElementById(from_id).select();
195 //              return false;
196 //      }
197 // }
198
199 // return true if the date is blocked.
200 function disable_from(date) {var limit = get_Calendar_limit(date,'to'  ); return (limit && limit < date);}
201 function disable_to  (date) {var limit = get_Calendar_limit(date,'from'); return (limit && limit > date);}
202
203 Calendar.setup({
204         inputField : "from",
205           ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
206                 button : "openCalendarFrom",
207            disableFunc : disable_from,
208         dateStatusFunc : disable_from
209 });
210 Calendar.setup({
211         inputField : "to",
212           ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
213                 button : "openCalendarTo",
214            disableFunc : disable_to,
215         dateStatusFunc : disable_to
216 });
217 //]]>
218 </script>
219 <form method="post" action="/cgi-bin/koha/tags/review.pl">
220   <h4>Displaying 
221         <!-- TMPL_IF NAME="filter_approved_all"     -->ALL<!-- /TMPL_IF -->
222         <!-- TMPL_IF NAME="filter_approved_ok"      -->Approved<!-- /TMPL_IF -->
223         <!-- TMPL_IF NAME="filter_approved_pending" -->Pending<!-- /TMPL_IF -->
224         <!-- TMPL_IF NAME="filter_approved_rej"     -->Rejected<!-- /TMPL_IF -->
225         Terms
226   </h4>
227   <p>
228    <input type="submit" value="approve" id="approve_button" name="op" />
229    <input type="submit" value="reject"  id="reject_button"  name="op" />
230    <input type="button" value="check all" class="ajax_buttons" onclick="check_all()" />
231    <input type="button" value="uncheck all" class="ajax_buttons" onclick="uncheck_all()" />
232   </p>
233   <!-- TMPL_IF NAME="op_count" -->
234   <div class="message" id="main_status">
235                 <!-- TMPL_IF EXPR="op eq 'approve'" -->         Approved
236                 <!-- TMPL_ELSIF EXPR="op eq 'reject'" -->       Rejected
237                 <!-- TMPL_ELSIF EXPR="op eq 'test'" -->         Tested
238                 <!-- TMPL_ELSE -->                                                      Unkown Operation (<!-- TMPL_VAR NAME="op" -->) on
239                 <!-- /TMPL_IF -->
240         <!-- TMPL_VAR NAME="op_count" --> Term(s).
241   </div>
242   <!-- /TMPL_IF -->
243   <!-- TMPL_IF NAME="message_loop" -->
244   <div class="error" id="main_error">
245         <!-- TMPL_LOOP NAME="message_loop" -->
246                 <!-- TMPL_IF    NAME="date_from"  -->ERROR: Date from is not a legal value (<!-- TMPL_VAR NAME="date_from" -->).
247                 <!-- TMPL_ELSIF NAME="date_to"    -->ERROR: Date to is not a legal value (<!-- TMPL_VAR NAME="date_to" -->).
248                 <!-- TMPL_ELSIF NAME="failed_ok"  -->ERROR: Failed to approve term (<!-- TMPL_VAR NAME="failed_ok" -->).
249                 <!-- TMPL_ELSIF NAME="failed_rej" -->ERROR: Failed to reject term (<!-- TMPL_VAR NAME="failed_rej" -->).
250                 <!-- TMPL_ELSIF NAME="approver"   -->ERROR: No match for user (<!-- TMPL_VAR NAME="approver" -->). FILTER REQUIRES BORROWERNUMBER (not name).
251                 <!-- TMPL_ELSIF NAME="approved_by"-->ERROR: No match for borrowernumber (<!-- TMPL_VAR NAME="approved_by" -->).
252                 <!-- TMPL_ELSIF NAME="op_zero"    -->ERROR: The root koha user in your KOHA_CONF file
253                                 (default: kohaadmin) is not a valid tag moderator.  These actions are logged 
254                                 by borrowernumber, so the moderator must exist in your borrowers table.
255                                 Please login as a different authorized staff user to moderate tags.  
256                 <!-- TMPL_ELSE -->                                      Unrecognized error! 
257                 <!-- /TMPL_IF -->
258                 <br />
259         <!-- /TMPL_LOOP -->
260   </div>
261   <!-- /TMPL_IF -->
262   <!-- TMPL_IF NAME="pagination_bar" -->
263   <div class="pagination" id="pagination_top">
264         <!-- TMPL_VAR NAME="pagination_bar" -->
265   </div>
266   <!-- /TMPL_IF -->
267   <!-- TMPL_IF NAME="tagloop" -->
268   <table>
269     <tr>
270         <th>&nbsp;</th>
271         <th>&nbsp;</th>
272                 <th>Status</th>
273                 <th>Term</th>
274                 <th>Weight</th>
275                 <th>Actions</th>
276                 <th>Reviewer</th>
277                 <th>Date</th>
278         </tr>
279         <!-- TMPL_LOOP NAME="tagloop" -->
280         <tr>
281             <td class="count"><!-- TMPL_VAR EXPR="offset + __counter__" -->
282             </td>
283             <td><span><input type="checkbox" value="<!-- TMPL_VAR NAME="term"-->" name="tags" /></span>
284             </td>
285             <!-- TMPL_IF EXPR="approved == -1" --><td class="red">rejected
286                 <!-- TMPL_ELSIF EXPR="approved == 1" --><td class="green"><img alt="OK" src="/intranet-tmpl/prog/img/approve.gif" />
287                 <!-- TMPL_ELSE --><td class="pending">
288                 <!-- /TMPL_IF -->
289             </td>
290             <td><!-- TMPL_VAR NAME="term" -->
291             </td>
292                 <td><!-- TMPL_VAR NAME="weight_total" -->
293             </td>
294                 <!-- TMPL_IF NAME="approved" -->
295             <td><span class="ajax_buttons" style="visibility:hidden">
296                         <!-- TMPL_IF EXPR="approved == -1" -->
297                         <input class="ok"  type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="approve" name="approve" />
298                         <input class="rej" disabled="disabled" type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="reject" name="reject" />
299                         <!-- TMPL_ELSE -->
300                         <input class="ok"  disabled="disabled" type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="approve" name="approve" />
301                         <input class="rej" type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="reject" name="reject" />
302                         <!-- /TMPL_IF -->
303                         </span>
304             </td>
305             <td><a href="?approved_by=<!-- TMPL_VAR NAME="approved_by" -->&amp;approved=all"><!-- TMPL_VAR NAME="approved_by_name" --></a>
306             </td>
307                 <!-- TMPL_ELSE -->
308                 <td colspan="2"><span class="ajax_buttons" style="visibility:hidden">
309                 <input class="ok"  type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="approve" name="approve" />
310                         <input class="rej" type="submit" title="<!-- TMPL_VAR NAME="term"-->" value="reject" name="reject" />
311                         </span>
312             </td>
313                 <!-- /TMPL_IF -->
314             <td><!-- TMPL_VAR NAME="date_approved"-->
315             </td>
316         </tr>
317         <!-- /TMPL_LOOP -->
318   </table>
319   <!-- /TMPL_IF -->
320   </form>
321   </div>
322  </div>
323  <div class="yui-b noprint">
324 <h1>Tags</h1>
325
326   <fieldset>
327   <legend>Terms Summary</legend>
328   <table class="summary">
329         <tr><td><a href="review.pl?approved=1">Approved</a>:</td>
330                 <td><span id="terms_summary_approved_count"><!-- TMPL_VAR NAME="approved_count" --></span></td>
331         </tr>
332         <tr><td><a href="review.pl?approved=-1">Rejected</a>:</td>
333                 <td><span id="terms_summary_rejected_count"><!-- TMPL_VAR NAME="rejected_count" --></span></td>
334         </tr>
335         <tr><td><a href="review.pl?approved=0">Pending</a>:</td>
336                 <td><span id="terms_summary_unapproved_count"><!-- TMPL_VAR NAME="unapproved_count" --></span></td>
337         </tr>
338         <tr><td><a href="review.pl?approved=all">Total</a>:</td>
339                 <td><span id="terms_summary_approved_total"><!-- TMPL_VAR NAME="approved_total" --></span></td>
340         </tr>
341   </table>
342   <span id="terms_summary_status">&nbsp;</span>
343   </fieldset>
344   <fieldset>
345    <legend>Test Blacklist</legend>
346    <div class="description">Enter a word or phrase here to test against your whitelist/blacklist.</div>
347    <form method="post" action="/cgi-bin/koha/tags/review.pl">
348    <input type="text" size="14" name="test" id="test" />
349    <input type="submit" value="test" id="test_button" name="op" />
350    <div id="verdict">
351         <!-- TMPL_IF NAME="test_term" -->
352         <!-- TMPL_IF NAME="verdict_ok" -->
353                 &quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is permitted.
354         <!-- TMPL_ELSIF NAME="verdict_rej" -->
355                 &quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is prohibited.
356         <!-- TMPL_ELSIF NAME="verdict_indeterminate" -->
357                 &quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is neither permitted nor prohibited.
358         <!-- /TMPL_IF -->
359         <!-- /TMPL_IF -->
360    </div>
361    </form>
362   </fieldset>
363  </div>
364 </div>
365 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
366