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