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