LP#1234220 Improve hold/copy ratio renewal messages
authorBill Erickson <berickxx@gmail.com>
Fri, 6 Mar 2015 16:04:01 +0000 (11:04 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 13 Mar 2015 21:20:16 +0000 (17:20 -0400)
Display friendlier messages in the TPAC and staff client client when a
hold/copy ratio rule prevents a renewal.

This creates top-level ILS events for total/avail hold copy ratios,
since that's what best works with the staff client.  The TPAC displays a
simple "item is needed for a hold" message, whereas the staff client
displays the raw event description, which is slightly more descriptive.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/templates/opac/myopac/circs.tt2
Open-ILS/src/templates/opac/parts/hold_error_messages.tt2
Open-ILS/xul/staff_client/server/circ/util.js

index 63385f3..cb860d4 100644 (file)
             for the selected transaction</desc>
     </event>
 
+    <event code='11106' textcode='TOTAL_HOLD_COPY_RATIO_EXCEEDED'>
+        <desc xml:lang="en-US">Renewal attempt failed because the "hold / total copies" ratio exceeds the configured limit</desc>
+    </event>
+
+    <event code='11107' textcode='AVAIL_HOLD_COPY_RATIO_EXCEEDED'>
+        <desc xml:lang="en-US">Renewal attempt failed because the "hold / available copies" ratio exceeds the configured limit</desc>
+    </event>
 
 </ils_events>
 
index 0aaa2c7..7a330b2 100644 (file)
@@ -1076,6 +1076,10 @@ my $LEGACY_CIRC_EVENT_MAP = {
     'config.circ_matrix_test.max_overdue' =>  'PATRON_EXCEEDS_OVERDUE_COUNT',
     'config.circ_matrix_test.max_fines' => 'PATRON_EXCEEDS_FINES',
     'config.circ_matrix_circ_mod_test' => 'PATRON_EXCEEDS_CHECKOUT_COUNT',
+    'config.circ_matrix_test.total_copy_hold_ratio' => 
+        'TOTAL_HOLD_COPY_RATIO_EXCEEDED',
+    'config.circ_matrix_test.available_copy_hold_ratio' => 
+        'AVAIL_HOLD_COPY_RATIO_EXCEEDED'
 };
 
 
index 4cd89ab..6ca68a1 100644 (file)
                     <tr>
                         <td colspan="6">[%# XXX colspan="0" does not work in IE %]
                             <span class="failure-text" title="[% circ.renewal_response.textcode | html %] / [% circ.renewal_response.payload.fail_part | html %]">
-                                [% (circ.renewal_response.desc || circ.renewal_response.payload.fail_part || circ.renewal_response.textcode) | html %]
+                                [%
+                                    renew_fail_msg = '';
+                                    IF circ.renewal_response.textcode == 'TOTAL_HOLD_COPY_RATIO_EXCEEDED' OR
+                                        circ.renewal_response.textcode == 'AVAIL_HOLD_COPY_RATIO_EXCEEDED';
+                                        # the stock hold ratio message may not be patron friendly
+                                        renew_fail_msg = l('Item is needed for a hold');
+                                    ELSE;
+                                        renew_fail_msg = circ.renewal_response.desc || 
+                                            circ.renewal_response.payload.fail_part || 
+                                            circ.renewal_response.textcode;
+                                    END;
+                                    renew_fail_msg | html;
+                                %]
                             </span>
                         </td>
                     </tr>
index 50a0ebf..407ea52 100644 (file)
@@ -14,9 +14,7 @@
         "asset.copy.status" => l("The item cannot circulate at this time"),
         "circ.holds.target_skip_me" => l("The item's circulation library does not fulfill holds"),
         "config.circ_matrix_circ_mod_test" => l("The patron has too many items of this type checked out"),
-        "config.circ_matrix_test.available_copy_hold_ratio" => l("The available item-to-hold ratio is too low"),
         "config.circ_matrix_test.circulate" => l("Circulation rules reject this item as non-circulatable"),
-        "config.circ_matrix_test.total_copy_hold_ratio" => l("The total item-to-hold ratio is too low"),
         "config.hold_matrix_test.holdable" => l("Hold rules reject this item as unholdable"),
         "config.hold_matrix_test.max_holds" => l("The patron has reached the maximum number of holds"),
         "config.rule_age_hold_protect.prox" => l("The item is too new to transit this far"),
index 1331e19..aa497d4 100644 (file)
@@ -3694,6 +3694,8 @@ circ.util.renew_via_barcode = function ( params, async ) {
                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
+                        case 11106 /* TOTAL_HOLD_COPY_RATIO_EXCEEDED */ : break;
+                        case 11107 /* AVAIL_HOLD_COPY_RATIO_EXCEEDED */ : break;
                         default:
                             throw(renew);
                         break;
@@ -3773,6 +3775,8 @@ circ.util.renew_via_barcode = function ( params, async ) {
                     7009 /* CIRC_CLAIMS_RETURNED */,
                     7010 /* COPY_ALERT_MESSAGE */,
                     7013 /* PATRON_EXCEEDS_FINES */,
+                    11106 /* TOTAL_HOLD_COPY_RATIO_EXCEEDED */,
+                    11107 /* AVAIL_HOLD_COPY_RATIO_EXCEEDED */
                 ],
                 'text' : {
                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },