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