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