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