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