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