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