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