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