diff options
author | Justin DeVuyst <justin@devuyst.com> | 2017-03-20 16:17:56 -0400 |
---|---|---|
committer | Justin DeVuyst <justin@devuyst.com> | 2017-03-20 16:17:56 -0400 |
commit | 247a72232486b809bd0f0d88f3506dc0a1e79d93 (patch) | |
tree | d6e8d52ed38d6ccac980118599abf1d0168e34d2 /FS/FS | |
parent | b285918ec3ab6c8203e9f8feaf234da306456e5e (diff) |
Add configurable daily auto-disable for quotations. See RT#74665.
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/Cron/disable_quotation.pm | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 34e465dda..8d83f92d2 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1506,6 +1506,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' => 'printing', '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; |