Bug 12230: Set a maximum suspension days as a new issuing rule
[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>Max. suspension duration (day)</th>
152                 <th>Renewals allowed (count)</th>
153                 <th>Renewal period</th>
154                 <th>No renewal before</th>
155                 <th>Holds allowed (count)</th>
156                 <th>Rental discount (%)</th>
157                 <th colspan="2">&nbsp;</th>
158             </tr>
159             </thead>
160             <tbody>
161                                 [% FOREACH rule IN rules %]
162                                         [% UNLESS ( loop.odd ) %]
163                                         <tr class="highlight" id="row_[% loop.count %]">
164                                         [% ELSE %]
165                                         <tr id="row_[% loop.count %]">
166                                         [% END %]
167                                                         <td>[% IF ( rule.default_humancategorycode ) %]
168                                                                         <em>All</em>
169                                                                 [% ELSE %]
170                                                                         [% rule.humancategorycode %]
171                                                                 [% END %]
172                                                         </td>
173                                                         <td>[% IF ( rule.default_humanitemtype ) %]
174                                                                         <em>All</em>
175                                                                 [% ELSE %]
176                                                                         [% rule.humanitemtype %]
177                                                                 [% END %]
178                                                         </td>
179                                                         <td>[% IF ( rule.unlimited_maxissueqty ) %]
180                                                                         Unlimited
181                                                                 [% ELSE %]
182                                                                         [% rule.maxissueqty %]
183                                                                 [% END %]
184                                                         </td>
185                                                         <td>[% rule.issuelength %]</td>
186                                                         <td>
187                                                             [% rule.lengthunit %]
188                                                         </td>
189                             <td>
190                               [% IF ( rule.hardduedate ) %]
191                                 [% IF ( rule.hardduedatebefore ) %]
192                                   before [% rule.hardduedate %]
193                                   <input type="hidden" name="hardduedatecomparebackup" value="-1" />
194                                 [% ELSIF ( rule.hardduedateexact ) %]
195                                   on [% rule.hardduedate %]
196                                   <input type="hidden" name="hardduedatecomparebackup" value="0" />
197                                 [% ELSIF ( rule.hardduedateafter ) %]
198                                   after [% rule.hardduedate %]
199                                   <input type="hidden" name="hardduedatecomparebackup" value="1" />
200                                 [% END %]
201                               [% ELSE %]
202                                 None defined
203                               [% END %]
204                             </td>
205                                                         <td>[% rule.fine %]</td>
206                                                         <td>[% rule.chargeperiod %]</td>
207                                                         <td>[% rule.firstremind %]</td>
208                             <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
209                                                         <td>[% rule.finedays %]</td>
210                             <td>[% rule.maxsuspensiondays %]</td>
211                                                         <td>[% rule.renewalsallowed %]</td>
212                             <td>[% rule.renewalperiod %]</td>
213                             <td>[% rule.norenewalbefore %]</td>
214                                                         <td>[% rule.reservesallowed %]</td>
215                                                         <td>[% rule.rentaldiscount %]</td>
216                             <td><a href="#" class="editrule">Edit</a></td>
217                                                         <td>
218                                                                 <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>
219                                                         </td>
220                         </tr>
221                 [% END %]
222                 <tr id="edit_row">
223                     <td>
224                         <select name="categorycode" id="categorycode">
225                             <option value="*">All</option>
226                         [% FOREACH categoryloo IN categoryloop %]
227                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
228                         [% END %]
229                         </select>
230                     </td>
231                     <td>
232                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
233                             <option value="*">All</option>
234                         [% FOREACH itemtypeloo IN itemtypeloop %]
235                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
236                         [% END %]
237                         </select>
238                     </td>
239                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
240                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
241                     <td>
242                       <select name="lengthunit" id="lengthunit">
243                         <option value="days" selected>Days</option>
244                         <option value="hours">Hours</option>
245                       </select>
246                     </td>
247                     <td>
248                         <select name="hardduedatecompare" id="hardduedatecompare">
249                            <option value="-1">Before</option>
250                            <option value="0">Exactly on</option>
251                            <option value="1">After</option>
252                         </select>
253                         <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate %]" class="datepicker" />
254                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
255                     </td>
256                     <td><input type="text" name="fine" id="fine" size="4" /></td>
257                     <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
258                     <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
259                     <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
260                     <td><input type="text" name="finedays" id="fined" size="3" /> </td>
261                     <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
262                     <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
263                     <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
264                     <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
265                     <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
266                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
267                     <td colspan="2">
268                         <input type="hidden" name="branch" value="[% current_branch %]"/>
269                         <input type="submit" value="Save" class="submit" />
270                         <input type="button" name="cancel" value="Clear" onclick="clear_edit();return false;" />
271                     </td>
272                 </tr>
273                 </tbody>
274             </table>
275         </form>
276     </div>
277     <div id="defaults-for-this-library" class="container">
278     <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
279         <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>
280         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
281             <input type="hidden" name="op" value="set-branch-defaults" />
282             <input type="hidden" name="branch" value="[% current_branch %]"/>
283             <table>
284                 <tr>
285                     <th>&nbsp;</th>
286                     <th>Total current checkouts allowed</th>
287                     <th>Hold policy</th>
288                     <th>Return policy</th>
289                     <th>&nbsp;</th>
290                     <th>&nbsp;</th>
291                 </tr>
292                 <tr>
293                     <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
294                     <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty %]"/></td>
295                     <td>
296                         <select name="holdallowed">
297                             [% IF ( default_holdallowed_any ) %]
298                             <option value="2" selected="selected">
299                             [% ELSE %]
300                             <option value="2">
301                             [% END %]
302                                 From any library
303                             </option>
304                             [% IF ( default_holdallowed_same ) %]
305                             <option value="1" selected="selected">
306                             [% ELSE %]
307                             <option value="1">
308                             [% END %]
309                                 From home library
310                             </option>
311                             [% IF ( default_holdallowed_none ) %]
312                             <option value="0" selected="selected">
313                             [% ELSE %]
314                             <option value="0">
315                             [% END %]
316                                 No holds allowed
317                             </option>
318                         </select>
319                     </td>
320                     <td>
321                         <select name="returnbranch">
322                             [% IF ( default_returnbranch == 'homebranch' ) %]
323                             <option value="homebranch" selected="selected">
324                             [% ELSE %]
325                             <option value="homebranch">
326                             [% END %]
327                                 Item returns home
328                             </option>
329                             [% IF ( default_returnbranch == 'holdingbranch' ) %]
330                             <option value="holdingbranch" selected="selected">
331                             [% ELSE %]
332                             <option value="holdingbranch">
333                             [% END %]
334                                 Item returns to issuing library
335                             </option>
336                             [% IF ( default_returnbranch == 'noreturn' ) %]
337                             <option value="noreturn" selected="selected">
338                             [% ELSE %]
339                             <option value="noreturn">
340                             [% END %]
341                                 Item floats
342                             </option>
343                         </select>
344                     </td>
345                     <td><input type="submit" value="Save" class="submit" /></td>
346                     <td>
347                         <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
348                     </td>
349                 </tr>
350             </table>
351         </form>
352     </div>
353     [% IF ( show_branch_cat_rule_form ) %]
354     <div id="holds-policy-by-patron-category" class="container">
355     <h3>[% IF humanbranch %]Checkout limit by patron category for [% humanbranch %][% ELSE %]Default checkout limit by patron category[% END %]</h3>
356         <p>For this library, you can specify the maximum number of loans that
357             a patron of a given category can make, regardless of the item type.
358         </p>
359         <p>If the total amount loanable for a given patron category is left blank,
360            no limit applies, except possibly for a limit you define for a specific item type.
361         </p>
362         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
363             <input type="hidden" name="op" value="add-branch-cat" />
364             <input type="hidden" name="branch" value="[% current_branch %]"/>
365             <table>
366                 <tr>
367                     <th>Patron category</th>
368                     <th>Total current checkouts allowed</th>
369                     <th>&nbsp;</th>
370                 </tr>
371                 [% FOREACH branch_cat_rule_loo IN branch_cat_rule_loop %]
372                     [% UNLESS ( loop.odd ) %]
373                     <tr class="highlight">
374                     [% ELSE %]
375                     <tr>
376                     [% END %]
377                         <td>[% IF ( branch_cat_rule_loo.default_humancategorycode ) %]
378                                 <em>Default</em>
379                             [% ELSE %]
380                                 [% branch_cat_rule_loo.humancategorycode %]
381                             [% END %]
382                         </td>
383                         <td>[% IF ( branch_cat_rule_loo.unlimited_maxissueqty ) %]
384                                 Unlimited
385                             [% ELSE %]
386                                 [% branch_cat_rule_loo.maxissueqty %]
387                             [% END %]
388                         </td>
389                         <td>
390                             <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>
391                         </td>
392                     </tr>
393                 [% END %]
394                 <tr>
395                     <td>
396                         <select name="categorycode">
397                         [% FOREACH categoryloo IN categoryloop %]
398                             <option value="[% categoryloo.categorycode %]">[% categoryloo.description %]</option>
399                         [% END %]
400                         </select>
401                     </td>
402                     <td><input name="maxissueqty" size="3" /></td>
403                     <td><input type="submit" value="Add" class="submit" /></td>
404                 </tr>
405             </table>
406         </form>
407     </div>
408     [% END %]
409     <div id="holds-policy-by-item-type" class="container">
410     <h3>[% IF humanbranch %]Holds policy by item type for [% humanbranch %][% ELSE %]Default holds policy by item type[% END %]</h3>
411         <p>
412             For this library, you can edit rules for given itemtypes, regardless
413             of the patron's category.
414         </p>
415         <p>
416             Currently, this means hold policies.
417             The various policies have the following effects:
418         </p>
419         <ul>
420             <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
421             <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
422             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
423         </ul>
424         <p>
425             Note that if the system preference
426             <code>AllowHoldPolicyOverride</code> is enabled, these policies can
427             be overridden by your circulation staff. Also, these policies are
428             based on the patron's home library, <em>not</em> the library where the hold is being placed..
429         </p>
430
431         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
432             <input type="hidden" name="op" value="add-branch-item" />
433             <input type="hidden" name="branch" value="[% current_branch %]"/>
434             <table>
435                 <tr>
436                     <th>Item type</th>
437                     <th>Hold policy</th>
438                     <th>Return policy</th>
439                     <th>&nbsp;</th>
440                 </tr>
441                 [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
442                     [% UNLESS ( loop.odd ) %]
443                     <tr class="highlight">
444                     [% ELSE %]
445                     <tr>
446                     [% END %]
447                         <td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
448                                 <em>Default</em>
449                             [% ELSE %]
450                                 [% branch_item_rule_loo.humanitemtype %]
451                             [% END %]
452                         </td>
453                         <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
454                                 From any library
455                             [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
456                                 From home library
457                             [% ELSE %]
458                                 No holds allowed
459                             [% END %]
460                         </td>
461                         <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
462                                 Item returns home
463                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
464                                 Item returns to issuing branch
465                             [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
466                                 Item floats
467                             [% ELSE %]
468                                 Error - unknown option
469                             [% END %]
470                         </td>
471                         <td>
472                             <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>
473                         </td>
474                     </tr>
475                 [% END %]
476                 <tr>
477                     <td>
478                         <select name="itemtype">
479                         [% FOREACH itemtypeloo IN itemtypeloop %]
480                             <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
481                         [% END %]
482                         </select>
483                     </td>
484                     <td>
485                         <select name="holdallowed">
486                             <option value="2">From any library</option>
487                             <option value="1">From home library</option>
488                             <option value="0">No holds allowed</option>
489                         </select>
490                     </td>
491                     <td>
492                         <select name="returnbranch">
493                             <option value="homebranch">Item returns home</option>
494                             <option value="holdingbranch">Item returns to issuing library</option>
495                             <option value="noreturn">Item floats</option>
496                         </select>
497                     </td>
498                     <td><input type="submit" value="Add" class="submit" /></td>
499                 </tr>
500             </table>
501         </form>
502     </div>
503 </div>
504
505 </div>
506 <div class="yui-b">
507 [% INCLUDE 'admin-menu.inc' %]
508 </div>
509 </div>
510 [% INCLUDE 'intranet-bottom.inc' %]