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