Bug 18930: Move lost item refund rules to circulation_rules table
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / smart-rules.tt
index fa3c75c..17ee8ce 100644 (file)
@@ -1,8 +1,18 @@
 [% USE raw %]
 [% USE Asset %]
+[% USE Koha %]
 [% USE Branches %]
+[% USE Categories %]
 [% USE CirculationRules %]
 [% SET footerjs = 1 %]
+
+[% SET branchcode = humanbranch %]
+
+[% SET categorycodes = ['*'] %]
+[% FOREACH pc IN patron_categories %]
+    [% categorycodes.push( pc.id ) %]
+[% END %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
 [% INCLUDE 'doc-head-close.inc' %]
         <p>To modify a rule, create a new one with the same patron category and item type.</p>
     </div>
     <div>
-        <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
-        Select a library :
-            <select name="branch" id="branch" style="width:20em;">
-                <option value="*">Standard rules for all libraries</option>
-                [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
-            </select>
-        </form>
-        [% IF ( definedbranch ) %]
-            <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
-                <label for="tobranch"><strong>Clone these rules to:</strong></label>
-                <input type="hidden" name="frombranch" value="[% current_branch | html %]" />
-                <select name="tobranch" id="tobranch">
-                    [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
+        [% UNLESS restricted_to_own_library %]
+            <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
+            Select a library :
+                <select name="branch" id="branch" style="width:20em;">
+                    <option value="*">Standard rules for all libraries</option>
+                    [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
                 </select>
-                <input type="submit" id="clone_rules" value="Clone" />
             </form>
+            [% IF ( definedbranch ) %]
+                <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
+                    <label for="tobranch"><strong>Clone these rules to:</strong></label>
+                    <input type="hidden" name="frombranch" value="[% current_branch | html %]" />
+                    <select name="tobranch" id="tobranch">
+                        [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
+                    </select>
+                    <input type="submit" id="clone_rules" value="Clone" />
+                </form>
+            [% END %]
         [% END %]
 
         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
@@ -68,6 +80,7 @@
                 <th>Patron category</th>
                 <th>Item type</th>
                 <th>Actions</th>
+                <th>Note</th>
                 <th>Current checkouts allowed</th>
                 <th>Current on-site checkouts allowed</th>
                 <th>Loan period</th>
                 <th>Automatic renewal</th>
                 <th>No automatic renewal after</th>
                 <th>No automatic renewal after (hard limit)</th>
-                <th>Holds allowed (count)</th>
+                <th>Holds allowed (total)</th>
+                <th>Holds allowed (daily)</th>
                 <th>Holds per record (count)</th>
                 <th>On shelf holds allowed</th>
                 <th>Item level holds</th>
                                                           <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype | html %]&amp;categorycode=[% rule.categorycode | html %]&amp;branch=[% rule.current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
                                                         </td>
 
-                                                       <td>[% IF ( rule.unlimited_maxissueqty ) %]
-                                                                       <span>Unlimited</span>
-                                                               [% ELSE %]
-                                                                       [% rule.maxissueqty | html %]
-                                                               [% END %]
-                                                       </td>
-                            <td>[% IF rule.unlimited_maxonsiteissueqty %]
+                                                        <td>
+                                                            [% IF rule.note %]
+                                                                <a name="viewnote" data-toggle="popover" title="Note" data-content="[% rule.note | html %]" data-placement="top" data-trigger="hover">View note</a>
+                                                            [% ELSE %]&nbsp;[% END %]
+                                                        </td>
+                            <td>
+                                [% SET rule_value = CirculationRules.Get( rule.branchcode, rule.categorycode, rule.itemtype, 'maxissueqty' ) %]
+                                [% IF rule_value || rule_value == "0"  %]
+                                    [% rule_value | html %]
+                                [% ELSE %]
                                     <span>Unlimited</span>
+                                [% END %]
+                            </td>
+                            <td>
+                                [% SET rule_value = CirculationRules.Get( rule.branchcode, rule.categorycode, rule.itemtype, 'maxonsiteissueqty' ) %]
+                                [% IF rule_value || rule_value == "0" %]
+                                    [% rule_value | html %]
                                 [% ELSE %]
-                                    [% rule.maxonsiteissueqty | html %]
+                                    <span>Unlimited</span>
                                 [% END %]
                             </td>
-                                                       <td>[% rule.issuelength | html %]</td>
-                                                       <td>
-                                                           [% rule.lengthunit | html %]
-                                                       </td>
+                            <td>[% rule.issuelength | html %]</td>
+                            <td>
+                                [% rule.lengthunit | html %]
+                            </td>
                             <td>
                               [% IF ( rule.hardduedate ) %]
                                 [% IF ( rule.hardduedatebefore ) %]
                             <td>[% rule.no_auto_renewal_after | html %]</td>
                             <td>[% rule.no_auto_renewal_after_hard_limit | html %]</td>
                                                        <td>[% rule.reservesallowed | html %]</td>
-                                                        <td>[% rule.holds_per_record | html %]</td>
+                            <td>[% IF rule.unlimited_holds_per_day %]
+                                    <span>Unlimited</span>
+                                [% ELSE %]
+                                    [% rule.holds_per_day | html %]
+                                [% END %]
+                            </td>
+                            <td>[% rule.holds_per_record | html %]</td>
                                                         <td>
                                                             [% IF rule.onshelfholds == 1 %]
                                                                 <span>Yes</span>
                                                                 <span>Item only</span>
                                                             [% END %]
                                                         </td>
-                                                       <td>[% rule.rentaldiscount | html %]</td>
+                                                        <td>[% rule.rentaldiscount | html %]</td>
                                                         <td class="actions">
                                                           <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
                                                           <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype | html %]&amp;categorycode=[% rule.categorycode | html %]&amp;branch=[% rule.current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
                         <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
                         <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
                     </td>
+                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
                     <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
                     <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
                     <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
                         <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"/>
                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                     </td>
-                    <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
+                    <td><input type="text" name="reservesallowed"  id="reservesallowed"  size="2" /></td>
+                    <td><input type="text" name="holds_per_day"    id="holds_per_day"    size="2" /></td>
                     <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
                     <td>
                         <select name="onshelfholds" id="onshelfholds">
                       <th>Patron category</th>
                       <th>Item type</th>
                       <th>&nbsp;</th>
+                      <th>Note</th>
                       <th>Current checkouts allowed</th>
                       <th>Current on-site checkouts allowed</th>
                       <th>Loan period</th>
                       <th>No renewal before</th>
                       <th>Automatic renewal</th>
                       <th>No automatic renewal after</th>
-                       <th>No automatic renewal after (hard limit)</th>
-                      <th>Holds allowed (count)</th>
+                      <th>No automatic renewal after (hard limit)</th>
+                      <th>Holds allowed (total)</th>
+                      <th>Holds allowed (daily)</th>
                       <th>Holds per record (count)</th>
                       <th>On shelf holds allowed</th>
                       <th>Item level holds</th>
                     <th>Actions</th>
                 </tr>
                 <tr>
-                    <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
-                    <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty | html %]"/></td>
-                    <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty | html %]"/></td>
+                    <td><em>Defaults</em></td>
+                    <td>
+                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
+                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
+                    </td>
                     <td>
-                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
+                        [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
+                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
+                    </td>
+                    <td>
+                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
                         <input name="max_holds" size="3" value="[% rule_value | html %]" />
                     </td>
                     <td>
                         <select name="holdallowed">
-                            [% IF ( default_holdallowed_any ) %]
-                            <option value="2" selected="selected">
+                            [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed' ) %]
+                            <option value="">
+                                Not set
+                            </option>
+
+                            [% IF holdallowed == 2 %]
+                                <option value="2" selected="selected">
                             [% ELSE %]
-                            <option value="2">
+                                <option value="2">
                             [% END %]
                                 From any library
                             </option>
-                            [% IF ( default_holdallowed_same ) %]
-                            <option value="1" selected="selected">
+
+                            [% IF holdallowed == 1 %]
+                                <option value="1" selected="selected">
                             [% ELSE %]
-                            <option value="1">
+                                <option value="1">
                             [% END %]
                                 From home library
                             </option>
-                            [% IF ( default_holdallowed_none ) %]
-                            <option value="0" selected="selected">
+
+                            [% IF holdallowed == 0 %]
+                                <option value="0" selected="selected">
                             [% ELSE %]
-                            <option value="0">
+                                <option value="0">
                             [% END %]
                                 No holds allowed
                             </option>
                     </td>
                     <td>
                         <select name="hold_fulfillment_policy">
-                            [% IF default_hold_fulfillment_policy == 'any' %]
+                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy' ) %]
+
+                            <option value="">
+                                Not set
+                            </option>
+
+                            [% IF hold_fulfillment_policy == 'any' %]
                                 <option value="any" selected="selected">
                                     any library
                                 </option>
                                 </option>
                             [% END %]
 
-                            [% IF default_hold_fulfillment_policy == 'homebranch' %]
+                            [% IF hold_fulfillment_policy == 'homebranch' %]
                                 <option value="homebranch" selected="selected">
                                     item's home library
                                 </option>
                                 </option>
                             [% END %]
 
-                            [% IF default_hold_fulfillment_policy == 'holdingbranch' %]
+                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
                                 <option value="holdingbranch" selected="selected">
                                     item's holding library
                                 </option>
                     </td>
                     <td>
                         <select name="returnbranch">
-                            [% IF ( default_returnbranch == 'homebranch' ) %]
+                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch' ) %]
+
+                            <option value="">
+                                Not set
+                            </option>
+
+                            [% IF returnbranch == 'homebranch' %]
                             <option value="homebranch" selected="selected">
                             [% ELSE %]
                             <option value="homebranch">
                             [% END %]
                                 Item returns home
                             </option>
-                            [% IF ( default_returnbranch == 'holdingbranch' ) %]
+                            [% IF returnbranch == 'holdingbranch' %]
                             <option value="holdingbranch" selected="selected">
                             [% ELSE %]
                             <option value="holdingbranch">
                             [% END %]
                                 Item returns to issuing library
                             </option>
-                            [% IF ( default_returnbranch == 'noreturn' ) %]
+                            [% IF returnbranch == 'noreturn' %]
                             <option value="noreturn" selected="selected">
                             [% ELSE %]
                             <option value="noreturn">
                     <th>Total holds allowed</th>
                     <th>&nbsp;</th>
                 </tr>
-                [% FOREACH branch_cat_rule_loo IN branch_cat_rule_loop %]
-                    [% UNLESS ( loop.odd ) %]
-                    <tr class="highlight">
-                    [% ELSE %]
+                [% FOREACH c IN categorycodes %]
+                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
+                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
+                    [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
+
+                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
                     <tr>
-                    [% END %]
-                        <td>[% IF ( branch_cat_rule_loo.default_humancategorycode ) %]
+                        <td>
+                            [% IF c == '*'%]
                                 <em>Default</em>
                             [% ELSE %]
-                                [% branch_cat_rule_loo.humancategorycode | html %]
+                                [% Categories.GetName(c) | html %]
                             [% END %]
                         </td>
-                        <td>[% IF ( branch_cat_rule_loo.unlimited_maxissueqty ) %]
-                                <span>Unlimited</span>
+                        <td>
+                            [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
+                                [% patron_maxissueqty | html %]
                             [% ELSE %]
-                                [% branch_cat_rule_loo.maxissueqty | html %]
+                                <span>Unlimited</span>
                             [% END %]
                         </td>
-                        <td>[% IF ( branch_cat_rule_loo.unlimited_maxonsiteissueqty ) %]
-                                <span>Unlimited</span>
+                        <td>
+                            [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
+                                [% patron_maxonsiteissueqty | html %]
                             [% ELSE %]
-                                [% branch_cat_rule_loo.maxonsiteissueqty | html %]
+                                <span>Unlimited</span>
                             [% END %]
                         </td>
                         <td>
-                            [% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode || '*', branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %]
-                            [% IF rule_value.defined && rule_value != '' %]
-                                [% rule_value | html %]
+                            [% IF max_holds.defined && max_holds != '' %]
+                                [% max_holds | html %]
                             [% ELSE %]
-                                Unlimited
+                                <span>Unlimited</span>
                             [% END %]
                         </td>
 
                         <td class="actions">
-                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% branch_cat_rule_loo.categorycode | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
+                            <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>
                         </td>
                     </tr>
+                    [% END %]
                 [% END %]
                 <tr>
                     <td>
                         [% END %]
                         </select>
                     </td>
-                    <td><input name="maxissueqty" size="3" type="text" /></td>
-                    <td><input name="maxonsiteissueqty" size="3" type="text" /></td>
+                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
+                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
                     <td><input name="max_holds" size="3" type="text" /></td>
                     <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
                 </tr>
                         <select name="refund">
                           [#% Default branch %#]
                           [% IF ( current_branch == '*' ) %]
-                            [% IF ( refundLostItemFeeRule.refund ) %]
+                            [% IF ( refundLostItemFeeRule.rule_value ) %]
                             <option value="1" selected="selected">
                             [% ELSE %]
                             <option value="1">
                             [% END %]
                                 Yes
                             </option>
-                            [% IF ( not refundLostItemFeeRule.refund ) %]
+                            [% IF ( not refundLostItemFeeRule.rule_value ) %]
                             <option value="0" selected="selected">
                             [% ELSE %]
                             <option value="0">
                                 <option value="1">Yes</option>
                                 <option value="0">No</option>
                             [% ELSE %]
-                                [% IF ( refundLostItemFeeRule.refund ) %]
+                                [% IF ( refundLostItemFeeRule.rule_value ) %]
                                 <option value="1" selected="selected">
                                 [% ELSE %]
                                 <option value="1">
                                 [% END %]
                                     Yes
                                 </option>
-                                [% IF ( not refundLostItemFeeRule.refund ) %]
+                                [% IF ( not refundLostItemFeeRule.rule_value ) %]
                                 <option value="0" selected="selected">
                                 [% ELSE %]
                                 <option value="0">
             <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
         </ul>
         <p><strong>Note: </strong>If the system preference 'AllowHoldPolicyOverride' is enabled, these policies can be overridden by your circulation staff.</br />
-            <strong>Important: </strong>The policies are based on the patron's home library, not the library where the hold is being placed.
+            <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>.
         </p>
 
         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
                     <th>Return policy</th>
                     <th>&nbsp;</th>
                 </tr>
-                [% FOREACH branch_item_rule_loo IN branch_item_rule_loop %]
-                    [% UNLESS ( loop.odd ) %]
-                    <tr class="highlight">
-                    [% ELSE %]
-                    <tr>
+                [% FOREACH i IN itemtypeloop %]
+                    [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
+                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
+                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
+
+                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
+                        <tr>
+                            <td>
+                                [% i.translated_description | html %]
+                            </td>
+                            <td>
+                                [% IF holdallowed == 2 %]
+                                    <span>From any library</span>
+                                [% ELSIF holdallowed == 1 %]
+                                    <span>From home library</span>
+                                [% ELSE %]
+                                    <span>No holds allowed</span>
+                                [% END %]
+                            </td>
+                            <td>
+                                [% IF hold_fulfillment_policy == 'any' %]
+                                    <span>any library</span>
+                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
+                                    <span>item's home library</span>
+                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
+                                    <span>item's holding library</span>
+                                [% END %]
+                            </td>
+                            <td>
+                                [% IF returnbranch == 'homebranch' %]
+                                    <span>Item returns home</span>
+                                [% ELSIF returnbranch == 'holdingbranch' %]
+                                    <span>Item returns to issuing branch</span>
+                                [% ELSIF returnbranch == 'noreturn' %]
+                                    <span>Item floats</span>
+                                [% END %]
+                            </td>
+                            <td class="actions">
+                                <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>
+                            </td>
+                        </tr>
                     [% END %]
-                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
-                                <em>Default</em>
-                            [% ELSE %]
-                                [% branch_item_rule_loo.translated_description | html %]
-                            [% END %]
-                        </td>
-                        <td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
-                                <span>From any library</span>
-                            [% ELSIF ( branch_item_rule_loo.holdallowed_same ) %]
-                                <span>From home library</span>
-                            [% ELSE %]
-                                <span>No holds allowed</span>
-                            [% END %]
-                        </td>
-                        <td>[% IF ( branch_item_rule_loo.hold_fulfillment_policy == 'any' ) %]
-                                <span>any library</span>
-                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'homebranch' ) %]
-                                <span>item's home library</span>
-                            [% ELSIF ( branch_item_rule_loo.hold_fulfillment_policy == 'holdingbranch' ) %]
-                                <span>item's holding library</span>
-                            [% END %]
-                        </td>
-                        <td>[% IF ( branch_item_rule_loo.returnbranch == 'homebranch' ) %]
-                                <span>Item returns home</span>
-                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'holdingbranch' ) %]
-                                <span>Item returns to issuing branch</span>
-                            [% ELSIF ( branch_item_rule_loo.returnbranch == 'noreturn' ) %]
-                                <span>Item floats</span>
-                            [% ELSE %]
-                                <span>Error - unknown option</span>
-                            [% END %]
-                        </td>
-                        <td class="actions">
-                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% branch_item_rule_loo.itemtype | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
-                        </td>
-                    </tr>
                 [% END %]
                 <tr>
                     <td>
         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
 
         $(document).ready(function() {
+            $('[data-toggle="popover"]').popover();
+
             $(".delete").on("click",function(){
                 return confirmDelete(MSG_CONFIRM_DELETE);
             });
                 }
             });
 
-            $('#cap_fine_to_replacement_price').on('change', function(){
-                $('#overduefinescap').prop('disabled', $(this).is(':checked') );
-            });
             $('#selectlibrary').find("input:submit").hide();
             $('#branch').change(function() {
                     $('#selectlibrary').submit();
                     itm = $(this).text();
                     itm = itm.replace(/^\s*|\s*$/g,'');
                     var current_column = $("#edit_row td:eq("+i+")");
-                    if ( i == 7 ) {
+                    if ( i == 3 ) {
+                        // specific processing for the Note column
+                        var note = $(this).find("a[name='viewnote']").data("content");
+                        $(current_column).find("input[type='text']").val(note);
+                    } else if ( i == 8 ) {
                         // specific processing for the Hard due date column
                         var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
                         var input_value = '';
                         }
                         $(current_column).find("input[type='text']").val(input_value);
                         $(current_column).find("select").val(select_value);
-                    } else if ( i == 13 ) {
+                    } else if ( i == 14 ) {
                         // specific processing for cap_fine_to_replacement_price
                         var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
                         $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
                             // Remove potential previous input added
                             $(current_column).find("input").remove();
                             $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
-                        } else if ( i == 3 || i == 4 ) {
-                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
+                        } else if ( i == 4 || i == 5 || i == 25 ) {
+                            // If the value is not an integer for
+                            //     - "Current checkouts allowed"
+                            //     - "Current on-site checkouts allowed"
+                            //     - "Holds allowed (daily)"
                             // The value is "Unlimited" (or an equivalent translated string)
                             // an it should be set to an empty string
                             if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {