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