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