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