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