Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\tasks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -38,8 +38,8 @@ class _sendInvoiceWarnings extends \IPS\Task
|
||||
{
|
||||
if ( \IPS\Settings::i()->cm_invoice_warning )
|
||||
{
|
||||
$normalCutoff = \IPS\DateTime::create()->add( new \DateInterval( 'P' . \IPS\Settings::i()->cm_invoice_generate . 'D' ) )->add( new \DateInterval( 'P' . \IPS\Settings::i()->cm_invoice_warning . 'D' ) )->getTimestamp();
|
||||
$billingAgreementCutoff = \IPS\DateTime::create()->add( new \DateInterval( 'P' . \IPS\Settings::i()->cm_invoice_warning . 'D' ) )->getTimestamp();
|
||||
$normalCutoff = \IPS\DateTime::create()->add( new \DateInterval( 'PT' . \IPS\Settings::i()->cm_invoice_generate . 'H' ) )->add( new \DateInterval( 'PT' . \IPS\Settings::i()->cm_invoice_warning . 'H' ) )->getTimestamp();
|
||||
$billingAgreementCutoff = \IPS\DateTime::create()->add( new \DateInterval( 'PT' . \IPS\Settings::i()->cm_invoice_warning . 'H' ) )->getTimestamp();
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_renewals>0 AND ps_invoice_pending=0 AND ps_invoice_warning_sent=0 AND ps_active=1 AND ps_expire>0 AND ( ( ps_billing_agreement IS NULL AND ps_expire<? ) OR ( ps_billing_agreement IS NOT NULL AND ps_expire<? ) )', $normalCutoff, $billingAgreementCutoff ), 'ps_member', 50 );
|
||||
|
||||
$groupedPurchases = array();
|
||||
@@ -76,7 +76,7 @@ class _sendInvoiceWarnings extends \IPS\Task
|
||||
}
|
||||
$invoice->setDefaultTitle();
|
||||
|
||||
/* If there is a billing agreement - send an email abiout that */
|
||||
/* If there is a billing agreement - send an email about that */
|
||||
$billingAgreement = NULL;
|
||||
if ( $billingAgreementId )
|
||||
{
|
||||
@@ -95,7 +95,8 @@ class _sendInvoiceWarnings extends \IPS\Task
|
||||
}
|
||||
if ( $billingAgreement )
|
||||
{
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'invoiceWarning', array( array(), NULL, $billingAgreement, $invoice, $invoice->summary() ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
$paymentDate = \IPS\DateTime::create()->add( new \DateInterval( 'PT' . \IPS\Settings::i()->cm_invoice_warning . 'H' ) )->localeDate( $member );
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'invoiceWarning', array( array(), NULL, $billingAgreement, $invoice, $invoice->summary( $member->language() ), $paymentDate ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
}
|
||||
/* Otherwise check account credit and cards */
|
||||
else
|
||||
@@ -113,9 +114,10 @@ class _sendInvoiceWarnings extends \IPS\Task
|
||||
$credits = $member->cm_credits;
|
||||
$credit = isset( $credits[ $currency ] ) ? $credits[ $currency ]->amount : ( new \IPS\Math\Number( '0' ) );
|
||||
|
||||
if ( count( $cards ) or $credit->isGreaterThanZero() )
|
||||
if ( \count( $cards ) or $credit->isGreaterThanZero() )
|
||||
{
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'invoiceWarning', array( $cards, isset( $credits[ $currency ] ) ? $credits[ $currency ] : ( new \IPS\nexus\Money( 0, $currency ) ), NULL, $invoice, $invoice->summary() ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
$paymentDate = \IPS\DateTime::create()->add( new \DateInterval( 'PT' . \IPS\Settings::i()->cm_invoice_warning . 'H' ) )->localeDate( $member );
|
||||
$email = \IPS\Email::buildFromTemplate( 'nexus', 'invoiceWarning', array( $cards, isset( $credits[ $currency ] ) ? $credits[ $currency ] : ( new \IPS\nexus\Money( 0, $currency ) ), NULL, $invoice, $invoice->summary( $member->language() ), $paymentDate ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +133,7 @@ class _sendInvoiceWarnings extends \IPS\Task
|
||||
},
|
||||
iterator_to_array( $member->alternativeContacts( array( 'billing=1' ) ) )
|
||||
),
|
||||
( ( in_array( 'invoice_warn', explode( ',', \IPS\Settings::i()->nexus_notify_copy_types ) ) AND \IPS\Settings::i()->nexus_notify_copy_email ) ? explode( ',', \IPS\Settings::i()->nexus_notify_copy_email ) : array() )
|
||||
( ( \in_array( 'invoice_warn', explode( ',', \IPS\Settings::i()->nexus_notify_copy_types ) ) AND \IPS\Settings::i()->nexus_notify_copy_email ) ? explode( ',', \IPS\Settings::i()->nexus_notify_copy_email ) : array() )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user