Bug 12686: Make more selected option XHTML compliant
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 [% INCLUDE 'calendar.inc' %]
5 <script type="text/javascript">
6 //<![CDATA[
7
8 function clear_edit(){
9     var cancel = confirm(_("Are you sure you want to cancel your changes?"));
10     if ( !cancel ) return;
11     $('#default-circulation-rules td').removeClass('highlighted-row');
12     var edit_row = $("#edit_row");
13     $(edit_row).find("input").each(function(){
14         var type = $(this).attr("type");
15         if (type != "button" && type != "submit" ) {
16             $(this).val("");
17             $(this).removeAttr("disabled");
18         }
19     });
20     $(edit_row).find("select").removeAttr("disabled");
21     $(edit_row).find("select option:first").attr("selected", "selected");
22     $(edit_row).find("td:last input[name='clear']").remove();
23 }
24
25 $(document).ready(function() {
26         $('#selectlibrary').find("input:submit").hide();
27         $('#branch').change(function() {
28                 $('#selectlibrary').submit();
29         });
30         $(".editrule").click(function(){
31             if ( $(edit_row).find("input[type='text'][value!='']").length > 0 ) {
32                 var edit = confirm(_("Are you sure you want to edit another rule?"));
33                 if (!edit) return false;
34             }
35             $('#default-circulation-rules td').removeClass('highlighted-row');
36             $(this).parent().parent().find("td").each(function (i) {
37                 $(this).addClass('highlighted-row');
38                 itm = $(this).text();
39                 itm = itm.replace(/^\s*|\s*$/g,'');
40                 var current_column = $("#edit_row td:eq("+i+")");
41                 if ( i != 5 ) {
42                     $(current_column).find("input[type='text']").val(itm);
43                     // select the corresponding option
44                     $(current_column).find("select option").each(function(){
45                         opt = $(this).text().toLowerCase();
46                         opt = opt.replace(/^\s*|\s*$/g,'');
47                         if ( opt == itm.toLowerCase() ) {
48                             $(this).attr('selected', 'selected');
49                         }
50                     });
51                     if ( i == 0 || i == 1 ) {
52                         // Disable the 2 first columns, we cannot update them.
53                         var val = $(current_column).find("select option:selected").val();
54                         var name = "categorycode";
55                         if ( i == 1 ) {
56                             name="itemtype";
57                         }
58                         // Remove potential previous input added
59                         $(current_column).find("input").remove();
60                         $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
61                     } else if ( i == 2 ) {
62                         // If the value is not an integer for "Current checkouts allowed"
63                         // The value is "Unlimited" (or an equivalent translated string)
64                         // an it should be set to an empty string
65                         if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
66                             $(current_column).find("input[type='text']").val("");
67                         }
68                     }
69                 } else {
70                     // specific processing for the Hard due date column
71                     var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
72                     var input_value = '';
73                     if (typeof select_value === 'undefined'){
74                         select_value = '-1';
75                     }else {
76                         input_value = itm.split(' ')[1];
77                     }
78                     $(current_column).find("input[type='text']").val(input_value);
79                     $(current_column).find("select").val(select_value);
80                 }
81             });
82             $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled');
83             $("#default-circulation-rules tr:last td:eq(1) select").attr('disabled', 'disabled');
84             return false;
85         });
86 });
87 //]]>
88 </script>
89 </head>
90 <body id="admin_smart-rules" class="admin">
91 [% INCLUDE 'header.inc' %]
92 [% INCLUDE 'cat-search.inc' %]
93
94 <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; Circulation and fine rules</div>
95
96 <div id="doc3" class="yui-t1">
97
98 <div id="bd">
99     <div id="yui-main">
100     <div class="yui-b">
101     <h1 class="parameters">
102         [% IF ( humanbranch ) %]
103             Defining circulation and fine rules for "[% humanbranch %]"
104         [% ELSE %]
105             Defining circulation and fine rules for all libraries
106         [% END %]
107     </h1>
108     <div class="help">
109         <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
110         <ul>
111             <li>same library, same patron type, same item type</li>
112             <li>same library, same patron type, all item types</li>
113             <li>same library, all patron types, same item type</li>
114             <li>same library, all patron types, all item types</li>
115             <li>default (all libraries), same patron type, same item type</li>
116             <li>default (all libraries), same patron type, all item types</li>
117             <li>default (all libraries), all patron types, same item type</li>
118             <li>default (all libraries), all patron types, all item types</li>
119         </ul>
120         <p>To modify a rule, create a new one with the same patron type and item type.</p>
121     </div>
122     <div>
123         <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
124         Select a library :
125             <select name="branch" id="branch" style="width:20em;">
126                 <option value="*">All libraries</option>
127             [% FOREACH branchloo IN branchloop %]
128                                 [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
129             [% END %]
130             </select>
131         </form>
132 [% IF ( definedbranch ) %]<form action="/cgi-bin/koha/admin/clone-rules.pl" method="post"><label 
133 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidden" name="frombranch" value="[% current_branch %]" />
134             <select name="tobranch" id="tobranch">[% FOREACH branchloo IN branchloop %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]</select> <input type="submit" value="Clone" /></form>[% END %]
135
136         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
137             <input type="hidden" name="op" value="add" />
138             <input type="hidden" name="branch" value="[% current_branch %]"/>
139             <table id="default-circulation-rules">
140             <thead>
141             <tr>
142                 <th>Patron category</th>
143                 <th>Item type</th>
144                 <th>Current checkouts allowed</th>
145                 <th>Loan period</th>
146                 <th>Unit</th>
147                 <th>Hard due date</th>
148                 <th>Fine amount</th>
149                 <th>Fine charging interval</th>
150                 <th>Fine grace period (day)</th>
151                 <th>Overdue fines cap (amount)</th>
152                 <th>Suspension in days (day)</th>
153                 <th>Max. suspension duration (day)</th>
154                 <th>Renewals allowed (count)</th>
155                 <th>Renewal period</th>
156                 <th>No renewal before</th>
157                 <th>Holds allowed (count)</th>
158                 <th>Rental discount (%)</th>
159                 <th colspan="2">&nbsp;</th>
160             </tr>
161             </thead>
162             <tbody>
163                                 [% FOREACH rule IN rules %]
164                                         [% UNLESS ( loop.odd ) %]
165                                         <tr class="highlight" id="row_[% loop.count %]">
166                                         [% ELSE %]
167                                         <tr id="row_[% loop.count %]">
168                                         [% END %]
169                                                         <td>[% IF ( rule.default_humancategorycode ) %]
170                                                                         <em>All</em>
171                                                                 [% ELSE %]
172                                                                         [% rule.humancategorycode %]
173                                                                 [% END %]
174                                                         </td>
175                                                         <td>[% IF ( rule.default_humanitemtype ) %]
176                                                                         <em>All</em>
177                                                                 [% ELSE %]
178                                                                         [% rule.humanitemtype %]
179                                                                 [% END %]
180                                                         </td>
181                                                         <td>[% IF ( rule.unlimited_maxissueqty ) %]
182                                                                         Unlimited
183                                                                 [% ELSE %]
184                                                                         [% rule.maxissueqty %]
185                                                                 [% END %]
186                                                         </td>
187                                                         <td>[% rule.issuelength %]</td>
188                                                         <td>
189                                                             [% rule.lengthunit %]
190                                                         </td>
191                             <td>
192                               [% IF ( rule.hardduedate ) %]
193                                 [% IF ( rule.hardduedatebefore ) %]
194                                   before [% rule.hardduedate %]
195                                   <input type="hidden" name="hardduedatecomparebackup" value="-1" />
196                                 [% ELSIF ( rule.hardduedateexact ) %]
197                                   on [% rule.hardduedate %]
198                                   <input type="hidden" name="hardduedatecomparebackup" value="0" />
199                                 [% ELSIF ( rule.hardduedateafter ) %]
200                                   after [% rule.hardduedate %]
201                                   <input type="hidden" name="hardduedatecomparebackup" value="1" />
202                                 [% END %]
203                               [% ELSE %]
204                                 None defined
205                               [% END %]
206                             </td>
207                                                         <td>[% rule.fine %]</td>
208                                                         <td>[% rule.chargeperiod %]</td>
209                                                         <td>[% rule.firstremind %]</td>
210                             <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
211                                                         <td>[% rule.finedays %]</td>
212                             <td>[% rule.maxsuspensiondays %]</td>
213                                                         <td>[% rule.renewalsallowed %]</td>
214                             <td>[% rule.renewalperiod %]</td>
215                             <td>[% rule.norenewalbefore %]</td>
216                                                         <td>[% rule.reservesallowed %]</td>
217                                                         <td>[% rule.rentaldiscount %]</td>
218                             <td><a href="#" class="editrule">Edit</a></td>
219                                                         <td>
220                                                                 <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]">Delete</a>
221                                                         </td>
222                         </tr>
223                 [% END %]
224                 <tr id="edit_row">
225                     <td>
226                         <select name="categorycode" id="categorycode">
227                             <option value="*">All</option>
228                         [% FOREACH categoryloo IN categoryloop %]
229                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
230                         [% END %]
231                         </select>
232                     </td>
233                     <td>
234                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
235                             <option value="*">All</option>
236                         [% FOREACH itemtypeloo IN itemtypeloop %]
237                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
238                         [% END %]
239                         </select>
240                     </td>
241                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
242                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
243                     <td>
244                       <select name="lengthunit" id="lengthunit">
245                         <option value="days" selected="selected">Days</option>
246                         <option value="hours">Hours</option>
247                       </select>
248                     </td>
249                     <td>
250                         <select name="hardduedatecompare" id="hardduedatecompare">
251                            <option value="-1">Before</option>
252                            <option value="0">Exactly on</option>
253                            <option value="1">After</option>
254                         </select>
255                         <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate %]" class="datepicker" />
256                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
257                     </td>
258                     <td><input type="text" name="fine" id="fine" size="4" /></td>
259                     <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
260                     <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
261                     <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
262                     <td><input type="text" name="finedays" id="fined" size="3" /> </td>
263                     <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
264                     <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
265                     <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
266                     <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
267                     <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
268                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
269                     <td colspan="2">
270                         <input type="hidden" name="branch" value="[% current_branch %]"/>
271                         <input type="submit" value="Save" class="submit" />
272                         <input type="button" name="cancel" value="Clear" onclick="clear_edit();return false;" />
273                     </td>
274                 </tr>
275                 </tbody>
276             </table>
277         </form>
278     </div>
279     <div id="defaults-for-this-library" class="container">
280     <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
281         <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
282         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
283             <input type="hidden" name="op" value="set-branch-defaults" />
284             <input type="hidden" name="branch" value="[% current_branch %]"/>
285             <table>
286                 <tr>
287                     <th>&nbsp;</th>
288                     <th>Total current checkouts allowed</th>
289                     <th>Hold policy</th>
290                     <th>Return policy</th>
291                     <th>&nbsp;</th>
292                     <th>&nbsp;</th>
293                 </tr>
294                 <tr>
295                     <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
296                     <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
297                     <td>
298                         <select name="holdallowed">
299                             [% IF ( default_holdallowed_any ) %]
300                             <option value="2" selected="selected">
301                             [% ELSE %]
302                             <option value="2">
303                             [% END %]
304                                 From any library
305                             </option>
306                             [% IF ( default_holdallowed_same ) %]
307                             <option value="1" selected="selected">
308                             [% ELSE %]
309                             <option value="1">
310                             [% END %]
311                                 From home library
312                             </option>
313                             [% IF ( default_holdallowed_none ) %]
314                             <option value="0" selected="selected">
315                             [% ELSE %]
316                             <option value="0">
317                             [% END %]
318                                 No holds allowed
319                             </option>
320                         </select>
321                     </td>
322                     <td>
323                         <select name="returnbranch">
324                             [% IF ( default_returnbranch == 'homebranch' ) %]
325                             <option value="homebranch" selected="selected">
326                             [% ELSE %]
327                             <option value="homebranch">
328                             [% END %]
329                                 Item returns home
330                             </option>
331                             [% IF ( default_returnbranch == 'holdingbranch' ) %]
332                             <option value="holdingbranch" selected="selected">
333                             [% ELSE %]
334                             <option value="holdingbranch">
335                             [% END %]
336                                 Item returns to issuing library
337                             </option>
338                             [% IF ( default_returnbranch == 'noreturn' ) %]
339                             <option value="noreturn" selected="selected">
340                             [% ELSE %]
341                             <option value="noreturn">
342                             [% END %]
343                                 Item floats
344                             </option>
345                         </select>
346                     </td>
347                     <td><input type="submit" value="Save" class="submit" /></td>
348                     <td>
349                         <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
350                     </td>
351                 </tr>
352             </table>
353         </form>
354     </div>
355     [% IF ( show_branch_cat_rule_form ) %]
356     <div id="holds-policy-by-patron-category" class="container">
357     <h3>[% IF humanbranch %]Checkout limit by patron category for [% humanbranch %][% ELSE %]Default checkout limit by patron category[% END %]</h3>
358         <p>For this library, you can specify the maximum number of loans that
359             a patron of a given category can make, regardless of the item type.
360         </p>
361         <p>If the total amount loanable for a given patron category is left blank,
362            no limit applies, except possibly for a limit you define for a specific item type.
363         </p>
364         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
365             <input type="hidden" name="op" value="add-branch-cat" />
366             <input type="hidden" name="branch" value="[% current_branch %]"/>
367             <table>
368                 <tr>
369                     <th>Patron category</th>
370                     <th>Total current checkouts allowed</th>
371                     <th>&nbsp;</th>
372                 </tr>
373                 [% FOREACH branch_cat_rule_loo IN branch_cat_rule_loop %]
374                     [% UNLESS ( loop.odd ) %]
375                     <tr class="highlight">
376                     [% ELSE %]
377                     <tr>
378                     [% END %]
379                         <td>[% IF ( branch_cat_rule_loo.default_humancategorycode ) %]
380                                 <em>Default</em>
381                             [% ELSE %]
382                                 [% branch_cat_rule_loo.humancategorycode %]
383                             [% END %]
384                         </td>
385                         <td>[% IF ( branch_cat_rule_loo.unlimited_maxissueqty ) %]
386                                 Unlimited
387                             [% ELSE %]
388                                 [% branch_cat_rule_loo.maxissueqty %]
389                             [% END %]
390                         </td>
391                         <td>
392                             <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode %]&amp;branch=[% current_branch %]">Delete</a>
393                         </td>
394                     </tr>
395                 [% END %]
396                 <tr>
397                     <td>
398                         <select name="categorycode">
399                         [% FOREACH categoryloo IN categoryloop %]
400                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
401                         [% END %]
402                         </select>
403                     </td>
404                     <td><input name="maxissueqty" size="3" /></td>
405                     <td><input type="submit" value="Add" class="submit" /></td>
406                 </tr>
407             </table>
408         </form>
409     </div>
410     [% END %]
411     <div id="holds-policy-by-item-type" class="container">
412     <h3>[% IF humanbranch %]Holds policy by item type for [% humanbranch %][% ELSE %]Default holds policy by item type[% END %]</h3>
413         <p>
414             For this library, you can edit rules for given itemtypes, regardless
415             of the patron's category.
416         </p>
417         <p>
418             Currently, this means hold policies.
419             The various policies have the following effects:
420         </p>
421         <ul>
422             <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
423             <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
424             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
425         </ul>
426         <p>
427             Note that if the system preference
428             <code>AllowHoldPolicyOverride</code> is enabled, these policies can
429             be overridden by your circulation staff. Also, these policies are
430             based on the patron's home library, <em>not</em> the library where the hold is being placed..
431         </p>
432
433         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
434             <input type="hidden" name="op" value="add-branch-item" />
435             <input type="hidden" name="branch" value="[% current_branch %]"/>
436             <table>
437                 <tr>
438                     <th>Item type</th>
439                     <th>Hold policy</th>
440                     <th>Return policy</th>
441                     <th>&nbsp;</th>
442                 </tr>
443                 [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
444                     [% UNLESS ( loop.odd ) %]
445                     <tr class="highlight">
446                     [% ELSE %]
447                     <tr>
448                     [% END %]
449                         <td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
450                                 <em>Default</em>
451                             [% ELSE %]
452                                 [% branch_item_rule_loo.humanitemtype %]
453                             [% END %]
454                         </td>
455                         <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
456                                 From any library
457                             [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
458                                 From home library
459                             [% ELSE %]
460                                 No holds allowed
461                             [% END %]
462                         </td>
463                         <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
464                                 Item returns home
465                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
466                                 Item returns to issuing branch
467                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
468                                 Item floats
469                             [% ELSE %]
470                                 Error - unknown option
471                             [% END %]
472                         </td>
473                         <td>
474                             <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]">Delete</a>
475                         </td>
476                     </tr>
477                 [% END %]
478                 <tr>
479                     <td>
480                         <select name="itemtype">
481                         [% FOREACH itemtypeloo IN itemtypeloop %]
482                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
483                         [% END %]
484                         </select>
485                     </td>
486                     <td>
487                         <select name="holdallowed">
488                             <option value="2">From any library</option>
489                             <option value="1">From home library</option>
490                             <option value="0">No holds allowed</option>
491                         </select>
492                     </td>
493                     <td>
494                         <select name="returnbranch">
495                             <option value="homebranch">Item returns home</option>
496                             <option value="holdingbranch">Item returns to issuing library</option>
497                             <option value="noreturn">Item floats</option>
498                         </select>
499                     </td>
500                     <td><input type="submit" value="Add" class="submit" /></td>
501                 </tr>
502             </table>
503         </form>
504     </div>
505 </div>
506
507 </div>
508 <div class="yui-b">
509 [% INCLUDE 'admin-menu.inc' %]
510 </div>
511 </div>
512 [% INCLUDE 'intranet-bottom.inc' %]