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