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