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