Bug 25896: Add missing closing </td> tag
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE ItemTypes %]
8 [% USE CirculationRules %]
9 [% SET footerjs = 1 %]
10
11 [% SET branchcode = humanbranch || undef %]
12
13 [% SET categorycodes = [] %]
14 [% FOREACH pc IN patron_categories %]
15     [% categorycodes.push( pc.id ) %]
16 [% END %]
17 [% categorycodes.push(undef) %]
18
19 [% SET itemtypes = [] %]
20 [% FOREACH i IN itemtypeloop %]
21     [% itemtypes.push( i.itemtype ) %]
22 [% END %]
23 [% itemtypes.push(undef) %]
24
25 [% INCLUDE 'doc-head-open.inc' %]
26 <title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
27 [% INCLUDE 'doc-head-close.inc' %]
28 </head>
29
30 <body id="admin_smart-rules" class="admin">
31 [% INCLUDE 'header.inc' %]
32 [% INCLUDE 'prefs-admin-search.inc' %]
33
34 <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>
35
36 <div class="main container-fluid">
37     <div class="row">
38         <div class="col-sm-10 col-sm-push-2">
39             <main>
40
41     <h1 class="parameters">
42         [% IF humanbranch %]
43             Defining circulation and fine rules for "[% Branches.GetName( humanbranch ) | html %]"
44         [% ELSE %]
45             Defining circulation and fine rules for all libraries
46         [% END %]
47     </h1>
48     <div class="help">
49         <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
50         <ul>
51             <li>same library, same patron category, same item type</li>
52             <li>same library, same patron category, all item types</li>
53             <li>same library, all patron categories, same item type</li>
54             <li>same library, all patron categories, all item types</li>
55             <li>default (all libraries), same patron category, same item type</li>
56             <li>default (all libraries), same patron category, all item types</li>
57             <li>default (all libraries), all patron categories, same item type</li>
58             <li>default (all libraries), all patron categories, all item types</li>
59         </ul>
60         <p>To modify a rule, create a new one with the same patron category and item type.</p>
61     </div>
62     <div>
63         [% UNLESS restricted_to_own_library %]
64             <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
65             Select a library :
66                 <select name="branch" id="branch" style="width:20em;">
67                     <option value="*">Standard rules for all libraries</option>
68                     [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
69                 </select>
70             </form>
71             [% IF ( definedbranch ) %]
72                 <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
73                     <label for="tobranch"><strong>Clone these rules to:</strong></label>
74                     <input type="hidden" name="frombranch" value="[% current_branch | html %]" />
75                     <select name="tobranch" id="tobranch">
76                         [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
77                     </select>
78                     <input type="submit" id="clone_rules" value="Clone" />
79                 </form>
80             [% END %]
81         [% END %]
82
83         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
84             <input type="hidden" name="op" value="add" />
85             <input type="hidden" name="branch" value="[% current_branch | html %]"/>
86             <table id="default-circulation-rules">
87             <thead>
88             <tr>
89                 <th>Patron category</th>
90                 <th>Item type</th>
91                 <th>Actions</th>
92                 <th>Note</th>
93                 <th>Current checkouts allowed</th>
94                 <th>Current on-site checkouts allowed</th>
95                 <th>Loan period</th>
96                 <th>Days mode</th>
97                 <th>Unit</th>
98                 <th>Hard due date</th>
99                 <th>Fine amount</th>
100                 <th>Fine charging interval</th>
101                 <th>When to charge</th>
102                 <th>Fine grace period</th>
103                 <th>Overdue fines cap (amount)</th>
104                 <th>Cap fine at replacement price</th>
105                 <th>Suspension in days (day)</th>
106                 <th>Max. suspension duration (day)</th>
107                 <th>Suspension charging interval</th>
108                 <th>Renewals allowed (count)</th>
109                 <th>Renewal period</th>
110                 <th>No renewal before</th>
111                 <th>Automatic renewal</th>
112                 <th>No automatic renewal after</th>
113                 <th>No automatic renewal after (hard limit)</th>
114                 <th>Holds allowed (total)</th>
115                 <th>Holds allowed (daily)</th>
116                 <th>Holds per record (count)</th>
117                 <th>On shelf holds allowed</th>
118                 <th>OPAC item level holds</th>
119                 <th>Article requests</th>
120                 <th>Rental discount (%)</th>
121                 <th>Actions</th>
122             </tr>
123             </thead>
124             <tbody>
125                 [% SET row_count = 0 %]
126                 [% FOREACH c IN categorycodes %]
127                     [% SET c = '' UNLESS c.defined %]
128                     [% FOREACH i IN itemtypes %]
129                         [% SET i = '' UNLESS i.defined %]
130                         [% SET note = all_rules.$c.$i.note %]
131                         [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
132                         [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
133                         [% SET issuelength = all_rules.$c.$i.issuelength %]
134                         [% SET daysmode = all_rules.$c.$i.daysmode %]
135                         [% SET lengthunit = all_rules.$c.$i.lengthunit %]
136                         [% SET hardduedate = all_rules.$c.$i.hardduedate %]
137                         [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %]
138                         [% SET fine = all_rules.$c.$i.fine %]
139                         [% SET chargeperiod = all_rules.$c.$i.chargeperiod %]
140                         [% SET chargeperiod_charge_at = all_rules.$c.$i.chargeperiod_charge_at %]
141                         [% SET firstremind = all_rules.$c.$i.firstremind %]
142                         [% SET overduefinescap = all_rules.$c.$i.overduefinescap %]
143                         [% SET cap_fine_to_replacement_price = all_rules.$c.$i.cap_fine_to_replacement_price %]
144                         [% SET finedays = all_rules.$c.$i.finedays %]
145                         [% SET maxsuspensiondays = all_rules.$c.$i.maxsuspensiondays %]
146                         [% SET suspension_chargeperiod = all_rules.$c.$i.suspension_chargeperiod %]
147                         [% SET renewalsallowed = all_rules.$c.$i.renewalsallowed %]
148                         [% SET renewalperiod = all_rules.$c.$i.renewalperiod %]
149                         [% SET norenewalbefore = all_rules.$c.$i.norenewalbefore %]
150                         [% SET auto_renew = all_rules.$c.$i.auto_renew %]
151                         [% SET no_auto_renewal_after = all_rules.$c.$i.no_auto_renewal_after %]
152                         [% SET no_auto_renewal_after_hard_limit = all_rules.$c.$i.no_auto_renewal_after_hard_limit %]
153                         [% SET reservesallowed = all_rules.$c.$i.reservesallowed %]
154                         [% SET holds_per_day = all_rules.$c.$i.holds_per_day %]
155                         [% SET holds_per_record = all_rules.$c.$i.holds_per_record %]
156                         [% SET onshelfholds = all_rules.$c.$i.onshelfholds %]
157                         [% SET opacitemholds = all_rules.$c.$i.opacitemholds %]
158                         [% SET article_requests = all_rules.$c.$i.article_requests %]
159                         [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
160
161                         [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalperiod || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount %]
162                         [% IF show_rule %]
163                             [% SET row_count = row_count + 1 %]
164                             <tr row_countd="row_[% row_count | html %]">
165                                     <td>
166                                         [% IF c == undef %]
167                                             <em>All</em>
168                                         [% ELSE %]
169                                             [% Categories.GetName(c) | html %]
170                                         [% END %]
171                                     </td>
172                                     <td>
173                                         [% IF i == undef %]
174                                             <em>All</em>
175                                         [% ELSE %]
176                                             [% ItemTypes.GetDescription(i) | html %]
177                                         [% END %]
178                                     </td>
179                                     <td class="actions">
180                                       <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
181                                       <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | html %]&amp;categorycode=[% c || '*' | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
182                                     </td>
183                                     <td>
184                                         [% IF note.defined && note != '' %]
185                                             <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
186                                         [% ELSE %]<span>&nbsp;</span>[% END %]
187                                     </td>
188                                     <td>
189                                         [% IF maxissueqty.defined && maxissueqty != '' %]
190                                             [% maxissueqty | html %]
191                                         [% ELSE %]
192                                             <span>Unlimited</span>
193                                         [% END %]
194                                     </td>
195                                     <td>
196                                         [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
197                                             [% maxonsiteissueqty | html %]
198                                         [% ELSE %]
199                                             <span>Unlimited</span>
200                                         [% END %]
201                                     </td>
202                                     <td>[% issuelength | html %]</td>
203                                     <td>
204                                         [% SWITCH daysmode %]
205                                         [% CASE 'Calendar' %]<span title="Use the calendar to skip days the library is closed">Calendar</span>
206                                         [% CASE 'Datedue' %]<span title="Use the calendar to push the due date to the next open day">Datedue</span>
207                                         [% CASE 'Days' %]<span title="Ignore the calendar">Days</span>
208                                         [% CASE 'Dayweek' %]<span title="Use the calendar to push the due date to the next open matching weekday for weekly loan periods, or the next open day otherwise">Dayweek</span>
209                                         [% CASE %]<span title="Use the system preference 'useDaysMode' as a default value">Default</span>
210                                         [% END %]
211                                     </td>
212                                     <td>
213                                         [% IF ( lengthunit == 'days' ) %]
214                                             Days
215                                         [% ELSIF ( lengthunit == 'hours') %]
216                                             Hours
217                                         [% ELSE %]
218                                             Undefined
219                                         [% END %]
220                                     </td>
221                                     <td>
222                                       [% IF ( hardduedate ) %]
223                                         [% IF ( hardduedatecompare == '-1' ) %]
224                                           before [% hardduedate | $KohaDates %]
225                                           <input type="hidden" name="hardduedatecomparebackup" value="-1" />
226                                         [% ELSIF ( hardduedatecompare == '0' ) %]
227                                           on [% hardduedate | $KohaDates %]
228                                           <input type="hidden" name="hardduedatecomparebackup" value="0" />
229                                         [% ELSIF ( hardduedatecompare == '1' ) %]
230                                           after [% hardduedate | $KohaDates %]
231                                           <input type="hidden" name="hardduedatecomparebackup" value="1" />
232                                         [% END %]
233                                       [% ELSE %]
234                                         <span>None defined</span>
235                                       [% END %]
236                                     </td>
237                                     <td>[% fine | html %]</td>
238                                     <td>[% chargeperiod | html %]</td>
239                                     <td>[% IF chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
240                                     <td>[% firstremind | html %]</td>
241                                     <td>[% overduefinescap FILTER format("%.2f") %]</td>
242                                     <td>
243                                         [% IF cap_fine_to_replacement_price %]
244                                             <input type="checkbox" checked="checked" disabled="disabled" />
245                                         [% ELSE %]
246                                             <input type="checkbox" disabled="disabled" />
247                                         [% END %]
248                                     </td>
249                                     <td>[% finedays | html %]</td>
250                                     <td>[% maxsuspensiondays | html %]</td>
251                                     <td>[% suspension_chargeperiod | html %]</td>
252                                     <td>[% renewalsallowed | html %]</td>
253                                     <td>[% renewalperiod | html %]</td>
254                                     <td>[% norenewalbefore | html %]</td>
255                                     <td>
256                                         [% IF auto_renew %]
257                                             <span>Yes</span>
258                                         [% ELSE %]
259                                             <span>No</span>
260                                         [% END %]
261                                     </td>
262                                     <td>[% no_auto_renewal_after | html %]</td>
263                                     <td>[% no_auto_renewal_after_hard_limit | $KohaDates %]</td>
264                                     <td>
265                                         [% IF reservesallowed.defined && reservesallowed != '' %]
266                                             [% reservesallowed | html %]
267                                         [% ELSE %]
268                                             <span>Unlimited</span>
269                                         [% END %]
270                                     </td>
271                                     <td>
272                                         [% IF holds_per_day.defined && holds_per_day != '' %]
273                                             [% holds_per_day | html %]
274                                         [% ELSE %]
275                                             <span>Unlimited</span>
276                                         [% END %]
277                                     </td>
278                                     <td>
279                                         [% IF holds_per_record.defined && holds_per_record != '' %]
280                                             [% holds_per_record | html %]
281                                         [% ELSE %]
282                                             <span>Unlimited</span>
283                                         [% END %]
284                                     </td>
285                                     <td>
286                                         [% IF onshelfholds == 1 %]
287                                             <span>Yes</span>
288                                         [% ELSIF onshelfholds == 2 %]
289                                             <span>If all unavailable</span>
290                                         [% ELSE %]
291                                             <span>If any unavailable</span>
292                                         [% END %]
293                                     </td>
294                                     <td>
295                                         [% IF opacitemholds == 'F'%]
296                                             <span>Force</span>
297                                         [% ELSIF opacitemholds == 'Y'%]
298                                             <span>Allow</span>
299                                         [% ELSE %]
300                                             <span>Don't allow</span>
301                                         [% END %]
302                                     </td>
303                                     <td>
304                                         [% IF article_requests == 'no' %]
305                                             <span>No</span>
306                                         [% ELSIF article_requests == 'yes' %]
307                                             <span>Yes</span>
308                                         [% ELSIF article_requests == 'bib_only' %]
309                                             <span>Record only</span>
310                                         [% ELSIF article_requests == 'item_only' %]
311                                             <span>Item only</span>
312                                         [% END %]
313                                     </td>
314                                     <td>[% rentaldiscount | html %]</td>
315                                     <td class="actions">
316                                       <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
317                                       <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
318                                     </td>
319                             </tr>
320                         [% END %]
321                     [% END %]
322                 [% END %]
323                 <tr id="edit_row">
324                     <td>
325                         <select name="categorycode" id="categorycode">
326                             <option value="*">All</option>
327                         [% FOREACH patron_category IN patron_categories%]
328                             <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
329                         [% END %]
330                         </select>
331                     </td>
332                     <td>
333                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
334                             <option value="*">All</option>
335                         [% FOREACH itemtypeloo IN itemtypeloop %]
336                             <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
337                         [% END %]
338                         </select>
339                     </td>
340                     <td class="actions">
341                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
342                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
343                         <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
344                     </td>
345                     <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
346                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
347                     <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
348                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
349                     <td>
350                         <select name="daysmode" id="daysmode">
351                             <option value="">Default</option>
352                             <option value="Calendar">Calendar</option>
353                             <option value="Datedue">Datedue</option>
354                             <option value="Days">Days</option>
355                             <option value="Dayweek">Dayweek</option>
356                         </select>
357                     </td>
358                     <td>
359                       <select name="lengthunit" id="lengthunit">
360                         <option value="days" selected="selected">Days</option>
361                         <option value="hours">Hours</option>
362                       </select>
363                     </td>
364                     <td>
365                         <select name="hardduedatecompare" id="hardduedatecompare">
366                            <option value="-1">Before</option>
367                            <option value="0">Exactly on</option>
368                            <option value="1">After</option>
369                         </select>
370                         <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate | html %]" class="datepicker" />
371                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
372                     </td>
373                     <td><input type="text" name="fine" id="fine" size="4" /></td>
374                     <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
375                     <td>
376                         <select name="chargeperiod_charge_at" id="chargeperiod_charge_at">
377                            <option value="0">End of interval</option>
378                            <option value="1">Start of interval</option>
379                         </select>
380                     </td>
381                     <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
382                     <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
383                     <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td>
384                     <td><input type="text" name="finedays" id="fined" size="3" /> </td>
385                     <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
386                     <td><input type="text" name="suspension_chargeperiod" id="suspension_chargeperiod" size="3" /> </td>
387                     <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
388                     <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
389                     <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
390                     <td>
391                         <select name="auto_renew" id="auto_renew">
392                             <option value="no" selected>No</option>
393                             <option value="yes">Yes</option>
394                         </select>
395                     </td>
396                     <td><input type="text" name="no_auto_renewal_after" id="no_auto_renewal_after" size="3" /></td>
397                     <td>
398                         <input type="text" size="10" name="no_auto_renewal_after_hard_limit" id="no_auto_renewal_after_hard_limit" value="[% no_auto_renewal_after_hard_limit | html %]" class="datepicker"/>
399                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
400                     </td>
401                     <td><input type="text" name="reservesallowed"  id="reservesallowed"  size="2" /></td>
402                     <td><input type="text" name="holds_per_day"    id="holds_per_day"    size="2" /></td>
403                     <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
404                     <td>
405                         <select name="onshelfholds" id="onshelfholds">
406                             <option value="1">Yes</option>
407                             <option value="0">If any unavailable</option>
408                             <option value="2">If all unavailable</option>
409                         </select>
410                     </td>
411                     <td>
412                         <select id="opacitemholds" name="opacitemholds">
413                             <option value="N">Don't allow</option>
414                             <option value="Y">Allow</option>
415                             <option value="F">Force</option>
416                         </select>
417                     </td>
418                     <td>
419                         <select id="article_requests" name="article_requests">
420                             <option value="no">No</option>
421                             <option value="yes">Yes</option>
422                             <option value="bib_only">Record only</option>
423                             <option value="item_only">Item only</option>
424                         </select>
425                     </td>
426                     <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
427                     <td class="actions">
428                         <input type="hidden" name="branch" value="[% current_branch | html %]"/>
429                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
430                         <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
431                     </td>
432                 </tr>
433                 <tfoot>
434                     <tr>
435                       <th>Patron category</th>
436                       <th>Item type</th>
437                       <th>&nbsp;</th>
438                       <th>Note</th>
439                       <th>Current checkouts allowed</th>
440                       <th>Current on-site checkouts allowed</th>
441                       <th>Loan period</th>
442                       <th>Days mode</th>
443                       <th>Unit</th>
444                       <th>Hard due date</th>
445                       <th>Fine amount</th>
446                       <th>Fine charging interval</th>
447                       <th>Charge when?</th>
448                       <th>Fine grace period</th>
449                       <th>Overdue fines cap (amount)</th>
450                       <th>Cap fine at replacement price</th>
451                       <th>Suspension in days (day)</th>
452                       <th>Max. suspension duration (day)</th>
453                       <th>Suspension charging interval</th>
454                       <th>Renewals allowed (count)</th>
455                       <th>Renewal period</th>
456                       <th>No renewal before</th>
457                       <th>Automatic renewal</th>
458                       <th>No automatic renewal after</th>
459                       <th>No automatic renewal after (hard limit)</th>
460                       <th>Holds allowed (total)</th>
461                       <th>Holds allowed (daily)</th>
462                       <th>Holds per record (count)</th>
463                       <th>On shelf holds allowed</th>
464                       <th>OPAC item level holds</th>
465                       <th>Article requests</th>
466                       <th>Rental discount (%)</th>
467                       <th>&nbsp;</th>
468                     </tr>
469                   </tfoot>
470                 </tbody>
471             </table>
472         </form>
473     </div>
474     <div id="defaults-for-this-library" class="container">
475     <h3>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) | html %][% END %]</h3>
476         <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>
477         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
478             <input type="hidden" name="op" value="set-branch-defaults" />
479             <input type="hidden" name="branch" value="[% current_branch | html %]"/>
480             <table>
481                 <tr>
482                     <th>&nbsp;</th>
483                     <th>Total current checkouts allowed</th>
484                     <th>Total current on-site checkouts allowed</th>
485                     <th>Maximum total holds allowed (count)</th>
486                     <th>Hold policy</th>
487                     <th>Hold pickup library match</th>
488                     <th>Return policy</th>
489                     <th>Actions</th>
490                 </tr>
491                 <tr>
492                     <td><em>Defaults</em></td>
493                     <td>
494                         [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
495                         <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
496                     </td>
497                     <td>
498                         [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
499                         <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
500                     </td>
501                     <td>
502                         [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
503                         <input name="max_holds" size="3" value="[% rule_value | html %]" />
504                     </td>
505                     <td>
506                         <select name="holdallowed">
507                             [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed' ) %]
508                             <option value="">
509                                 Not set
510                             </option>
511
512                             [% IF holdallowed == 2 %]
513                                 <option value="2" selected="selected">
514                             [% ELSE %]
515                                 <option value="2">
516                             [% END %]
517                                 From any library
518                             </option>
519
520                             [% IF holdallowed == 3 %]
521                             <option value="3" selected="selected">
522                             [% ELSE %]
523                             <option value="3">
524                             [% END %]
525                                 From local hold group
526                             </option>
527
528                             [% IF holdallowed == 1 %]
529                                 <option value="1" selected="selected">
530                             [% ELSE %]
531                                 <option value="1">
532                             [% END %]
533                                 From home library
534                             </option>
535
536                             [% IF holdallowed == 0 %]
537                                 <option value="0" selected="selected">
538                             [% ELSE %]
539                                 <option value="0">
540                             [% END %]
541                                 No holds allowed
542                             </option>
543                         </select>
544                     </td>
545                     <td>
546                         <select name="hold_fulfillment_policy">
547                             [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy' ) %]
548
549                             <option value="">
550                                 Not set
551                             </option>
552
553                             [% IF hold_fulfillment_policy == 'any' %]
554                                 <option value="any" selected="selected">
555                                     any library
556                                 </option>
557                             [% ELSE %]
558                                 <option value="any">
559                                     any library
560                                 </option>
561                             [% END %]
562
563                             [% IF hold_fulfillment_policy == 'holdgroup' %]
564                                 <option value="holdgroup" selected="selected">
565                                     item's hold group
566                                 </option>
567                             [% ELSE %]
568                                 <option value="holdgroup">
569                                     item's hold group
570                                 </option>
571                             [% END %]
572
573                             [% IF hold_fulfillment_policy == 'patrongroup' %]
574                                 <option value="patrongroup" selected="selected">
575                                     patron's hold group
576                                 </option>
577                             [% ELSE %]
578                                 <option value="patrongroup">
579                                     patron's hold group
580                                 </option>
581                             [% END %]
582
583                             [% IF hold_fulfillment_policy == 'homebranch' %]
584                                 <option value="homebranch" selected="selected">
585                                     item's home library
586                                 </option>
587                             [% ELSE %]
588                                 <option value="homebranch">
589                                     item's home library
590                                 </option>
591                             [% END %]
592
593                             [% IF hold_fulfillment_policy == 'holdingbranch' %]
594                                 <option value="holdingbranch" selected="selected">
595                                     item's holding library
596                                 </option>
597                             [% ELSE %]
598                                 <option value="holdingbranch">
599                                     item's holding library
600                                 </option>
601                             [% END %]
602                         </select>
603                     </td>
604                     <td>
605                         <select name="returnbranch">
606                             [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch' ) %]
607
608                             <option value="">
609                                 Not set
610                             </option>
611
612                             [% IF returnbranch == 'homebranch' %]
613                             <option value="homebranch" selected="selected">
614                             [% ELSE %]
615                             <option value="homebranch">
616                             [% END %]
617                                 Item returns home
618                             </option>
619                             [% IF returnbranch == 'holdingbranch' %]
620                             <option value="holdingbranch" selected="selected">
621                             [% ELSE %]
622                             <option value="holdingbranch">
623                             [% END %]
624                                 Item returns to issuing library
625                             </option>
626                             [% IF returnbranch == 'noreturn' %]
627                             <option value="noreturn" selected="selected">
628                             [% ELSE %]
629                             <option value="noreturn">
630                             [% END %]
631                                 Item floats
632                             </option>
633                         </select>
634                     </td>
635                     <td class="actions">
636                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
637                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
638                     </td>
639                 </tr>
640             </table>
641         </form>
642     </div>
643     [% IF ( show_branch_cat_rule_form ) %]
644     <div id="holds-policy-by-patron-category" class="container">
645     <h3>[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]</h3>
646         <p>For this library, you can specify the maximum number of loans that
647             a patron of a given category can make, regardless of the item type.
648         </p>
649         <p>If the total amount loanable for a given patron category is left blank,
650            no limit applies, except possibly for a limit you define for a specific item type.
651         </p>
652         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
653             <input type="hidden" name="op" value="add-branch-cat" />
654             <input type="hidden" name="branch" value="[% current_branch | html %]"/>
655             <table>
656                 <tr>
657                     <th>Patron category</th>
658                     <th>Total current checkouts allowed</th>
659                     <th>Total current on-site checkouts allowed</th>
660                     <th>Total holds allowed</th>
661                     <th>&nbsp;</th>
662                 </tr>
663                 [% FOREACH c IN categorycodes %]
664                     [% NEXT UNLESS c %]
665                     [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
666                     [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
667                     [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
668
669                     [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
670                     <tr>
671                         <td>
672                             [% IF c == undef %]
673                                 <em>Default</em>
674                             [% ELSE %]
675                                 [% Categories.GetName(c) | html %]
676                             [% END %]
677                         </td>
678                         <td>
679                             [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
680                                 [% patron_maxissueqty | html %]
681                             [% ELSE %]
682                                 <span>Unlimited</span>
683                             [% END %]
684                         </td>
685                         <td>
686                             [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
687                                 [% patron_maxonsiteissueqty | html %]
688                             [% ELSE %]
689                                 <span>Unlimited</span>
690                             [% END %]
691                         </td>
692                         <td>
693                             [% IF max_holds.defined && max_holds != '' %]
694                                 [% max_holds | html %]
695                             [% ELSE %]
696                                 <span>Unlimited</span>
697                             [% END %]
698                         </td>
699
700                         <td class="actions">
701                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
702                         </td>
703                     </tr>
704                     [% END %]
705                 [% END %]
706                 <tr>
707                     <td>
708                         <select name="categorycode">
709                         [% FOREACH patron_category IN patron_categories%]
710                             <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option>
711                         [% END %]
712                         </select>
713                     </td>
714                     <td><input name="patron_maxissueqty" size="3" type="text" /></td>
715                     <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
716                     <td><input name="max_holds" size="3" type="text" /></td>
717                     <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
718                 </tr>
719             </table>
720         </form>
721     </div>
722     [% END %]
723
724     <div id="refund-lost-item-fee-on-return" class="container">
725         [% IF current_branch == '*' %]
726             <h3>Default lost item fee refund on return policy</h3>
727         [% ELSE %]
728             <h3>Lost item fee refund on return policy for [% Branches.GetName(current_branch) | html %]</h3>
729         [% END %]
730         <p>Specify the default policy for lost item fees on return.
731         </p>
732         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
733             <input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
734             <input type="hidden" name="branch" value="[% current_branch | html %]" />
735             <table>
736                 <tr>
737                     <th>Refund lost item fee</th>
738                     <th>&nbsp;</th>
739                 </tr>
740                 <tr>
741                     <td>
742                         <select name="refund">
743                           [%# Default branch %]
744                           [% IF ( current_branch == '*' ) %]
745                             [% IF ( defaultRefundRule ) %]
746                             <option value="1" selected="selected">
747                             [% ELSE %]
748                             <option value="1">
749                             [% END %]
750                                 Yes
751                             </option>
752                             [% IF ( not defaultRefundRule ) %]
753                             <option value="0" selected="selected">
754                             [% ELSE %]
755                             <option value="0">
756                             [% END %]
757                                 No
758                             </option>
759                           [% ELSE %]
760                           [%# Branch-specific %]
761                             [% IF ( not refundLostItemFeeRule ) %]
762                                 <option value="*" selected="selected">
763                             [% ELSE %]
764                                 <option value="*">
765                             [% END %]
766                               [% IF defaultRefundRule %]
767                                 Use default (Yes)
768                               [% ELSE %]
769                                 Use default (No)
770                               [% END %]
771                                 </option>
772                             [% IF ( not refundLostItemFeeRule ) %]
773                                 <option value="1">Yes</option>
774                                 <option value="0">No</option>
775                             [% ELSE %]
776                                 [% IF ( refundLostItemFeeRule.rule_value ) %]
777                                 <option value="1" selected="selected">
778                                 [% ELSE %]
779                                 <option value="1">
780                                 [% END %]
781                                     Yes
782                                 </option>
783                                 [% IF ( not refundLostItemFeeRule.rule_value ) %]
784                                 <option value="0" selected="selected">
785                                 [% ELSE %]
786                                 <option value="0">
787                                 [% END %]
788                                     No
789                                 </option>
790                             [% END %]
791                           [% END %]
792                         </select>
793                     </td>
794                     <td class="actions">
795                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
796                     </td>
797                     </td>
798                 </tr>
799             </table>
800         </form>
801     </div>
802
803     <div id="holds-policy-by-item-type" class="container">
804     <h3>[% IF humanbranch %]Holds policy by item type for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default holds policy by item type[% END %]</h3>
805         <p>
806             For this library, you can edit rules for given itemtypes, regardless
807             of the patron's category.
808         </p>
809         <p>
810             Currently, this means hold policies.
811             The various policies have the following effects:
812         </p>
813         <ul>
814             <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
815             <li><strong>From local hold group:</strong> Only patrons from libraries in the same item's home library hold groups may put this book on hold.</li>
816             <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
817             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
818         </ul>
819         <p><strong>Note: </strong>If the system preference 'AllowHoldPolicyOverride' is enabled, these policies can be overridden by your circulation staff.</br />
820             <strong>Important: </strong>The policies are applied based on the ReservesControlBranch system preference which is set to <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ReservesControlBranch">[% Koha.Preference('ReservesControlBranch') | html %]</a>.
821         </p>
822
823         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
824             <input type="hidden" name="op" value="add-branch-item" />
825             <input type="hidden" name="branch" value="[% current_branch | html %]"/>
826             <table>
827                 <tr>
828                     <th>Item type</th>
829                     <th>Hold policy</th>
830                     <th>Hold pickup library match</th>
831                     <th>Return policy</th>
832                     <th>&nbsp;</th>
833                 </tr>
834                 [% FOREACH i IN itemtypeloop %]
835                     [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
836                     [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
837                     [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
838
839                     [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
840                         <tr>
841                             <td>
842                                 [% i.translated_description | html %]
843                             </td>
844                             <td>
845                                 [% IF holdallowed == 2 %]
846                                     <span>From any library</span>
847                                 [% ELSIF holdallowed == 3 %]
848                                     <span>From local hold group</span>
849                                 [% ELSIF holdallowed == 1 %]
850                                     <span>From home library</span>
851                                 [% ELSE %]
852                                     <span>No holds allowed</span>
853                                 [% END %]
854                             </td>
855                             <td>
856                                 [% IF hold_fulfillment_policy == 'any' %]
857                                     <span>any library</span>
858                                 [% ELSIF hold_fulfillment_policy == 'homebranch' %]
859                                     <span>item's home library</span>
860                                 [% ELSIF hold_fulfillment_policy == 'holdgroup' %]
861                                     <span>item's hold group</span>
862                                 [% ELSIF hold_fulfillment_policy == 'patrongroup' %]
863                                     <span>patron's hold group</span>
864                                 [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
865                                     <span>item's holding library</span>
866                                 [% END %]
867                             </td>
868                             <td>
869                                 [% IF returnbranch == 'homebranch' %]
870                                     <span>Item returns home</span>
871                                 [% ELSIF returnbranch == 'holdingbranch' %]
872                                     <span>Item returns to issuing branch</span>
873                                 [% ELSIF returnbranch == 'noreturn' %]
874                                     <span>Item floats</span>
875                                 [% END %]
876                             </td>
877                             <td class="actions">
878                                 <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% i.itemtype | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
879                             </td>
880                         </tr>
881                     [% END %]
882                 [% END %]
883                 <tr>
884                     <td>
885                         <select name="itemtype">
886                         [% FOREACH itemtypeloo IN itemtypeloop %]
887                             <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
888                         [% END %]
889                         </select>
890                     </td>
891                     <td>
892                         <select name="holdallowed">
893                             <option value="2">From any library</option>
894                             <option value="3">From local hold group</option>
895                             <option value="1">From home library</option>
896                             <option value="0">No holds allowed</option>
897                         </select>
898                     </td>
899                     <td>
900                         <select name="hold_fulfillment_policy">
901                             <option value="any">
902                                 any library
903                             </option>
904
905                             <option value="holdgroup">
906                                 item's hold group
907                             </option>
908
909                             <option value="patrongroup">
910                                 patron's hold group
911                             </option>
912
913                             <option value="homebranch">
914                                 item's home library
915                             </option>
916
917                             <option value="holdingbranch">
918                                 item's holding library
919                             </option>
920                         </select>
921                     </td>
922                     <td>
923                         <select name="returnbranch">
924                             <option value="homebranch">Item returns home</option>
925                             <option value="holdingbranch">Item returns to issuing library</option>
926                             <option value="noreturn">Item floats</option>
927                         </select>
928                     </td>
929                     <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
930                 </tr>
931             </table>
932         </form>
933     </div>
934             </main>
935         </div> <!-- /.col-sm-10.col-sm-push-2 -->
936
937         <div class="col-sm-2 col-sm-pull-10">
938             <aside>
939                 [% INCLUDE 'admin-menu.inc' %]
940             </aside>
941         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
942      </div> <!-- /.row -->
943
944 [% MACRO jsinclude BLOCK %]
945     [% Asset.js("js/admin-menu.js") | $raw %]
946     [% INCLUDE 'calendar.inc' %]
947     <script>
948
949         function clear_edit(){
950             var cancel = confirm(_("Are you sure you want to cancel your changes?"));
951             if ( !cancel ) return;
952             $('#default-circulation-rules td').removeClass('highlighted-row');
953             var edit_row = $("#edit_row");
954             $(edit_row).find("input").each(function(){
955                 var type = $(this).attr("type");
956                 if (type != "button" && type != "submit" ) {
957                     $(this).val("");
958                     $(this).prop('disabled', false);
959                 }
960                 if ( type == "checkbox" ) {
961                     $(this).prop('checked', false);
962                 }
963             });
964             $(edit_row).find("select").prop('disabled', false);
965             $(edit_row).find("select option:first-child").attr("selected", "selected");
966             $(edit_row).find("td:last input[name='clear']").remove();
967         }
968
969         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
970
971         $(document).ready(function() {
972             $('[data-toggle="popover"]').popover();
973
974             $(".delete").on("click",function(){
975                 return confirmDelete(MSG_CONFIRM_DELETE);
976             });
977
978             $("#clone_rules").on("click",function(){
979                 var library_dropdown = document.getElementById("branch");
980                 var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value;
981                 var selected_library_text = $("#branch option:selected").text();
982                 var to_library = $("#tobranch option:selected").text();
983                 var MSG_CONFIRM_CLONE;
984                 if (selected_library === "*") {
985                     MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library);
986                     return confirmClone(MSG_CONFIRM_CLONE);
987                 } else {
988                     MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library);
989                     return confirmClone(MSG_CONFIRM_CLONE);
990                 }
991             });
992
993             $('#selectlibrary').find("input:submit").hide();
994             $('#branch').change(function() {
995                     $('#selectlibrary').submit();
996             });
997             $(".editrule").click(function(){
998                 if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) {
999                     var edit = confirm(_("Are you sure you want to edit another rule?"));
1000                     if (!edit) return false;
1001                 }
1002                 $('#default-circulation-rules td').removeClass('highlighted-row');
1003                 $(this).parent().parent().find("td").each(function (i) {
1004                     $(this).addClass('highlighted-row');
1005                     itm = $(this).text();
1006                     itm = itm.replace(/^\s*|\s*$/g,'');
1007                     var current_column = $("#edit_row td:eq("+i+")");
1008                     if ( i == 3 ) {
1009                         // specific processing for the Note column
1010                         var note = $(this).find("a[name='viewnote']").data("content");
1011                         $(current_column).find("input[type='text']").val(note);
1012                     } else if ( i == 9 ) {
1013                         // specific processing for the Hard due date column
1014                         var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
1015                         var input_value = '';
1016                         if (typeof select_value === 'undefined'){
1017                             select_value = '-1';
1018                         }else {
1019                             input_value = itm.split(' ')[1];
1020                         }
1021                         $(current_column).find("input[type='text']").val(input_value);
1022                         $(current_column).find("select").val(select_value);
1023                     } else if ( i == 15 ) {
1024                         // specific processing for cap_fine_to_replacement_price
1025                         var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1026                         $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
1027                         $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
1028                     } else {
1029                         $(current_column).find("input[type='text']").val(itm);
1030                         // select the corresponding option
1031                         $(current_column).find("select option").each(function(){
1032                             opt = $(this).text().toLowerCase();
1033                             opt = opt.replace(/^\s*|\s*$/g,'');
1034                             if ( opt == itm.toLowerCase() ) {
1035                                 $(this).attr('selected', 'selected');
1036                             }
1037                         });
1038                         if ( i == 0 || i == 1 ) {
1039                             // Disable the 2 first columns, we cannot update them.
1040                             var val = $(current_column).find("select option:selected").val();
1041                             var name = "categorycode";
1042                             if ( i == 1 ) {
1043                                 name="itemtype";
1044                             }
1045                             // Remove potential previous input added
1046                             $(current_column).find("input").remove();
1047                             $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1048                         } else if ( i == 5 || i == 6 || i == 25 || i == 26 || i == 27 ) {
1049                             // If the value is not an integer for
1050                             //     - "Current checkouts allowed"
1051                             //     - "Current on-site checkouts allowed"
1052                             //     - "Holds allowed (total)"
1053                             //     - "Holds allowed (daily)"
1054                             //     - "Holds per record (count)"
1055                             // The value is "Unlimited" (or an equivalent translated string)
1056                             // an it should be set to an empty string
1057                             if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
1058                                 $(current_column).find("input[type='text']").val("");
1059                             }
1060                         }
1061                     }
1062                 });
1063                 $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1064                 $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1065                 return false;
1066             });
1067             $(".clear_edit").on("click",function(e){
1068                 e.preventDefault();
1069                 clear_edit();
1070             });
1071         });
1072     </script>
1073 [% END %]
1074 [% INCLUDE 'intranet-bottom.inc' %]