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