summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin DeVuyst <justin@devuyst.com>2017-03-20 16:17:56 -0400
committerChristopher Burger <burgerc@freeside.biz>2017-08-01 11:48:48 -0400
commit0f9f314fa40adf66b672065f8f3477789c50ae56 (patch)
treee42cbcb8ccaf3445384c97eb38ee6e6324776572
parente41036e2c2c9fa3c70e13d56ec4ffb8168de99cc (diff)
Add configurable daily auto-disable for quotations. See RT#74665.
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/Cron/disable_quotation.pm21
-rwxr-xr-xFS/bin/freeside-daily4
3 files changed, 32 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index c7dbd0b58..9f660733c 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1646,6 +1646,13 @@ and customer address. Include units.',
},
{
+ 'key' => 'quotation_disable_after_days',
+ 'section' => 'quotations',
+ 'description' => 'The number of days, if set, after which a non-converted quotation will be automatically disabled.',
+ 'type' => 'text'
+ },
+
+ {
'key' => 'invoice_print_pdf',
'section' => 'invoicing',
'description' => 'For all invoice print operations, store postal invoices for download in PDF format rather than printing them directly.',
diff --git a/FS/FS/Cron/disable_quotation.pm b/FS/FS/Cron/disable_quotation.pm
new file mode 100644
index 000000000..fde2686eb
--- /dev/null
+++ b/FS/FS/Cron/disable_quotation.pm
@@ -0,0 +1,21 @@
+package FS::Cron::disable_quotation;
+
+use vars qw( @ISA @EXPORT_OK );
+use Exporter;
+use FS::UID qw(dbh);
+use FS::Conf;
+
+@ISA = qw( Exporter );
+@EXPORT_OK = qw( disable_quotation );
+
+sub disable_quotation {
+ if ( my $days = FS::Conf->new->config( 'quotation_disable_after_days' ) ) {
+ my $sth = dbh->prepare(
+ "UPDATE quotation SET disabled = 'Y' WHERE _date < ?"
+ ) or die dbh->errstr;
+ $sth->execute( time - ( $days * 86400 ) ) or die $sth->errstr;
+ dbh->commit or die dbh->errstr if $FS::UID::AutoCommit;
+ }
+}
+
+1;
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index eb1a3e347..5276a2ff0 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -82,6 +82,10 @@ agent_email(%opt);
use FS::Cron::send_subscribed qw(send_subscribed);
send_subscribed(%opt);
+#does nothing unless quotation_disable_after_days is set.
+use FS::Cron::disable_quotation qw(disable_quotation);
+disable_quotation();
+
#clears out cacti imports & deletes select database cache files
use FS::Cron::cleanup qw( cleanup cleanup_before_backup );
cleanup_before_backup();