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