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