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