YAOUS to limit OPAC payment history display to configured interval
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 25 Jul 2011 20:21:48 +0000 (16:21 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 25 Jul 2011 20:21:48 +0000 (16:21 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.opac_payment_history_age_limit.sql [new file with mode: 0644]

index a715ab3..213965d 100644 (file)
@@ -797,6 +797,17 @@ sub load_myopac_payments {
     $args->{limit} = $limit if $limit;
     $args->{offset} = $offset if $offset;
 
+    if (my $max_age = $self->ctx->{get_org_setting}->(
+        $e->requestor->home_ou, "opac.payment_history_age_limit"
+    )) {
+        my $min_ts = DateTime->now(
+            "time_zone" => DateTime::TimeZone->new("name" => "local"),
+        )->subtract("seconds" => interval_to_seconds($max_age))->iso8601();
+        
+        $logger->info("XXX min_ts: $min_ts");
+        $args->{"where"} = {"payment_ts" => {">=" => $min_ts}};
+    }
+
     $self->ctx->{payments} = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.user.payments.retrieve.atomic',
index 9cf3bbc..61197f7 100644 (file)
@@ -2750,7 +2750,12 @@ INSERT into config.org_unit_setting_type
 ( 'org.patron_opt_default',
     oils_i18n_gettext( 'org.patron_opt_default', 'Circ: Patron Opt-In Default', 'coust', 'label'),
     oils_i18n_gettext( 'org.patron_opt_default', 'This is the default depth at which a patron is opted in; it is calculated as an org unit relative to the current workstation.', 'coust', 'label'),
-    'integer')
+    'integer'),
+
+( 'opac.payment_history_age_limit',
+    oils_i18n_gettext( 'opac.payment_history_age_limit', 'OPAC: Payment History Age Limit', 'coust', 'label'),
+    oils_i18n_gettext( 'opac.payment_history_age_limit', 'The OPAC should not display payments by patrons that are older than any interval defined here.', 'coust', 'label'),
+    'interval')
 
 ;
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.opac_payment_history_age_limit.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.opac_payment_history_age_limit.sql
new file mode 100644 (file)
index 0000000..f8790ef
--- /dev/null
@@ -0,0 +1,17 @@
+-- Evergreen DB patch XXXX.data.opac_payment_history_age_limit.sql
+
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type (name, label, description, datatype)
+VALUES (
+    'opac.payment_history_age_limit',
+    oils_i18n_gettext('opac.payment_history_age_limit',
+        'OPAC: Payment History Age Limit', 'coust', 'label'),
+    oils_i18n_gettext('opac.payment_history_age_limit',
+        'The OPAC should not display payments by patrons that are older than any interval defined here.', 'coust', 'label'),
+    'interval'
+);
+
+COMMIT;