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