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