Add library setting to control pre-expire warning for patrons
authorBen Shum <bshum@biblio.org>
Wed, 14 Nov 2012 18:30:11 +0000 (13:30 -0500)
committerBen Shum <bshum@biblio.org>
Wed, 21 Nov 2012 15:03:54 +0000 (10:03 -0500)
Thanks to some more inspiration by Thomas Berezansky, this change adds a
library setting to control when the pre-expire warning will be displayed.

Signed-off-by: Ben Shum <bshum@biblio.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.prewarn_expire_setting.sql [new file with mode: 0644]
Open-ILS/xul/staff_client/server/patron/display.js

index 394e7bc..fe719f0 100644 (file)
@@ -11859,3 +11859,23 @@ INSERT INTO config.org_unit_setting_type
         ),
         'bool'
     );
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'circ.prewarn_expire_setting',
+        'circ',
+        oils_i18n_gettext(
+            'circ.prewarn_expire_setting',
+            'Pre-warning for patron expiration',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.prewarn_expire_setting',
+            'Pre-warning for patron expiration. This setting defines the number of days before patron expiration to display a message suggesting it is time to renew the patron account. Value is in number of days, for example: 3 for 3 days.',
+            'coust',
+            'description'
+        ),
+        'integer'
+    );
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.prewarn_expire_setting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.prewarn_expire_setting.sql
new file mode 100644 (file)
index 0000000..151761b
--- /dev/null
@@ -0,0 +1,25 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'circ.prewarn_expire_setting',
+        'circ',
+        oils_i18n_gettext(
+            'circ.prewarn_expire_setting',
+            'Pre-warning for patron expiration',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'circ.prewarn_expire_setting',
+            'Pre-warning for patron expiration. This setting defines the number of days before patron expiration to display a message suggesting it is time to renew the patron account. Value is in number of days, for example: 3 for 3 days.',
+            'coust',
+            'description'
+        ),
+        'integer'
+    );
+
+COMMIT;
index 393fa32..d68d6a2 100644 (file)
@@ -973,9 +973,6 @@ patron.display.prototype = {
                 if (patron.expire_date()) {
                     var now = new Date();
                     now = now.getTime()/1000;
-                     var preexpire = new Date();
-                     preexpire.setDate(preexpire.getDate() + 28);
-                     preexpire = preexpire.getTime()/1000;
 
                     var expire_parts = patron.expire_date().substr(0,10).split('-');
                     expire_parts[1] = expire_parts[1] - 1;
@@ -984,11 +981,23 @@ patron.display.prototype = {
                     expire.setFullYear(expire_parts[0], expire_parts[1], expire_parts[2]);
                     expire = expire.getTime()/1000
 
+                    var preexpire = new Date();
+                    var preexpire_value;
+                    if (obj.OpenILS.data.hash.aous['circ.prewarn_expire_setting']) {
+                        if (typeof obj.OpenILS.data.hash.aous['circ.prewarn_expire_setting'] == "string") { 
+                            preexpire_value = parseInt(obj.OpenILS.data.hash.aous['circ.prewarn_expire_setting']);  
+                        } else {
+                            preexpire_value = obj.OpenILS.data.hash.aous['circ.prewarn_expire_setting'];
+                        }
+                        preexpire.setDate(preexpire.getDate() + preexpire_value);
+                    }
+                    preexpire = preexpire.getTime()/1000;
+
                     if (expire < now) {
                         msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_expired');
                         obj.stop_checkouts = true;
-                    } else if (expire < preexpire) {
-                         msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_expire_soon');   
+                    } else if (expire < preexpire && obj.OpenILS.data.hash.aous['circ.prewarn_expire_setting']) {
+                        msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_expire_soon');
                     }
                 }
                 var penalties = patron.standing_penalties();