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