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