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