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