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