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