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