Bug 13618: Remove html filters at the intranet
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / categories.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3 [% USE Price %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF op == 'add_form' %][% IF ( categorycode ) %]Modify category '[% categorycode %]'[% ELSE %]New category[% END %][% END %]
6 [% IF op == 'delete_confirm' %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode %] in use[% ELSE %]Confirm deletion of category '[% categorycode %]'[% END %][% END %]
7 </title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% INCLUDE 'calendar.inc' %]
10 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
11 [% INCLUDE 'datatables.inc' %]
12 <script type="text/javascript" id="js">
13 //<![CDATA[
14     $(document).ready(function() {
15         $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
16             "aoColumnDefs": [{
17                 "aTargets": [-1, -2],
18                 "bSortable": false,
19                 "bSearchable": false
20             }, {
21                 "aTargets": [3, 4, 5],
22                 "sType": "natural"
23             }, ],
24             "aaSorting": [
25                 [1, "asc"]
26             ],
27             "sPaginationType": "four_button"
28         }));
29
30         $("#enrolmentperioddate").datepicker({
31             minDate: 1
32         }); // Require that "until date" be in the future
33
34         if ($("#branches option:selected").length < 1) {
35             $("#branches option:first").attr("selected", "selected");
36         }
37     });
38
39     function isNotNull(f, noalert) {
40         if (f.value.length == 0) {
41             return false;
42         }
43         return true;
44     }
45
46     function isNum(v, maybenull) {
47         var n = new Number(v.value);
48         if (isNaN(n)) {
49             return false;
50         }
51         if (maybenull == 0 && v.value == '') {
52             return false;
53         }
54         return true;
55     }
56
57     // to check if the data are correctly entered.
58     function Check(ff) {
59         var ok = 0;
60         var _alertString = _("Form not submitted because of the following problem(s)");
61         _alertString += "\n-------------------------------------------------------------------\n\n";
62         ff.categorycode.value = $.trim(ff.categorycode.value);
63         if (ff.categorycode.value.length == 0) {
64             ok = 1;
65             _alertString += _("- categorycode missing") + "\n";
66         } else {
67             var patt = /^[a-zA-Z0-9\-_]+$/g;
68             if (!patt.test(ff.categorycode.value)) {
69                 ok = 1;
70                 _alertString += _("- category code can only contain the following characters: letters, numbers, - and _") + "\n";
71             }
72         }
73         if (!(ff.category_type.value)) {
74             ok = 1;
75             _alertString += _("- category type missing") + "\n";
76         }
77         if (!(isNotNull(ff.description, 1))) {
78             ok = 1;
79             _alertString += _("- description missing") + "\n";
80         }
81         if (!isNum(ff.upperagelimit, 0) && ff.category_type.value == 'C') {
82             ok = 1;
83             _alertString += _("- upperagelimit is not a number") + "\n";
84
85         }
86         if (!(ff.enrolmentperioddate.value || ff.enrolmentperiod.value)) {
87             ok = 1;
88             _alertString += _("- either Enrollment period or Until date must be provided") + "\n";
89         }
90         if (ff.enrolmentperioddate.value && ff.enrolmentperiod.value) {
91             document.getElementById('enrolmentmessage').className = "error";
92             return false;
93         }
94
95         if (ok) { // if there is a problem
96             alert(_alertString);
97             return false;
98         }
99         // if all is good
100         ff.submit();
101     }
102 //]]>
103 </script>
104 <style type="text/css">#enrolmentmessage.hint { display : none; }</style>
105 </head>
106 <body id="admin_categorie" class="admin">
107 [% INCLUDE 'header.inc' %]
108 [% INCLUDE 'patrons-admin-search.inc' %]
109
110 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF op == 'add_form' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode %]'[% ELSE %]New category[% END %][% END %]
111 [% IF op == 'delete_confirm' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode %] in use[% ELSE %]Confirm deletion of category '[% categorycode %]'[% END %][% END %]
112 [% IF op == 'delete_confirmed' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
113 [% IF op == 'list' %]Patron categories[% END %]</div>
114
115 <div id="doc3" class="yui-t2">
116    <div id="bd">
117     <div id="yui-main">
118     <div class="yui-b">
119
120 [% FOR m IN messages %]
121     <div class="dialog [% m.type %]">
122         [% SWITCH m.code %]
123         [% CASE 'error_on_update' %]
124             An error occurred when updating this patron category. Perhaps it already exists.
125         [% CASE 'error_on_insert' %]
126             An error occurred when inserting this patron category. The patron category might already exist.
127         [% CASE 'error_on_delete' %]
128             An error occurred when deleting this patron category. Check the logs.
129         [% CASE 'success_on_update' %]
130             Patron category updated successfully.
131         [% CASE 'success_on_insert' %]
132             Patron category inserted successfully.
133         [% CASE 'success_on_delete' %]
134             Patron category deleted successfully.
135         [% CASE 'already_exists' %]
136             This patron category already exists.
137         [% CASE %]
138             [% m.code %]
139         [% END %]
140     </div>
141 [% END %]
142
143 [% IF op == 'add_form' %]
144     <form name="Aform" action="/cgi-bin/koha/admin/categories.pl" method="post">
145         <input type="hidden" name="op" value="add_validate" />
146         <input type="hidden" name="checked" value="0" />
147         [% IF category %]
148             <h1>Modify category [% categorycode %]</h1>
149         [% ELSE %]
150             <h1>New category</h1>
151         [% END %]
152         <fieldset class="rows">
153             <ol>
154                 [% IF category %]
155                     <li>
156                         <span class="label">Category code: </span>[% categorycode %]
157                         <input type="hidden" name="categorycode" value="[% category.categorycode %]" /><input type="hidden" name="is_a_modif" value="1" />
158                     </li>
159                 [% ELSE %]
160                     <li>
161                         <label for="categorycode" class="required">Category code: </label>
162                         <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" onblur="toUC(this)" />
163                         <span class="required">Required</span>
164                     </li>
165                 [% END %]
166                 <li>
167                     <label for="description" class="required">Description: </label>
168                     <input type="text" name="description" id="description" size="40" maxlength="80" value="[% category.description %]" />
169                     <span class="required">Required</span>
170                 </li>
171                 <li>
172                     <label for="enrolmentperiod" class="required">Enrollment period: </label>
173                     <fieldset>
174                         <legend>Choose one</legend>
175                         <ol>
176                             <li>
177                                 <label for="enrolmentperiod" style="width:6em;">In months: </label>
178                                 <input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
179                             </li>
180                             <li>
181                                 <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
182                                 <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
183                                 <div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div>
184                             </li>
185                         </ol>
186                     </fieldset>
187                 </li>
188                 <li>
189                     <label for="dateofbirthrequired">Age required: </label>
190                     <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% category.dateofbirthrequired %]" size="3" maxlength="3" /> years
191                 </li>
192                 <li>
193                     <label for="upperagelimit">Upperage limit: </label>
194                     <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% category.upperagelimit %]" /> years
195                 </li>
196                 <li>
197                     <label for="enrolmentfee">Enrollment fee: </label>
198                     <input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% category.enrolmentfee | $Price on_editing => 1 %]" />
199                 </li>
200                 <li>
201                     <label for="overduenoticerequired">Overdue notice required: </label>
202                     <select name="overduenoticerequired" id="overduenoticerequired">
203                         [% IF category.overduenoticerequired %]
204                             <option value="0">No</option>
205                             <option value="1" selected="selected">Yes</option>
206                         [% ELSE %]
207                             <option value="0" selected="selected">No</option>
208                             <option value="1">Yes</option>
209                         [% END %]
210                     </select>
211                 </li>
212                 <li>
213                     <label for="hidelostitems">Lost items in staff client: </label>
214                     <select name="hidelostitems" id="hidelostitems">
215                         [% IF category.hidelostitems %]
216                             <option value="0">Shown</option>
217                             <option value="1" selected="selected">Hidden by default</option>
218                         [% ELSE %]
219                             <option value="0" selected="selected">Shown</option>
220                             <option value="1">Hidden by default</option>
221                         [% END %]
222                     </select>
223                 </li>
224                 <li>
225                     <label for="reservefee">Hold fee: </label>
226                     <input type="text" name="reservefee" id="reservefee" size="6" value="[% category.reservefee | $Price on_editing => 1 %]" />
227                 </li>
228                 <li>
229                     <label for="category_type" class="required">Category type: </label>
230                     <select name="category_type" id="category_type">
231                         [% UNLESS category %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %]
232                         [% IF category and category.category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
233                         [% IF category and category.category_type == 'C' %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
234                         [% IF category and category.category_type == 'S' %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
235                         [% IF category and category.category_type == 'I' %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
236                         [% IF category and category.category_type == 'P' %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
237                         [% IF category and category.category_type == 'X' %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
238                     </select>
239                     <span class="required">Required</span>
240                 </li>
241                 <li><label for="branches">Branches limitation: </label>
242                     <select id="branches" name="branches" multiple size="10">
243                         <option value="">All branches</option>
244                         [% FOREACH branch IN branches_loop %]
245                           [% IF branch.selected %]
246                             <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
247                           [% ELSE %]
248                             <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
249                           [% END %]
250                         [% END %]
251                     </select>
252                     <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
253                     </span>
254                 </li>
255                 <li><label for="block_expired">Block expired patrons</label>
256                     <select name="BlockExpiredPatronOpacActions" id="block_expired">
257                         [% IF not category or category.BlockExpiredPatronOpacActions == -1%]
258                             <option value="-1" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
259                         [% ELSE %]
260                             <option value="-1"> Follow system preference BlockExpiredPatronOpacActions </option>
261                         [% END %]
262
263                         [% IF category and category.BlockExpiredPatronOpacActions == 1 %]
264                             <option value="1" selected="selected"> Block </option>
265                         [% ELSE %]
266                             <option value="1"> Block </option>
267                         [% END %]
268
269                         [% IF category and category.BlockExpiredPatronOpacActions == 0 %]
270                             <option value="0" selected="selected"> Don't block </option>
271                         [% ELSE %]
272                             <option value="0"> Don't block </option>
273                         [% END %]
274                     </select>
275                     <span>
276                         Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
277                     </span>
278                 </li>
279                 <li>
280                     <label for="default_privacy">Default privacy: </label>
281                     <select id="default_privacy" name="default_privacy">
282                         [% SET default_privacy = 'default' %]
283                         [% IF category %][% SET default_privacy = category.default_privacy %][% END %]
284                         [% SWITCH default_privacy %]
285                         [% CASE 'forever' %]
286                             <option value="default">Default</option>
287                             <option value="never">Never</option>
288                             <option value="forever" selected="selected">Forever</option>
289                         [% CASE 'never' %]
290                             <option value="default">Default</option>
291                             <option value="never" selected="selected">Never</option>
292                             <option value="forever">Forever</option>
293                         [% CASE %]
294                             <option value="default" selected="selected">Default</option>
295                             <option value="never">Never</option>
296                             <option value="forever">Forever</option>
297                         [% END %]
298                     </select>
299                     <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span>
300                 </li>
301             </ol>
302         </fieldset>
303
304         [% IF ( EnhancedMessagingPreferences ) %]
305             <fieldset class="rows">
306                 <h4>Default messaging preferences for this patron category</h4>
307                 [% INCLUDE 'messaging-preference-form.inc' %]
308             </fieldset>
309         [% END %]
310         <fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
311     </form>
312 [% END %]
313
314 [% IF op == 'delete_confirm' %]
315     <form action="/cgi-bin/koha/admin/categories.pl" method="post">
316         <fieldset>
317             <legend>
318                 [% IF patrons_in_category > 0 %]
319                     Category [% categorycode %] is in use.  Deletion not possible!
320                 [% ELSE %]
321                     Confirm deletion of category [% categorycode %]
322                 [% END %]
323             </legend>
324
325             [% IF patrons_in_category > 0  %]
326                 <div class="dialog alert">
327                     <strong>This category is used [% patrons_in_category %] times</strong>. Deletion not possible
328                 </div>
329             [% END %]
330             <table>
331                 <tr><th scope="row">Category code: </th><td>[% category.categorycode %]</td></tr>
332                 <tr><th scope="row">Description: </th><td>[% category.description %]</td></tr>
333                 <tr><th scope="row">Enrollment period: </th>
334                     <td>
335                         [% IF category.enrolmentperiod %]
336                             [% category.enrolmentperiod %] months
337                         [% ELSE %]
338                             until [% category.enrolmentperioddate | $KohaDates %]
339                         [% END %]
340                     </td>
341                 </tr>
342                 <tr><th scope="row">Age required: </th><td>[% category.dateofbirthrequired %] years</td></tr>
343                 <tr><th scope="row">Upperage limit: </th><td>[% category.upperagelimit %] years</td></tr>
344                 <tr><th scope="row">Enrollment fee: </th><td>[% category.enrolmentfee | $Price %]</td></tr>
345                 <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
346                 <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
347                 <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
348                 <tr>
349                     <th scope="row">Default privacy: </th>
350                     <td>
351                         [% SWITCH category.default_privacy %]
352                         [% CASE 'default' %]
353                             Default
354                         [% CASE 'never' %]
355                             Never
356                         [% CASE 'forever' %]
357                             Forever
358                         [% END %]
359                     </td>
360                 </tr>
361             </table>
362             <fieldset class="action">
363                 [% IF patrons_in_category > 0 %]
364                     <input type="submit" value="OK" />
365                 [% ELSE %]
366                     <input type="hidden" name="op" value="delete_confirmed" />
367                     <input type="hidden" name="categorycode" value="[% categorycode %]" />
368                     <input type="submit" value="Delete this category" />
369                     <a class="cancel" href="/cgi-bin/koha/admin/categories.pl">Cancel</a>
370                 [% END %]
371             </fieldset>
372         </fieldset>
373     </form>
374 [% END %]
375
376 [% IF op == 'list' %]
377
378     <div id="toolbar" class="btn-toolbar">
379         <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/categories.pl?op=add_form"><i class="fa fa-plus"></i> New category</a>
380     </div>
381
382     <h2>Patron category administration</h2>
383     [% IF searchfield %]
384         You Searched for [% searchfield %]</span>
385     [% END %]
386     [% IF categories%]
387         <table id="table_categorie">
388             <thead>
389                 <tr>
390                     <th scope="col">Code</th>
391                     <th scope="col">Category name</th>
392                     <th scope="col">Type</th>
393                     <th scope="col">Enrollment period</th>
394                     <th scope="col">Age required</th>
395                     <th scope="col">Upper age limit</th>
396                     <th scope="col">Enrollment fee</th>
397                     <th scope="col">Overdue</th>
398                     <th scope="col">Lost items</th>
399                     <th scope="col">Hold fee</th>
400                     [% IF ( EnhancedMessagingPreferences ) %]
401                     <th scope="col">Messaging</th>
402                     [% END %]
403                     <th scope="col">Branches limitations</th>
404                     <th scope="col">Default privacy</th>
405                     <th scope="col">&nbsp; </th>
406                     <th scope="col">&nbsp; </th>
407                 </tr>
408             </thead>
409             <tbody>
410                 [% FOREACH category IN categories %]
411                     <tr>
412                         <td>[% category.categorycode %]</td>
413                         <td>
414                             <a href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">[% category.description %]</a>
415                         </td>
416                         <td>
417                             [% SWITCH category.category_type %]
418                                 [% CASE 'A' %]Adult
419                                 [% CASE 'C' %]Child
420                                 [% CASE 'P' %]Prof.
421                                 [% CASE 'I' %]Org.
422                                 [% CASE 'S' %]Staff
423                                 [% CASE 'X' %]Statistical
424                             [% END %]
425                         </td>
426                         <td>
427                             [% IF ( category.enrolmentperiod ) %]
428                                 [% category.enrolmentperiod %] months
429                             [% ELSE %]
430                                 until [% category.enrolmentperioddate | $KohaDates %]
431                             [% END %]
432                         </td>
433                         <td>[% category.dateofbirthrequired %] years</td>
434                         <td>[% category.upperagelimit %] years</td>
435                         <td>[% category.enrolmentfee | $Price %]</td>
436                         <td>[% IF ( category.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
437                         <td>[% IF ( category.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
438                         <td>[% category.reservefee | $Price %]</td>
439                         [% IF Koha.Preference('EnhancedMessagingPreferences') %]
440                             <td style="white-space: nowrap; font-size:80%;">
441                                 [% SET default_messaging = category.default_messaging %]
442                                 [% IF default_messaging.size %]
443                                     [% FOREACH prefs IN default_messaging %]
444                                         [% FOREACH transport IN prefs.transports %]
445                                             [% IF ( transport.transport ) %]
446                                                 [% IF ( prefs.Item_Due ) %]Item due
447                                                 [% ELSIF ( prefs.Advance_Notice ) %]Advance notice
448                                                 [% ELSIF ( prefs.Upcoming_Events ) %]Upcoming events
449                                                 [% ELSIF ( prefs.Hold_Filled ) %]Hold filled
450                                                 [% ELSIF ( prefs.Item_Check_in ) %]Item check-in
451                                                 [% ELSIF ( prefs.Item_Checkout ) %]Item checkout
452                                                 [% ELSE %]Unknown
453                                                 [% END %]:
454                                                 <strong>[% transport.transport %]</strong><br />
455                                             [% ELSE %]None<br />[% END %]
456                                         [% END %]
457                                     [% END %]
458                                 [% ELSE %]
459                                     None
460                                 [% END %]
461                             </td>
462                         [% END %]
463                         <td>
464                             [% SET branch_limitations = category.branch_limitations %]
465                             [% IF branch_limitations.size > 0 %]
466                                 [% branches_str = "" %]
467                                 [% FOREACH branch IN branch_limitations %]
468                                     [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
469                                 [% END %]
470                                 <span title="[% branches_str %]">
471                                     [% IF branch_limitations.size > 1 %]
472                                         [% branch_limitations.size %] branches limitations
473                                     [% ELSE %]
474                                         [% branch_limitations.size %] branch limitation
475                                     [% END %]
476                                 </span>
477                             [% ELSE %]
478                                 No limitation
479                             [% END %]
480                         </td>
481                         <td>
482                             [% SWITCH category.default_privacy %]
483                             [% CASE 'default' %]
484                                 Default
485                             [% CASE 'never' %]
486                                 Never
487                             [% CASE 'forever' %]
488                                 Forever
489                             [% END %]
490                         </td>
491                         <td><a href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">Edit</a></td>
492                         <td><a href="/cgi-bin/koha/admin/categories.pl?op=delete_confirm&amp;categorycode=[% category.categorycode |uri %]">Delete</a></td>
493                     </tr>
494                 [% END %]
495             </tbody>
496         </table>
497     [% ELSE %]
498         <div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categories.pl?op=add_form">Create a new category</a>.</div>
499     [% END %]
500 [% END %]
501
502 </div>
503 </div>
504 <div class="yui-b">
505 [% INCLUDE 'admin-menu.inc' %]
506 </div>
507 </div>
508 [% INCLUDE 'intranet-bottom.inc' %]