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