Bug 9525: (QA follow-up) Clarify how float groups are selected in circulation rules
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE ItemTypes %]
8 [% USE CirculationRules %]
9 [% USE Price %]
10 [% PROCESS 'i18n.inc' %]
11 [% SET footerjs = 1 %]
12
13 [% SET branchcode = humanbranch || undef %]
14
15 [% SET categorycodes = [] %]
16 [% FOREACH pc IN patron_categories %]
17     [% categorycodes.push( pc.id ) %]
18 [% END %]
19 [% categorycodes.push(undef) %]
20
21 [% SET itemtypes = [] %]
22 [% FOREACH i IN itemtypeloop %]
23     [% itemtypes.push( i.itemtype ) %]
24 [% END %]
25 [% itemtypes.push(undef) %]
26
27 [% INCLUDE 'doc-head-open.inc' %]
28 <title>[% FILTER collapse %]
29     [% t("Circulation and fine rules") | html %] &rsaquo;
30     [% t("Administration") | html %] &rsaquo;
31     [% t("Koha") | html %]
32 [% END %]</title>
33 [% INCLUDE 'doc-head-close.inc' %]
34 </head>
35
36 <body id="admin_smart-rules" class="admin">
37 [% WRAPPER 'header.inc' %]
38     [% INCLUDE 'prefs-admin-search.inc' %]
39 [% END %]
40
41 [% WRAPPER 'sub-header.inc' %]
42     [% WRAPPER breadcrumbs %]
43         [% WRAPPER breadcrumb_item %]
44             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
45        [% END %]
46         [% WRAPPER breadcrumb_item bc_active= 1 %]
47             <span>Circulation and fine rules</span>
48        [% END %]
49     [% END #/ WRAPPER breadcrumbs %]
50 [% END #/ WRAPPER sub-header.inc %]
51
52 <div class="main container-fluid">
53     <div class="row">
54         <div class="col-sm-10 col-sm-push-2">
55             <main>
56                 <h1 class="parameters">
57                     [% IF humanbranch %]
58                         Defining circulation and fine rules for "[% Branches.GetName( humanbranch ) | html %]"
59                     [% ELSE %]
60                         Defining circulation and fine rules for all libraries
61                     [% END %]
62                 </h1>
63
64                 <div class="page-section bg-info">
65                     <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
66                     <ul>
67                         <li>same library, same patron category, same item type</li>
68                         <li>same library, same patron category, all item types</li>
69                         <li>same library, all patron categories, same item type</li>
70                         <li>same library, all patron categories, all item types</li>
71                         <li>default (all libraries), same patron category, same item type</li>
72                         <li>default (all libraries), same patron category, all item types</li>
73                         <li>default (all libraries), all patron categories, same item type</li>
74                         <li>default (all libraries), all patron categories, all item types</li>
75                     </ul>
76
77                     <p>Where an itemtype has a parent, the rule will display as "Parent->Child" and the number of
78                     current checkouts allowed will be limited to either the maximum for the parent (counting sibling types)
79                     or the specific rule's type, whichever is less.</p>
80                     <p>To modify a rule, create a new one with the same patron category and item type.</p>
81                 </div>
82
83                 <div class="page-section">
84                     [% UNLESS restricted_to_own_library %]
85                         <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
86                         Select a library :
87                             <select name="branch" id="branch" style="width:20em;">
88                                 <option value="*">Standard rules for all libraries</option>
89                                 [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
90                             </select>
91                         </form>
92                         [% IF ( definedbranch ) %]
93                             <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
94                                 <label for="tobranch"><strong>Clone these rules to:</strong></label>
95                                 <input type="hidden" name="frombranch" value="[% current_branch | html %]" />
96                                 <select name="tobranch" id="tobranch">
97                                     [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
98                                 </select>
99                                 <input type="submit" id="clone_rules" class="btn btn-primary" value="Clone" />
100                             </form>
101                         [% END %]
102                     [% END %]
103                 </div>
104
105                 <div class="page-section">
106                     <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
107                         <input type="hidden" name="op" value="add" />
108                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
109                         <table id="default-circulation-rules">
110                         <thead>
111                         <tr>
112                             <th>&nbsp;</th>
113                             <th class="fixed_sort">Patron category</th>
114                             <th>&nbsp;</th>
115                             <th class="fixed_sort">Item type</th>
116                             <th class="noExport">Actions</th>
117                             <th>Note</th>
118                             <th>Current checkouts allowed</th>
119                             <th>Current on-site checkouts allowed</th>
120                             <th>Loan period</th>
121                             <th>Days mode</th>
122                             <th>Unit</th>
123                             <th>Hard due date</th>
124                             <th>Decreased loan period for high holds (day)</th>
125                             <th>Fine amount</th>
126                             <th>Fine charging interval</th>
127                             <th>When to charge</th>
128                             <th>Fine/suspension grace period</th>
129                             <th>Overdue fines cap (amount)</th>
130                             <th>Cap fine at replacement price</th>
131                             <th>Suspension in days (day)</th>
132                             <th>Max. suspension duration (day)</th>
133                             <th>Suspension charging interval</th>
134                             <th>Renewals allowed (count)</th>
135                             [% IF Koha.Preference('UnseenRenewals') %]
136                             <th>Unseen renewals allowed (count)</th>
137                             [% END %]
138                             <th>Renewal period</th>
139                             <th>No renewal before</th>
140                             <th>Automatic renewal</th>
141                             <th>No automatic renewal after</th>
142                             <th>No automatic renewal after (hard limit)</th>
143                             <th>Holds allowed (total)</th>
144                             <th>Holds allowed (daily)</th>
145                             <th>Holds per record (count)</th>
146                             <th>On shelf holds allowed</th>
147                             <th>OPAC item level holds</th>
148                             [% IF Koha.Preference('ArticleRequests') %]
149                             <th>Article requests</th>
150                             [% END %]
151                             <th>Rental discount (%)</th>
152                             [% IF Koha.Preference('UseRecalls') %]
153                                 <th>Recalls allowed (total)</th>
154                                 <th>Recalls per record (count)</th>
155                                 <th>On shelf recalls allowed</th>
156                                 <th>Recall due date interval (day)</th>
157                                 <th>Recall overdue fine amount</th>
158                                 <th>Recall pickup period (day)</th>
159                             [% END %]
160                             <th class="noExport">Actions</th>
161                         </tr>
162                         </thead>
163                         <tbody>
164                             [% SET row_count = 0 %]
165                             [% FOREACH c IN categorycodes %]
166                                 [% SET c = '' UNLESS c.defined %]
167                                 [% FOREACH i IN itemtypes %]
168                                     [% SET i = '' UNLESS i.defined %]
169                                     [% SET note = all_rules.$c.$i.note %]
170                                     [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
171                                     [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
172                                     [% SET issuelength = all_rules.$c.$i.issuelength %]
173                                     [% SET daysmode = all_rules.$c.$i.daysmode %]
174                                     [% SET lengthunit = all_rules.$c.$i.lengthunit %]
175                                     [% SET hardduedate = all_rules.$c.$i.hardduedate %]
176                                     [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
177                                     [% SET fine = all_rules.$c.$i.fine %]
178                                     [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
179                                     [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
180                                     [% SET firstremind = all_rules.$c.$i.firstremind %]
181                                     [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
182                                     [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
183                                     [% SET finedays = all_rules.$c.$i.finedays %]
184                                     [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
185                                     [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
186                                     [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
187                                     [% SET unseenrenewalsallowed = all_rules.$c.$i.unseen_renewals_allowed %]
188                                     [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
189                                     [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
190                                     [% SET auto_renew = all_rules.$c.$i.auto_renew %]
191                                     [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
192                                     [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
193                                     [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
194                                     [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
195                                     [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
196                                     [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
197                                     [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
198                                     [% SET article_requests = all_rules.$c.$i.article_requests %]
199                                     [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
200                                     [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
201                                     [% SET recalls_allowed = all_rules.$c.$i.recalls_allowed %]
202                                     [% SET recalls_per_record = all_rules.$c.$i.recalls_per_record %]
203                                     [% SET on_shelf_recalls = all_rules.$c.$i.on_shelf_recalls %]
204                                     [% SET recall_due_date_interval = all_rules.$c.$i.recall_due_date_interval %]
205                                     [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %]
206                                     [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %]
207
208                                     [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time %]
209                                     [% IF show_rule %]
210                                         [% SET row_count = row_count + 1 %]
211                                         <tr row_countd="row_[% row_count | html %]">
212                                                 <td>[% IF ( c == undef ) %]
213                                                         1
214                                                     [% ELSE %]
215                                                         0
216                                                     [% END %]</td>
217                                                 <td data-code="[% c | html %]">
218                                                     [% IF c == undef %]
219                                                         <em>All</em>
220                                                     [% ELSE %]
221                                                         [% Categories.GetName(c) | html %]
222                                                     [% END %]
223                                                 </td>
224                                                 <td>[% IF ( i == undef ) %]
225                                                         1
226                                                     [% ELSE %]
227                                                         0
228                                                     [% END %]</td>
229                                                 <td data-code="[% i | html %]">
230                                                     [% IF i == undef %]
231                                                         <em>All</em>
232                                                     [% ELSE %]
233                                                         [% ItemTypes.GetDescription(i,1) | html %]
234                                                     [% END %]
235                                                 </td>
236                                                 <td class="actions">
237                                                   <a href="#" class="editrule btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
238                                                   <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | html %]&amp;categorycode=[% c || '*' | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a>
239                                                 </td>
240                                                 <td>
241                                                     [% IF note.defined && note != '' %]
242                                                         <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
243                                                     [% ELSE %]<span>&nbsp;</span>[% END %]
244                                                 </td>
245                                                 <td>
246                                                     [% IF maxissueqty.defined && maxissueqty != '' %]
247                                                         [% maxissueqty | html %]
248                                                     [% ELSE %]
249                                                         <span>Unlimited</span>
250                                                     [% END %]
251                                                 </td>
252                                                 <td>
253                                                     [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
254                                                         [% maxonsiteissueqty | html %]
255                                                     [% ELSE %]
256                                                         <span>Unlimited</span>
257                                                     [% END %]
258                                                 </td>
259                                                 <td>[% issuelength | html %]</td>
260                                                 <td data-code="[% daysmode | html %]">
261                                                     [% SWITCH daysmode %]
262                                                     [% CASE 'Calendar' %]<span title="Use the calendar to skip days the library is closed">Skip closed days</span>
263                                                     [% CASE 'Datedue' %]<span title="Use the calendar to push the due date to the next open day">Next open day</span>
264                                                     [% CASE 'Days' %]<span title="Ignore the calendar">Ignore the calendar</span>
265                                                     [% CASE 'Dayweek' %]<span title="Use the calendar to push the due date to the next open matching weekday for weekly loan periods, or the next open day otherwise">Same week day</span>
266                                                     [% CASE %]<span title="Use the system preference 'useDaysMode' as a default value">Default</span>
267                                                     [% END %]
268                                                 </td>
269                                                 <td data-code="[% lengthunit | html %]">
270                                                     [% IF ( lengthunit == 'days' ) %]
271                                                         <span>Days</span>
272                                                     [% ELSIF ( lengthunit == 'hours') %]
273                                                         <span>Hours</span>
274                                                     [% ELSE %]
275                                                         <span>Undefined</span>
276                                                     [% END %]
277                                                 </td>
278                                                 <td data-code="[% hardduedatecompare | html %]">
279                                                   [% IF ( hardduedate ) %]
280                                                     [% IF ( hardduedatecompare == '-1' ) %]
281                                                       before [% hardduedate | $KohaDates %]
282                                                       <input type="hidden" name="hardduedatecomparebackup" value="-1" />
283                                                     [% ELSIF ( hardduedatecompare == '0' ) %]
284                                                       on [% hardduedate | $KohaDates %]
285                                                       <input type="hidden" name="hardduedatecomparebackup" value="0" />
286                                                     [% ELSIF ( hardduedatecompare == '1' ) %]
287                                                       after [% hardduedate | $KohaDates %]
288                                                       <input type="hidden" name="hardduedatecomparebackup" value="1" />
289                                                     [% END %]
290                                                   [% ELSE %]
291                                                     <span>None defined</span>
292                                                   [% END %]
293                                                 </td>
294                                                 <td>[% decreaseloanholds | html %]</td>
295                                                 <td>[% fine | $Price %]</td>
296                                                 <td>[% chargeperiod | html %]</td>
297                                                 <td>[% IF chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
298                                                 <td>[% firstremind | html %]</td>
299                                                 <td>[% IF overduefinescap %][% overduefinescap | $Price %][% ELSE %][% END %]</td>
300                                                 <td>
301                                                     [% IF cap_fine_to_replacement_price %]
302                                                         <input type="checkbox" checked="checked" disabled="disabled" />
303                                                     [% ELSE %]
304                                                         <input type="checkbox" disabled="disabled" />
305                                                     [% END %]
306                                                 </td>
307                                                 <td>[% finedays | html %]</td>
308                                                 <td>[% maxsuspensiondays | html %]</td>
309                                                 <td>[% suspension_chargeperiod | html %]</td>
310                                                 <td>[% renewalsallowed | html %]</td>
311                                                 [% IF Koha.Preference('UnseenRenewals') %]
312                                                     <td>
313                                                         [% IF unseenrenewalsallowed.defined && unseenrenewalsallowed != '' %]
314                                                             [% unseenrenewalsallowed | html %]
315                                                         [% ELSE %]
316                                                             <span>Unlimited</span>
317                                                         [% END %]
318                                                     </td>
319                                                 [% END %]
320                                                 <td>[% renewalperiod | html %]</td>
321                                                 <td>[% norenewalbefore | html %]</td>
322                                                 <td data-code="[%- IF auto_renew -%]yes[%- ELSE -%]no[%- END -%]">
323                                                     [% IF auto_renew %]
324                                                         <span>Yes</span>
325                                                     [% ELSE %]
326                                                         <span>No</span>
327                                                     [% END %]
328                                                 </td>
329                                                 <td>[% no_auto_renewal_after | html %]</td>
330                                                 <td>[% no_auto_renewal_after_hard_limit | $KohaDates %]</td>
331                                                 <td>
332                                                     [% IF reservesallowed.defined && reservesallowed != '' %]
333                                                         [% reservesallowed | html %]
334                                                     [% ELSE %]
335                                                         <span>Unlimited</span>
336                                                     [% END %]
337                                                 </td>
338                                                 <td>
339                                                     [% IF holds_per_day.defined && holds_per_day != '' %]
340                                                         [% holds_per_day | html %]
341                                                     [% ELSE %]
342                                                         <span>Unlimited</span>
343                                                     [% END %]
344                                                 </td>
345                                                 <td>
346                                                     [% IF holds_per_record.defined && holds_per_record != '' %]
347                                                         [% holds_per_record | html %]
348                                                     [% ELSE %]
349                                                         <span>Unlimited</span>
350                                                     [% END %]
351                                                 </td>
352                                                 <td data-code="[% onshelfholds | html %]">
353                                                     [% IF onshelfholds == 1 %]
354                                                         <span>Yes</span>
355                                                     [% ELSIF onshelfholds == 2 %]
356                                                         <span>If all unavailable</span>
357                                                     [% ELSE %]
358                                                         <span>If any unavailable</span>
359                                                     [% END %]
360                                                 </td>
361                                                 <td data-code="[% opacitemholds | html %]">
362                                                     [% IF opacitemholds == 'F'%]
363                                                         <span>Force</span>
364                                                     [% ELSIF opacitemholds == 'Y'%]
365                                                         <span>Allow</span>
366                                                     [% ELSE %]
367                                                         <span>Don't allow</span>
368                                                     [% END %]
369                                                 </td>
370                                                 [% IF Koha.Preference('ArticleRequests') %]
371                                                 <td data-code="[% article_requests | html %]">
372                                                     [% IF article_requests == 'no' %]
373                                                         <span>No</span>
374                                                     [% ELSIF article_requests == 'yes' %]
375                                                         <span>Yes</span>
376                                                     [% ELSIF article_requests == 'bib_only' %]
377                                                         <span>Record only</span>
378                                                     [% ELSIF article_requests == 'item_only' %]
379                                                         <span>Item only</span>
380                                                     [% END %]
381                                                 </td>
382                                                 [% END %]
383                                                 <td>[% rentaldiscount | html %]</td>
384                                                 [% IF Koha.Preference('UseRecalls') %]
385                                                     <td>[% recalls_allowed | html %]</td>
386                                                     <td>[% recalls_per_record | html %]</td>
387                                                     <td data-code="[% on_shelf_recalls | html %]">
388                                                         [% IF on_shelf_recalls == 'all' %]
389                                                             <span>If all unavailable</span>
390                                                         [% ELSE %]
391                                                             <span>If any unavailable</span>
392                                                         [% END %]
393                                                     </td>
394                                                     <td>[% recall_due_date_interval | html %]</td>
395                                                     <td>[% recall_overdue_fine | $Price %]</td>
396                                                     <td>[% recall_shelf_time | html %]</td>
397                                                 [% END %]
398                                                 <td class="actions">
399                                                   <a href="#" class="editrule btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
400                                                   <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
401                                                 </td>
402                                         </tr>
403                                     [% END %]
404                                 [% END %]
405                             [% END %]
406                             <tr class="noExport" id="edit_row">
407                                 <td>2</td>
408                                 <td>
409                                     <select name="categorycode" id="categorycode">
410                                         <option value="*">All</option>
411                                     [% FOREACH patron_category IN patron_categories%]
412                                         <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
413                                     [% END %]
414                                     </select>
415                                 </td>
416                                 <td>0</td>
417                                 <td>
418                                     <select name="itemtype" id="matrixitemtype" style="width:13em;">
419                                         <option value="*">All</option>
420                                         [% FOREACH itemtypeloo IN itemtypeloop %]
421                                             [% NEXT IF itemtypeloo.parent_type %]
422                                             [% SET children = itemtypeloo.children_with_localization %]
423                                             [% IF children.count %]
424                                                 <optgroup label="[% itemtypeloo.translated_description | html %]">
425                                                     <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %] (All)</option>
426                                                     [% FOREACH child IN children %]
427                                                         <option value="[% child.itemtype | html %]">[% child.translated_description | html %]</option>
428                                                     [% END %]
429                                                 </optgroup>
430                                             [% ELSE %]
431                                                 <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
432                                             [% END %]
433                                         [% END %]
434                                     </select>
435                                 </td>
436                                 <td class="actions">
437                                     <input type="hidden" name="branch" value="[% current_branch | html %]"/>
438                                     <button type="submit" class="btn btn-primary btn-xs"><i class="fa fa-save"></i> Save</button>
439                                     <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
440                                 </td>
441                                 <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
442                                 <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
443                                 <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
444                                 <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
445                                 <td>
446                                     <select name="daysmode" id="daysmode">
447                                         <option value="" title="Use the system preference 'useDaysMode' as a default value">Default</option>
448                                         <option value="Calendar" title="Use the calendar to skip days the library is closed">Skip closed days</option>
449                                         <option value="Datedue" title="Use the calendar to push the due date to the next open day">Next open day</option>
450                                         <option value="Days" title="Ignore the calendar">Ignore the calendar</option>
451                                         <option value="Dayweek" title="Use the calendar to push the due date to the next open matching weekday for weekly loan periods, or the next open day otherwise">Same week day</option>
452                                     </select>
453                                 </td>
454                                 <td>
455                                   <select name="lengthunit" id="lengthunit">
456                                     <option value="days" selected="selected">Days</option>
457                                     <option value="hours">Hours</option>
458                                   </select>
459                                 </td>
460                                 <td>
461                                     <select name="hardduedatecompare" id="hardduedatecompare">
462                                        <option value="-1">Before</option>
463                                        <option value="0">Exactly on</option>
464                                        <option value="1">After</option>
465                                     </select>
466                                     <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate | html %]" class="flatpickr" />
467                                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
468                                 </td>
469                                 <td><input type="text" name="decreaseloanholds" id="decreaseloanholds" size="2" /></td>
470                                 <td><input type="text" name="fine" id="fine" size="4" inputmode="decimal" pattern="^\d+(\.\d{2})?$" /></td>
471                                 <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
472                                 <td>
473                                     <select name="chargeperiod_charge_at" id="chargeperiod_charge_at">
474                                        <option value="0">End of interval</option>
475                                        <option value="1">Start of interval</option>
476                                     </select>
477                                 </td>
478                                 <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
479                                 <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" inputmode="decimal" pattern="^\d+(\.\d{2})?$" /> </td>
480                                 <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td>
481                                 <td><input type="text" name="finedays" id="fined" size="3" /> </td>
482                                 <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
483                                 <td><input type="text" name="suspension_chargeperiod" id="suspension_chargeperiod" size="3" /> </td>
484                                 <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
485                                 [% IF Koha.Preference('UnseenRenewals') %]
486                                     <td><input type="text" name="unseen_renewals_allowed" id="unseen_renewals_allowed" size="2" /></td>
487                                 [% END %]
488                                 <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
489                                 <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
490                                 <td>
491                                     <select name="auto_renew" id="auto_renew">
492                                         <option value="no" selected>No</option>
493                                         <option value="yes">Yes</option>
494                                     </select>
495                                 </td>
496                                 <td><input type="text" name="no_auto_renewal_after" id="no_auto_renewal_after" size="3" /></td>
497                                 <td>
498                                     <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 | html %]" class="flatpickr"/>
499                                     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
500                                 </td>
501                                 <td><input type="text" name="reservesallowed"  id="reservesallowed"  size="2" /></td>
502                                 <td><input type="text" name="holds_per_day"    id="holds_per_day"    size="2" /></td>
503                                 <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
504                                 <td>
505                                     <select name="onshelfholds" id="onshelfholds">
506                                         <option value="1">Yes</option>
507                                         <option value="0">If any unavailable</option>
508                                         <option value="2">If all unavailable</option>
509                                     </select>
510                                 </td>
511                                 <td>
512                                     <select id="opacitemholds" name="opacitemholds">
513                                         <option value="N">Don't allow</option>
514                                         <option value="Y">Allow</option>
515                                         <option value="F">Force</option>
516                                     </select>
517                                 </td>
518                                 [% IF Koha.Preference('ArticleRequests') %]
519                                 <td>
520                                     <select id="article_requests" name="article_requests">
521                                         <option value="no">No</option>
522                                         <option value="yes">Yes</option>
523                                         <option value="bib_only">Record only</option>
524                                         <option value="item_only">Item only</option>
525                                     </select>
526                                 </td>
527                                 [% END %]
528                                 <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
529                                 [% IF Koha.Preference('UseRecalls') %]
530                                     <td><input type="text" name="recalls_allowed" id="recalls_allowed" size="3"></td>
531                                     <td><input type="text" name="recalls_per_record" id="recalls_per_record" size="3"></td>
532                                     <td>
533                                         <select name="on_shelf_recalls" id="on_shelf_recalls">
534                                             <option value="any">If any unavailable</option>
535                                             <option value="all">If all unavailable</option>
536                                         </select>
537                                     </td>
538                                     <td><input type="text" name="recall_due_date_interval" id="recall_due_date_interval" size="3"></td>
539                                     <td><input type="text" name="recall_overdue_fine" id="recall_overdue_fine" size="6" inputmode="decimal" pattern="^\d+(\.\d{2})?$"></td>
540                                     <td><input type="text" name="recall_shelf_time" id="recall_shelf_time" size="3"></td>
541                                 [% END %]
542                                 <td class="actions">
543                                     <input type="hidden" name="branch" value="[% current_branch | html %]"/>
544                                     <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
545                                     <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
546                                 </td>
547                             </tr>
548                             </tbody>
549                             <tfoot>
550                                 <tr>
551                                   <th>&nbsp;</th>
552                                   <th>Patron category</th>
553                                   <th>&nbsp;</th>
554                                   <th>Item type</th>
555                                   <th>&nbsp;</th>
556                                   <th>Note</th>
557                                   <th>Current checkouts allowed</th>
558                                   <th>Current on-site checkouts allowed</th>
559                                   <th>Loan period</th>
560                                   <th>Days mode</th>
561                                   <th>Unit</th>
562                                   <th>Hard due date</th>
563                                   <th>Decreased loan period for high holds (day)</th>
564                                   <th>Fine amount</th>
565                                   <th>Fine charging interval</th>
566                                   <th>Charge when?</th>
567                                   <th>Fine/suspension grace period</th>
568                                   <th>Overdue fines cap (amount)</th>
569                                   <th>Cap fine at replacement price</th>
570                                   <th>Suspension in days (day)</th>
571                                   <th>Max. suspension duration (day)</th>
572                                   <th>Suspension charging interval</th>
573                                   <th>Renewals allowed (count)</th>
574                                   [% IF Koha.Preference('UnseenRenewals') %]
575                                   <th>Unseen renewals allowed (count)</th>
576                                   [% END %]
577                                   <th>Renewal period</th>
578                                   <th>No renewal before</th>
579                                   <th>Automatic renewal</th>
580                                   <th>No automatic renewal after</th>
581                                   <th>No automatic renewal after (hard limit)</th>
582                                   <th>Holds allowed (total)</th>
583                                   <th>Holds allowed (daily)</th>
584                                   <th>Holds per record (count)</th>
585                                   <th>On shelf holds allowed</th>
586                                   <th>OPAC item level holds</th>
587                                   [% IF Koha.Preference('ArticleRequests') %]
588                                   <th>Article requests</th>
589                                   [% END %]
590                                   <th>Rental discount (%)</th>
591                                   [% IF Koha.Preference('UseRecalls') %]
592                                     <th>Recalls allowed (total)</th>
593                                     <th>Recalls per record (count)</th>
594                                     <th>On shelf recalls allowed</th>
595                                     <th>Recall due date interval (day)</th>
596                                     <th>Recall overdue fine amount</th>
597                                     <th>Recall pickup period (day)</th>
598                                   [% END %]
599                                   <th>&nbsp;</th>
600                                 </tr>
601                             </tfoot>
602                         </table>
603                     </form>
604                 </div><!-- ./page-section -->
605
606                 <div id="defaults-for-this-library" class="page-section">
607                     <h2>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) | html %][% END %]</h2>
608                     <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>
609                     <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
610                         <input type="hidden" name="op" value="set-branch-defaults" />
611                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
612                         <table>
613                             <tr>
614                                 <th>&nbsp;</th>
615                                 <th>Total current checkouts allowed</th>
616                                 <th>Total current on-site checkouts allowed</th>
617                                 <th>Maximum total holds allowed (count)</th>
618                                 <th>Hold policy</th>
619                                 <th>Hold pickup library match</th>
620                                 <th>Return policy</th>
621                                 <th class="noExport">Actions</th>
622                             </tr>
623                             [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty', { want_rule => 1 } ) %]
624                             [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty', { want_rule => 1 } ) %]
625                             [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds', { want_rule => 1 } ) %]
626                             [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed', { want_rule => 1 } ) %]
627                             [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', { want_rule => 1 }) %]
628                             [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', { want_rule => 1 }) %]
629                             [% SET default_checkout_hold_and_return_policy = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %]
630                             <tr>
631                                 <td>
632                                     [% IF ( default_checkout_hold_and_return_policy ) %]
633                                         <em>
634                                         Defaults
635                                         </em>
636                                     [% ELSE %]
637                                         Not set
638                                     [% END %]
639                                 </td>
640                                 <td>
641                                     <input type="text" name="patron_maxissueqty" size="9" value="[% patron_maxissueqty.rule_value | html %]" placeholder="Unlimited"/>
642                                 </td>
643                                 <td>
644                                     <input type="text" name="patron_maxonsiteissueqty" size="9" value="[% patron_maxonsiteissueqty.rule_value | html %]" placeholder="Unlimited"/>
645                                 </td>
646                                 <td>
647                                     <input name="max_holds" size="9" value="[% rule_value.rule_value | html %]" placeholder="Unlimited"/>
648                                 </td>
649                                 <td>
650                                     <select name="holdallowed">
651                                         <option value="">
652                                             Not set
653                                         </option>
654
655                                         [% IF holdallowed.rule_value == 'from_any_library' %]
656                                             <option value="from_any_library" selected="selected">
657                                         [% ELSE %]
658                                             <option value="from_any_library">
659                                         [% END %]
660                                             From any library
661                                         </option>
662
663                                         [% IF holdallowed.rule_value == 'from_local_hold_group' %]
664                                         <option value="from_local_hold_group" selected="selected">
665                                         [% ELSE %]
666                                         <option value="from_local_hold_group">
667                                         [% END %]
668                                             From local hold group
669                                         </option>
670
671                                         [% IF holdallowed.rule_value == 'from_home_library' %]
672                                             <option value="from_home_library" selected="selected">
673                                         [% ELSE %]
674                                             <option value="from_home_library">
675                                         [% END %]
676                                             From home library
677                                         </option>
678
679                                         [% IF holdallowed.rule_value == 'not_allowed' %]
680                                             <option value="not_allowed" selected="selected">
681                                         [% ELSE %]
682                                             <option value="not_allowed">
683                                         [% END %]
684                                             No holds allowed
685                                         </option>
686                                     </select>
687                                 </td>
688                                 <td>
689                                     <select name="hold_fulfillment_policy">
690
691                                         <option value="">
692                                             Not set
693                                         </option>
694
695                                         [% IF hold_fulfillment_policy.rule_value == 'any' %]
696                                             <option value="any" selected="selected">
697                                                 any library
698                                             </option>
699                                         [% ELSE %]
700                                             <option value="any">
701                                                 any library
702                                             </option>
703                                         [% END %]
704
705                                         [% IF hold_fulfillment_policy.rule_value == 'holdgroup' %]
706                                             <option value="holdgroup" selected="selected">
707                                                 item's hold group
708                                             </option>
709                                         [% ELSE %]
710                                             <option value="holdgroup">
711                                                 item's hold group
712                                             </option>
713                                         [% END %]
714
715                                         [% IF hold_fulfillment_policy.rule_value == 'patrongroup' %]
716                                             <option value="patrongroup" selected="selected">
717                                                 patron's hold group
718                                             </option>
719                                         [% ELSE %]
720                                             <option value="patrongroup">
721                                                 patron's hold group
722                                             </option>
723                                         [% END %]
724
725                                         [% IF hold_fulfillment_policy.rule_value == 'homebranch' %]
726                                             <option value="homebranch" selected="selected">
727                                                 item's home library
728                                             </option>
729                                         [% ELSE %]
730                                             <option value="homebranch">
731                                                 item's home library
732                                             </option>
733                                         [% END %]
734
735                                         [% IF hold_fulfillment_policy.rule_value == 'holdingbranch' %]
736                                             <option value="holdingbranch" selected="selected">
737                                                 item's holding library
738                                             </option>
739                                         [% ELSE %]
740                                             <option value="holdingbranch">
741                                                 item's holding library
742                                             </option>
743                                         [% END %]
744                                     </select>
745                                 </td>
746                                 <td>
747                                     <select name="returnbranch">
748
749                                         <option value="">
750                                             Not set
751                                         </option>
752
753                                         [% IF returnbranch.rule_value == 'homebranch' %]
754                                         <option value="homebranch" selected="selected">
755                                         [% ELSE %]
756                                         <option value="homebranch">
757                                         [% END %]
758                                             Item returns home
759                                         </option>
760                                         [% IF returnbranch.rule_value == 'holdingbranch' %]
761                                         <option value="holdingbranch" selected="selected">
762                                         [% ELSE %]
763                                         <option value="holdingbranch">
764                                         [% END %]
765                                             Item returns to issuing library
766                                         </option>
767                                         [% IF returnbranch.rule_value == 'noreturn' %]
768                                         <option value="noreturn" selected="selected">
769                                         [% ELSE %]
770                                         <option value="noreturn">
771                                         [% END %]
772                                             Item floats
773                                         </option>
774                                         [% IF returnbranch.rule_value == 'returnbylibrarygroup' %]
775                                         <option value="returnbylibrarygroup" selected="selected">
776                                         [% ELSE %]
777                                         <option value="returnbylibrarygroup">
778                                         [% END %]
779                                             Item floats by library group
780                                         </option>
781                                     </select>
782                                 </td>
783                                 <td class="actions">
784                                     <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
785                                     [% IF ( default_checkout_hold_and_return_policy ) %]
786                                         <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 | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
787                                     [% END %]
788                                 </td>
789                             </tr>
790                         </table>
791                     </form>
792                 </div>
793
794                 [% IF ( show_branch_cat_rule_form ) %]
795                 <div id="holds-policy-by-patron-category" class="page-section">
796                     <h2>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h2>
797                     <p>For this library, you can specify the maximum number of loans that
798                         a patron of a given category can make, regardless of the item type.
799                     </p>
800                     <p>If the total amount loanable for a given patron category is left blank,
801                        no limit applies, except possibly for a limit you define for a specific item type.
802                     </p>
803                     <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
804                         <input type="hidden" name="op" value="add-branch-cat" />
805                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
806                         <table>
807                             <tr>
808                                 <th>Patron category</th>
809                                 <th>Total current checkouts allowed</th>
810                                 <th>Total current on-site checkouts allowed</th>
811                                 <th>Total holds allowed</th>
812                                 <th>&nbsp;</th>
813                             </tr>
814                             [% FOREACH c IN categorycodes %]
815                                 [% NEXT UNLESS c %]
816                                 [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
817                                 [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
818                                 [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
819
820                                 [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
821                                 <tr>
822                                     <td>
823                                         [% IF c == undef %]
824                                             <em>Default</em>
825                                         [% ELSE %]
826                                             [% Categories.GetName(c) | html %]
827                                         [% END %]
828                                     </td>
829                                     <td>
830                                         [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
831                                             [% patron_maxissueqty | html %]
832                                         [% ELSE %]
833                                             <span>Unlimited</span>
834                                         [% END %]
835                                     </td>
836                                     <td>
837                                         [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
838                                             [% patron_maxonsiteissueqty | html %]
839                                         [% ELSE %]
840                                             <span>Unlimited</span>
841                                         [% END %]
842                                     </td>
843                                     <td>
844                                         [% IF max_holds.defined && max_holds != '' %]
845                                             [% max_holds | html %]
846                                         [% ELSE %]
847                                             <span>Unlimited</span>
848                                         [% END %]
849                                     </td>
850
851                                     <td class="actions">
852                                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a>
853                                     </td>
854                                 </tr>
855                                 [% END %]
856                             [% END %]
857                             <tr>
858                                 <td>
859                                     <select name="categorycode">
860                                     [% FOREACH patron_category IN patron_categories%]
861                                         <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
862                                     [% END %]
863                                     </select>
864                                 </td>
865                                 <td><input name="patron_maxissueqty" size="3" type="text" /></td>
866                                 <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
867                                 <td><input name="max_holds" size="3" type="text" /></td>
868                                 <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
869                             </tr>
870                         </table>
871                     </form>
872                 </div>
873                 [% END %]
874
875                 <div id="waiting-hold-cancel-category" class="page-section">
876                 [% IF humanbranch %]
877                     <h2>Waiting hold cancellation policy for [% Branches.GetName( humanbranch ) | html %]</h2>
878                 [% ELSE %]
879                     <h2>Default waiting hold cancellation policy</h2>
880                 [% END %]
881                     <p>Specify if waiting holds can be cancelled for a given patron category.</p>
882                     <form id="set-waiting-hold-cancellation" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
883                         <input type="hidden" name="op" value="set-waiting-hold-cancellation" />
884                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
885                         <table>
886                             <tr>
887                                 <th>Patron category</th>
888                                 <th>Item type</th>
889                                 <th>Cancellation allowed</th>
890                                 <th>&nbsp;</th>
891                             </tr>
892                             [% FOREACH c IN categorycodes %]
893                                 [% SET c = '*' UNLESS c.defined AND c != '' %]
894                                 [% FOREACH i IN itemtypes %]
895                                     [% SET i = '*' UNLESS i.defined AND i != '' %]
896
897                                     [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %]
898
899                                     [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %]
900                                         <tr>
901                                             <td>
902                                                 [% IF c == '*' %]
903                                                     <em>All</em>
904                                                 [% ELSE %]
905                                                     [% Categories.GetName(c) | html %]
906                                                 [% END %]
907                                             </td>
908                                             <td>
909                                                 [% IF i == '*' %]
910                                                     <em>All</em>
911                                                 [% ELSE %]
912                                                     [% ItemTypes.GetDescription(i,1) | html %]
913                                                 [% END %]
914                                             </td>
915                                             <td>
916                                                 [% IF waiting_hold_cancellation %]
917                                                     <span>Yes</span>
918                                                 [% ELSE %]
919                                                     <span>No</span>
920                                                 [% END %]
921                                             </td>
922                                             <td class="actions">
923                                                 <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-waiting-hold-cancellation&amp;waiting_hold_cancellation_category=[% c | uri %]&amp;waiting_hold_cancellation_itemtype=[% i | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
924                                             </td>
925                                         </tr>
926                                     [% END %]
927                                 [% END %]
928                             [% END %]
929                             <tr>
930                                 <td>
931                                     <select name="waiting_hold_cancellation_category" id="waiting_hold_cancellation_category">
932                                         <option value="*">All</option>
933                                     [% FOREACH patron_category IN patron_categories %]
934                                         <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
935                                     [% END %]
936                                     </select>
937                                 </td>
938                                 <td>
939                                     <select name="waiting_hold_cancellation_itemtype" id="waiting_hold_cancellation_itemtype">
940                                         <option value="*">All</option>
941                                     [% FOREACH itemtype IN itemtypeloop %]
942                                         <option value="[% itemtype.itemtype | html %]">[% ItemTypes.GetDescription(itemtype.itemtype) | html %]</option>
943                                     [% END %]
944                                     </select>
945                                 </td>
946                                 <td>
947                                     <select name="waiting_hold_cancellation_policy" id="waiting_hold_cancellation_policy">
948                                         <option value="0" selected>No</option>
949                                         <option value="1">Yes</option>
950                                     </select>
951                                 </td>
952                                 <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
953                             </tr>
954                         </table>
955                     </form>
956                 </div>
957
958                 [% IF Koha.Preference('ArticleRequests') %]
959                 <div id="open-article-requests-limit-patron-category" class="page-section">
960                 [% IF humanbranch %]
961                     <h2>Daily open article requests limit for [% Branches.GetName( humanbranch ) | html %]</h2>
962                 [% ELSE %]
963                     <h2>Default open article requests limit</h2>
964                 [% END %]
965                     <p>Specify the maximum number simultaneous current article requests a patron of a given category can have.</p>
966                     <form id="set-article-requests-daily-limit" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
967                         <input type="hidden" name="op" value="add-open-article-requests-limit" />
968                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
969                         <table>
970                             <tr>
971                                 <th>Patron category</th>
972                                 <th>Total article requests</th>
973                                 <th>&nbsp;</th>
974                             </tr>
975                             [% FOREACH c IN categorycodes %]
976                                 [% NEXT UNLESS c %]
977                                 [% SET open_article_requests_limit = CirculationRules.Search( branchcode, c, undef, 'open_article_requests_limit' ) %]
978
979                                 [% IF ( open_article_requests_limit.defined && open_article_requests_limit != '' ) %]
980                                 <tr>
981                                     <td>
982                                         [% Categories.GetName(c) | html %]
983                                     </td>
984                                     <td>
985                                         [% IF open_article_requests_limit.defined && open_article_requests_limit != '' %]
986                                             [% open_article_requests_limit | html %]
987                                         [% ELSE %]
988                                             <span>Unlimited</span>
989                                         [% END %]
990                                     </td>
991
992                                     <td class="actions">
993                                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-open-article-requests-limit&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a>
994                                     </td>
995                                 </tr>
996                                 [% END %]
997                             [% END %]
998                             <tr>
999                                 <td>
1000                                     <select name="categorycode">
1001                                     [% FOREACH patron_category IN patron_categories %]
1002                                         <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
1003                                     [% END %]
1004                                     </select>
1005                                 </td>
1006                                 <td><input name="open_article_requests_limit" size="3" type="text" /></td>
1007                                 <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
1008                             </tr>
1009                         </table>
1010                     </form>
1011                 </div>
1012
1013                 <div id="article-request-fee-category" class="page-section">
1014                 [% IF humanbranch %]
1015                     <h2>Article request fees for [% Branches.GetName( humanbranch ) | html %]</h2>
1016                 [% ELSE %]
1017                     <h2>Default article request fees</h2>
1018                 [% END %]
1019                     <p>Specify the article request fee for a given patron category.</p>
1020                     <form id="set-article-request-fee" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
1021                         <input type="hidden" name="op" value="set-article-request-fee" />
1022                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
1023                         <table>
1024                             <tr>
1025                                 <th>Patron category</th>
1026                                 <th>Fee</th>
1027                                 <th>&nbsp;</th>
1028                             </tr>
1029                             [% FOREACH c IN categorycodes %]
1030                                 [% SET c = '*' UNLESS c.defined AND c != '' %]
1031
1032                                 [% SET article_request_fee = CirculationRules.Search( current_branch, c, undef, 'article_request_fee' ) %]
1033
1034                                 [% IF ( article_request_fee.defined && article_request_fee != '' ) %]
1035                                 <tr>
1036                                     <td>
1037                                         [% IF c == '*' %]
1038                                             <em>All</em>
1039                                         [% ELSE %]
1040                                             [% Categories.GetName(c) | html %]
1041                                         [% END %]
1042                                     </td>
1043                                     <td>
1044                                         [% IF article_request_fee.defined && article_request_fee != '' %]
1045                                             [% article_request_fee | $Price %]
1046                                         [% ELSE %]
1047                                             <span>0</span>
1048                                         [% END %]
1049                                     </td>
1050                                     <td class="actions">
1051                                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-article-request-fee&amp;article_request_fee_category=[% c | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
1052                                     </td>
1053                                 </tr>
1054                                 [% END %]
1055                             [% END %]
1056                             <tr>
1057                                 <td>
1058                                     <select name="article_request_fee_category" id="article_request_fee_category">
1059                                         <option value="*">All</option>
1060                                     [% FOREACH patron_category IN patron_categories%]
1061                                         <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
1062                                     [% END %]
1063                                     </select>
1064                                 </td>
1065                                 <td><input name="article_request_fee" size="5" type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" /></td>
1066                                 <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
1067                             </tr>
1068                         </table>
1069                     </form>
1070                 </div>
1071                 [% END %]
1072
1073                 <div id="refund-lost-item-fee-on-return" class="page-section">
1074                 [% IF current_branch == '*' %]
1075                     <h2>Default lost item fee refund on return policy</h2>
1076                 [% ELSE %]
1077                     <h2>Lost item fee refund on return policy for [% Branches.GetName(current_branch) | html %]</h2>
1078                 [% END %]
1079                     <p>Specify the default policy for lost item fees on return.</p>
1080                     <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
1081                         <input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
1082                         <input type="hidden" name="branch" value="[% current_branch | html %]" />
1083                         <table>
1084                             <tr>
1085                                 <th>Refund lost item replacement fee</th>
1086                                 <th>Refund lost item processing fee</th>
1087                                 <th>&nbsp;</th>
1088                             </tr>
1089                             <tr>
1090                                 <td>
1091                                     <select name="lostreturn">
1092                                       [%# Default branch %]
1093                                       [% IF ( current_branch == '*' ) %]
1094                                         [% IF ( defaultRefundRule == 'refund' ) %]
1095                                         <option value="refund" selected="selected">Refund lost item charge</option>
1096                                         <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1097                                         <option value="charge">Refund lost item charge and charge new overdue fine</option>
1098                                         <option value="restore">Refund lost item charge and restore overdue fine</option>
1099                                         <option value="0">Leave lost item charge</option>
1100                                         [% ELSIF ( defaultRefundRule == 'refund_unpaid' ) %]
1101                                         <option value="refund">Refund lost item charge</option>
1102                                         <option value="refund_unpaid" selected="selected">Refund lost item charge (only if unpaid)</option>
1103                                         <option value="charge">Refund lost item charge and charge new overdue fine</option>
1104                                         <option value="restore">Refund lost item charge and restore overdue fine</option>
1105                                         <option value="0">Leave lost item charge</option>
1106                                         [% ELSIF ( defaultRefundRule == 'charge' ) %]
1107                                         <option value="refund">Refund lost item charge</option>
1108                                         <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1109                                         <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
1110                                         <option value="restore">Refund lost item charge and restore overdue fine</option>
1111                                         <option value="0">Leave lost item charge</option>
1112                                         [% ELSIF ( defaultRefundRule == 'restore' ) %]
1113                                         <option value="refund">Refund lost item charge</option>
1114                                         <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1115                                         <option value="charge">Refund lost item charge and charge new overdue fine</option>
1116                                         <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
1117                                         <option value="0">Leave lost item charge</option>
1118                                         [% ELSIF ( defaultRefundRule == 0 ) %]
1119                                         <option value="refund">Refund lost item charge</option>
1120                                         <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1121                                         <option value="charge">Refund lost item charge and charge new overdue fine</option>
1122                                         <option value="restore">Refund lost item charge and restore overdue fine</option>
1123                                         <option value="0" selected="selected">Leave lost item charge</option>
1124                                         [% ELSE %]
1125                                         <option value="refund">Refund lost item charge</option>
1126                                         <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1127                                         <option value="charge">Refund lost item charge and charge new overdue fine</option>
1128                                         <option value="restore">Refund lost item charge and restore overdue fine</option>
1129                                         <option value="0">Leave lost item charge</option>
1130                                         [% END %]
1131                                       [% ELSE %]
1132                                       [%# Branch-specific %]
1133                                         [% IF ( not refundLostItemFeeRule ) %]
1134                                             <option value="*" selected="selected">
1135                                         [% ELSE %]
1136                                             <option value="*">
1137                                         [% END %]
1138                                           [% IF defaultRefundRule == 'refund' %]
1139                                             <span>Use default (Refund lost item charge)</span>
1140                                           [% ELSIF defaultRefundRule == 'refund_unpaid' %]
1141                                             Use default (Refund lost item charge (only if unpaid))
1142                                           [% ELSIF defaultRefundRule == 'charge' %]
1143                                             <span>Use default (Refund lost item charge and charge new overdue fine)</span>
1144                                           [% ELSIF defaultRefundRule == 'restore' %]
1145                                             <span>Use default (Refund lost item charge and restore overdue fine)</span>
1146                                           [% ELSE %]
1147                                             <span>Use default (Leave lost item charge)</span>
1148                                           [% END %]
1149                                             </option>
1150                                         [% IF ( not refundLostItemFeeRule ) %]
1151                                             <option value="refund">Refund lost item charge</option>
1152                                             <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1153                                             <option value="charge">Refund lost item charge and charge new overdue fine</option>
1154                                             <option value="restore">Refund lost item charge and restore overdue fine</option>
1155                                             <option value="0">Leave lost item charge</option>
1156                                         [% ELSE %]
1157                                             [% IF ( refundLostItemFeeRule.rule_value == 'refund' ) %]
1158                                             <option value="refund" selected="selected">Refund lost item charge</option>
1159                                             <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1160                                             <option value="charge">Refund lost item charge and charge new overdue fine</option>
1161                                             <option value="restore">Refund lost item charge and restore overdue fine</option>
1162                                             <option value="0">Leave lost item charge</option>
1163                                             [% ELSIF ( refundLostItemFeeRule.rule_value == 'refund_unpaid' ) %]
1164                                             <option value="refund">Refund lost item charge</option>
1165                                             <option value="refund_unpaid" selected="selected">Refund lost item charge (only if unpaid)</option>
1166                                             <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
1167                                             <option value="restore">Refund lost item charge and restore overdue fine</option>
1168                                             <option value="0">Leave lost item charge</option>
1169                                             [% ELSIF ( refundLostItemFeeRule.rule_value == 'charge' ) %]
1170                                             <option value="refund">Refund lost item charge</option>
1171                                             <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1172                                             <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
1173                                             <option value="restore">Refund lost item charge and restore overdue fine</option>
1174                                             <option value="0">Leave lost item charge</option>
1175                                             [% ELSIF ( refundLostItemFeeRule.rule_value == 'restore' ) %]
1176                                             <option value="refund">Refund lost item charge</option>
1177                                             <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1178                                             <option value="charge">Refund lost item charge and charge new overdue fine</option>
1179                                             <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
1180                                             <option value="0">Leave lost item charge</option>
1181                                             [% ELSIF ( refundLostItemFeeRule.rule_value == 0 ) %]
1182                                             <option value="refund">Refund lost item charge</option>
1183                                             <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
1184                                             <option value="charge">Refund lost item charge and charge new overdue fine</option>
1185                                             <option value="restore">Refund lost item charge and restore overdue fine</option>
1186                                             <option value="0" selected="selected">Leave lost item charge</option>
1187                                             [% END %]
1188                                         [% END %]
1189                                       [% END %]
1190                                     </select>
1191                                 </td>
1192                                 <td>
1193                                     <select name="processingreturn">
1194                                       [%# Default branch %]
1195                                       [% IF ( current_branch == '*' ) %]
1196                                         [% IF ( defaultProcessingRefundRule == 'refund' ) %]
1197                                         <option value="refund" selected="selected">Refund lost item processing charge</option>
1198                                         <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1199                                         <option value="0">Leave lost item processing charge</option>
1200                                         [% ELSIF ( defaultProcessingRefundRule == 'refund_unpaid' ) %]
1201                                         <option value="refund">Refund lost item charge</option>
1202                                         <option value="refund_unpaid" selected="selected">Refund lost item processing charge (only if unpaid)</option>
1203                                         <option value="0">Leave lost item processing charge</option>
1204                                         [% ELSIF ( defaultProcessingRefundRule == 0 ) %]
1205                                         <option value="refund">Refund lost item processing charge</option>
1206                                         <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1207                                         <option value="0" selected="selected">Leave lost item processing charge</option>
1208                                         [% ELSE %]
1209                                         <option value="refund">Refund lost item processing charge</option>
1210                                         <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1211                                         <option value="0">Leave lost item processing charge</option>
1212                                         [% END %]
1213                                       [% ELSE %]
1214                                       [%# Branch-specific %]
1215                                         [% IF ( not refundProcessingFeeRule ) %]
1216                                             <option value="*" selected="selected">
1217                                         [% ELSE %]
1218                                             <option value="*">
1219                                         [% END %]
1220                                           [% IF defaultProcessingRefundRule == 'refund' %]
1221                                             <span>Use default (Refund lost item processing charge)</span>
1222                                           [% ELSIF defaultProcessingRefundRule == 'refund_unpaid' %]
1223                                             Use default (Refund lost item processing charge (only if unpaid))
1224                                           [% ELSE %]
1225                                             <span>Use default (Leave lost item processing charge)</span>
1226                                           [% END %]
1227                                             </option>
1228                                         [% IF ( not refundProcessingFeeRule ) %]
1229                                             <option value="refund">Refund lost item processing charge</option>
1230                                             <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1231                                             <option value="0">Leave lost item processing charge</option>
1232                                         [% ELSE %]
1233                                             [% IF ( refundProcessingFeeRule.rule_value == 'refund' ) %]
1234                                             <option value="refund" selected="selected">Refund lost item processing charge</option>
1235                                             <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1236                                             <option value="0">Leave lost item processing charge</option>
1237                                             [% ELSIF ( refundProcessingFeeRule.rule_value == 'refund_unpaid' ) %]
1238                                             <option value="refund">Refund lost item processing charge</option>
1239                                             <option value="refund_unpaid" selected="selected">Refund lost item processing charge (only if unpaid)</option>
1240                                             <option value="0">Leave lost item processing charge</option>
1241                                             [% ELSIF ( refundProcessingFeeRule.rule_value == 0 ) %]
1242                                             <option value="refund">Refund lost item processing charge</option>
1243                                             <option value="refund_unpaid">Refund lost item processing charge (only if unpaid)</option>
1244                                             <option value="0" selected="selected">Leave lost item processing charge</option>
1245                                             [% END %]
1246                                         [% END %]
1247                                       [% END %]
1248                                     </select>
1249                                 </td>
1250                                 <td class="actions">
1251                                     <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
1252                                 </td>
1253                             </tr>
1254                         </table>
1255                     </form>
1256                 </div>
1257
1258                 <div id="holds-policy-by-item-type" class="page-section">
1259                     <h2>[% IF humanbranch %]Holds policy by item type for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default holds policy by item type[% END %]</h2>
1260                     <p>
1261                         For this library, you can edit rules for given itemtypes, regardless of the patron's category.
1262                     </p>
1263                     <p>
1264                         Currently, this means hold policies. The various policies have the following effects:
1265                     </p>
1266                     <ul>
1267                         <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
1268                         <li><strong>From local hold group:</strong> Only patrons from libraries in the same item's home library hold groups may put this book on hold.</li>
1269                         <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
1270                         <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
1271                     </ul>
1272
1273                     <p><strong>Note: </strong>If the system preference 'AllowHoldPolicyOverride' is enabled, these policies can be overridden by your circulation staff.</p>
1274                     <p><strong>Important:</strong></p>
1275
1276                     <ul>
1277                         <li>The hold policies are applied based on the ReservesControlBranch system preference which is set to <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ReservesControlBranch">[% Koha.Preference('ReservesControlBranch') | html %]</a>.</li>
1278                         <li>The return policy is applied based on the CircControlReturnsBranch system preference which is set to <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CircControlReturnsBranch">[% Koha.Preference('CircControlReturnsBranch') | html %]</a>.</li>
1279                         <li>When return policy is set to 'item floats by library group' the item's homebranch will be used to find groups.</li>
1280                     </ul>
1281
1282                     <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
1283                         <input type="hidden" name="op" value="add-branch-item" />
1284                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
1285                         <table>
1286                             <tr>
1287                                 <th>Item type</th>
1288                                 <th>Hold policy</th>
1289                                 <th>Hold pickup library match</th>
1290                                 <th>Return policy</th>
1291                                 <th>&nbsp;</th>
1292                             </tr>
1293                             [% FOREACH i IN itemtypeloop %]
1294                                 [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
1295                                 [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
1296                                 [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
1297
1298                                 [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
1299                                     <tr>
1300                                         <td>
1301                                             [% i.translated_description | html %]
1302                                         </td>
1303                                         <td>
1304                                             [% IF holdallowed == 'from_any_library' %]
1305                                                 <span>From any library</span>
1306                                             [% ELSIF holdallowed == 'from_local_hold_group' %]
1307                                                 <span>From local hold group</span>
1308                                             [% ELSIF holdallowed == 'from_home_library' %]
1309                                                 <span>From home library</span>
1310                                             [% ELSE %]
1311                                                 <span>No holds allowed</span>
1312                                             [% END %]
1313                                         </td>
1314                                         <td>
1315                                             [% IF hold_fulfillment_policy == 'any' %]
1316                                                 <span>any library</span>
1317                                             [% ELSIF hold_fulfillment_policy == 'homebranch' %]
1318                                                 <span>item's home library</span>
1319                                             [% ELSIF hold_fulfillment_policy == 'holdgroup' %]
1320                                                 <span>item's hold group</span>
1321                                             [% ELSIF hold_fulfillment_policy == 'patrongroup' %]
1322                                                 <span>patron's hold group</span>
1323                                             [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
1324                                                 <span>item's holding library</span>
1325                                             [% END %]
1326                                         </td>
1327                                         <td>
1328                                             [% IF returnbranch == 'homebranch' %]
1329                                                 <span>Item returns home</span>
1330                                             [% ELSIF returnbranch == 'holdingbranch' %]
1331                                                 <span>Item returns to issuing branch</span>
1332                                             [% ELSIF returnbranch == 'noreturn' %]
1333                                                 <span>Item floats</span>
1334                                             [% ELSIF returnbranch == 'returnbylibrarygroup'%]
1335                                                 <span>Item floats by library group</span>
1336                                             [% END %]
1337                                         </td>
1338                                         <td class="actions">
1339                                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% i.itemtype | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
1340                                         </td>
1341                                     </tr>
1342                                 [% END %]
1343                             [% END %]
1344                             <tr>
1345                                 <td>
1346                                     <select name="itemtype">
1347                                     [% FOREACH itemtypeloo IN itemtypeloop %]
1348                                         <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
1349                                     [% END %]
1350                                     </select>
1351                                 </td>
1352                                 <td>
1353                                     <select name="holdallowed">
1354                                         <option value="from_any_library">From any library</option>
1355                                         <option value="from_local_hold_group">From local hold group</option>
1356                                         <option value="from_home_library">From home library</option>
1357                                         <option value="not_allowed">No holds allowed</option>
1358                                     </select>
1359                                 </td>
1360                                 <td>
1361                                     <select name="hold_fulfillment_policy">
1362                                         <option value="any">
1363                                             any library
1364                                         </option>
1365
1366                                         <option value="holdgroup">
1367                                             item's hold group
1368                                         </option>
1369
1370                                         <option value="patrongroup">
1371                                             patron's hold group
1372                                         </option>
1373
1374                                         <option value="homebranch">
1375                                             item's home library
1376                                         </option>
1377
1378                                         <option value="holdingbranch">
1379                                             item's holding library
1380                                         </option>
1381                                     </select>
1382                                 </td>
1383                                 <td>
1384                                     <select name="returnbranch">
1385                                         <option value="homebranch">Item returns home</option>
1386                                         <option value="holdingbranch">Item returns to issuing library</option>
1387                                         <option value="noreturn">Item floats</option>
1388                                         <option value="returnbylibrarygroup">Item floats by library group</option>
1389                                     </select>
1390                                 </td>
1391                                 <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
1392                             </tr>
1393                         </table>
1394                     </form>
1395                 </div>
1396             </main>
1397         </div> <!-- /.col-sm-10.col-sm-push-2 -->
1398
1399         <div class="col-sm-2 col-sm-pull-10">
1400             <aside>
1401                 [% INCLUDE 'admin-menu.inc' %]
1402             </aside>
1403         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1404      </div> <!-- /.row -->
1405
1406 [% MACRO jsinclude BLOCK %]
1407     [% Asset.js("js/admin-menu.js") | $raw %]
1408     [% INCLUDE 'datatables.inc' %]
1409     [% INCLUDE 'calendar.inc' %]
1410     [% INCLUDE 'columns_settings.inc' %]
1411     [% INCLUDE 'format_price.inc' %]
1412     <script>
1413          $(document).ready(function() {
1414             KohaTable("default-circulation-rules", {
1415                 "aoColumnDefs": [
1416                     { "bVisible": false, "aTargets": [ 0,2 ] },
1417                     { "bSortable": false, "aTargets": ["_all"] }
1418                 ],
1419                 "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'] ],
1420                 "bPaginate": false,
1421                 "bAutoWidth": false
1422             });
1423         });
1424
1425         function clear_edit(){
1426             var cancel = confirm(_("Are you sure you want to cancel your changes?"));
1427             if ( !cancel ) return;
1428             $('#default-circulation-rules td').removeClass('highlighted-row');
1429             var edit_row = $("#edit_row");
1430             $(edit_row).find("input").each(function(){
1431                 var type = $(this).attr("type");
1432                 if (type != "button" && type != "submit" ) {
1433                     $(this).val("");
1434                     $(this).prop('disabled', false);
1435                 }
1436                 if ( type == "checkbox" ) {
1437                     $(this).prop('checked', false);
1438                 }
1439             });
1440             $(edit_row).find("select").prop('disabled', false);
1441             $(edit_row).find("select option:first-child").attr("selected", "selected");
1442             $(edit_row).find("td:last input[name='clear']").remove();
1443         }
1444
1445         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
1446
1447         $(document).ready(function() {
1448             $('[data-toggle="popover"]').popover();
1449
1450             $(".delete").on("click",function(){
1451                 return confirmDelete(MSG_CONFIRM_DELETE);
1452             });
1453
1454             $("#clone_rules").on("click",function(){
1455                 var library_dropdown = document.getElementById("branch");
1456                 var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value;
1457                 var selected_library_text = $("#branch option:selected").text();
1458                 var to_library = $("#tobranch option:selected").text();
1459                 var MSG_CONFIRM_CLONE;
1460                 if (selected_library === "*") {
1461                     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);
1462                     return confirmClone(MSG_CONFIRM_CLONE);
1463                 } else {
1464                     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);
1465                     return confirmClone(MSG_CONFIRM_CLONE);
1466                 }
1467             });
1468
1469             $('#selectlibrary').find("input:submit").hide();
1470             $('#branch').change(function() {
1471                     $('#selectlibrary').submit();
1472             });
1473             $(".editrule").click(function(){
1474                 if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) {
1475                     var edit = confirm(_("Are you sure you want to edit another rule?"));
1476                     if (!edit) return false;
1477                 }
1478                 $('#default-circulation-rules td').removeClass('highlighted-row');
1479                 $(this).parent().parent().find("td").each(function (i) {
1480                     $(this).addClass('highlighted-row');
1481                     itm_code = $(this).data('code');
1482                     itm_text = $(this).text();
1483                     itm_text = itm_text.replace(/^\s*|\s*$/g,'');
1484                     var current_column = $("#edit_row td:eq("+i+")");
1485                     if ( i == 3 ) {
1486                         // specific processing for the Note column
1487                         var note = $(this).find("a[name='viewnote']").data("content");
1488                         $(current_column).find("input[type='text']").val(note);
1489                     } else if ( i == 9 ) {
1490                         // specific processing for the Hard due date column
1491                         var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
1492                         var input_value = '';
1493                         if (typeof select_value === 'undefined'){
1494                             select_value = '-1';
1495                         }else {
1496                             input_value = itm_text.split(' ')[1];
1497                         }
1498                         $(current_column).find("input[type='text']").val(input_value);
1499                         $(current_column).find("select").val(select_value);
1500                     } else if ( i == 16 ) {
1501                         // specific processing for cap_fine_to_replacement_price
1502                         var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1503                         $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1504                         $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1505                     } else {
1506                         $(current_column).find("input[type='text']").val(itm_text);
1507                         // unformat prices
1508                         $(current_column).find("input[inputmode='decimal']").each(function() {
1509                           $(this).val(itm_text.unformat_price());
1510                         });
1511                         // select the corresponding option
1512                         $(current_column).find("select option").each(function(){
1513                             opt = $(this).attr('value');
1514                             if ( opt == itm_code ) {
1515                                 $(this).attr('selected', 'selected');
1516                             }
1517                         });
1518                         if ( i == 0 || i == 1 ) {
1519                             // Disable the 2 first columns, we cannot update them.
1520                             var val = $(current_column).find("select option:selected").val();
1521                             var name = "categorycode";
1522                             if ( i == 1 ) {
1523                                 name="itemtype";
1524                             }
1525                             // Remove potential previous input added
1526                             $(current_column).find("input").remove();
1527                             $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1528                         } else if ( i == 5 || i == 6 || i == 26 || i == 27 || i == 28 ) {
1529                             // If the value is not an integer for
1530                             //     - "Current checkouts allowed"
1531                             //     - "Current on-site checkouts allowed"
1532                             //     - "Holds allowed (total)"
1533                             //     - "Holds allowed (daily)"
1534                             //     - "Holds per record (count)"
1535                             // The value is "Unlimited" (or an equivalent translated string)
1536                             // an it should be set to an empty string
1537                             if( !((parseFloat(itm_text) == parseInt(itm_text)) && !isNaN(itm_text)) ) {
1538                                 $(current_column).find("input[type='text']").val("");
1539                             }
1540                         }
1541                     }
1542                 });
1543                 $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1544                 $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1545                 return false;
1546             });
1547             $(".clear_edit").on("click",function(e){
1548                 e.preventDefault();
1549                 clear_edit();
1550             });
1551
1552             $("#set-article-requests-daily-limit").on("submit", function(){
1553                 if (! $("input[name='open_article_requests_limit'").val().length){
1554                     alert("Please set a daily limit for this patron's category");
1555                     return false;
1556                 }
1557                 return true;
1558             });
1559
1560             $("#set-article-request-fee").on("submit", function(){
1561                 if (! $("input[name='article_request_fee'").val().length){
1562                     alert("Please set a valid value for the fee");
1563                     return false;
1564                 }
1565                 return true;
1566             });
1567         });
1568     </script>
1569 [% END %]
1570 [% INCLUDE 'intranet-bottom.inc' %]