Bug 5786 - Move AllowOnShelfHolds and OPACItemHolds system prefs to the Circulation...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 [% INCLUDE 'calendar.inc' %]
5 <script type="text/javascript">
6 //<![CDATA[
7
8 function clear_edit(){
9     var cancel = confirm(_("Are you sure you want to cancel your changes?"));
10     if ( !cancel ) return;
11     $('#default-circulation-rules td').removeClass('highlighted-row');
12     var edit_row = $("#edit_row");
13     $(edit_row).find("input").each(function(){
14         var type = $(this).attr("type");
15         if (type != "button" && type != "submit" ) {
16             $(this).val("");
17             $(this).removeAttr("disabled");
18         }
19     });
20     $(edit_row).find("select").removeAttr("disabled");
21     $(edit_row).find("select option:first").attr("selected", "selected");
22     $(edit_row).find("td:last input[name='clear']").remove();
23 }
24
25 $(document).ready(function() {
26         $('#selectlibrary').find("input:submit").hide();
27         $('#branch').change(function() {
28                 $('#selectlibrary').submit();
29         });
30         $(".editrule").click(function(){
31             if ( $(edit_row).find("input[type='text'][value!='']").length > 0 ) {
32                 var edit = confirm(_("Are you sure you want to edit another rule?"));
33                 if (!edit) return false;
34             }
35             $('#default-circulation-rules td').removeClass('highlighted-row');
36             $(this).parent().parent().find("td").each(function (i) {
37                 $(this).addClass('highlighted-row');
38                 itm = $(this).text();
39                 itm = itm.replace(/^\s*|\s*$/g,'');
40                 var current_column = $("#edit_row td:eq("+i+")");
41                 if ( i != 5 ) {
42                     $(current_column).find("input[type='text']").val(itm);
43                     // select the corresponding option
44                     $(current_column).find("select option").each(function(){
45                         opt = $(this).text().toLowerCase();
46                         opt = opt.replace(/^\s*|\s*$/g,'');
47                         if ( opt == itm.toLowerCase() ) {
48                             $(this).attr('selected', 'selected');
49                         }
50                     });
51                     if ( i == 0 || i == 1 ) {
52                         // Disable the 2 first columns, we cannot update them.
53                         var val = $(current_column).find("select option:selected").val();
54                         var name = "categorycode";
55                         if ( i == 1 ) {
56                             name="itemtype";
57                         }
58                         // Remove potential previous input added
59                         $(current_column).find("input").remove();
60                         $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
61                     } else if ( i == 2 ) {
62                         // If the value is not an integer for "Current checkouts allowed"
63                         // The value is "Unlimited" (or an equivalent translated string)
64                         // an it should be set to an empty string
65                         if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
66                             $(current_column).find("input[type='text']").val("");
67                         }
68                     }
69                 } else {
70                     // specific processing for the Hard due date column
71                     var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
72                     var input_value = '';
73                     if (typeof select_value === 'undefined'){
74                         select_value = '-1';
75                     }else {
76                         input_value = itm.split(' ')[1];
77                     }
78                     $(current_column).find("input[type='text']").val(input_value);
79                     $(current_column).find("select").val(select_value);
80                 }
81             });
82             $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled');
83             $("#default-circulation-rules tr:last td:eq(1) select").attr('disabled', 'disabled');
84             return false;
85         });
86 });
87 //]]>
88 </script>
89 </head>
90 <body id="admin_smart-rules" class="admin">
91 [% INCLUDE 'header.inc' %]
92 [% INCLUDE 'cat-search.inc' %]
93
94 <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>
95
96 <div id="doc3" class="yui-t1">
97
98 <div id="bd">
99     <div id="yui-main">
100     <div class="yui-b">
101     <h1 class="parameters">
102         [% IF ( humanbranch ) %]
103             Defining circulation and fine rules for "[% humanbranch %]"
104         [% ELSE %]
105             Defining circulation and fine rules for all libraries
106         [% END %]
107     </h1>
108     <div class="help">
109         <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
110         <ul>
111             <li>same library, same patron type, same item type</li>
112             <li>same library, same patron type, all item types</li>
113             <li>same library, all patron types, same item type</li>
114             <li>same library, all patron types, all item types</li>
115             <li>default (all libraries), same patron type, same item type</li>
116             <li>default (all libraries), same patron type, all item types</li>
117             <li>default (all libraries), all patron types, same item type</li>
118             <li>default (all libraries), all patron types, all item types</li>
119         </ul>
120         <p>To modify a rule, create a new one with the same patron type and item type.</p>
121     </div>
122     <div>
123         <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
124         Select a library :
125             <select name="branch" id="branch" style="width:20em;">
126                 <option value="*">All libraries</option>
127             [% FOREACH branchloo IN branchloop %]
128                                 [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
129             [% END %]
130             </select>
131         </form>
132 [% IF ( definedbranch ) %]<form action="/cgi-bin/koha/admin/clone-rules.pl" method="post"><label 
133 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidden" name="frombranch" value="[% current_branch %]" />
134             <select name="tobranch" id="tobranch">[% FOREACH branchloo IN branchloop %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]</select> <input type="submit" value="Clone" /></form>[% END %]
135
136         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
137             <input type="hidden" name="op" value="add" />
138             <input type="hidden" name="branch" value="[% current_branch %]"/>
139             <table id="default-circulation-rules">
140             <thead>
141             <tr>
142                 <th>Patron category</th>
143                 <th>Item type</th>
144                 <th>Current checkouts allowed</th>
145                 <th>Loan period</th>
146                 <th>Unit</th>
147                 <th>Hard due date</th>
148                 <th>Fine amount</th>
149                 <th>Fine charging interval</th>
150                 <th>Fine grace period (day)</th>
151                 <th>Overdue fines cap (amount)</th>
152                 <th>Suspension in days (day)</th>
153                 <th>Max. suspension duration (day)</th>
154                 <th>Renewals allowed (count)</th>
155                 <th>Renewal period</th>
156                 <th>No renewal before</th>
157                 <th>Automatic renewal</th>
158                 <th>Holds allowed (count)</th>
159                 <th>On shelf holds allowed</th>
160                 <th>Item level holds</th>
161                 <th>Rental discount (%)</th>
162                 <th colspan="2">&nbsp;</th>
163             </tr>
164             </thead>
165             <tbody>
166                                 [% FOREACH rule IN rules %]
167                                         <tr id="row_[% loop.count %]">
168                                                         <td>[% IF ( rule.default_humancategorycode ) %]
169                                                                         <em>All</em>
170                                                                 [% ELSE %]
171                                                                         [% rule.humancategorycode %]
172                                                                 [% END %]
173                                                         </td>
174                                                         <td>[% IF ( rule.default_humanitemtype ) %]
175                                                                         <em>All</em>
176                                                                 [% ELSE %]
177                                                                         [% rule.humanitemtype %]
178                                                                 [% END %]
179                                                         </td>
180                                                         <td>[% IF ( rule.unlimited_maxissueqty ) %]
181                                                                         Unlimited
182                                                                 [% ELSE %]
183                                                                         [% rule.maxissueqty %]
184                                                                 [% END %]
185                                                         </td>
186                                                         <td>[% rule.issuelength %]</td>
187                                                         <td>
188                                                             [% rule.lengthunit %]
189                                                         </td>
190                             <td>
191                               [% IF ( rule.hardduedate ) %]
192                                 [% IF ( rule.hardduedatebefore ) %]
193                                   before [% rule.hardduedate %]
194                                   <input type="hidden" name="hardduedatecomparebackup" value="-1" />
195                                 [% ELSIF ( rule.hardduedateexact ) %]
196                                   on [% rule.hardduedate %]
197                                   <input type="hidden" name="hardduedatecomparebackup" value="0" />
198                                 [% ELSIF ( rule.hardduedateafter ) %]
199                                   after [% rule.hardduedate %]
200                                   <input type="hidden" name="hardduedatecomparebackup" value="1" />
201                                 [% END %]
202                               [% ELSE %]
203                                 None defined
204                               [% END %]
205                             </td>
206                                                         <td>[% rule.fine %]</td>
207                                                         <td>[% rule.chargeperiod %]</td>
208                                                         <td>[% rule.firstremind %]</td>
209                             <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
210                                                         <td>[% rule.finedays %]</td>
211                             <td>[% rule.maxsuspensiondays %]</td>
212                                                         <td>[% rule.renewalsallowed %]</td>
213                             <td>[% rule.renewalperiod %]</td>
214                             <td>[% rule.norenewalbefore %]</td>
215                             <td>
216                                 [% IF ( rule.auto_renew ) %]
217                                 Yes
218                                 [% ELSE %]
219                                 No
220                                 [% END %]
221                             </td>
222                                                         <td>[% rule.reservesallowed %]</td>
223                                                         <td>[% IF rule.onshelfholds %]Yes[% ELSE %]No[% END %]</td>
224                                                         <td>[% IF rule.opacitemholds == 'F'%]Enforce[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
225                                                         <td>[% rule.rentaldiscount %]</td>
226                             <td><a href="#" class="editrule">Edit</a></td>
227                                                         <td>
228                                                                 <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]">Delete</a>
229                                                         </td>
230                         </tr>
231                 [% END %]
232                 <tr id="edit_row">
233                     <td>
234                         <select name="categorycode" id="categorycode">
235                             <option value="*">All</option>
236                         [% FOREACH categoryloo IN categoryloop %]
237                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
238                         [% END %]
239                         </select>
240                     </td>
241                     <td>
242                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
243                             <option value="*">All</option>
244                         [% FOREACH itemtypeloo IN itemtypeloop %]
245                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
246                         [% END %]
247                         </select>
248                     </td>
249                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
250                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
251                     <td>
252                       <select name="lengthunit" id="lengthunit">
253                         <option value="days" selected="selected">Days</option>
254                         <option value="hours">Hours</option>
255                       </select>
256                     </td>
257                     <td>
258                         <select name="hardduedatecompare" id="hardduedatecompare">
259                            <option value="-1">Before</option>
260                            <option value="0">Exactly on</option>
261                            <option value="1">After</option>
262                         </select>
263                         <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate %]" class="datepicker" />
264                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
265                     </td>
266                     <td><input type="text" name="fine" id="fine" size="4" /></td>
267                     <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
268                     <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
269                     <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
270                     <td><input type="text" name="finedays" id="fined" size="3" /> </td>
271                     <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
272                     <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
273                     <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
274                     <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
275                     <td>
276                         <select name="auto_renew" id="auto_renew">
277                             <option value="no" selected>No</option>
278                             <option value="yes">Yes</option>
279                         </select>
280                     </td>
281                     <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
282                     <td>
283                         <select name="onshelfholds" id="onshelfholds">
284                             <option value="0" selected>No</option>
285                             <option value="1">Yes</option>
286                         </select>
287                     </td>
288                     <td>
289                         <select id="opacitemholds" name="opacitemholds">
290                             <option value="N">Don't allow</option>
291                             <option value="Y">Allow</option>
292                             <option value="F">Enforce</option>
293                         </select>
294                     </td>
295                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
296                     <td colspan="2">
297                         <input type="hidden" name="branch" value="[% current_branch %]"/>
298                         <input type="submit" value="Save" class="submit" />
299                         <input type="button" name="cancel" value="Clear" onclick="clear_edit();return false;" />
300                     </td>
301                 </tr>
302                 </tbody>
303             </table>
304         </form>
305     </div>
306     <div id="defaults-for-this-library" class="container">
307     <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
308         <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>
309         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
310             <input type="hidden" name="op" value="set-branch-defaults" />
311             <input type="hidden" name="branch" value="[% current_branch %]"/>
312             <table>
313                 <tr>
314                     <th>&nbsp;</th>
315                     <th>Total current checkouts allowed</th>
316                     <th>Hold policy</th>
317                     <th>Return policy</th>
318                     <th>&nbsp;</th>
319                     <th>&nbsp;</th>
320                 </tr>
321                 <tr>
322                     <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
323                     <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
324                     <td>
325                         <select name="holdallowed">
326                             [% IF ( default_holdallowed_any ) %]
327                             <option value="2" selected="selected">
328                             [% ELSE %]
329                             <option value="2">
330                             [% END %]
331                                 From any library
332                             </option>
333                             [% IF ( default_holdallowed_same ) %]
334                             <option value="1" selected="selected">
335                             [% ELSE %]
336                             <option value="1">
337                             [% END %]
338                                 From home library
339                             </option>
340                             [% IF ( default_holdallowed_none ) %]
341                             <option value="0" selected="selected">
342                             [% ELSE %]
343                             <option value="0">
344                             [% END %]
345                                 No holds allowed
346                             </option>
347                         </select>
348                     </td>
349                     <td>
350                         <select name="returnbranch">
351                             [% IF ( default_returnbranch == 'homebranch' ) %]
352                             <option value="homebranch" selected="selected">
353                             [% ELSE %]
354                             <option value="homebranch">
355                             [% END %]
356                                 Item returns home
357                             </option>
358                             [% IF ( default_returnbranch == 'holdingbranch' ) %]
359                             <option value="holdingbranch" selected="selected">
360                             [% ELSE %]
361                             <option value="holdingbranch">
362                             [% END %]
363                                 Item returns to issuing library
364                             </option>
365                             [% IF ( default_returnbranch == 'noreturn' ) %]
366                             <option value="noreturn" selected="selected">
367                             [% ELSE %]
368                             <option value="noreturn">
369                             [% END %]
370                                 Item floats
371                             </option>
372                         </select>
373                     </td>
374                     <td><input type="submit" value="Save" class="submit" /></td>
375                     <td>
376                         <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
377                     </td>
378                 </tr>
379             </table>
380         </form>
381     </div>
382     [% IF ( show_branch_cat_rule_form ) %]
383     <div id="holds-policy-by-patron-category" class="container">
384     <h3>[% IF humanbranch %]Checkout limit by patron category for [% humanbranch %][% ELSE %]Default checkout limit by patron category[% END %]</h3>
385         <p>For this library, you can specify the maximum number of loans that
386             a patron of a given category can make, regardless of the item type.
387         </p>
388         <p>If the total amount loanable for a given patron category is left blank,
389            no limit applies, except possibly for a limit you define for a specific item type.
390         </p>
391         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
392             <input type="hidden" name="op" value="add-branch-cat" />
393             <input type="hidden" name="branch" value="[% current_branch %]"/>
394             <table>
395                 <tr>
396                     <th>Patron category</th>
397                     <th>Total current checkouts allowed</th>
398                     <th>&nbsp;</th>
399                 </tr>
400                 [% FOREACH branch_cat_rule_loo IN branch_cat_rule_loop %]
401                     [% UNLESS ( loop.odd ) %]
402                     <tr class="highlight">
403                     [% ELSE %]
404                     <tr>
405                     [% END %]
406                         <td>[% IF ( branch_cat_rule_loo.default_humancategorycode ) %]
407                                 <em>Default</em>
408                             [% ELSE %]
409                                 [% branch_cat_rule_loo.humancategorycode %]
410                             [% END %]
411                         </td>
412                         <td>[% IF ( branch_cat_rule_loo.unlimited_maxissueqty ) %]
413                                 Unlimited
414                             [% ELSE %]
415                                 [% branch_cat_rule_loo.maxissueqty %]
416                             [% END %]
417                         </td>
418                         <td>
419                             <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode %]&amp;branch=[% current_branch %]">Delete</a>
420                         </td>
421                     </tr>
422                 [% END %]
423                 <tr>
424                     <td>
425                         <select name="categorycode">
426                         [% FOREACH categoryloo IN categoryloop %]
427                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
428                         [% END %]
429                         </select>
430                     </td>
431                     <td><input name="maxissueqty" size="3" /></td>
432                     <td><input type="submit" value="Add" class="submit" /></td>
433                 </tr>
434             </table>
435         </form>
436     </div>
437     [% END %]
438     <div id="holds-policy-by-item-type" class="container">
439     <h3>[% IF humanbranch %]Holds policy by item type for [% humanbranch %][% ELSE %]Default holds policy by item type[% END %]</h3>
440         <p>
441             For this library, you can edit rules for given itemtypes, regardless
442             of the patron's category.
443         </p>
444         <p>
445             Currently, this means hold policies.
446             The various policies have the following effects:
447         </p>
448         <ul>
449             <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
450             <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
451             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
452         </ul>
453         <p>
454             Note that if the system preference
455             <code>AllowHoldPolicyOverride</code> is enabled, these policies can
456             be overridden by your circulation staff. Also, these policies are
457             based on the patron's home library, <em>not</em> the library where the hold is being placed..
458         </p>
459
460         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
461             <input type="hidden" name="op" value="add-branch-item" />
462             <input type="hidden" name="branch" value="[% current_branch %]"/>
463             <table>
464                 <tr>
465                     <th>Item type</th>
466                     <th>Hold policy</th>
467                     <th>Return policy</th>
468                     <th>&nbsp;</th>
469                 </tr>
470                 [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
471                     [% UNLESS ( loop.odd ) %]
472                     <tr class="highlight">
473                     [% ELSE %]
474                     <tr>
475                     [% END %]
476                         <td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
477                                 <em>Default</em>
478                             [% ELSE %]
479                                 [% branch_item_rule_loo.humanitemtype %]
480                             [% END %]
481                         </td>
482                         <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
483                                 From any library
484                             [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
485                                 From home library
486                             [% ELSE %]
487                                 No holds allowed
488                             [% END %]
489                         </td>
490                         <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
491                                 Item returns home
492                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
493                                 Item returns to issuing branch
494                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
495                                 Item floats
496                             [% ELSE %]
497                                 Error - unknown option
498                             [% END %]
499                         </td>
500                         <td>
501                             <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype %]&amp;branch=[% current_branch %]">Delete</a>
502                         </td>
503                     </tr>
504                 [% END %]
505                 <tr>
506                     <td>
507                         <select name="itemtype">
508                         [% FOREACH itemtypeloo IN itemtypeloop %]
509                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
510                         [% END %]
511                         </select>
512                     </td>
513                     <td>
514                         <select name="holdallowed">
515                             <option value="2">From any library</option>
516                             <option value="1">From home library</option>
517                             <option value="0">No holds allowed</option>
518                         </select>
519                     </td>
520                     <td>
521                         <select name="returnbranch">
522                             <option value="homebranch">Item returns home</option>
523                             <option value="holdingbranch">Item returns to issuing library</option>
524                             <option value="noreturn">Item floats</option>
525                         </select>
526                     </td>
527                     <td><input type="submit" value="Add" class="submit" /></td>
528                 </tr>
529             </table>
530         </form>
531     </div>
532 </div>
533
534 </div>
535 <div class="yui-b">
536 [% INCLUDE 'admin-menu.inc' %]
537 </div>
538 </div>
539 [% INCLUDE 'intranet-bottom.inc' %]