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