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