Bug 19539: Fix column index shift in cirulation rules
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
1 [% USE Branches %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% INCLUDE 'calendar.inc' %]
6 <script type="text/javascript">
7 //<![CDATA[
8
9 function clear_edit(){
10     var cancel = confirm(_("Are you sure you want to cancel your changes?"));
11     if ( !cancel ) return;
12     $('#default-circulation-rules td').removeClass('highlighted-row');
13     var edit_row = $("#edit_row");
14     $(edit_row).find("input").each(function(){
15         var type = $(this).attr("type");
16         if (type != "button" && type != "submit" ) {
17             $(this).val("");
18             $(this).prop('disabled', false);
19         }
20         if ( type == "checkbox" ) {
21             $(this).prop('checked', false);
22         }
23     });
24     $(edit_row).find("select").prop('disabled', false);
25     $(edit_row).find("select option:first").attr("selected", "selected");
26     $(edit_row).find("td:last input[name='clear']").remove();
27 }
28
29 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
30
31
32 $(document).ready(function() {
33     $(".delete").on("click",function(){
34         return confirmDelete(MSG_CONFIRM_DELETE);
35     });
36
37     $("#clone_rules").on("click",function(){
38         var library_dropdown = document.getElementById("branch");
39         var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value;
40         var selected_library_text = $("#branch option:selected").text();
41         var to_library = $("#tobranch option:selected").text();
42         var MSG_CONFIRM_CLONE;
43         if (selected_library === "*") {
44             MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library);
45             return confirmClone(MSG_CONFIRM_CLONE);
46         } else {
47             MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library);
48             return confirmClone(MSG_CONFIRM_CLONE);
49         }
50     });
51
52         $('#cap_fine_to_replacement_price').on('change', function(){
53             $('#overduefinescap').prop('disabled', $(this).is(':checked') );
54         });
55         $('#selectlibrary').find("input:submit").hide();
56         $('#branch').change(function() {
57                 $('#selectlibrary').submit();
58         });
59         $(".editrule").click(function(){
60             if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) {
61                 var edit = confirm(_("Are you sure you want to edit another rule?"));
62                 if (!edit) return false;
63             }
64             $('#default-circulation-rules td').removeClass('highlighted-row');
65             $(this).parent().parent().find("td").each(function (i) {
66                 $(this).addClass('highlighted-row');
67                 itm = $(this).text();
68                 itm = itm.replace(/^\s*|\s*$/g,'');
69                 var current_column = $("#edit_row td:eq("+i+")");
70                 if ( i == 6 ) {
71                     // specific processing for the Hard due date column
72                     var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
73                     var input_value = '';
74                     if (typeof select_value === 'undefined'){
75                         select_value = '-1';
76                     }else {
77                         input_value = itm.split(' ')[1];
78                     }
79                     $(current_column).find("input[type='text']").val(input_value);
80                     $(current_column).find("select").val(select_value);
81                 } else if ( i == 12 ) {
82                     // specific processing for cap_fine_to_replacement_price
83                     var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
84                     $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
85                     $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
86                 } else {
87                     $(current_column).find("input[type='text']").val(itm);
88                     // select the corresponding option
89                     $(current_column).find("select option").each(function(){
90                         opt = $(this).text().toLowerCase();
91                         opt = opt.replace(/^\s*|\s*$/g,'');
92                         if ( opt == itm.toLowerCase() ) {
93                             $(this).attr('selected', 'selected');
94                         }
95                     });
96                     if ( i == 0 || i == 1 ) {
97                         // Disable the 2 first columns, we cannot update them.
98                         var val = $(current_column).find("select option:selected").val();
99                         var name = "categorycode";
100                         if ( i == 1 ) {
101                             name="itemtype";
102                         }
103                         // Remove potential previous input added
104                         $(current_column).find("input").remove();
105                         $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
106                     } else if ( i == 3 || i == 4 ) {
107                         // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
108                         // The value is "Unlimited" (or an equivalent translated string)
109                         // an it should be set to an empty string
110                         if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
111                             $(current_column).find("input[type='text']").val("");
112                         }
113                     }
114                 }
115             });
116             $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
117             $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
118             return false;
119         });
120         $(".clear_edit").on("click",function(e){
121             e.preventDefault();
122             clear_edit();
123         });
124 });
125 //]]>
126 </script>
127 </head>
128 <body id="admin_smart-rules" class="admin">
129 [% INCLUDE 'header.inc' %]
130 [% INCLUDE 'prefs-admin-search.inc' %]
131
132 <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>
133
134 <div id="doc3" class="yui-t1">
135
136 <div id="bd">
137     <div id="yui-main">
138     <div class="yui-b">
139     <h1 class="parameters">
140         [% IF humanbranch %]
141             Defining circulation and fine rules for "[% Branches.GetName( humanbranch ) %]"
142         [% ELSE %]
143             Defining circulation and fine rules for all libraries
144         [% END %]
145     </h1>
146     <div class="help">
147         <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
148         <ul>
149             <li>same library, same patron category, same item type</li>
150             <li>same library, same patron category, all item types</li>
151             <li>same library, all patron categories, same item type</li>
152             <li>same library, all patron categories, all item types</li>
153             <li>default (all libraries), same patron category, same item type</li>
154             <li>default (all libraries), same patron category, all item types</li>
155             <li>default (all libraries), all patron categories, same item type</li>
156             <li>default (all libraries), all patron categories, all item types</li>
157         </ul>
158         <p>To modify a rule, create a new one with the same patron category and item type.</p>
159     </div>
160     <div>
161         <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
162         Select a library :
163             <select name="branch" id="branch" style="width:20em;">
164                 <option value="*">Standard rules for all libraries</option>
165                 [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
166             </select>
167         </form>
168         [% IF ( definedbranch ) %]
169             <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
170                 <label for="tobranch"><strong>Clone these rules to:</strong></label>
171                 <input type="hidden" name="frombranch" value="[% current_branch %]" />
172                 <select name="tobranch" id="tobranch">
173                     [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
174                 </select>
175                 <input type="submit" id="clone_rules" value="Clone" />
176             </form>
177         [% END %]
178
179         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
180             <input type="hidden" name="op" value="add" />
181             <input type="hidden" name="branch" value="[% current_branch %]"/>
182             <table id="default-circulation-rules">
183             <thead>
184             <tr>
185                 <th>Patron category</th>
186                 <th>Item type</th>
187                 <th>Actions</th>
188                 <th>Current checkouts allowed</th>
189                 <th>Current on-site checkouts allowed</th>
190                 <th>Loan period</th>
191                 <th>Unit</th>
192                 <th>Hard due date</th>
193                 <th>Fine amount</th>
194                 <th>Fine charging interval</th>
195                 <th>When to charge</th>
196                 <th>Fine grace period</th>
197                 <th>Overdue fines cap (amount)</th>
198                 <th>Cap fine at replacement price</th>
199                 <th>Suspension in days (day)</th>
200                 <th>Max. suspension duration (day)</th>
201                 <th>Renewals allowed (count)</th>
202                 <th>Renewal period</th>
203                 <th>No renewal before</th>
204                 <th>Automatic renewal</th>
205                 <th>No automatic renewal after</th>
206                 <th>No automatic renewal after (hard limit)</th>
207                 <th>Holds allowed (count)</th>
208                 <th>Holds per record (count)</th>
209                 <th>On shelf holds allowed</th>
210                 <th>Item level holds</th>
211                 <th>Article requests</th>
212                 <th>Rental discount (%)</th>
213                 <th>Actions</th>
214             </tr>
215             </thead>
216             <tbody>
217                                 [% FOREACH rule IN rules %]
218                                         <tr id="row_[% loop.count %]">
219                                                         <td>[% IF ( rule.default_humancategorycode ) %]
220                                                                         <em>All</em>
221                                                                 [% ELSE %]
222                                                                         [% rule.humancategorycode %]
223                                                                 [% END %]
224                                                         </td>
225                             <td>[% IF rule.default_translated_description %]
226                                                                         <em>All</em>
227                                                                 [% ELSE %]
228                                                                         [% rule.translated_description %]
229                                                                 [% END %]
230                                                         </td>
231                                                         <td class="actions">
232                                                           <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
233                                                           <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
234                                                         </td>
235
236                                                         <td>[% IF ( rule.unlimited_maxissueqty ) %]
237                                                                         Unlimited
238                                                                 [% ELSE %]
239                                                                         [% rule.maxissueqty %]
240                                                                 [% END %]
241                                                         </td>
242                             <td>[% IF rule.unlimited_maxonsiteissueqty %]
243                                     Unlimited
244                                 [% ELSE %]
245                                     [% rule.maxonsiteissueqty %]
246                                 [% END %]
247                             </td>
248                                                         <td>[% rule.issuelength %]</td>
249                                                         <td>
250                                                             [% rule.lengthunit %]
251                                                         </td>
252                             <td>
253                               [% IF ( rule.hardduedate ) %]
254                                 [% IF ( rule.hardduedatebefore ) %]
255                                   before [% rule.hardduedate %]
256                                   <input type="hidden" name="hardduedatecomparebackup" value="-1" />
257                                 [% ELSIF ( rule.hardduedateexact ) %]
258                                   on [% rule.hardduedate %]
259                                   <input type="hidden" name="hardduedatecomparebackup" value="0" />
260                                 [% ELSIF ( rule.hardduedateafter ) %]
261                                   after [% rule.hardduedate %]
262                                   <input type="hidden" name="hardduedatecomparebackup" value="1" />
263                                 [% END %]
264                               [% ELSE %]
265                                 None defined
266                               [% END %]
267                             </td>
268                                                         <td>[% rule.fine %]</td>
269                                                         <td>[% rule.chargeperiod %]</td>
270                 <td>[% IF rule.chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
271                                                         <td>[% rule.firstremind %]</td>
272                             <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
273                             <td>
274                                 [% IF rule.cap_fine_to_replacement_price %]
275                                     <input type="checkbox" checked="checked" disabled="disabled" />
276                                 [% ELSE %]
277                                     <input type="checkbox" disabled="disabled" />
278                                 [% END %]
279                             </td>
280                                                         <td>[% rule.finedays %]</td>
281                             <td>[% rule.maxsuspensiondays %]</td>
282                                                         <td>[% rule.renewalsallowed %]</td>
283                             <td>[% rule.renewalperiod %]</td>
284                             <td>[% rule.norenewalbefore %]</td>
285                             <td>
286                                 [% IF ( rule.auto_renew ) %]
287                                 Yes
288                                 [% ELSE %]
289                                 No
290                                 [% END %]
291                             </td>
292                             <td>[% rule.no_auto_renewal_after %]</td>
293                             <td>[% rule.no_auto_renewal_after_hard_limit %]</td>
294                                                         <td>[% rule.reservesallowed %]</td>
295                                                         <td>[% rule.holds_per_record %]</td>
296                                                         <td>
297                                                             [% IF rule.onshelfholds == 1 %]
298                                                                 Yes
299                                                             [% ELSIF rule.onshelfholds == 2 %]
300                                                                 If all unavailable
301                                                             [% ELSE %]
302                                                                 If any unavailable
303                                                             [% END %]</td>
304                                                         <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
305                                                         <td>
306                                                             [% IF rule.article_requests == 'no' %]
307                                                                 No
308                                                             [% ELSIF rule.article_requests == 'yes' %]
309                                                                 Yes
310                                                             [% ELSIF rule.article_requests == 'bib_only' %]
311                                                                 Record only
312                                                             [% ELSIF rule.article_requests == 'item_only' %]
313                                                                 Item only
314                                                             [% END %]
315                                                         </td>
316                                                         <td>[% rule.rentaldiscount %]</td>
317                                                         <td class="actions">
318                                                           <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
319                                                           <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
320                                                         </td>
321
322                         </tr>
323                 [% END %]
324                 <tr id="edit_row">
325                     <td>
326                         <select name="categorycode" id="categorycode">
327                             <option value="*">All</option>
328                         [% FOREACH patron_category IN patron_categories%]
329                             <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option>
330                         [% END %]
331                         </select>
332                     </td>
333                     <td>
334                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
335                             <option value="*">All</option>
336                         [% FOREACH itemtypeloo IN itemtypeloop %]
337                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
338                         [% END %]
339                         </select>
340                     </td>
341                     <td class="actions">
342                         <input type="hidden" name="branch" value="[% current_branch %]"/>
343                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
344                         <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
345                     </td>
346                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
347                     <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
348                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
349                     <td>
350                       <select name="lengthunit" id="lengthunit">
351                         <option value="days" selected="selected">Days</option>
352                         <option value="hours">Hours</option>
353                       </select>
354                     </td>
355                     <td>
356                         <select name="hardduedatecompare" id="hardduedatecompare">
357                            <option value="-1">Before</option>
358                            <option value="0">Exactly on</option>
359                            <option value="1">After</option>
360                         </select>
361                         <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate %]" class="datepicker" />
362                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
363                     </td>
364                     <td><input type="text" name="fine" id="fine" size="4" /></td>
365                     <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
366                     <td>
367                         <select name="chargeperiod_charge_at" id="chargeperiod_charge_at">
368                            <option value="0">End of interval</option>
369                            <option value="1">Start of interval</option>
370                         </select>
371                     </td>
372                     <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
373                     <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
374                     <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td>
375                     <td><input type="text" name="finedays" id="fined" size="3" /> </td>
376                     <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
377                     <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
378                     <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
379                     <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
380                     <td>
381                         <select name="auto_renew" id="auto_renew">
382                             <option value="no" selected>No</option>
383                             <option value="yes">Yes</option>
384                         </select>
385                     </td>
386                     <td><input type="text" name="no_auto_renewal_after" id="no_auto_renewal_after" size="3" /></td>
387                     <td>
388                         <input type="text" size="10" name="no_auto_renewal_after_hard_limit" id="no_auto_renewal_after_hard_limit" value="[% no_auto_renewal_after_hard_limit %]" class="datepicker"/>
389                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
390                     </td>
391                     <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
392                     <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
393                     <td>
394                         <select name="onshelfholds" id="onshelfholds">
395                             <option value="1">Yes</option>
396                             <option value="0">If any unavailable</option>
397                             <option value="2">If all unavailable</option>
398                         </select>
399                     </td>
400                     <td>
401                         <select id="opacitemholds" name="opacitemholds">
402                             <option value="N">Don't allow</option>
403                             <option value="Y">Allow</option>
404                             <option value="F">Force</option>
405                         </select>
406                     </td>
407                     <td>
408                         <select id="article_requests" name="article_requests">
409                             <option value="no">No</option>
410                             <option value="yes">Yes</option>
411                             <option value="bib_only">Record only</option>
412                             <option value="item_only">Item only</option>
413                         </select>
414                     </td>
415                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
416                     <td class="actions">
417                         <input type="hidden" name="branch" value="[% current_branch %]"/>
418                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
419                         <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
420                     </td>
421                 </tr>
422                 <tfoot>
423                     <tr>
424                       <th>Patron category</th>
425                       <th>Item type</th>
426                       <th>&nbsp;</th>
427                       <th>Current checkouts allowed</th>
428                       <th>Current on-site checkouts allowed</th>
429                       <th>Loan period</th>
430                       <th>Unit</th>
431                       <th>Hard due date</th>
432                       <th>Fine amount</th>
433                       <th>Fine charging interval</th>
434                       <th>Charge when?</th>
435                       <th>Fine grace period</th>
436                       <th>Overdue fines cap (amount)</th>
437                       <th>Cap fine at replacement price</th>
438                       <th>Suspension in days (day)</th>
439                       <th>Max. suspension duration (day)</th>
440                       <th>Renewals allowed (count)</th>
441                       <th>Renewal period</th>
442                       <th>No renewal before</th>
443                       <th>Automatic renewal</th>
444                       <th>No automatic renewal after</th>
445                        <th>No automatic renewal after (hard limit)</th>
446                       <th>Holds allowed (count)</th>
447                       <th>Holds per record (count)</th>
448                       <th>On shelf holds allowed</th>
449                       <th>Item level holds</th>
450                       <th>Article requests</th>
451                       <th>Rental discount (%)</th>
452                       <th>&nbsp;</th>
453                     </tr>
454                   </tfoot>
455                 </tbody>
456             </table>
457         </form>
458     </div>
459     <div id="defaults-for-this-library" class="container">
460     <h3>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) %][% END %]</h3>
461         <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>
462         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
463             <input type="hidden" name="op" value="set-branch-defaults" />
464             <input type="hidden" name="branch" value="[% current_branch %]"/>
465             <table>
466                 <tr>
467                     <th>&nbsp;</th>
468                     <th>Total current checkouts allowed</th>
469                     <th>Total current on-site checkouts allowed</th>
470                     <th>Hold policy</th>
471                     <th>Hold pickup library match</th>
472                     <th>Return policy</th>
473                     <th>Actions</th>
474                 </tr>
475                 <tr>
476                     <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
477                     <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
478                     <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty %]"/></td>
479                     <td>
480                         <select name="holdallowed">
481                             [% IF ( default_holdallowed_any ) %]
482                             <option value="2" selected="selected">
483                             [% ELSE %]
484                             <option value="2">
485                             [% END %]
486                                 From any library
487                             </option>
488                             [% IF ( default_holdallowed_same ) %]
489                             <option value="1" selected="selected">
490                             [% ELSE %]
491                             <option value="1">
492                             [% END %]
493                                 From home library
494                             </option>
495                             [% IF ( default_holdallowed_none ) %]
496                             <option value="0" selected="selected">
497                             [% ELSE %]
498                             <option value="0">
499                             [% END %]
500                                 No holds allowed
501                             </option>
502                         </select>
503                     </td>
504                     <td>
505                         <select name="hold_fulfillment_policy">
506                             [% IF default_hold_fulfillment_policy == 'any' %]
507                                 <option value="any" selected="selected">
508                                     any library
509                                 </option>
510                             [% ELSE %]
511                                 <option value="any">
512                                     any library
513                                 </option>
514                             [% END %]
515
516                             [% IF default_hold_fulfillment_policy == 'homebranch' %]
517                                 <option value="homebranch" selected="selected">
518                                     item's home library
519                                 </option>
520                             [% ELSE %]
521                                 <option value="homebranch">
522                                     item's home library
523                                 </option>
524                             [% END %]
525
526                             [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
527                                 <option value="holdingbranch" selected="selected">
528                                     item's holding library
529                                 </option>
530                             [% ELSE %]
531                                 <option value="holdingbranch">
532                                     item's holding library
533                                 </option>
534                             [% END %]
535                         </select>
536                     </td>
537                     <td>
538                         <select name="returnbranch">
539                             [% IF ( default_returnbranch == 'homebranch' ) %]
540                             <option value="homebranch" selected="selected">
541                             [% ELSE %]
542                             <option value="homebranch">
543                             [% END %]
544                                 Item returns home
545                             </option>
546                             [% IF ( default_returnbranch == 'holdingbranch' ) %]
547                             <option value="holdingbranch" selected="selected">
548                             [% ELSE %]
549                             <option value="holdingbranch">
550                             [% END %]
551                                 Item returns to issuing library
552                             </option>
553                             [% IF ( default_returnbranch == 'noreturn' ) %]
554                             <option value="noreturn" selected="selected">
555                             [% ELSE %]
556                             <option value="noreturn">
557                             [% END %]
558                                 Item floats
559                             </option>
560                         </select>
561                     </td>
562                     <td class="actions">
563                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
564                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
565                     </td>
566                 </tr>
567             </table>
568         </form>
569     </div>
570     [% IF ( show_branch_cat_rule_form ) %]
571     <div id="holds-policy-by-patron-category" class="container">
572     <h3>[% IF humanbranch %]Checkout limit by patron category for [% Branches.GetName( humanbranch ) %][% ELSE %]Default checkout limit by patron category[% END %]</h3>
573         <p>For this library, you can specify the maximum number of loans that
574             a patron of a given category can make, regardless of the item type.
575         </p>
576         <p>If the total amount loanable for a given patron category is left blank,
577            no limit applies, except possibly for a limit you define for a specific item type.
578         </p>
579         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
580             <input type="hidden" name="op" value="add-branch-cat" />
581             <input type="hidden" name="branch" value="[% current_branch %]"/>
582             <table>
583                 <tr>
584                     <th>Patron category</th>
585                     <th>Total current checkouts allowed</th>
586                     <th>Total current on-site checkouts allowed</th>
587                     <th>&nbsp;</th>
588                 </tr>
589                 [% FOREACH branch_cat_rule_loo IN branch_cat_rule_loop %]
590                     [% UNLESS ( loop.odd ) %]
591                     <tr class="highlight">
592                     [% ELSE %]
593                     <tr>
594                     [% END %]
595                         <td>[% IF ( branch_cat_rule_loo.default_humancategorycode ) %]
596                                 <em>Default</em>
597                             [% ELSE %]
598                                 [% branch_cat_rule_loo.humancategorycode %]
599                             [% END %]
600                         </td>
601                         <td>[% IF ( branch_cat_rule_loo.unlimited_maxissueqty ) %]
602                                 Unlimited
603                             [% ELSE %]
604                                 [% branch_cat_rule_loo.maxissueqty %]
605                             [% END %]
606                         </td>
607                         <td>[% IF ( branch_cat_rule_loo.unlimited_maxonsiteissueqty ) %]
608                                 Unlimited
609                             [% ELSE %]
610                                 [% branch_cat_rule_loo.maxonsiteissueqty %]
611                             [% END %]
612                         </td>
613
614                         <td class="actions">
615                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
616                         </td>
617                     </tr>
618                 [% END %]
619                 <tr>
620                     <td>
621                         <select name="categorycode">
622                         [% FOREACH patron_category IN patron_categories%]
623                             <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option>
624                         [% END %]
625                         </select>
626                     </td>
627                     <td><input name="maxissueqty" size="3" /></td>
628                     <td><input name="maxonsiteissueqty" size="3" /></td>
629                     <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
630                 </tr>
631             </table>
632         </form>
633     </div>
634     [% END %]
635
636     <div id="refund-lost-item-fee-on-return" class="container">
637   [% IF current_branch == '*' %]
638     <h3>Default lost item fee refund on return policy</h3>
639   [% ELSE %]
640     <h3>Lost item fee refund on return policy for [% Branches.GetName(current_branch) %]</h3>
641   [% END %]
642         <p>Specify the default policy for lost item fees on return.
643         </p>
644         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
645             <input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
646             <input type="hidden" name="branch" value="[% current_branch %]" />
647             <table>
648                 <tr>
649                     <th>Refund lost item fee</th>
650                     <th>&nbsp;</th>
651                 </tr>
652                 <tr>
653                     <td>
654                         <select name="refund">
655                           [#% Default branch %#]
656                           [% IF ( current_branch == '*' ) %]
657                             [% IF ( refundLostItemFeeRule.refund ) %]
658                             <option value="1" selected="selected">
659                             [% ELSE %]
660                             <option value="1">
661                             [% END %]
662                                 Yes
663                             </option>
664                             [% IF ( not refundLostItemFeeRule.refund ) %]
665                             <option value="0" selected="selected">
666                             [% ELSE %]
667                             <option value="0">
668                             [% END %]
669                                 No
670                             </option>
671                           [% ELSE %]
672                           [#% Branch-specific %#]
673                             [% IF ( not refundLostItemFeeRule ) %]
674                                 <option value="*" selected="selected">
675                             [% ELSE %]
676                                 <option value="*">
677                             [% END %]
678                               [% IF defaultRefundRule %]
679                                 Use default (Yes)
680                               [% ELSE %]
681                                 Use default (No)
682                               [% END %]
683                                 </option>
684                             [% IF ( not refundLostItemFeeRule ) %]
685                                 <option value="1">Yes</option>
686                                 <option value="0">No</option>
687                             [% ELSE %]
688                                 [% IF ( refundLostItemFeeRule.refund ) %]
689                                 <option value="1" selected="selected">
690                                 [% ELSE %]
691                                 <option value="1">
692                                 [% END %]
693                                     Yes
694                                 </option>
695                                 [% IF ( not refundLostItemFeeRule.refund ) %]
696                                 <option value="0" selected="selected">
697                                 [% ELSE %]
698                                 <option value="0">
699                                 [% END %]
700                                     No
701                                 </option>
702                             [% END %]
703                           [% END %]
704                         </select>
705                     </td>
706                     <td class="actions">
707                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
708                     </td>
709                     </td>
710                 </tr>
711             </table>
712         </form>
713     </div>
714
715     <div id="holds-policy-by-item-type" class="container">
716     <h3>[% IF humanbranch %]Holds policy by item type for [% Branches.GetName( humanbranch ) %][% ELSE %]Default holds policy by item type[% END %]</h3>
717         <p>
718             For this library, you can edit rules for given itemtypes, regardless
719             of the patron's category.
720         </p>
721         <p>
722             Currently, this means hold policies.
723             The various policies have the following effects:
724         </p>
725         <ul>
726             <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
727             <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
728             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
729         </ul>
730         <p><strong>Note: </strong>If the system preference 'AllowHoldPolicyOverride' is enabled, these policies can be overridden by your circulation staff.</br />
731             <strong>Important: </strong>The policies are based on the patron's home library, not the library where the hold is being placed.
732         </p>
733
734         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
735             <input type="hidden" name="op" value="add-branch-item" />
736             <input type="hidden" name="branch" value="[% current_branch %]"/>
737             <table>
738                 <tr>
739                     <th>Item type</th>
740                     <th>Hold policy</th>
741                     <th>Hold pickup library match</th>
742                     <th>Return policy</th>
743                     <th>&nbsp;</th>
744                 </tr>
745                 [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
746                     [% UNLESS ( loop.odd ) %]
747                     <tr class="highlight">
748                     [% ELSE %]
749                     <tr>
750                     [% END %]
751                         <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
752                                 <em>Default</em>
753                             [% ELSE %]
754                                 [% branch_item_rule_loo.translated_description %]
755                             [% END %]
756                         </td>
757                         <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
758                                 From any library
759                             [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
760                                 From home library
761                             [% ELSE %]
762                                 No holds allowed
763                             [% END %]
764                         </td>
765                         <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
766                                 any library
767                             [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
768                                 item's home library
769                             [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
770                                 item's holding library
771                             [% END %]
772                         </td>
773                         <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
774                                 Item returns home
775                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
776                                 Item returns to issuing branch
777                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
778                                 Item floats
779                             [% ELSE %]
780                                 Error - unknown option
781                             [% END %]
782                         </td>
783                         <td class="actions">
784                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
785                         </td>
786                     </tr>
787                 [% END %]
788                 <tr>
789                     <td>
790                         <select name="itemtype">
791                         [% FOREACH itemtypeloo IN itemtypeloop %]
792                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
793                         [% END %]
794                         </select>
795                     </td>
796                     <td>
797                         <select name="holdallowed">
798                             <option value="2">From any library</option>
799                             <option value="1">From home library</option>
800                             <option value="0">No holds allowed</option>
801                         </select>
802                     </td>
803                     <td>
804                         <select name="hold_fulfillment_policy">
805                             <option value="any">
806                                 any library
807                             </option>
808
809                             <option value="homebranch">
810                                 item's home library
811                             </option>
812
813                             <option value="holdingbranch">
814                                 item's holding library
815                             </option>
816                         </select>
817                     </td>
818                     <td>
819                         <select name="returnbranch">
820                             <option value="homebranch">Item returns home</option>
821                             <option value="holdingbranch">Item returns to issuing library</option>
822                             <option value="noreturn">Item floats</option>
823                         </select>
824                     </td>
825                     <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
826                 </tr>
827             </table>
828         </form>
829     </div>
830 </div>
831
832 </div>
833 <div class="yui-b">
834 [% INCLUDE 'admin-menu.inc' %]
835 </div>
836 </div>
837 [% INCLUDE 'intranet-bottom.inc' %]