d1c2e4c38750c7a5bb8bafe6fc178e07785578f4
[koha_fer] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / categorie.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
3 [% IF ( add_validate ) %]Data recorded[% END %]
4 [% IF ( delete_confirm ) %][% IF ( totalgtzero ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
5 [% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% INCLUDE 'calendar.inc' %]
8 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
9 [% INCLUDE 'datatables.inc' %]
10 <script type="text/javascript" id="js">
11 //<![CDATA[
12     $(document).ready(function() {
13         $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
14             "aoColumnDefs": [
15                 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
16                 { "aTargets": [ 3,4,5 ], "sType": "natural" },
17             ],
18             "aaSorting": [[ 1, "asc" ]],
19             "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
20             "iDisplayLength": 20,
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 toUC(f) {
38                 var x=f.value.toUpperCase();
39                 f.value=x;
40                 return true;
41         }
42         //
43         function isNum(v,maybenull) {
44         var n = new Number(v.value);
45         if (isNaN(n)) {
46                 return false;
47                 }
48         if (maybenull==0 && v.value=='') {
49                 return false;
50         }
51         return true;
52         }
53         //
54         function isDate(f) {
55                 var t = Date.parse(f.value);
56                 if (isNaN(t)) {
57                         return false;
58                 }
59         }
60         // to check if the data are correctly entered.
61         function Check(ff) {
62             var ok=0;
63                 var _alertString=_("Form not submitted because of the following problem(s)");
64                 _alertString +="\n-------------------------------------------------------------------\n\n";
65                 ff.categorycode.value = ff.categorycode.value.trim();
66                 if (ff.categorycode.value.length==0) {
67                    ok=1;
68                    _alertString += _("- categorycode missing") + "\n";
69                 }
70                 else{
71                    var patt=/^[a-zA-Z0-9\-_]+$/g;
72                    if ( !patt.test(ff.categorycode.value) ) {
73                       ok=1;
74                       _alertString += _("- category code can only contain the following characters: letters, numbers, - and _") + "\n";
75                    }
76                 }
77                 if (!(ff.category_type.value)){
78                     ok=1;
79                     _alertString += _("- category type missing") + "\n";
80                 }
81                 if (!(isNotNull(ff.description,1))) {
82                     ok=1;
83                         _alertString += _("- description missing") + "\n";
84                 }
85                 if (!isNum(ff.upperagelimit,0) && ff.category_type.value=='C') {
86                     ok=1;
87                         _alertString += _("- upperagelimit is not a number") + "\n";
88                                 
89                 }
90                 if(!(ff.enrolmentperioddate.value || ff.enrolmentperiod.value)) {
91                     ok=1;
92                     _alertString += _("- either Enrollment period or Until date must be provided") + "\n";
93                 }
94                 if(ff.enrolmentperioddate.value && ff.enrolmentperiod.value){
95                         document.getElementById('enrolmentmessage').className = "error";
96                         return false;
97                 }
98                 
99                 if (ok) { // if there is a problem
100                     alert(_alertString);
101                     return false;
102                 }
103                 // if all is good
104                 ff.submit();
105         }
106         //]]>
107 </script>
108 <style type="text/css">#enrolmentmessage.hint { display : none; }</style>
109 </head>
110 <body id="admin_categorie" class="admin">
111 [% INCLUDE 'header.inc' %]
112 [% INCLUDE 'patrons-admin-search.inc' %]
113
114 <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 ( 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 %]
115 [% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Data recorded[% END %]
116 [% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( totalgtzero ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
117 [% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
118 [% IF ( else ) %]Patron categories[% END %]</div>
119
120 <div id="doc3" class="yui-t2">
121    
122    <div id="bd">
123         <div id="yui-main">
124         <div class="yui-b">
125
126 [% IF ( add_form ) %]
127         
128
129
130         
131         <form name="Aform" action="[% script_name %]" method="post">
132         <input type="hidden" name="op" value="add_validate" />
133         <input type="hidden" name="checked" value="0" />
134 [% IF ( categorycode ) %]
135                 <h1>Modify category [% categorycode |html %]</h1>
136         [% ELSE %]
137                 <h1>New category</h1>
138         [% END %]
139         <fieldset class="rows">
140         <ol>[% IF ( categorycode ) %]
141     <li><span class="label">Category code: </span>[% categorycode |html %]
142                                 <input type="hidden" name="categorycode" value="[% categorycode |html %]" /><input type="hidden" name="is_a_modif" value="1" /></li>
143         [% ELSE %]
144     <li><label for="categorycode" class="required">Category code: </label> <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" onblur="toUC(this)" /></li>
145         [% END %]
146     <li><label for="description" class="required">Description: </label> <input type="text" name="description" id="description" size="40" maxlength="80" value="[% description |html %]" /></li>
147     <li><label for="enrolmentperiod" class="required">Enrollment period: </label>
148         <fieldset>
149         <legend>Choose one</legend>
150         <ol>
151         <li><label for="enrolmentperiod" style="width:6em;">In months: </label>
152                 <input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF ( enrolmentperiod ) %][% enrolmentperiod %][% END %]" /> months</li>
153         <li><label for="enrolmentperioddate" style="width:6em;">Until date: </label>
154         <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% enrolmentperioddate %]" />
155                 <div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div>
156         </li>
157         </ol>
158         </fieldset>
159         </li>
160         <li><label for="dateofbirthrequired">Age required: </label> <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% dateofbirthrequired %]" size="3" maxlength="3" /> years</li>
161         <li><label for="upperagelimit">Upperage limit: </label> <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% upperagelimit %]" /> years</li>
162         <li><label for="enrolmentfee">Enrollment fee: </label><input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% enrolmentfee %]" /></li>
163         <li><label for="overduenoticerequired">Overdue notice required: </label> <select name="overduenoticerequired" id="overduenoticerequired">
164                         [% IF ( overduenoticerequired ) %]
165                                                 <option value="0">No</option>
166                                                 <option value="1" selected="selected">Yes</option>
167                         [% ELSE %]
168                                                 <option value="0" selected="selected">No</option>
169                                                 <option value="1">Yes</option>
170                         [% END %]
171                                         </select></li>
172     <li><label for="hidelostitems">Lost items in staff client: </label> <select name="hidelostitems" id="hidelostitems">
173                         [% IF ( hidelostitems ) %]
174                                                 <option value="0">Shown</option>
175                                                 <option value="1" selected="selected">Hidden by default</option>
176                         [% ELSE %]
177                                                 <option value="0" selected="selected">Shown</option>
178                                                 <option value="1">Hidden by default</option>
179                         [% END %]
180                                         </select></li>
181         <li><label for="reservefee">Hold fee: </label><input type="text" name="reservefee" id="reservefee" size="6" value="[% reservefee %]" /></li>
182     <li><label for="category_type" class="required">Category type: </label> <select name="category_type" id="category_type">
183                         [% IF ( type_n ) %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %]
184                                         [% IF ( type_A ) %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
185                                         [% IF ( type_C ) %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
186                                         [% IF ( type_S ) %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
187                                         [% IF ( type_I ) %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
188                                         [% IF ( type_P ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
189                                         [% IF ( type_X ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
190                                         </select>
191     </li>
192     <li><label for="branches">Branches limitation: </label>
193         <select id="branches" name="branches" multiple size="10">
194             <option value="">All branches</option>
195             [% FOREACH branch IN branches_loop %]
196               [% IF ( branch.selected ) %]
197                 <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
198               [% ELSE %]
199                 <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
200               [% END %]
201             [% END %]
202         </select>
203         <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
204         </span>
205     </li>
206     </ol>
207 </fieldset>
208
209     [% IF ( EnhancedMessagingPreferences ) %]
210       <fieldset class="rows">
211         <h4>Default messaging preferences for this patron category</h4>
212         [% INCLUDE 'messaging-preference-form.inc' %]
213       </fieldset>
214     [% END %]
215         <fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
216         </form>
217
218 [% END %]
219
220 [% IF ( add_validate ) %]
221 <h3>Data recorded</h3>
222         <form action="[% script_name %]" method="post">
223                 <input type="submit" value="OK" />
224         </form>
225
226 [% END %]
227
228 [% IF ( delete_confirm ) %]
229         
230         <form action="[% script_name %]" method="post">
231         <fieldset><legend>      
232         [% IF ( totalgtzero ) %]
233         Category [% categorycode |html %] is in use.  Deletion not possible![% ELSE %]
234 Confirm deletion of category [% categorycode |html %][% END %]</legend>
235
236 [% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %]
237         <table>
238         <tr><th scope="row">Category code: </th><td>[% categorycode |html %]</td></tr>
239         <tr><th scope="row">Description: </th><td>[% description |html %]</td></tr>
240         <tr><th scope="row">Enrollment period: </th>
241                 <td>
242                         [% IF ( enrolmentperiod ) %]
243                                 [% enrolmentperiod %] months
244                         [% ELSE %]
245                                 until [% enrolmentperioddate %]
246                         [% END %]
247                 </td>
248         </tr>
249         <tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
250         <tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
251         <tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
252         <tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
253         <tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
254         <tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
255 </table>
256                 <fieldset class="action">[% IF ( totalgtzero ) %]
257 <input type="submit" value="OK" /></form>
258                 [% ELSE %]
259                         <input type="hidden" name="op" value="delete_confirmed" />
260             <input type="hidden" name="categorycode" value="[% categorycode |html %]" /> <input type="submit" value="Delete this category" /> <a class="cancel" href="/cgi-bin/koha/admin/categorie.pl">Cancel</a>
261                 [% END %]</fieldset></fieldset></form>
262 [% END %]
263
264 [% IF ( delete_confirmed ) %]
265 <h3>Category deleted</h3>
266
267         <form action="[% script_name %]" method="post">
268         <input type="submit" value="OK" />
269         </form>
270 [% END %]
271
272 [% IF ( else ) %]
273
274 <div id="toolbar" class="btn-toolbar">
275     <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/categorie.pl?op=add_form"><i class="icon-plus"></i> New category</a>
276 </div>
277
278 <h2>Patron category administration</h2>
279 [% IF ( searchfield ) %]
280                 You Searched for [% searchfield %]</span>
281         [% END %]
282 [% IF ( loop ) %]
283 <div id="pagertable_categorie">
284 </div>
285         <table id="table_categorie">
286                 <thead>
287         <tr>
288                         <th scope="col">Code</th>
289                         <th scope="col">Category name</th>
290                         <th scope="col">Type</th>
291                         <th scope="col">Enrollment period</th>
292                         <th scope="col">Age required</th>
293                         <th scope="col">Upper age limit</th>
294                         <th scope="col">Enrollment fee</th>
295                         <th scope="col">Overdue</th>
296             <th scope="col">Lost items</th>
297                         <th scope="col">Hold fee</th>
298             [% IF ( EnhancedMessagingPreferences ) %]
299             <th scope="col">Messaging</th>
300             [% END %]
301             <th scope="col">Branches limitations</th>
302             <th scope="col">&nbsp; </th>
303             <th scope="col">&nbsp; </th>
304         </tr>
305                 </thead>
306         <tbody>
307                 [% FOREACH loo IN loop %]
308                         <tr>
309                         <td>[% loo.categorycode |html %]</td>
310                         <td>
311                             <a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">[% loo.description |html %]</a>
312                         </td>
313                         <td>
314                             [% IF ( loo.type_A ) %]Adult[% END %]
315                             [% IF ( loo.type_C ) %]Child[% END %]
316                             [% IF ( loo.type_P ) %]Prof.[% END %]
317                             [% IF ( loo.type_I ) %]Org.[% END %]
318                             [% IF ( loo.type_S ) %]Staff[% END %]
319                             [% IF ( loo.type_X ) %]Statistical[% END %]
320                         </td>
321                         <td>
322                                 [% IF ( loo.enrolmentperiod ) %]
323                                         [% loo.enrolmentperiod %] months
324                                 [% ELSE %]
325                                         until [% loo.enrolmentperioddate %]
326                                 [% END %]
327                         
328                         </td>
329                         <td>[% loo.dateofbirthrequired %] years</td>
330                         <td>[% loo.upperagelimit %] years</td>
331                         <td>[% loo.enrolmentfee %]</td>
332                         <td>[% IF ( loo.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
333                         <td>[% IF ( loo.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
334                         <td>[% loo.reservefee %]</td>
335                         [% IF ( EnhancedMessagingPreferences ) %]
336                         <td style="white-space: nowrap; font-size:80%;">
337                             [% IF ( loo.messaging_prefs ) %]
338                               [% FOREACH prefs IN loo.messaging_prefs %]
339                                         [% FOREACH transport IN prefs.transports %]
340                                          [% IF ( transport.transport ) %]
341                                             [% IF ( prefs.Item_Due ) %]Item due
342                                             [% ELSIF ( prefs.Advance_Notice ) %]Advance notice
343                                             [% ELSIF ( prefs.Upcoming_Events ) %]Upcoming events
344                                             [% ELSIF ( prefs.Hold_Filled ) %]Hold filled
345                                             [% ELSIF ( prefs.Item_Check_in ) %]Item check-in
346                                             [% ELSIF ( prefs.Item_Checkout ) %]Item checkout
347                                                         [% ELSE %]Unknown
348                                                         [% END %]:
349                                                             <strong>[% transport.transport %]</strong><br />
350                                                          [% ELSE %]None<br />[% END %]
351                                         [% END %]
352                                 [% END %]
353                             [% ELSE %]
354                                 None
355                             [% END %]
356                         </td>
357                         [% END %]
358                         <td>
359                             [% IF loo.branches.size > 0 %]
360                                 [% branches_str = "" %]
361                                 [% FOREACH branch IN loo.branches %]
362                                     [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
363                                 [% END %]
364                                 <span title="[% branches_str %]">
365                                     [% IF loo.branches.size > 1 %]
366                                         [% loo.branches.size %] branches limitations
367                                     [% ELSE %]
368                                         [% loo.branches.size %] branch limitation
369                                     [% END %]
370                                 </span>
371                             [% ELSE %]
372                                 No limitation
373                             [% END %]
374                         </td>
375                         <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
376                         <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
377                 </tr>
378                 [% END %]
379         </tbody>
380         </table>
381 [% ELSE %]
382         <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>
383 [% END %]
384 [% END %]
385
386 </div>
387 </div>
388 <div class="yui-b">
389 [% INCLUDE 'admin-menu.inc' %]
390 </div>
391 </div>
392 [% INCLUDE 'intranet-bottom.inc' %]