summaryrefslogtreecommitdiff
path: root/FS/FS/msg_template.pm
diff options
context:
space:
mode:
authormark <mark>2011-09-01 05:13:09 +0000
committermark <mark>2011-09-01 05:13:09 +0000
commit53ea5a72067a9b0ebcd3417692c3884d6f91f74a (patch)
tree1fcf7144305e5ab821ab9d0f04ebfd91a88a91cb /FS/FS/msg_template.pm
parent81d973916db8389df760f4055b3eb3825b3ed262 (diff)
svc_acct events for usage limits, #13202
Diffstat (limited to 'FS/FS/msg_template.pm')
-rw-r--r--FS/FS/msg_template.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index c183477fb..d980ab9e2 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -430,6 +430,20 @@ sub send {
# helper sub for package dates
my $ymd = sub { $_[0] ? time2str('%Y-%m-%d', $_[0]) : '' };
+# helper sub for usage-related messages
+my $usage_warning = sub {
+ my $svc = shift;
+ foreach my $col (qw(seconds upbytes downbytes totalbytes)) {
+ my $amount = $svc->$col; next if $amount eq '';
+ my $method = $col.'_threshold';
+ my $threshold = $svc->$method; next if $threshold eq '';
+ return [$col, $amount, $threshold] if $amount <= $threshold;
+ # this only returns the first one that's below threshold, if there are
+ # several.
+ }
+ return ['', '', ''];
+};
+
#my $conf = new FS::Conf;
#return contexts and fill-in values
@@ -514,6 +528,9 @@ sub substitutions {
domain
),
[ password => sub { shift->getfield('_password') } ],
+ [ column => sub { &$usage_warning(shift)->[0] } ],
+ [ amount => sub { &$usage_warning(shift)->[1] } ],
+ [ threshold => sub { &$usage_warning(shift)->[2] } ],
],
'svc_domain' => [qw(
svcnum