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