summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorivan <ivan>2005-09-21 12:49:51 +0000
committerivan <ivan>2005-09-21 12:49:51 +0000
commit0186436eb38e70da0a015e49dab67cec5f1a3467 (patch)
tree635b3cb85f45ebff70c30fe1ff725a55b3698997 /FS/bin
parent6c6b3fe527d046ec3ca83ba1fa67ee414f702bca (diff)
add prepaid support which sets RADIUS Expiration attribute, update customer view package UI
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-daily13
-rw-r--r--FS/bin/freeside-prepaidd75
2 files changed, 88 insertions, 0 deletions
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index 589af8998..603da12b8 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -89,6 +89,19 @@ foreach $cust_main ( @cust_main ) {
$cust_main->custnum. ": $error"
if $error;
}
+ # $^T not $time because -d is for pre-printing invoices
+ foreach my $cust_pkg (
+ grep { $_->part_pkg->is_prepaid
+ && $_->bill && $_->bill < $^T && ! $_->susp
+ }
+ $cust_main->ncancelled_pkgs
+ ) {
+ my $error = $cust_pkg->suspend;
+ warn "Error suspending package ". $cust_pkg->pkgnum.
+ " for custnum ". $cust_main->custnum.
+ ": $error"
+ if $error;
+ }
my $error = $cust_main->bill( 'time' => $time,
'resetup' => $opt_s, );
diff --git a/FS/bin/freeside-prepaidd b/FS/bin/freeside-prepaidd
new file mode 100644
index 000000000..e51a56350
--- /dev/null
+++ b/FS/bin/freeside-prepaidd
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -w
+
+use strict;
+use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch); # qsearchs);
+use FS::cust_pkg;
+
+my $user = shift or die &usage;
+
+#daemonize1('freeside-sprepaidd', $user); #keep unique pid files w/multi installs
+daemonize1('freeside-prepaidd');
+
+drop_root();
+
+adminsuidsetup($user);
+
+logfile( "/usr/local/etc/freeside/prepaidd-log.". $FS::UID::datasrc );
+
+daemonize2();
+
+#--
+
+while (1) {
+
+ foreach my $cust_pkg (
+ qsearch( {
+ 'select' => 'cust_pkg.*, part_pkg.plan',
+ 'table' => 'cust_pkg',
+ 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )',
+ #'hashref' => { 'plan' => 'prepaid' },#should check part_pkg::is_prepaid
+ #'extra_sql' => "AND bill < ". time.
+ 'hashref' => {},
+ 'extra_sql' => "WHERE plan = 'prepaid' AND bill < ". time.
+ " AND bill IS NOT NULL".
+ " AND ( susp IS NULL OR susp = 0)".
+ " AND ( cancel IS NULL OR cancel = 0)"
+ } )
+ ) {
+ my $error = $cust_pkg->suspend;
+ warn "Error suspended package ". $cust_pkg->pkgnum.
+ " for custnum ". $cust_pkg->custnum.
+ ": $error\n"
+ if $error;
+ }
+
+ die "exiting" if sigterm() || sigint();
+ sleep 5;
+
+}
+
+#--
+
+sub usage {
+ die "Usage:\n\n freeside-prepaidd user\n";
+}
+
+=head1 NAME
+
+freeside-prepaidd - Real-time daemon for prepaid packages
+
+=head1 SYNOPSIS
+
+ freeside-prepaidd
+
+=head1 DESCRIPTION
+
+Runs continuously and suspendes any prepaid customer packages which have
+passed their renewal date (next bill date).
+
+=head1 SEE ALSO
+
+=cut
+
+1;